react-native-unistyles 1.0.0-rc.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +16 -3
- package/lib/commonjs/UnistylesTheme.js +2 -2
- package/lib/commonjs/UnistylesTheme.js.map +1 -1
- package/lib/commonjs/hooks/useDimensions.web.js +3 -2
- package/lib/commonjs/hooks/useDimensions.web.js.map +1 -1
- package/lib/commonjs/types/index.js +15 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/normalizer.js +6 -0
- package/lib/commonjs/types/normalizer.js.map +1 -0
- package/lib/commonjs/utils/common.js +3 -3
- package/lib/commonjs/utils/common.js.map +1 -1
- package/lib/commonjs/utils/index.js +34 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
- package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
- package/lib/commonjs/utils/normalizer.js +83 -0
- package/lib/commonjs/utils/normalizer.js.map +1 -0
- package/lib/commonjs/utils/styles.js +1 -1
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/hooks/useDimensions.web.js +3 -2
- package/lib/module/hooks/useDimensions.web.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/normalizer.js +2 -0
- package/lib/module/types/normalizer.js.map +1 -0
- package/lib/module/utils/common.js +2 -1
- package/lib/module/utils/common.js.map +1 -1
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/normalizeStyles.web.js +13 -13
- package/lib/module/utils/normalizeStyles.web.js.map +1 -1
- package/lib/module/utils/normalizer.js +75 -0
- package/lib/module/utils/normalizer.js.map +1 -0
- package/lib/module/utils/styles.js +1 -1
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/examples/expo/src/App.d.ts +3 -0
- package/lib/typescript/examples/expo/src/App.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +7 -0
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts +8 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/index.d.ts +2 -0
- package/lib/typescript/examples/expo/src/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +8 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts +46 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +24 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/normalizer.d.ts +20 -0
- package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/utils/common.d.ts +2 -1
- package/lib/typescript/src/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizer.d.ts +11 -0
- package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
- package/package.json +16 -11
- package/src/hooks/useDimensions.web.ts +3 -2
- package/src/types/index.ts +1 -0
- package/src/types/normalizer.ts +29 -0
- package/src/utils/common.ts +2 -1
- package/src/utils/index.ts +2 -0
- package/src/utils/normalizeStyles.web.ts +21 -42
- package/src/utils/normalizer.ts +105 -0
- package/src/utils/styles.ts +1 -1
@@ -0,0 +1,75 @@
|
|
1
|
+
// based on react-native-web normalizer
|
2
|
+
// https://github.com/necolas/react-native-web
|
3
|
+
|
4
|
+
// for now supports
|
5
|
+
// hex colors (3, 6, 8) chars
|
6
|
+
// colors like orange red etc.
|
7
|
+
export const normalizeColor = function (color) {
|
8
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
9
|
+
if (!color.startsWith('#')) {
|
10
|
+
return color;
|
11
|
+
}
|
12
|
+
if (color.length === 9) {
|
13
|
+
const [r, g, b, a] = color.slice(1).split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
|
14
|
+
return `rgba(${r},${g},${b},${a / 255})`;
|
15
|
+
}
|
16
|
+
const sanitizedHex = color.length === 4 ? color.slice(1).split('').map(char => `${char}${char}`).join('') : color.slice(1);
|
17
|
+
return sanitizedHex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num)).reduce((acc, color) => `${acc}${color},`, 'rgba(').concat(`${opacity})`);
|
18
|
+
};
|
19
|
+
export const normalizeNumericValue = value => value ? `${value}px` : value;
|
20
|
+
const normalizeTransform = (key, value) => {
|
21
|
+
if (key.includes('scale')) {
|
22
|
+
return value;
|
23
|
+
}
|
24
|
+
if (typeof value === 'number') {
|
25
|
+
return normalizeNumericValue(value);
|
26
|
+
}
|
27
|
+
return value;
|
28
|
+
};
|
29
|
+
const createTextShadowValue = style => {
|
30
|
+
// at this point every prop is present
|
31
|
+
const {
|
32
|
+
textShadowColor,
|
33
|
+
textShadowOffset,
|
34
|
+
textShadowRadius
|
35
|
+
} = style;
|
36
|
+
const offsetX = normalizeNumericValue(textShadowOffset.width);
|
37
|
+
const offsetY = normalizeNumericValue(textShadowOffset.height);
|
38
|
+
const radius = normalizeNumericValue(textShadowRadius);
|
39
|
+
const color = normalizeColor(textShadowColor);
|
40
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
41
|
+
};
|
42
|
+
const createBoxShadowValue = style => {
|
43
|
+
// at this point every prop is present
|
44
|
+
const {
|
45
|
+
shadowColor,
|
46
|
+
shadowOffset,
|
47
|
+
shadowOpacity,
|
48
|
+
shadowRadius
|
49
|
+
} = style;
|
50
|
+
const offsetX = normalizeNumericValue(shadowOffset.width);
|
51
|
+
const offsetY = normalizeNumericValue(shadowOffset.height);
|
52
|
+
const radius = normalizeNumericValue(shadowRadius);
|
53
|
+
const color = normalizeColor(shadowColor, shadowOpacity);
|
54
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
55
|
+
};
|
56
|
+
const createTransformValue = transforms => transforms.map(transform => {
|
57
|
+
const [key] = Object.keys(transform);
|
58
|
+
if (!key) {
|
59
|
+
return undefined;
|
60
|
+
}
|
61
|
+
const value = transform[key];
|
62
|
+
switch (key) {
|
63
|
+
case 'matrix':
|
64
|
+
case 'matrix3d':
|
65
|
+
return `${key}(${value.join(',')})`;
|
66
|
+
default:
|
67
|
+
return `${key}(${normalizeTransform(key, value)})`;
|
68
|
+
}
|
69
|
+
}).filter(Boolean).join(' ');
|
70
|
+
export const preprocessor = {
|
71
|
+
createTextShadowValue,
|
72
|
+
createBoxShadowValue,
|
73
|
+
createTransformValue
|
74
|
+
};
|
75
|
+
//# sourceMappingURL=normalizer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["normalizeColor","color","opacity","arguments","length","undefined","startsWith","r","g","b","a","slice","split","map","x","parseInt","filter","num","isNaN","sanitizedHex","char","join","reduce","acc","concat","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["utils/normalizer.ts"],"mappings":"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"}
|
@@ -71,6 +71,6 @@ export const parseStyle = (style, breakpoint, screenSize, breakpointPairs) => {
|
|
71
71
|
}
|
72
72
|
return [key, getValueForBreakpoint(value, breakpoint, screenSize, breakpointPairs)];
|
73
73
|
}));
|
74
|
-
return isWeb
|
74
|
+
return isWeb ? normalizeStyles(parsedStyles) : parsedStyles;
|
75
75
|
};
|
76
76
|
//# sourceMappingURL=styles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getValueForBreakpoint","normalizeStyles","isWeb","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","Proxy","apply","target","thisArg","argumentsList","parseStyle","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","value","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,UAAU;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA4B,EAC1CC,UAAsB,EACtBC,eAA2C,KAChC,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,UAAU,EAAEC,UAAU,EAAEC,eAAe;AAChG,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,UAAU,GAAGA,CACtBC,KAA8B,EAC9BT,UAA4B,EAC5BC,UAAsB,EACtBC,eAA2C,KACvC;EACJ,MAAMQ,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACD,KAAK,CAGnC;EAED,MAAMG,YAAY,GAAGD,MAAM,CACtBE,WAAW,CAACH,OAAO,CACfI,GAAG,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACd,MAAMG,mBAAmB,GAAGF,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB;IAEhF,IAAIE,mBAAmB,EAAE;MACrB,OAAO,CACHF,GAAG,EACHR,UAAU,CAACS,KAAK,EAA6BjB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CACxF;IACL;IAEA,MAAMiB,WAAW,GAAGH,GAAG,KAAK,WAAW;IAEvC,IAAIG,WAAW,IAAIC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;MACrC,OAAO,CACHD,GAAG,EACHC,KAAK,CAACH,GAAG,CAACG,KAAK,IAAIT,UAAU,CAACS,KAAK,EAAEjB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CAAC,CACjF;IACL;IAEA,MAAMoB,iBAAiB,GAAG,OAAOL,KAAK,KAAK,UAAU;IACrD,MAAMM,YAAY,GAAG,OAAON,KAAK,KAAK,QAAQ;IAE9C,IAAIK,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACP,GAAG,EAAEC,KAAK,CAAC;IACvB;IAEA,OAAO,CACHD,GAAG,EACHrB,qBAAqB,CACjBsB,KAAK,EACLjB,UAAU,EACVC,UAAU,EACVC,eACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAOL,KAAK,
|
1
|
+
{"version":3,"names":["getValueForBreakpoint","normalizeStyles","isWeb","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","Proxy","apply","target","thisArg","argumentsList","parseStyle","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","value","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,UAAU;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA4B,EAC1CC,UAAsB,EACtBC,eAA2C,KAChC,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,UAAU,EAAEC,UAAU,EAAEC,eAAe;AAChG,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,UAAU,GAAGA,CACtBC,KAA8B,EAC9BT,UAA4B,EAC5BC,UAAsB,EACtBC,eAA2C,KACvC;EACJ,MAAMQ,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACD,KAAK,CAGnC;EAED,MAAMG,YAAY,GAAGD,MAAM,CACtBE,WAAW,CAACH,OAAO,CACfI,GAAG,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACd,MAAMG,mBAAmB,GAAGF,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB;IAEhF,IAAIE,mBAAmB,EAAE;MACrB,OAAO,CACHF,GAAG,EACHR,UAAU,CAACS,KAAK,EAA6BjB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CACxF;IACL;IAEA,MAAMiB,WAAW,GAAGH,GAAG,KAAK,WAAW;IAEvC,IAAIG,WAAW,IAAIC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;MACrC,OAAO,CACHD,GAAG,EACHC,KAAK,CAACH,GAAG,CAACG,KAAK,IAAIT,UAAU,CAACS,KAAK,EAAEjB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CAAC,CACjF;IACL;IAEA,MAAMoB,iBAAiB,GAAG,OAAOL,KAAK,KAAK,UAAU;IACrD,MAAMM,YAAY,GAAG,OAAON,KAAK,KAAK,QAAQ;IAE9C,IAAIK,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACP,GAAG,EAAEC,KAAK,CAAC;IACvB;IAEA,OAAO,CACHD,GAAG,EACHrB,qBAAqB,CACjBsB,KAAK,EACLjB,UAAU,EACVC,UAAU,EACVC,eACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAOL,KAAK,GACND,eAAe,CAACgB,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../../examples/expo/src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAUvC,eAAO,MAAM,GAAG,EAAE,KAAK,CAAC,iBAgBvB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Breakpoints.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Breakpoints.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,iBAiB/B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EmptyStyles.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/EmptyStyles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,iBAU/B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Extreme.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Extreme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,KAAK,YAAY,GAAG;IAChB,aAAa,EAAE,YAAY,CAAA;CAC9B,CAAA;AAGD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,YAAY,CAezD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MediaQueries.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/MediaQueries.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,iBAahC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Memoization.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Memoization.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,iBAY/B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Minimal.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Minimal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,iBAU3B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MinimalWithCreateStyleSheet.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/MinimalWithCreateStyleSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,iBAU/C,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Theme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,iBAUzB,CAAA"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export { Minimal } from './Minimal';
|
2
|
+
export { MinimalWithCreateStyleSheet } from './MinimalWithCreateStyleSheet';
|
3
|
+
export { Theme } from './Theme';
|
4
|
+
export { Breakpoints } from './Breakpoints';
|
5
|
+
export { MediaQueries } from './MediaQueries';
|
6
|
+
export { Extreme } from './Extreme';
|
7
|
+
export { Memoization } from './Memoization';
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../examples/expo/src/index.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/styles/breakpoints.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAA"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import type { AppTheme } from './theme';
|
2
|
+
import { lightTheme, darkTheme } from './theme';
|
3
|
+
export declare const useStyles: <ST extends import("../../../../src/types").CustomNamedStyles<ST, {
|
4
|
+
xs: number;
|
5
|
+
sm: number;
|
6
|
+
md: number;
|
7
|
+
lg: number;
|
8
|
+
xl: number;
|
9
|
+
}>>(stylesheet?: ST | import("../../../../src/types").CreateStylesFactory<ST, AppTheme> | undefined) => {
|
10
|
+
theme: AppTheme;
|
11
|
+
breakpoint: "xs" | "sm" | "md" | "lg" | "xl";
|
12
|
+
styles: import("../../../../src/types").ExtractBreakpoints<import("../../../../src/types").RemoveKeysWithPrefix<ST, {
|
13
|
+
xs: number;
|
14
|
+
sm: number;
|
15
|
+
md: number;
|
16
|
+
lg: number;
|
17
|
+
xl: number;
|
18
|
+
}>, {
|
19
|
+
xs: number;
|
20
|
+
sm: number;
|
21
|
+
md: number;
|
22
|
+
lg: number;
|
23
|
+
xl: number;
|
24
|
+
}>;
|
25
|
+
}, createStyleSheet: <S extends import("../../../../src/types").CustomNamedStyles<S, {
|
26
|
+
xs: number;
|
27
|
+
sm: number;
|
28
|
+
md: number;
|
29
|
+
lg: number;
|
30
|
+
xl: number;
|
31
|
+
}>, X>(styles: S | X | import("../../../../src/types").CustomNamedStyles<S, {
|
32
|
+
xs: number;
|
33
|
+
sm: number;
|
34
|
+
md: number;
|
35
|
+
lg: number;
|
36
|
+
xl: number;
|
37
|
+
}> | ((theme: AppTheme) => X | import("../../../../src/types").CustomNamedStyles<X, {
|
38
|
+
xs: number;
|
39
|
+
sm: number;
|
40
|
+
md: number;
|
41
|
+
lg: number;
|
42
|
+
xl: number;
|
43
|
+
}>)) => S | X;
|
44
|
+
export { lightTheme, darkTheme };
|
45
|
+
export type { AppTheme };
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/styles/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE/C,eAAO,MAAQ,SAAS;;;;;;;;;;;;;;;;;;;;;;GAAE,gBAAgB;;;;;;;;;;;;;;;;;;aAA+D,CAAA;AAEzG,OAAO,EACH,UAAU,EACV,SAAS,EACZ,CAAA;AAED,YAAY,EACR,QAAQ,EACX,CAAA"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export declare const lightTheme: {
|
2
|
+
colors: {
|
3
|
+
backgroundColor: string;
|
4
|
+
typography: string;
|
5
|
+
barbie: string;
|
6
|
+
oak: string;
|
7
|
+
sky: string;
|
8
|
+
fog: string;
|
9
|
+
aloes: string;
|
10
|
+
};
|
11
|
+
};
|
12
|
+
export declare const darkTheme: {
|
13
|
+
colors: {
|
14
|
+
backgroundColor: string;
|
15
|
+
typography: string;
|
16
|
+
barbie: string;
|
17
|
+
oak: string;
|
18
|
+
sky: string;
|
19
|
+
fog: string;
|
20
|
+
aloes: string;
|
21
|
+
};
|
22
|
+
};
|
23
|
+
export type AppTheme = typeof lightTheme | typeof darkTheme;
|
24
|
+
//# sourceMappingURL=theme.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/styles/theme.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU;;;;;;;;;;CAOtB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;;;;;;CAOrB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,UAAU,GAAG,OAAO,SAAS,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDimensions.web.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"useDimensions.web.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C,eAAO,MAAM,aAAa,QAAO,UA0BhC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/C,YAAY,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EAC1B,MAAM,eAAe,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/C,YAAY,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EAC1B,MAAM,eAAe,CAAA"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import type { ShadowStyleIOS, TextStyle, TransformsStyle } from 'react-native';
|
2
|
+
type TransformArrayElement<T> = T extends Array<infer U> ? U : never;
|
3
|
+
type BoxShadow = Required<ShadowStyleIOS>;
|
4
|
+
type TextShadow = Required<Pick<TextStyle, 'textShadowColor' | 'textShadowOffset' | 'textShadowRadius'>>;
|
5
|
+
type Transforms = Array<TransformArrayElement<TransformsStyle['transform']>>;
|
6
|
+
type NormalizedBoxShadow = {
|
7
|
+
shadowColor: undefined;
|
8
|
+
shadowOffset: undefined;
|
9
|
+
shadowOpacity: undefined;
|
10
|
+
shadowRadius: undefined;
|
11
|
+
boxShadow?: string;
|
12
|
+
};
|
13
|
+
type NormalizedTextShadow = {
|
14
|
+
textShadowColor: undefined;
|
15
|
+
textShadowOffset: undefined;
|
16
|
+
textShadowRadius: undefined;
|
17
|
+
textShadow?: string;
|
18
|
+
};
|
19
|
+
export type { BoxShadow, TextShadow, Transforms, NormalizedBoxShadow, NormalizedTextShadow };
|
20
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../src/types/normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9E,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AACpE,KAAK,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAA;AACzC,KAAK,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC,CAAC,CAAA;AACxG,KAAK,UAAU,GAAG,KAAK,CAAC,qBAAqB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AAE5E,KAAK,mBAAmB,GAAG;IACvB,WAAW,EAAE,SAAS,CAAC;IACvB,YAAY,EAAE,SAAS,CAAC;IACxB,aAAa,EAAE,SAAS,CAAC;IACzB,YAAY,EAAE,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,oBAAoB,GAAG;IACxB,eAAe,EAAE,SAAS,CAAA;IAC1B,gBAAgB,EAAE,SAAS,CAAA;IAC3B,gBAAgB,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,YAAY,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACvB,CAAA"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export declare const throwError: (message: string) => never;
|
2
2
|
export declare const warn: (message: string) => void;
|
3
|
-
export declare const isWeb:
|
3
|
+
export declare const isWeb: boolean;
|
4
|
+
export declare const isServer: boolean;
|
4
5
|
//# sourceMappingURL=common.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,YAAa,MAAM,UAEzC,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,YAAa,MAAM,UAEzC,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,QAAQ,SAAgC,CAAA"}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
export { normalizeStyles } from './normalizeStyles';
|
2
|
+
export * from './normalizer';
|
2
3
|
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
|
3
4
|
export { proxifyFunction, parseStyle } from './styles';
|
5
|
+
export { isServer } from './common';
|
4
6
|
export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
|
@@ -1,2 +1,5 @@
|
|
1
|
-
|
1
|
+
import type { Transforms } from '../types';
|
2
|
+
export declare const normalizeStyles: <T extends Required<import("react-native").ShadowStyleIOS> | Required<Pick<import("react-native").TextStyle, "textShadowColor" | "textShadowOffset" | "textShadowRadius">> | {
|
3
|
+
transform: Transforms;
|
4
|
+
}>(style: T) => T;
|
2
5
|
//# sourceMappingURL=normalizeStyles.web.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"normalizeStyles.web.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizeStyles.web.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"normalizeStyles.web.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizeStyles.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoE,UAAU,EAAE,MAAM,UAAU,CAAA;AAuD5G,eAAO,MAAM,eAAe;;iBAwB3B,CAAA"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { TextShadow, Transforms, BoxShadow } from '../types';
|
2
|
+
type Preprocessor = {
|
3
|
+
createTextShadowValue(style: TextShadow): string;
|
4
|
+
createBoxShadowValue(style: Required<BoxShadow>): string;
|
5
|
+
createTransformValue(transforms: Required<Transforms>): string;
|
6
|
+
};
|
7
|
+
export declare const normalizeColor: (color: string, opacity?: number) => string;
|
8
|
+
export declare const normalizeNumericValue: (value: number) => string | number;
|
9
|
+
export declare const preprocessor: Preprocessor;
|
10
|
+
export {};
|
11
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEjE,KAAK,YAAY,GAAG;IAChB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC;IACjD,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IACzD,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;CAClE,CAAA;AAKD,eAAO,MAAM,cAAc,UAAW,MAAM,YAAW,MAAM,WA6B5D,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,MAAM,oBAAiC,CAAA;AAwDpF,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAA"}
|
package/package.json
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.1.0",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
7
|
+
"test:coverage": "jest --coverage",
|
7
8
|
"tsc": "node_modules/typescript/bin/tsc --noEmit",
|
8
9
|
"lint": "eslint . --ext .ts,.tsx",
|
9
10
|
"clean": "del-cli lib",
|
10
11
|
"prepare": "husky install && bob build",
|
11
12
|
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
|
12
|
-
"release": "release-it
|
13
|
+
"release": "release-it"
|
13
14
|
},
|
14
15
|
"main": "lib/commonjs/index",
|
15
16
|
"module": "lib/module/index",
|
@@ -38,17 +39,17 @@
|
|
38
39
|
"registry": "https://registry.npmjs.org/"
|
39
40
|
},
|
40
41
|
"devDependencies": {
|
41
|
-
"@commitlint/config-conventional": "17.
|
42
|
-
"@react-native/eslint-config": "0.
|
42
|
+
"@commitlint/config-conventional": "17.8.0",
|
43
|
+
"@react-native/eslint-config": "0.74.0",
|
43
44
|
"@release-it/conventional-changelog": "5.1.1",
|
44
45
|
"@testing-library/react-hooks": "8.0.1",
|
45
46
|
"@types/jest": "29.5.5",
|
46
47
|
"@types/react": "18.2.28",
|
47
48
|
"@types/react-native": "0.72.3",
|
48
|
-
"@typescript-eslint/eslint-plugin": "6.
|
49
|
-
"@typescript-eslint/eslint-plugin-tslint": "6.
|
50
|
-
"@typescript-eslint/parser": "6.
|
51
|
-
"commitlint": "17.
|
49
|
+
"@typescript-eslint/eslint-plugin": "6.8.0",
|
50
|
+
"@typescript-eslint/eslint-plugin-tslint": "6.8.0",
|
51
|
+
"@typescript-eslint/parser": "6.8.0",
|
52
|
+
"commitlint": "17.8.0",
|
52
53
|
"concurrently": "8.2.1",
|
53
54
|
"del-cli": "5.1.0",
|
54
55
|
"eslint": "8.51.0",
|
@@ -66,7 +67,7 @@
|
|
66
67
|
"husky": "8.0.3",
|
67
68
|
"jest": "29.7.0",
|
68
69
|
"react": "18.2.0",
|
69
|
-
"react-native": "0.72.
|
70
|
+
"react-native": "0.72.6",
|
70
71
|
"react-native-builder-bob": "0.23.1",
|
71
72
|
"react-native-web": "0.19.9",
|
72
73
|
"react-test-renderer": "18.2.0",
|
@@ -84,7 +85,7 @@
|
|
84
85
|
}
|
85
86
|
},
|
86
87
|
"workspaces": [
|
87
|
-
"
|
88
|
+
"examples/expo",
|
88
89
|
"docs"
|
89
90
|
],
|
90
91
|
"packageManager": "yarn@3.6.1",
|
@@ -94,9 +95,13 @@
|
|
94
95
|
"jest": {
|
95
96
|
"preset": "react-native",
|
96
97
|
"modulePathIgnorePatterns": [
|
97
|
-
"<rootDir>/
|
98
|
+
"<rootDir>/examples/expo/node_modules",
|
99
|
+
"<rootDir>/examples/ssr/node_modules",
|
98
100
|
"<rootDir>/docs/node_modules",
|
99
101
|
"<rootDir>/lib/"
|
102
|
+
],
|
103
|
+
"coverageReporters": [
|
104
|
+
"html"
|
100
105
|
]
|
101
106
|
},
|
102
107
|
"commitlint": {
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
2
2
|
import type { ScreenSize } from '../types'
|
3
|
+
import { isServer } from '../utils'
|
3
4
|
|
4
5
|
export const useDimensions = (): ScreenSize => {
|
5
6
|
const timerRef = useRef<ReturnType<typeof setTimeout>>()
|
6
7
|
const [screenSize, setScreenSize] = useState<ScreenSize>({
|
7
|
-
width: window.innerWidth,
|
8
|
-
height: window.innerHeight
|
8
|
+
width: isServer ? 0 : window.innerWidth,
|
9
|
+
height: isServer ? 0 : window.innerHeight
|
9
10
|
})
|
10
11
|
|
11
12
|
useEffect(() => {
|
package/src/types/index.ts
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
import type { ShadowStyleIOS, TextStyle, TransformsStyle } from 'react-native'
|
2
|
+
|
3
|
+
type TransformArrayElement<T> = T extends Array<infer U> ? U : never
|
4
|
+
type BoxShadow = Required<ShadowStyleIOS>
|
5
|
+
type TextShadow = Required<Pick<TextStyle, 'textShadowColor' | 'textShadowOffset' | 'textShadowRadius'>>
|
6
|
+
type Transforms = Array<TransformArrayElement<TransformsStyle['transform']>>
|
7
|
+
|
8
|
+
type NormalizedBoxShadow = {
|
9
|
+
shadowColor: undefined,
|
10
|
+
shadowOffset: undefined,
|
11
|
+
shadowOpacity: undefined,
|
12
|
+
shadowRadius: undefined,
|
13
|
+
boxShadow?: string
|
14
|
+
}
|
15
|
+
|
16
|
+
type NormalizedTextShadow = {
|
17
|
+
textShadowColor: undefined
|
18
|
+
textShadowOffset: undefined
|
19
|
+
textShadowRadius: undefined,
|
20
|
+
textShadow?: string
|
21
|
+
}
|
22
|
+
|
23
|
+
export type {
|
24
|
+
BoxShadow,
|
25
|
+
TextShadow,
|
26
|
+
Transforms,
|
27
|
+
NormalizedBoxShadow,
|
28
|
+
NormalizedTextShadow
|
29
|
+
}
|
package/src/utils/common.ts
CHANGED
package/src/utils/index.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
export { normalizeStyles } from './normalizeStyles'
|
2
|
+
export * from './normalizer'
|
2
3
|
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints'
|
3
4
|
export { proxifyFunction, parseStyle } from './styles'
|
5
|
+
export { isServer } from './common'
|
4
6
|
export {
|
5
7
|
extractValues,
|
6
8
|
getKeyForCustomMediaQuery,
|