rn-css 1.11.6 → 1.11.8
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.
|
@@ -34,7 +34,11 @@ export declare function placeContent(value: string): {
|
|
|
34
34
|
justifyContent: string;
|
|
35
35
|
};
|
|
36
36
|
export declare function background(value: string): {
|
|
37
|
-
backgroundColor: string
|
|
37
|
+
backgroundColor: string;
|
|
38
|
+
background: string;
|
|
39
|
+
} | {
|
|
40
|
+
backgroundColor: string;
|
|
41
|
+
background?: undefined;
|
|
38
42
|
};
|
|
39
43
|
export declare function textDecoration(value: string): {
|
|
40
44
|
textDecorationLine: string;
|
|
@@ -46,7 +50,7 @@ export declare function transform(value: string): {
|
|
|
46
50
|
};
|
|
47
51
|
export declare function font(value: string): Style;
|
|
48
52
|
/** Parses a css value for the side of an element (border-width, margin, padding) */
|
|
49
|
-
export declare function sideValue<T extends 'padding' | 'margin' | 'border'>(prefixKey: T, value: string, postFix?: T extends 'border' ? 'Width' | 'Style' | 'Color' | '' : ''): {
|
|
53
|
+
export declare function sideValue<T extends 'padding' | 'margin' | 'border' | 'outline'>(prefixKey: T, value: string, postFix?: T extends 'border' | 'outline' ? 'Width' | 'Style' | 'Color' | '' : ''): {
|
|
50
54
|
[x: string]: string;
|
|
51
55
|
};
|
|
52
56
|
/** Parses a css value for the corner of an element (border-radius) */
|
package/dist/cssToRN/convert.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cornerValue = exports.sideValue = exports.font = exports.transform = exports.textDecoration = exports.background = exports.placeContent = exports.flexFlow = exports.flex = exports.shadow = exports.borderLike = exports.border = void 0;
|
|
4
|
+
const react_native_1 = require("../react-native");
|
|
4
5
|
/**
|
|
5
6
|
* Check if the value is a number. Numbers start with a digit, a decimal point or calc(, max( ou min(.
|
|
6
7
|
* Optionally accept "auto" value (for margins)
|
|
@@ -134,10 +135,10 @@ function placeContent(value) {
|
|
|
134
135
|
}
|
|
135
136
|
exports.placeContent = placeContent;
|
|
136
137
|
function background(value) {
|
|
137
|
-
const values = value.
|
|
138
|
-
const
|
|
139
|
-
//
|
|
140
|
-
return { backgroundColor:
|
|
138
|
+
const values = value.match(/(linear-gradient\(|url\().*?\)|[^\s]+/mg) || [];
|
|
139
|
+
const backgroundColor = values.reverse().find(isColor) || 'transparent';
|
|
140
|
+
// We support everything on web
|
|
141
|
+
return react_native_1.Platform.OS === 'web' ? { backgroundColor, background: value } : { backgroundColor };
|
|
141
142
|
}
|
|
142
143
|
exports.background = background;
|
|
143
144
|
function textDecoration(value) {
|
|
@@ -264,6 +265,8 @@ function isColor(value) {
|
|
|
264
265
|
return false;
|
|
265
266
|
if (value.startsWith('#') || value.startsWith('rgb') || value.startsWith('hsl'))
|
|
266
267
|
return true;
|
|
268
|
+
if (react_native_1.Platform.OS === 'web' && value.match(/^\s*linear-gradient\(.*\)/s))
|
|
269
|
+
return true;
|
|
267
270
|
const CSS_COLOR_NAMES = [
|
|
268
271
|
'aliceblue',
|
|
269
272
|
'antiquewhite',
|
package/dist/cssToRN/index.js
CHANGED
|
@@ -96,6 +96,11 @@ function cssChunkToStyle(css) {
|
|
|
96
96
|
case 'borderWidth':
|
|
97
97
|
Object.assign(result, (0, convert_1.sideValue)('border', value, key.split('border').pop()));
|
|
98
98
|
break;
|
|
99
|
+
case 'outlineStyle':
|
|
100
|
+
case 'outlineColor':
|
|
101
|
+
case 'outlineWidth':
|
|
102
|
+
Object.assign(result, (0, convert_1.sideValue)('outline', value, key.split('outline').pop()));
|
|
103
|
+
break;
|
|
99
104
|
case 'background':
|
|
100
105
|
Object.assign(result, (0, convert_1.background)(value));
|
|
101
106
|
break;
|
|
@@ -133,6 +138,9 @@ function cssChunkToStyle(css) {
|
|
|
133
138
|
else
|
|
134
139
|
Object.assign(result, (0, convert_1.shadow)(key === 'boxShadow' ? 'shadow' : key, value));
|
|
135
140
|
break;
|
|
141
|
+
case 'userSelect':
|
|
142
|
+
Object.assign(result, { userSelect: value, WebkitUserSelect: value });
|
|
143
|
+
break;
|
|
136
144
|
// Other keys don't require any special treatment
|
|
137
145
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
138
146
|
// @ts-ignore
|
package/package.json
CHANGED
package/src/cssToRN/convert.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Platform } from '../react-native'
|
|
1
2
|
import type { Style, Transform } from '../types'
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -117,10 +118,10 @@ export function placeContent (value: string) {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
export function background (value: string) {
|
|
120
|
-
const values = value.
|
|
121
|
-
const
|
|
122
|
-
//
|
|
123
|
-
return { backgroundColor:
|
|
121
|
+
const values = value.match(/(linear-gradient\(|url\().*?\)|[^\s]+/mg) || []
|
|
122
|
+
const backgroundColor = values.reverse().find(isColor) || 'transparent'
|
|
123
|
+
// We support everything on web
|
|
124
|
+
return Platform.OS === 'web' ? { backgroundColor, background: value } : { backgroundColor }
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
export function textDecoration (value: string) {
|
|
@@ -205,7 +206,7 @@ export function font (value: string) {
|
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
/** Parses a css value for the side of an element (border-width, margin, padding) */
|
|
208
|
-
export function sideValue <T extends 'padding' | 'margin' | 'border'> (prefixKey: T, value: string, postFix: T extends 'border' ? 'Width' | 'Style' | 'Color' | '' : '' = ''): { [x: string]: string} {
|
|
209
|
+
export function sideValue <T extends 'padding' | 'margin' | 'border' | 'outline'> (prefixKey: T, value: string, postFix: T extends 'border' | 'outline' ? 'Width' | 'Style' | 'Color' | '' : '' = ''): { [x: string]: string} {
|
|
209
210
|
if (value === 'none') return sideValue(prefixKey, '0', postFix)
|
|
210
211
|
const [top = value, right = top, bottom = top, left = right] = findNumbers(value, prefixKey === 'margin').numbers
|
|
211
212
|
return {
|
|
@@ -230,6 +231,7 @@ export function cornerValue (prefixKey: 'border', value: string, postFix: 'Radiu
|
|
|
230
231
|
function isColor (value?: string) {
|
|
231
232
|
if (!value) return false
|
|
232
233
|
if (value.startsWith('#') || value.startsWith('rgb') || value.startsWith('hsl')) return true
|
|
234
|
+
if (Platform.OS === 'web' && value.match(/^\s*linear-gradient\(.*\)/s)) return true
|
|
233
235
|
const CSS_COLOR_NAMES = [
|
|
234
236
|
'aliceblue',
|
|
235
237
|
'antiquewhite',
|
package/src/cssToRN/index.ts
CHANGED
|
@@ -93,6 +93,11 @@ function cssChunkToStyle (css: string) {
|
|
|
93
93
|
case 'borderWidth':
|
|
94
94
|
Object.assign(result, sideValue('border', value, key.split('border').pop() as '' | 'Width' | 'Style' | 'Color'))
|
|
95
95
|
break
|
|
96
|
+
case 'outlineStyle':
|
|
97
|
+
case 'outlineColor':
|
|
98
|
+
case 'outlineWidth':
|
|
99
|
+
Object.assign(result, sideValue('outline', value, key.split('outline').pop() as '' | 'Width' | 'Style' | 'Color'))
|
|
100
|
+
break
|
|
96
101
|
case 'background':
|
|
97
102
|
Object.assign(result, background(value))
|
|
98
103
|
break
|
|
@@ -128,6 +133,9 @@ function cssChunkToStyle (css: string) {
|
|
|
128
133
|
// We need to replace boxShadow by shadow
|
|
129
134
|
else Object.assign(result, shadow(key === 'boxShadow' ? 'shadow' : key, value))
|
|
130
135
|
break
|
|
136
|
+
case 'userSelect':
|
|
137
|
+
Object.assign(result, { userSelect: value, WebkitUserSelect: value })
|
|
138
|
+
break
|
|
131
139
|
// Other keys don't require any special treatment
|
|
132
140
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
133
141
|
// @ts-ignore
|