react-native-unistyles 1.0.0-beta.4 → 1.0.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/createUnistyles.js +10 -12
- package/lib/commonjs/createUnistyles.js.map +1 -1
- package/lib/commonjs/mediaQueries.js +2 -0
- package/lib/commonjs/mediaQueries.js.map +1 -0
- package/lib/commonjs/utils/breakpoints.js +12 -16
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.spec.js +20 -15
- package/lib/commonjs/utils/breakpoints.spec.js.map +1 -1
- package/lib/commonjs/utils/common.js +8 -1
- package/lib/commonjs/utils/common.js.map +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mediaQueries.spec.js +1 -1
- package/lib/commonjs/utils/mediaQueries.spec.js.map +1 -1
- package/lib/commonjs/utils/normalizeStyles.js +10 -0
- package/lib/commonjs/utils/normalizeStyles.js.map +1 -0
- package/lib/commonjs/utils/normalizeStyles.web.js +59 -0
- package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -0
- package/lib/commonjs/utils/styles.js +14 -11
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/styles.spec.js +17 -7
- package/lib/commonjs/utils/styles.spec.js.map +1 -1
- package/lib/module/createUnistyles.js +10 -12
- package/lib/module/createUnistyles.js.map +1 -1
- package/lib/module/mediaQueries.js +2 -0
- package/lib/module/mediaQueries.js.map +1 -0
- package/lib/module/utils/breakpoints.js +12 -16
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/breakpoints.spec.js +20 -15
- package/lib/module/utils/breakpoints.spec.js.map +1 -1
- package/lib/module/utils/common.js +5 -0
- package/lib/module/utils/common.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mediaQueries.spec.js +1 -1
- package/lib/module/utils/mediaQueries.spec.js.map +1 -1
- package/lib/module/utils/normalizeStyles.js +3 -0
- package/lib/module/utils/normalizeStyles.js.map +1 -0
- package/lib/module/utils/normalizeStyles.web.js +52 -0
- package/lib/module/utils/normalizeStyles.web.js.map +1 -0
- package/lib/module/utils/styles.js +14 -11
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/styles.spec.js +17 -7
- package/lib/module/utils/styles.spec.js.map +1 -1
- package/lib/typescript/src/createUnistyles.d.ts +2 -2
- package/lib/typescript/src/createUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/mediaQueries.d.ts +2 -0
- package/lib/typescript/src/mediaQueries.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +35 -13
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +6 -6
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/common.d.ts +2 -0
- package/lib/typescript/src/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizeStyles.d.ts +2 -0
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +2 -0
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts +5 -5
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +9 -2
- package/src/createUnistyles.ts +20 -14
- package/src/mediaQueries.ts +33 -0
- package/src/types.ts +42 -15
- package/src/utils/breakpoints.ts +15 -15
- package/src/utils/common.ts +8 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/normalizeStyles.ts +2 -0
- package/src/utils/normalizeStyles.web.ts +103 -0
- package/src/utils/styles.ts +20 -14
@@ -14,13 +14,14 @@ describe('styles', () => {
|
|
14
14
|
sm: 400,
|
15
15
|
md: 800
|
16
16
|
};
|
17
|
+
const breakpointPairs = Object.entries(breakpoints);
|
17
18
|
const dynamicFunction = isEven => ({
|
18
19
|
backgroundColor: {
|
19
20
|
sm: isEven ? 'green' : 'red',
|
20
21
|
md: isEven ? 'orange' : 'pink'
|
21
22
|
}
|
22
23
|
});
|
23
|
-
expect((0, _styles.proxifyFunction)(dynamicFunction, breakpoint, screenSize,
|
24
|
+
expect((0, _styles.proxifyFunction)(dynamicFunction, breakpoint, screenSize, breakpointPairs)(true)).toEqual({
|
24
25
|
backgroundColor: 'green'
|
25
26
|
});
|
26
27
|
});
|
@@ -35,13 +36,14 @@ describe('styles', () => {
|
|
35
36
|
sm: 400,
|
36
37
|
md: 800
|
37
38
|
};
|
39
|
+
const breakpointPairs = Object.entries(breakpoints);
|
38
40
|
const dynamicFunction = isEven => ({
|
39
41
|
backgroundColor: {
|
40
42
|
':w[,399]': isEven ? 'green' : 'red',
|
41
43
|
':w[400]': isEven ? 'orange' : 'pink'
|
42
44
|
}
|
43
45
|
});
|
44
|
-
expect((0, _styles.proxifyFunction)(dynamicFunction, breakpoint, screenSize,
|
46
|
+
expect((0, _styles.proxifyFunction)(dynamicFunction, breakpoint, screenSize, breakpointPairs)(false)).toEqual({
|
45
47
|
backgroundColor: 'pink'
|
46
48
|
});
|
47
49
|
});
|
@@ -56,10 +58,11 @@ describe('styles', () => {
|
|
56
58
|
sm: 400,
|
57
59
|
md: 800
|
58
60
|
};
|
61
|
+
const breakpointPairs = Object.entries(breakpoints);
|
59
62
|
const dynamicFunction = isEven => ({
|
60
63
|
backgroundColor: isEven ? 'pink' : 'purple'
|
61
64
|
});
|
62
|
-
expect((0, _styles.proxifyFunction)(dynamicFunction, breakpoint, screenSize,
|
65
|
+
expect((0, _styles.proxifyFunction)(dynamicFunction, breakpoint, screenSize, breakpointPairs)(false)).toEqual({
|
63
66
|
backgroundColor: 'purple'
|
64
67
|
});
|
65
68
|
});
|
@@ -76,6 +79,7 @@ describe('styles', () => {
|
|
76
79
|
sm: 400,
|
77
80
|
md: 800
|
78
81
|
};
|
82
|
+
const breakpointPairs = Object.entries(breakpoints);
|
79
83
|
const style = {
|
80
84
|
fontSize: {
|
81
85
|
sm: 12,
|
@@ -87,7 +91,8 @@ describe('styles', () => {
|
|
87
91
|
},
|
88
92
|
fontWeight: 'bold'
|
89
93
|
};
|
90
|
-
|
94
|
+
const parsedStyles = (0, _styles.parseStyle)(style, breakpoint, screenSize, breakpointPairs);
|
95
|
+
expect(parsedStyles).toEqual({
|
91
96
|
fontSize: 12,
|
92
97
|
backgroundColor: 'pink',
|
93
98
|
fontWeight: 'bold'
|
@@ -104,6 +109,7 @@ describe('styles', () => {
|
|
104
109
|
sm: 400,
|
105
110
|
md: 800
|
106
111
|
};
|
112
|
+
const breakpointPairs = Object.entries(breakpoints);
|
107
113
|
const style = {
|
108
114
|
transform: [{
|
109
115
|
translateX: {
|
@@ -113,7 +119,8 @@ describe('styles', () => {
|
|
113
119
|
translateY: 200
|
114
120
|
}]
|
115
121
|
};
|
116
|
-
|
122
|
+
const parsedStyles = (0, _styles.parseStyle)(style, breakpoint, screenSize, breakpointPairs);
|
123
|
+
expect(parsedStyles).toEqual({
|
117
124
|
transform: [{
|
118
125
|
translateX: 120,
|
119
126
|
translateY: 200
|
@@ -131,6 +138,7 @@ describe('styles', () => {
|
|
131
138
|
sm: 400,
|
132
139
|
md: 800
|
133
140
|
};
|
141
|
+
const breakpointPairs = Object.entries(breakpoints);
|
134
142
|
const style = {
|
135
143
|
shadowOffset: {
|
136
144
|
width: 0,
|
@@ -146,13 +154,15 @@ describe('styles', () => {
|
|
146
154
|
}
|
147
155
|
}
|
148
156
|
};
|
149
|
-
|
157
|
+
const parsedStyles = (0, _styles.parseStyle)(style, breakpoint, screenSize, breakpointPairs);
|
158
|
+
const parsedStylesWithBreakpoints = (0, _styles.parseStyle)(styleWithBreakpoints, breakpoint, screenSize, breakpointPairs);
|
159
|
+
expect(parsedStyles).toEqual({
|
150
160
|
shadowOffset: {
|
151
161
|
width: 0,
|
152
162
|
height: 4
|
153
163
|
}
|
154
164
|
});
|
155
|
-
expect(
|
165
|
+
expect(parsedStylesWithBreakpoints).toEqual({
|
156
166
|
shadowOffset: {
|
157
167
|
width: 0,
|
158
168
|
height: 10
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_styles","require","describe","it","screenSize","width","height","breakpoint","breakpoints","xs","sm","md","dynamicFunction","isEven","backgroundColor","expect","proxifyFunction","toEqual","style","fontSize","fontWeight","parseStyle","transform","translateX","translateY","shadowOffset","styleWithBreakpoints"],"sourceRoot":"../../../src","sources":["utils/styles.spec.ts"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;
|
1
|
+
{"version":3,"names":["_styles","require","describe","it","screenSize","width","height","breakpoint","breakpoints","xs","sm","md","breakpointPairs","Object","entries","dynamicFunction","isEven","backgroundColor","expect","proxifyFunction","toEqual","style","fontSize","fontWeight","parsedStyles","parseStyle","transform","translateX","translateY","shadowOffset","styleWithBreakpoints","parsedStylesWithBreakpoints"],"sourceRoot":"../../../src","sources":["utils/styles.spec.ts"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAIAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;EACrBA,QAAQ,CAAC,iBAAiB,EAAE,MAAM;IAC9BC,EAAE,CAAC,yCAAyC,EAAE,MAAM;MAChD,MAAMC,UAAsB,GAAG;QAC3BC,KAAK,EAAE,GAAG;QACVC,MAAM,EAAE;MACZ,CAAC;MACD,MAAMC,UAAU,GAAG,IAAI;MACvB,MAAMC,WAAW,GAAG;QAChBC,EAAE,EAAE,CAAC;QACLC,EAAE,EAAE,GAAG;QACPC,EAAE,EAAE;MACR,CAAC;MACD,MAAMC,eAAe,GAAGC,MAAM,CACzBC,OAAO,CAACN,WAAW,CAAgD;MACxE,MAAMO,eAAe,GAAIC,MAAe,KAAM;QAC1CC,eAAe,EAAE;UACbP,EAAE,EAAEM,MAAM,GACJ,OAAO,GACP,KAAK;UACXL,EAAE,EAAEK,MAAM,GACJ,QAAQ,GACR;QACV;M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BJ,KAAK,EACLd,UAAU,EACVH,UAAU,EACVQ,eACJ,CAAC;MACD,MAAMmB,2BAA2B,GAAG,IAAAN,kBAAU,EAC1CK,oBAAoB,EACpBvB,UAAU,EACVH,UAAU,EACVQ,eACJ,CAAC;MAEDM,MAAM,CAACM,YAAY,CAAC,CAACJ,OAAO,CAAC;QACzBS,YAAY,EAAE;UACVxB,KAAK,EAAE,CAAC;UACRC,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;MACFY,MAAM,CAACa,2BAA2B,CAAC,CAACX,OAAO,CAAC;QACxCS,YAAY,EAAE;UACVxB,KAAK,EAAE,CAAC;UACRC,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC"}
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import { useContext } from 'react';
|
2
|
+
import { StyleSheet } from 'react-native';
|
2
3
|
import { UnistylesContext } from './UnistylesTheme';
|
3
|
-
import { getBreakpointFromScreenWidth, proxifyFunction, parseStyle, sortAndValidateBreakpoints } from './utils';
|
4
4
|
import { useDimensions } from './hooks';
|
5
|
+
import { getBreakpointFromScreenWidth, proxifyFunction, parseStyle, sortAndValidateBreakpoints } from './utils';
|
5
6
|
export const createUnistyles = breakpoints => {
|
6
7
|
const sortedBreakpoints = sortAndValidateBreakpoints(breakpoints);
|
8
|
+
const sortedBreakpointEntries = Object.entries(sortedBreakpoints);
|
7
9
|
return {
|
8
10
|
/**
|
9
11
|
* @deprecated The method should not be used, proposed version by the community is createStyleSheet, will be removed in RC
|
@@ -22,12 +24,7 @@ export const createUnistyles = breakpoints => {
|
|
22
24
|
},
|
23
25
|
useStyles: stylesheet => {
|
24
26
|
const theme = useContext(UnistylesContext);
|
25
|
-
const
|
26
|
-
const breakpoint = getBreakpointFromScreenWidth(dimensions.width, sortedBreakpoints);
|
27
|
-
const screenSize = {
|
28
|
-
width: dimensions.width,
|
29
|
-
height: dimensions.height
|
30
|
-
};
|
27
|
+
const screenSize = useDimensions();
|
31
28
|
if (!stylesheet) {
|
32
29
|
return {
|
33
30
|
theme,
|
@@ -35,19 +32,20 @@ export const createUnistyles = breakpoints => {
|
|
35
32
|
};
|
36
33
|
}
|
37
34
|
const parsedStyles = typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet;
|
35
|
+
const breakpoint = getBreakpointFromScreenWidth(screenSize.width, sortedBreakpointEntries);
|
38
36
|
const dynamicStyleSheet = Object.entries(parsedStyles).reduce((acc, _ref) => {
|
39
37
|
let [key, value] = _ref;
|
40
|
-
const
|
38
|
+
const style = value;
|
41
39
|
if (typeof value === 'function') {
|
42
40
|
return {
|
43
41
|
...acc,
|
44
|
-
[key]: proxifyFunction(value, breakpoint, screenSize,
|
42
|
+
[key]: proxifyFunction(value, breakpoint, screenSize, sortedBreakpointEntries)
|
45
43
|
};
|
46
44
|
}
|
47
|
-
return {
|
45
|
+
return StyleSheet.create({
|
48
46
|
...acc,
|
49
|
-
[key]: parseStyle(
|
50
|
-
};
|
47
|
+
[key]: parseStyle(style, breakpoint, screenSize, sortedBreakpointEntries)
|
48
|
+
});
|
51
49
|
}, {});
|
52
50
|
return {
|
53
51
|
theme,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useContext","UnistylesContext","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","
|
1
|
+
{"version":3,"names":["useContext","StyleSheet","UnistylesContext","useDimensions","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","createUnistyles","breakpoints","sortedBreakpoints","sortedBreakpointEntries","Object","entries","createStyles","styles","createStyleSheet","useStyles","stylesheet","theme","screenSize","parsedStyles","breakpoint","width","dynamicStyleSheet","reduce","acc","_ref","key","value","style","create"],"sourceRoot":"../../src","sources":["createUnistyles.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,UAAU,QAAQ,cAAc;AASzC,SAASC,gBAAgB,QAAQ,kBA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,KAAK,KAAK,UAAU,EAAE;UAC7B,OAAO;YACH,GAAGH,GAAG;YACN,CAACE,GAAG,GAAGvB,eAAe,CAAIwB,KAAK,EAAEP,UAAU,EAAEF,UAAU,EAAET,uBAAuB;UACpF,CAAC;QACL;QAEA,OAAOV,UAAU,CAAC8B,MAAM,CAAC;UACrB,GAAGL,GAAG;UACN,CAACE,GAAG,GAAGtB,UAAU,CAAQwB,KAAK,EAAER,UAAU,EAAEF,UAAU,EAAET,uBAAuB;QACnF,CAAC,CAAC;MACN,CAAC,EAAE,CAAC,CAAO,CAAC;MAEhB,OAAO;QACHQ,KAAK;QACLJ,MAAM,EAAES;MACZ,CAAC;IACL;EACJ,CAAC;AACL,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["mediaQueries.ts"],"mappings":""}
|
@@ -46,15 +46,15 @@ export const sortAndValidateBreakpoints = breakpoints => {
|
|
46
46
|
*
|
47
47
|
* @template B - An object type where keys are strings and values are numbers representing screen widths.
|
48
48
|
* @param {number} width - The screen width to determine the breakpoint for.
|
49
|
-
* @param
|
49
|
+
* @param breakpointEntries - sorted pairs of breakpoints
|
50
50
|
* @returns {keyof B & string} The key of the breakpoint that the screen width falls into.
|
51
51
|
*
|
52
52
|
* @example
|
53
53
|
* const breakpoints = { sm: 0, md: 768, lg: 1024 }
|
54
54
|
* getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
|
55
55
|
*/
|
56
|
-
export const getBreakpointFromScreenWidth = (width,
|
57
|
-
const [key] =
|
56
|
+
export const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
57
|
+
const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
|
58
58
|
let [, value] = _ref;
|
59
59
|
const minVal = value;
|
60
60
|
const maxVal = otherBreakpoints[index + 1]?.[1];
|
@@ -78,7 +78,7 @@ export const getBreakpointFromScreenWidth = (width, breakpoints) => {
|
|
78
78
|
* @param {Record<keyof B & string, string | number>} value - An object containing values associated with breakpoints or custom media queries.
|
79
79
|
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
80
80
|
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
81
|
-
* @param
|
81
|
+
* @param breakpointPairs - sorted pairs of breakpoints
|
82
82
|
*
|
83
83
|
* @returns {string | number | undefined} Returns the value associated with the matching breakpoint or custom media query, or `undefined` if no match is found.
|
84
84
|
*
|
@@ -90,7 +90,7 @@ export const getBreakpointFromScreenWidth = (width, breakpoints) => {
|
|
90
90
|
*
|
91
91
|
* getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
|
92
92
|
*/
|
93
|
-
export const getValueForBreakpoint = (value, breakpoint, screenSize,
|
93
|
+
export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointPairs) => {
|
94
94
|
// the highest priority is for custom media queries
|
95
95
|
const customMediaQueries = Object.entries(value).filter(_ref2 => {
|
96
96
|
let [key] = _ref2;
|
@@ -111,21 +111,17 @@ export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpoints
|
|
111
111
|
}
|
112
112
|
|
113
113
|
// there is no direct hit for breakpoint nor media-query, so let's simulate CSS cascading
|
114
|
-
const
|
115
|
-
let [key
|
116
|
-
return [key.toLowerCase(), bpValue];
|
117
|
-
});
|
118
|
-
const currentBreakpoint = allBreakpoints.findIndex(_ref4 => {
|
119
|
-
let [key] = _ref4;
|
114
|
+
const currentBreakpoint = breakpointPairs.findIndex(_ref3 => {
|
115
|
+
let [key] = _ref3;
|
120
116
|
return key === unifiedKey;
|
121
117
|
});
|
122
|
-
const availableBreakpoints =
|
123
|
-
let [key] =
|
118
|
+
const availableBreakpoints = breakpointPairs.filter((_ref4, index) => {
|
119
|
+
let [key] = _ref4;
|
124
120
|
return index < currentBreakpoint && key && key in value;
|
125
|
-
}).map(
|
126
|
-
let [key] =
|
121
|
+
}).map(_ref5 => {
|
122
|
+
let [key] = _ref5;
|
127
123
|
return key;
|
128
124
|
});
|
129
|
-
return
|
125
|
+
return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
|
130
126
|
};
|
131
127
|
//# sourceMappingURL=breakpoints.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["throwError","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","customMediaQueryKey","unifiedKey","toLowerCase","directBreakpoint","
|
1
|
+
{"version":3,"names":["throwError","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","breakpointPairs","customMediaQueries","filter","_ref2","customMediaQueryKey","unifiedKey","toLowerCase","directBreakpoint","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,UAAU;AAErC,SAASC,yBAAyB,EAAEC,YAAY,QAAQ,gBAAgB;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAA2BC,WAAc,IAAQ;EACpF,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IA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AC;EAExB,OAAOW,eAAe,CAACjB,MAAM,GAAG,CAAC,GAC3BW,KAAK,CAACiB,oBAAoB,CAACA,oBAAoB,CAAC5B,MAAM,GAAG,CAAC,CAAC,CAAqB,GAChFgC,SAAS;AACnB,CAAC"}
|
@@ -52,17 +52,18 @@ describe('breakpoints', () => {
|
|
52
52
|
md: 500,
|
53
53
|
xl: 1200
|
54
54
|
};
|
55
|
-
|
56
|
-
expect(getBreakpointFromScreenWidth(
|
57
|
-
expect(getBreakpointFromScreenWidth(
|
58
|
-
expect(getBreakpointFromScreenWidth(
|
59
|
-
expect(getBreakpointFromScreenWidth(
|
60
|
-
expect(getBreakpointFromScreenWidth(
|
61
|
-
expect(getBreakpointFromScreenWidth(
|
62
|
-
expect(getBreakpointFromScreenWidth(
|
63
|
-
expect(getBreakpointFromScreenWidth(
|
64
|
-
expect(getBreakpointFromScreenWidth(
|
65
|
-
expect(getBreakpointFromScreenWidth(
|
55
|
+
const breakpointPairs = Object.entries(breakpoints);
|
56
|
+
expect(getBreakpointFromScreenWidth(0, breakpointPairs)).toEqual('xs');
|
57
|
+
expect(getBreakpointFromScreenWidth(20, breakpointPairs)).toEqual('xs');
|
58
|
+
expect(getBreakpointFromScreenWidth(100, breakpointPairs)).toEqual('xs');
|
59
|
+
expect(getBreakpointFromScreenWidth(101, breakpointPairs)).toEqual('xs');
|
60
|
+
expect(getBreakpointFromScreenWidth(250, breakpointPairs)).toEqual('xs');
|
61
|
+
expect(getBreakpointFromScreenWidth(300, breakpointPairs)).toEqual('sm');
|
62
|
+
expect(getBreakpointFromScreenWidth(499, breakpointPairs)).toEqual('sm');
|
63
|
+
expect(getBreakpointFromScreenWidth(500, breakpointPairs)).toEqual('md');
|
64
|
+
expect(getBreakpointFromScreenWidth(799, breakpointPairs)).toEqual('md');
|
65
|
+
expect(getBreakpointFromScreenWidth(1200, breakpointPairs)).toEqual('xl');
|
66
|
+
expect(getBreakpointFromScreenWidth(2000, breakpointPairs)).toEqual('xl');
|
66
67
|
});
|
67
68
|
});
|
68
69
|
describe('getValueForBreakpoint', () => {
|
@@ -73,6 +74,7 @@ describe('breakpoints', () => {
|
|
73
74
|
sm: 200,
|
74
75
|
md: 500
|
75
76
|
};
|
77
|
+
const breakpointPairs = Object.entries(breakpoints);
|
76
78
|
const style = {
|
77
79
|
':w[, 200]': 'green',
|
78
80
|
':w[201]': 'orange',
|
@@ -82,7 +84,7 @@ describe('breakpoints', () => {
|
|
82
84
|
width: 200,
|
83
85
|
height: 800
|
84
86
|
};
|
85
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize,
|
87
|
+
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual('green');
|
86
88
|
});
|
87
89
|
});
|
88
90
|
it('should match breakpoint if media query doesnt exist', () => {
|
@@ -92,6 +94,7 @@ describe('breakpoints', () => {
|
|
92
94
|
sm: 200,
|
93
95
|
md: 500
|
94
96
|
};
|
97
|
+
const breakpointPairs = Object.entries(breakpoints);
|
95
98
|
const style = {
|
96
99
|
':w[, 200]': 'green',
|
97
100
|
':w[201, 499]': 'orange',
|
@@ -102,7 +105,7 @@ describe('breakpoints', () => {
|
|
102
105
|
width: 500,
|
103
106
|
height: 1200
|
104
107
|
};
|
105
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize,
|
108
|
+
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual('red');
|
106
109
|
});
|
107
110
|
it('should match breakpoint even if value is undefined', () => {
|
108
111
|
const breakpoint = 'md';
|
@@ -111,6 +114,7 @@ describe('breakpoints', () => {
|
|
111
114
|
sm: 200,
|
112
115
|
md: 500
|
113
116
|
};
|
117
|
+
const breakpointPairs = Object.entries(breakpoints);
|
114
118
|
const style = {
|
115
119
|
':w[, 200]': 'green',
|
116
120
|
':w[201, 499]': 'orange',
|
@@ -121,7 +125,7 @@ describe('breakpoints', () => {
|
|
121
125
|
width: 500,
|
122
126
|
height: 1200
|
123
127
|
};
|
124
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize,
|
128
|
+
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual(undefined);
|
125
129
|
});
|
126
130
|
it('should match lower breakpoint to match css cascading', () => {
|
127
131
|
const breakpoint = 'xl';
|
@@ -131,6 +135,7 @@ describe('breakpoints', () => {
|
|
131
135
|
md: 500,
|
132
136
|
xl: 600
|
133
137
|
};
|
138
|
+
const breakpointPairs = Object.entries(breakpoints);
|
134
139
|
const style = {
|
135
140
|
':w[, 200]': 'green',
|
136
141
|
':w[201, 499]': 'orange',
|
@@ -141,7 +146,7 @@ describe('breakpoints', () => {
|
|
141
146
|
width: 500,
|
142
147
|
height: 1200
|
143
148
|
};
|
144
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize,
|
149
|
+
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual('red');
|
145
150
|
});
|
146
151
|
});
|
147
152
|
//# sourceMappingURL=breakpoints.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getBreakpointFromScreenWidth","getValueForBreakpoint","sortAndValidateBreakpoints","describe","it","breakpoints","expect","toThrow","sm","md","lg","xl","toEqual","xs","breakpoint","style","screenSize","width","height","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.spec.ts"],"mappings":"AAAA,SAASA,4BAA4B,EAAEC,qBAAqB,EAAEC,0BAA0B,QAAQ,eAAe;AAG/GC,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC1BA,QAAQ,CAAC,4BAA4B,EAAE,MAAM;IACzCC,EAAE,CAAC,0CAA0C,EAAE,MAAM;MACjD,MAAMC,WAAW,GAAG,CAAC,CAAC;MAEtBC,MAAM,CAAC,MAAMJ,0BAA0B,CAACG,WAAW,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC;IAEFH,EAAE,CAAC,6DAA6D,EAAE,MAAM;MACpE,MAAMC,WAAW,GAAG;QAChBG,EAAE,EAAE,C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,EAAE;MACR,CAAC;
|
1
|
+
{"version":3,"names":["getBreakpointFromScreenWidth","getValueForBreakpoint","sortAndValidateBreakpoints","describe","it","breakpoints","expect","toThrow","sm","md","lg","xl","toEqual","xs","breakpointPairs","Object","entries","breakpoint","style","screenSize","width","height","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.spec.ts"],"mappings":"AAAA,SAASA,4BAA4B,EAAEC,qBAAqB,EAAEC,0BAA0B,QAAQ,eAAe;AAG/GC,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC1BA,QAAQ,CAAC,4BAA4B,EAAE,MAAM;IACzCC,EAAE,CAAC,0CAA0C,EAAE,MAAM;MACjD,MAAMC,WAAW,GAAG,CAAC,CAAC;MAEtBC,MAAM,CAAC,MAAMJ,0BAA0B,CAACG,WAAW,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC;IAEFH,EAAE,CAAC,6DAA6D,EAAE,MAAM;MACpE,MAAMC,WAAW,GAAG;QAChBG,EAAE,EAAE,CAAC;MACT,CAAC;MAEDF,MAAM,CAAC,MAAMJ,0BAA0B,CAACG,WAAW,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC;IAEFH,EAAE,CAAC,8CAA8C,EAAE,MAAM;MACrD,MAAMC,WAAW,GAAG;QAChBG,EAAE,EAAE,CAAC;QACLC,EAAE,EAAE,GAAG;QACPC,EAAE,EAAE,GAAG;QACPC,EAAE,EAAE;MACR,CAAC;MAEDL,MAAM,CAACJ,0BAA0B,CAACG,WAAW,CAAC,CAAC,CAACO,OAAO,CAACP,WAAW,CAAC;IACxE,CAAC,CAAC;IAEFD,EAAE,CAAC,sCAAsC,EAAE,MAAM;MAC7C,MAAMC,WAAW,GAAG;QAChBI,EAAE,EAAE,GAAG;QACPD,EAAE,EAAE,CAAC;QACLE,EAAE,EAAE,GAAG;QACPC,EAAE,EAAE;MACR,CAAC;MAEDL,MAAM,CAACJ,0BAA0B,CAACG,WAA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,MAAMZ,WAAW,GAAG;MAChBQ,EAAE,EAAE,CAAC;MACLL,EAAE,EAAE,GAAG;MACPC,EAAE,EAAE,GAAG;MACPE,EAAE,EAAE;IACR,CAAC;IACD,MAAMG,eAAe,GAAGC,MAAM,CACzBC,OAAO,CAACX,WAAW,CAAgD;IACxE,MAAMa,KAAyC,GAAG;MAC9C,WAAW,EAAE,OAAO;MACpB,cAAc,EAAE,QAAQ;MACxBV,EAAE,EAAE,MAAM;MACVC,EAAE,EAAE;IACR,CAAC;IACD,MAAMU,UAAsB,GAAG;MAC3BC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACZ,CAAC;IAEDf,MAAM,CAACL,qBAAqB,CAACiB,KAAK,EAAED,UAAU,EAAEE,UAAU,EAAEL,eAAe,CAAC,CAAC,CAACF,OAAO,CAAC,KAAK,CAAC;EAChG,CAAC,CAAC;AACN,CAAC,CAAC"}
|
@@ -1,4 +1,9 @@
|
|
1
|
+
import { Platform } from 'react-native';
|
1
2
|
export const throwError = message => {
|
2
3
|
throw new Error(`🦄 [react-native-unistyles]: ${message}`);
|
3
4
|
};
|
5
|
+
export const warn = message => {
|
6
|
+
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
7
|
+
};
|
8
|
+
export const isWeb = () => Platform.OS === 'web';
|
4
9
|
//# sourceMappingURL=common.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["throwError","message","Error"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"names":["Platform","throwError","message","Error","warn","console","isWeb","OS"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,KAAK,GAAGA,CAAA,KAAMN,QAAQ,CAACO,EAAE,KAAK,KAAK"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getBreakpointFromScreenWidth","sortAndValidateBreakpoints","proxifyFunction","parseStyle"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,4BAA4B,EAAEC,0BAA0B,QAAQ,eAAe;AACxF,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU"}
|
1
|
+
{"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","proxifyFunction","parseStyle"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,4BAA4B,EAAEC,0BAA0B,QAAQ,eAAe;AACxF,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU"}
|
@@ -174,7 +174,7 @@ describe('utils', () => {
|
|
174
174
|
});
|
175
175
|
});
|
176
176
|
it('should detect incorrect media queries', () => {
|
177
|
-
const incorrectMediaQueries = [':w100]', ':w[100, 200', ':p[, 300]', ':&[200]', ':h[0 500]', ':h[p, 750]', ':w[0]:l[200]', ':[100]:w[200]', ':h(100, 200):w[400]', ':w[2OO]:h[200, 400]', '', 'x', '>300', ']]w200[['];
|
177
|
+
const incorrectMediaQueries = [':w100]', ':w[100, 200', ':p[, 300]', ':&[200]', ':h[0 500]', ':h[p, 750]', ':w[0]:l[200]', ':[100]:w[200]', ':h(100, 200):w[400]', ':w[2OO]:h[200, 400]', '', 'x', '>300', ']]w200[[', ':w[ 100]', ':w[ , 300]', ':w[ , 200]:h[ 200 , 400]'];
|
178
178
|
incorrectMediaQueries.forEach(query => {
|
179
179
|
expect(isMediaQuery(query)).toEqual(false);
|
180
180
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight","describe","it","mediaQuery","expect","toEqual","pairs","width","query","forEach","_ref","_ref2","height","_ref3","_ref4","screenSize","_ref5","_ref6","correctMediaQueries","incorrectMediaQueries","mediaQueries","undefined"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.spec.ts"],"mappings":"AAAA,SACIA,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB;AAGvBC,QAAQ,CAAC,OAAO,EAAE,MAAM;EACpBA,QAAQ,CAAC,eAAe,EAAE,MAAM;IAC5BC,EAAE,CAAC,mDAAmD,EAAE,MAAM;MAC1D,MAAMC,UAAU,GAAG,aAAa;MAEhCC,MAAM,CAACT,aAAa,CAACQ,UAAU,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC,CAAC;IAEFH,EAAE,CAAC,8DAA8D,EAAE,MAAM;MACrE,MAAMC,UAAU,GAAG,WAAW;MAE9BC,MAAM,CAACT,aAAa,CAACQ,UAAU,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC,CAAC;IAEFH,EAAE,CAAC,qDAAqD,EAAE,MAAM;MAC5D,MAAMC,UAAU,GAAG,QAAQ;MAE3BC,MAAM,CAACT,aAAa,CAACQ,UAAU,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC,CAAC;IAEFH,EAAE,CAAC,+DAA+D,EAAE,MAAM;MACtE,MAAMC,UAAU,GAAG,OAAO;MAE1BC,MAAM,CAACT,aAAa,CAACQ,UAAU,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC;IAEFH,EAAE,CAAC,sDAAsD,EAAE,MAAM;M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AC,qCAAqC,EAAE,MAAM;MAC5C,MAAMgB,mBAAmB,GAAG,CACxB,SAAS,EACT,cAAc,EACd,WAAW,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,CACxB;MAEDA,mBAAmB,CAACT,OAAO,CAACD,KAAK,IAAI;QACjCJ,MAAM,CAACP,YAAY,CAACW,KAAK,CAAC,CAAC,CAACH,OAAO,CAAC,IAAI,CAAC;MAC7C,CAAC,CAAC;IACN,CAAC,CAAC;IAEFH,EAAE,CAAC,uCAAuC,EAAE,MAAM;MAC9C,MAAMiB,qBAAqB,GAAG,CAC1B,QAAQ,EACR,aAAa,EACb,WAAW,EACX,SAAS,EACT,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,EAAE,EACF,GAAG,EACH,MAAM,EACN,UAAU,
|
1
|
+
{"version":3,"names":["extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight","describe","it","mediaQuery","expect","toEqual","pairs","width","query","forEach","_ref","_ref2","height","_ref3","_ref4","screenSize","_ref5","_ref6","correctMediaQueries","incorrectMediaQueries","mediaQueries","undefined"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.spec.ts"],"mappings":"AAAA,SACIA,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB;AAGvBC,QAAQ,CAAC,OAAO,EAAE,MAAM;EACpBA,QAAQ,CAAC,eAAe,EAAE,MAAM;IAC5BC,EAAE,CAAC,mDAAmD,EAAE,MAAM;MAC1D,MAAMC,UAAU,GAAG,aAAa;MAEhCC,MAAM,CAACT,aAAa,CAACQ,UAAU,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC,CAAC;IA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AY,EAAEL,UAAU,CAAC,CAAC,CAACV,OAAO,CAACgB,SAAS,CAAC;IAClF,CAAC,CAAC;IAEFnB,EAAE,CAAC,+CAA+C,EAAE,MAAM;MACtD,MAAMkB,YAAY,GAAG,CACjB,CAAC,oBAAoB,EAAE,GAAG,CAAC,EAC3B,CAAC,eAAe,EAAE,GAAG,CAAC,EACtB,CAAC,QAAQ,EAAE,GAAG,CAAC,CACkB;MACrC,MAAML,UAAsB,GAAG;QAC3BR,KAAK,EAAE,GAAG;QACVK,MAAM,EAAE;MACZ,CAAC;MAEDR,MAAM,CAACR,yBAAyB,CAACwB,YAAY,EAAEL,UAAU,CAAC,CAAC,CAACV,OAAO,CAAC,oBAAoB,CAAC;IAC7F,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["normalizeStyles","styles"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.ts"],"mappings":"AAAA;AACA,OAAO,MAAMA,eAAe,GAAOC,MAAS,IAAKA,MAAW"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { warn } from './common';
|
2
|
+
const preprocessor = require('react-native-web/src/exports/StyleSheet/preprocess.js');
|
3
|
+
const normalizeBoxShadow = styles => {
|
4
|
+
const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
|
5
|
+
if (!requiredBoxShadowProperties.every(prop => prop in styles)) {
|
6
|
+
warn(`can't apply box shadow as you miss at least one of these properties: ${requiredBoxShadowProperties.join(', ')}`);
|
7
|
+
return {
|
8
|
+
shadowColor: undefined,
|
9
|
+
shadowOffset: undefined,
|
10
|
+
shadowOpacity: undefined,
|
11
|
+
shadowRadius: undefined
|
12
|
+
};
|
13
|
+
}
|
14
|
+
return {
|
15
|
+
boxShadow: preprocessor.createBoxShadowValue(styles),
|
16
|
+
shadowColor: undefined,
|
17
|
+
shadowOffset: undefined,
|
18
|
+
shadowOpacity: undefined,
|
19
|
+
shadowRadius: undefined
|
20
|
+
};
|
21
|
+
};
|
22
|
+
const normalizeTextShadow = styles => {
|
23
|
+
const requiredTextShadowProperties = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
|
24
|
+
if (!requiredTextShadowProperties.every(prop => prop in styles)) {
|
25
|
+
warn(`can't apply text shadow as you miss at least one of these properties: ${requiredTextShadowProperties.join(', ')}`);
|
26
|
+
return {
|
27
|
+
textShadowColor: undefined,
|
28
|
+
textShadowOffset: undefined,
|
29
|
+
textShadowRadius: undefined
|
30
|
+
};
|
31
|
+
}
|
32
|
+
return {
|
33
|
+
textShadow: preprocessor.createTextShadowValue(styles),
|
34
|
+
textShadowColor: undefined,
|
35
|
+
textShadowOffset: undefined,
|
36
|
+
textShadowRadius: undefined
|
37
|
+
};
|
38
|
+
};
|
39
|
+
export const normalizeStyles = styles => {
|
40
|
+
const normalizedTransform = 'transform' in styles && Array.isArray(styles.transform) ? {
|
41
|
+
transform: preprocessor.createTransformValue(styles.transform)
|
42
|
+
} : {};
|
43
|
+
const normalizedBoxShadow = 'shadowColor' in styles || 'shadowOffset' in styles || 'shadowOpacity' in styles || 'shadowRadius' in styles ? normalizeBoxShadow(styles) : {};
|
44
|
+
const normalizedTextShadow = 'textShadowColor' in styles || 'textShadowOffset' in styles || 'textShadowRadius' in styles ? normalizeTextShadow(styles) : {};
|
45
|
+
return {
|
46
|
+
...styles,
|
47
|
+
...normalizedTransform,
|
48
|
+
...normalizedBoxShadow,
|
49
|
+
...normalizedTextShadow
|
50
|
+
};
|
51
|
+
};
|
52
|
+
//# sourceMappingURL=normalizeStyles.web.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["warn","preprocessor","require","normalizeBoxShadow","styles","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,UAAU;AAE/B,MAAMC,YAA0B,GAAGC,OAAO,CAAC,uDAAuD,CAAC;AAuBnG,MAAMC,kBAAkB,GAAkBC,MAAS,IAA0B;EACzE,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,MAAM,CAAC,EAAE;IAC5DJ,IAAI,CAAE,wEAAuEK,2BAA2B,CAACG,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEb,YAAY,CAACc,oBAAoB,CAACX,MAAM,CAAC;IACpDK,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAAC;AACL,CAAC;AAED,MAAMM,mBAAmB,GAAkBZ,MAAS,IAA2B;EAC3E,MAAMa,4BAA4B,GAAG,CACjC,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CACrB;EAED,IAAI,CAACA,4BAA4B,CAACX,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,MAAM,CAAC,EAAE;IAC7DJ,IAAI,CAAE,yEAAwEiB,4BAA4B,CAACT,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAExH,OAAO;MACHU,eAAe,EAAER,SAAS;MAC1BS,gBAAgB,EAAET,SAAS;MAC3BU,gBAAgB,EAAEV;IACtB,CAAC;EACL;EAEA,OAAO;IAC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