rn-css 1.11.7 → 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,10 +34,10 @@ export declare function placeContent(value: string): {
34
34
  justifyContent: string;
35
35
  };
36
36
  export declare function background(value: string): {
37
+ backgroundColor: string;
37
38
  background: string;
38
- backgroundColor?: undefined;
39
39
  } | {
40
- backgroundColor: string | undefined;
40
+ backgroundColor: string;
41
41
  background?: undefined;
42
42
  };
43
43
  export declare function textDecoration(value: string): {
@@ -50,7 +50,7 @@ export declare function transform(value: string): {
50
50
  };
51
51
  export declare function font(value: string): Style;
52
52
  /** Parses a css value for the side of an element (border-width, margin, padding) */
53
- 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' | '' : ''): {
54
54
  [x: string]: string;
55
55
  };
56
56
  /** Parses a css value for the corner of an element (border-radius) */
@@ -135,15 +135,10 @@ function placeContent(value) {
135
135
  }
136
136
  exports.placeContent = placeContent;
137
137
  function background(value) {
138
+ const values = value.match(/(linear-gradient\(|url\().*?\)|[^\s]+/mg) || [];
139
+ const backgroundColor = values.reverse().find(isColor) || 'transparent';
138
140
  // We support everything on web
139
- if (react_native_1.Platform.OS === 'web')
140
- return { background: value };
141
- else {
142
- const values = value.split(/\s+/mg);
143
- const color = values.pop();
144
- // The background-color is the only one that we support on RN and it's the last value
145
- return { backgroundColor: isColor(color) ? color : 'transparent' };
146
- }
141
+ return react_native_1.Platform.OS === 'web' ? { backgroundColor, background: value } : { backgroundColor };
147
142
  }
148
143
  exports.background = background;
149
144
  function textDecoration(value) {
@@ -270,6 +265,8 @@ function isColor(value) {
270
265
  return false;
271
266
  if (value.startsWith('#') || value.startsWith('rgb') || value.startsWith('hsl'))
272
267
  return true;
268
+ if (react_native_1.Platform.OS === 'web' && value.match(/^\s*linear-gradient\(.*\)/s))
269
+ return true;
273
270
  const CSS_COLOR_NAMES = [
274
271
  'aliceblue',
275
272
  'antiquewhite',
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.11.7",
3
+ "version": "1.11.8",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.js",
@@ -118,14 +118,10 @@ export function placeContent (value: string) {
118
118
  }
119
119
 
120
120
  export function background (value: string) {
121
+ const values = value.match(/(linear-gradient\(|url\().*?\)|[^\s]+/mg) || []
122
+ const backgroundColor = values.reverse().find(isColor) || 'transparent'
121
123
  // We support everything on web
122
- if (Platform.OS === 'web') return { background: value }
123
- else {
124
- const values = value.split(/\s+/mg)
125
- const color = values.pop()
126
- // The background-color is the only one that we support on RN and it's the last value
127
- return { backgroundColor: isColor(color) ? color : 'transparent' }
128
- }
124
+ return Platform.OS === 'web' ? { backgroundColor, background: value } : { backgroundColor }
129
125
  }
130
126
 
131
127
  export function textDecoration (value: string) {
@@ -210,7 +206,7 @@ export function font (value: string) {
210
206
  }
211
207
 
212
208
  /** Parses a css value for the side of an element (border-width, margin, padding) */
213
- 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} {
214
210
  if (value === 'none') return sideValue(prefixKey, '0', postFix)
215
211
  const [top = value, right = top, bottom = top, left = right] = findNumbers(value, prefixKey === 'margin').numbers
216
212
  return {
@@ -235,6 +231,7 @@ export function cornerValue (prefixKey: 'border', value: string, postFix: 'Radiu
235
231
  function isColor (value?: string) {
236
232
  if (!value) return false
237
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
238
235
  const CSS_COLOR_NAMES = [
239
236
  'aliceblue',
240
237
  'antiquewhite',
@@ -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