react-native-unistyles 2.0.0-alpha.1 → 2.0.0-alpha.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. package/README.md +4 -4
  2. package/cxx/UnistylesRuntime.cpp +255 -0
  3. package/cxx/UnistylesRuntime.h +60 -0
  4. package/ios/UnistylesHelpers.h +4 -0
  5. package/ios/UnistylesHelpers.mm +20 -0
  6. package/ios/UnistylesModule.h +10 -0
  7. package/ios/UnistylesModule.mm +158 -0
  8. package/lib/commonjs/common.js +26 -0
  9. package/lib/commonjs/common.js.map +1 -0
  10. package/lib/commonjs/core/UnistyleRegistry.js +38 -0
  11. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
  12. package/lib/commonjs/core/Unistyles.js +31 -0
  13. package/lib/commonjs/core/Unistyles.js.map +1 -0
  14. package/lib/commonjs/core/UnistylesModule.js +9 -0
  15. package/lib/commonjs/core/UnistylesModule.js.map +1 -0
  16. package/lib/commonjs/core/UnistylesRuntime.js +66 -0
  17. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
  18. package/lib/commonjs/core/index.js +13 -0
  19. package/lib/commonjs/core/index.js.map +1 -0
  20. package/lib/commonjs/createStyleSheet.js +14 -0
  21. package/lib/commonjs/createStyleSheet.js.map +1 -0
  22. package/lib/commonjs/global.js +2 -0
  23. package/lib/commonjs/global.js.map +1 -0
  24. package/lib/commonjs/hooks/index.js +10 -3
  25. package/lib/commonjs/hooks/index.js.map +1 -1
  26. package/lib/commonjs/hooks/useInitialTheme.js +17 -0
  27. package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
  28. package/lib/commonjs/hooks/useUnistyles.js +54 -0
  29. package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
  30. package/lib/commonjs/index.js +35 -6
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/types/common.js +2 -0
  33. package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
  34. package/lib/commonjs/types/index.js +26 -0
  35. package/lib/commonjs/types/index.js.map +1 -1
  36. package/lib/commonjs/types/mq.js +6 -0
  37. package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
  38. package/lib/commonjs/types/normalizer.js +6 -0
  39. package/lib/commonjs/types/normalizer.js.map +1 -0
  40. package/lib/commonjs/types/unistyles.js +6 -0
  41. package/lib/commonjs/types/unistyles.js.map +1 -0
  42. package/lib/commonjs/useStyles.js +49 -0
  43. package/lib/commonjs/useStyles.js.map +1 -0
  44. package/lib/commonjs/utils/breakpoints.js +44 -82
  45. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  46. package/lib/commonjs/utils/common.js +10 -3
  47. package/lib/commonjs/utils/common.js.map +1 -1
  48. package/lib/commonjs/utils/index.js +46 -17
  49. package/lib/commonjs/utils/index.js.map +1 -1
  50. package/lib/commonjs/utils/module.d.js +2 -0
  51. package/lib/commonjs/utils/module.d.js.map +1 -0
  52. package/lib/commonjs/utils/mq.js +89 -0
  53. package/lib/commonjs/utils/mq.js.map +1 -0
  54. package/lib/commonjs/utils/mqParser.js +86 -0
  55. package/lib/commonjs/utils/mqParser.js.map +1 -0
  56. package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
  57. package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
  58. package/lib/commonjs/utils/normalizer.js +89 -0
  59. package/lib/commonjs/utils/normalizer.js.map +1 -0
  60. package/lib/commonjs/utils/styles.js +17 -57
  61. package/lib/commonjs/utils/styles.js.map +1 -1
  62. package/lib/commonjs/utils/variants.js +20 -0
  63. package/lib/commonjs/utils/variants.js.map +1 -0
  64. package/lib/module/common.js +22 -0
  65. package/lib/module/common.js.map +1 -0
  66. package/lib/module/core/UnistyleRegistry.js +31 -0
  67. package/lib/module/core/UnistyleRegistry.js.map +1 -0
  68. package/lib/module/core/Unistyles.js +25 -0
  69. package/lib/module/core/Unistyles.js.map +1 -0
  70. package/lib/module/core/UnistylesModule.js +3 -0
  71. package/lib/module/core/UnistylesModule.js.map +1 -0
  72. package/lib/module/core/UnistylesRuntime.js +59 -0
  73. package/lib/module/core/UnistylesRuntime.js.map +1 -0
  74. package/lib/module/core/index.js +2 -0
  75. package/lib/module/core/index.js.map +1 -0
  76. package/lib/module/createStyleSheet.js +7 -0
  77. package/lib/module/createStyleSheet.js.map +1 -0
  78. package/lib/module/global.js +2 -0
  79. package/lib/module/global.js.map +1 -0
  80. package/lib/module/hooks/index.js +2 -1
  81. package/lib/module/hooks/index.js.map +1 -1
  82. package/lib/module/hooks/useInitialTheme.js +10 -0
  83. package/lib/module/hooks/useInitialTheme.js.map +1 -0
  84. package/lib/module/hooks/useUnistyles.js +47 -0
  85. package/lib/module/hooks/useUnistyles.js.map +1 -0
  86. package/lib/module/index.js +13 -2
  87. package/lib/module/index.js.map +1 -1
  88. package/lib/module/types/common.js +2 -0
  89. package/lib/module/types/common.js.map +1 -0
  90. package/lib/module/types/index.js +2 -1
  91. package/lib/module/types/index.js.map +1 -1
  92. package/lib/module/types/mq.js +2 -0
  93. package/lib/module/types/mq.js.map +1 -0
  94. package/lib/module/types/normalizer.js +2 -0
  95. package/lib/module/types/normalizer.js.map +1 -0
  96. package/lib/module/types/unistyles.js +2 -0
  97. package/lib/module/types/unistyles.js.map +1 -0
  98. package/lib/module/useStyles.js +42 -0
  99. package/lib/module/useStyles.js.map +1 -0
  100. package/lib/module/utils/breakpoints.js +43 -82
  101. package/lib/module/utils/breakpoints.js.map +1 -1
  102. package/lib/module/utils/common.js +9 -1
  103. package/lib/module/utils/common.js.map +1 -1
  104. package/lib/module/utils/index.js +6 -2
  105. package/lib/module/utils/index.js.map +1 -1
  106. package/lib/module/utils/module.d.js +2 -0
  107. package/lib/module/utils/module.d.js.map +1 -0
  108. package/lib/module/utils/mq.js +83 -0
  109. package/lib/module/utils/mq.js.map +1 -0
  110. package/lib/module/utils/mqParser.js +79 -0
  111. package/lib/module/utils/mqParser.js.map +1 -0
  112. package/lib/module/utils/normalizeStyles.web.js +13 -13
  113. package/lib/module/utils/normalizeStyles.web.js.map +1 -1
  114. package/lib/module/utils/normalizer.js +79 -0
  115. package/lib/module/utils/normalizer.js.map +1 -0
  116. package/lib/module/utils/styles.js +17 -59
  117. package/lib/module/utils/styles.js.map +1 -1
  118. package/lib/module/utils/variants.js +13 -0
  119. package/lib/module/utils/variants.js.map +1 -0
  120. package/lib/typescript/src/common.d.ts +17 -0
  121. package/lib/typescript/src/common.d.ts.map +1 -0
  122. package/lib/typescript/src/core/UnistyleRegistry.d.ts +15 -0
  123. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
  124. package/lib/typescript/src/core/Unistyles.d.ts +13 -0
  125. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
  126. package/lib/typescript/src/core/UnistylesModule.d.ts +6 -0
  127. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
  128. package/lib/typescript/src/core/UnistylesRuntime.d.ts +24 -0
  129. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
  130. package/lib/typescript/src/core/index.d.ts +2 -0
  131. package/lib/typescript/src/core/index.d.ts.map +1 -0
  132. package/lib/typescript/src/createStyleSheet.d.ts +3 -0
  133. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  134. package/lib/typescript/src/global.d.ts +7 -0
  135. package/lib/typescript/src/global.d.ts.map +1 -0
  136. package/lib/typescript/src/hooks/index.d.ts +2 -1
  137. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  138. package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
  139. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
  140. package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
  141. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
  142. package/lib/typescript/src/index.d.ts +14 -2
  143. package/lib/typescript/src/index.d.ts.map +1 -1
  144. package/lib/typescript/src/types/breakpoints.d.ts +13 -13
  145. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  146. package/lib/typescript/src/types/common.d.ts +3 -0
  147. package/lib/typescript/src/types/common.d.ts.map +1 -0
  148. package/lib/typescript/src/types/core.d.ts +34 -18
  149. package/lib/typescript/src/types/core.d.ts.map +1 -1
  150. package/lib/typescript/src/types/index.d.ts +6 -2
  151. package/lib/typescript/src/types/index.d.ts.map +1 -1
  152. package/lib/typescript/src/types/mq.d.ts +3 -0
  153. package/lib/typescript/src/types/mq.d.ts.map +1 -0
  154. package/lib/typescript/src/types/normalizer.d.ts +20 -0
  155. package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
  156. package/lib/typescript/src/types/unistyles.d.ts +37 -0
  157. package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
  158. package/lib/typescript/src/useStyles.d.ts +10 -0
  159. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  160. package/lib/typescript/src/utils/breakpoints.d.ts +5 -62
  161. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  162. package/lib/typescript/src/utils/common.d.ts +9 -1
  163. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  164. package/lib/typescript/src/utils/index.d.ts +6 -2
  165. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  166. package/lib/typescript/src/utils/mq.d.ts +21 -0
  167. package/lib/typescript/src/utils/mq.d.ts.map +1 -0
  168. package/lib/typescript/src/utils/mqParser.d.ts +3 -0
  169. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
  170. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
  171. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
  172. package/lib/typescript/src/utils/normalizer.d.ts +11 -0
  173. package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
  174. package/lib/typescript/src/utils/styles.d.ts +5 -49
  175. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  176. package/lib/typescript/src/utils/variants.d.ts +3 -0
  177. package/lib/typescript/src/utils/variants.d.ts.map +1 -0
  178. package/package.json +33 -15
  179. package/react-native-unistyles.podspec +22 -0
  180. package/src/common.ts +19 -0
  181. package/src/core/UnistyleRegistry.ts +41 -0
  182. package/src/core/Unistyles.ts +34 -0
  183. package/src/core/UnistylesModule.ts +7 -0
  184. package/src/core/UnistylesRuntime.ts +73 -0
  185. package/src/core/index.ts +1 -0
  186. package/src/createStyleSheet.ts +9 -0
  187. package/src/global.ts +5 -0
  188. package/src/hooks/index.ts +2 -1
  189. package/src/hooks/useInitialTheme.ts +11 -0
  190. package/src/hooks/useUnistyles.ts +55 -0
  191. package/src/index.ts +30 -2
  192. package/src/types/breakpoints.ts +20 -20
  193. package/src/types/common.ts +2 -0
  194. package/src/types/core.ts +42 -24
  195. package/src/types/index.ts +6 -9
  196. package/src/types/mq.ts +3 -0
  197. package/src/types/normalizer.ts +29 -0
  198. package/src/types/unistyles.ts +45 -0
  199. package/src/useStyles.ts +56 -0
  200. package/src/utils/breakpoints.ts +57 -88
  201. package/src/utils/common.ts +10 -1
  202. package/src/utils/index.ts +6 -9
  203. package/src/utils/module.d.ts +3 -0
  204. package/src/utils/mq.ts +106 -0
  205. package/src/utils/mqParser.ts +99 -0
  206. package/src/utils/normalizeStyles.web.ts +21 -42
  207. package/src/utils/normalizer.ts +99 -0
  208. package/src/utils/styles.ts +29 -68
  209. package/src/utils/variants.ts +17 -0
  210. package/lib/commonjs/UnistylesTheme.js +0 -21
  211. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  212. package/lib/commonjs/createUnistyles.js +0 -57
  213. package/lib/commonjs/createUnistyles.js.map +0 -1
  214. package/lib/commonjs/hooks/useDimensions.js +0 -10
  215. package/lib/commonjs/hooks/useDimensions.js.map +0 -1
  216. package/lib/commonjs/hooks/useDimensions.web.js +0 -31
  217. package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
  218. package/lib/commonjs/types/mediaQueries.js +0 -2
  219. package/lib/commonjs/utils/mediaQueries.js +0 -189
  220. package/lib/commonjs/utils/mediaQueries.js.map +0 -1
  221. package/lib/module/UnistylesTheme.js +0 -12
  222. package/lib/module/UnistylesTheme.js.map +0 -1
  223. package/lib/module/createUnistyles.js +0 -50
  224. package/lib/module/createUnistyles.js.map +0 -1
  225. package/lib/module/hooks/useDimensions.js +0 -3
  226. package/lib/module/hooks/useDimensions.js.map +0 -1
  227. package/lib/module/hooks/useDimensions.web.js +0 -24
  228. package/lib/module/hooks/useDimensions.web.js.map +0 -1
  229. package/lib/module/types/mediaQueries.js +0 -2
  230. package/lib/module/utils/mediaQueries.js +0 -176
  231. package/lib/module/utils/mediaQueries.js.map +0 -1
  232. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  233. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  234. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  235. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  236. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  237. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  238. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  239. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  240. package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
  241. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  242. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
  243. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  244. package/src/UnistylesTheme.tsx +0 -17
  245. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  246. package/src/createUnistyles.ts +0 -70
  247. package/src/hooks/useDimensions.ts +0 -4
  248. package/src/hooks/useDimensions.web.ts +0 -30
  249. package/src/types/mediaQueries.ts +0 -10
  250. package/src/utils/mediaQueries.ts +0 -201
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","isWeb","Platform","OS"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAAAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEM,MAAMI,IAAI,GAAIH,OAAe,IAAK;EACrCI,OAAO,CAACD,IAAI,CAAE,gCAA+BH,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAEM,MAAME,KAAK,GAAGA,CAAA,KAAMC,qBAAQ,CAACC,EAAE,KAAK,KAAK;AAAAL,OAAA,CAAAG,KAAA,GAAAA,KAAA"}
1
+ {"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAAAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEM,MAAMI,IAAI,GAAIH,OAAe,IAAK;EACrCI,OAAO,CAACD,IAAI,CAAE,gCAA+BH,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAEM,MAAME,QAAQ,GAAAH,OAAA,CAAAG,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAN,OAAA,CAAAM,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,KAAK,GAAAP,OAAA,CAAAO,KAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMG,SAAS,GAAAR,OAAA,CAAAQ,SAAA,GAAGJ,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMI,QAAQ,GAAAT,OAAA,CAAAS,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,WAAW,GAAAX,OAAA,CAAAW,WAAA,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
@@ -3,52 +3,66 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "extractValues", {
6
+ var _exportNames = {
7
+ normalizeStyles: true,
8
+ mq: true,
9
+ MQSymbol: true,
10
+ getKeyForVariant: true,
11
+ getKeyForUnistylesMediaQuery: true,
12
+ getBreakpointFromScreenWidth: true,
13
+ sortAndValidateBreakpoints: true,
14
+ getValueForNestedStyle: true,
15
+ proxifyFunction: true,
16
+ parseStyle: true,
17
+ isServer: true,
18
+ Orientation: true
19
+ };
20
+ Object.defineProperty(exports, "MQSymbol", {
7
21
  enumerable: true,
8
22
  get: function () {
9
- return _mediaQueries.extractValues;
23
+ return _mq.MQSymbol;
10
24
  }
11
25
  });
12
- Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
26
+ Object.defineProperty(exports, "Orientation", {
13
27
  enumerable: true,
14
28
  get: function () {
15
- return _breakpoints.getBreakpointFromScreenWidth;
29
+ return _common.Orientation;
16
30
  }
17
31
  });
18
- Object.defineProperty(exports, "getKeyForCustomMediaQuery", {
32
+ Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
19
33
  enumerable: true,
20
34
  get: function () {
21
- return _mediaQueries.getKeyForCustomMediaQuery;
35
+ return _breakpoints.getBreakpointFromScreenWidth;
22
36
  }
23
37
  });
24
- Object.defineProperty(exports, "getValueForBreakpoint", {
38
+ Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
25
39
  enumerable: true,
26
40
  get: function () {
27
- return _breakpoints.getValueForBreakpoint;
41
+ return _mqParser.getKeyForUnistylesMediaQuery;
28
42
  }
29
43
  });
30
- Object.defineProperty(exports, "isMediaQuery", {
44
+ Object.defineProperty(exports, "getKeyForVariant", {
31
45
  enumerable: true,
32
46
  get: function () {
33
- return _mediaQueries.isMediaQuery;
47
+ return _variants.getKeyForVariant;
34
48
  }
35
49
  });
36
- Object.defineProperty(exports, "isWithinTheHeight", {
50
+ Object.defineProperty(exports, "getValueForNestedStyle", {
37
51
  enumerable: true,
38
52
  get: function () {
39
- return _mediaQueries.isWithinTheHeight;
53
+ return _breakpoints.getValueForNestedStyle;
40
54
  }
41
55
  });
42
- Object.defineProperty(exports, "isWithinTheWidth", {
56
+ Object.defineProperty(exports, "isServer", {
43
57
  enumerable: true,
44
58
  get: function () {
45
- return _mediaQueries.isWithinTheWidth;
59
+ return _common.isServer;
46
60
  }
47
61
  });
48
- Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
62
+ Object.defineProperty(exports, "mq", {
49
63
  enumerable: true,
50
64
  get: function () {
51
- return _mediaQueries.isWithinTheWidthAndHeight;
65
+ return _mq.mq;
52
66
  }
53
67
  });
54
68
  Object.defineProperty(exports, "normalizeStyles", {
@@ -76,7 +90,22 @@ Object.defineProperty(exports, "sortAndValidateBreakpoints", {
76
90
  }
77
91
  });
78
92
  var _normalizeStyles = require("./normalizeStyles");
93
+ var _normalizer = require("./normalizer");
94
+ Object.keys(_normalizer).forEach(function (key) {
95
+ if (key === "default" || key === "__esModule") return;
96
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
97
+ if (key in exports && exports[key] === _normalizer[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _normalizer[key];
102
+ }
103
+ });
104
+ });
105
+ var _mq = require("./mq");
106
+ var _variants = require("./variants");
107
+ var _mqParser = require("./mqParser");
79
108
  var _breakpoints = require("./breakpoints");
80
109
  var _styles = require("./styles");
81
- var _mediaQueries = require("./mediaQueries");
110
+ var _common = require("./common");
82
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_normalizeStyles","require","_breakpoints","_styles","_mediaQueries"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA"}
1
+ {"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_variants","_mqParser","_breakpoints","_styles","_common"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAd,OAAA;AACA,IAAAe,SAAA,GAAAf,OAAA;AACA,IAAAgB,SAAA,GAAAhB,OAAA;AACA,IAAAiB,YAAA,GAAAjB,OAAA;AACA,IAAAkB,OAAA,GAAAlB,OAAA;AACA,IAAAmB,OAAA,GAAAnB,OAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=module.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mq = exports.MQSymbol = void 0;
7
+ var _core = require("../core");
8
+ const MQSymbol = exports.MQSymbol = Symbol('unistyles-mq');
9
+ var MQProp = /*#__PURE__*/function (MQProp) {
10
+ MQProp["toString"] = "toString";
11
+ MQProp["width"] = "width";
12
+ MQProp["height"] = "height";
13
+ MQProp["shortW"] = "w";
14
+ MQProp["shortH"] = "h";
15
+ return MQProp;
16
+ }(MQProp || {});
17
+ const getMQValue = value => {
18
+ if (typeof value === 'number') {
19
+ return value;
20
+ }
21
+ if (value === null) {
22
+ return 0;
23
+ }
24
+ return _core.unistyles.registry.breakpoints[value] ?? 0;
25
+ };
26
+ const widthHandler = function () {
27
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
28
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
29
+ return new Proxy({}, {
30
+ get: (target, prop, receiver) => {
31
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
32
+ return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
33
+ }
34
+ if (prop === MQProp.width || prop === MQProp.shortW) {
35
+ return function () {
36
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
37
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
38
+ return new Proxy({}, {
39
+ get: (target, prop, receiver) => {
40
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
41
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
42
+ }
43
+ return Reflect.get(target, prop, receiver);
44
+ }
45
+ });
46
+ };
47
+ }
48
+ return Reflect.get(target, prop, receiver);
49
+ }
50
+ });
51
+ };
52
+ const heightHandler = function () {
53
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
54
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
55
+ return new Proxy({}, {
56
+ get: (target, prop, receiver) => {
57
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
58
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
59
+ }
60
+ if (prop === MQProp.height || prop === MQProp.shortH) {
61
+ return function () {
62
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
63
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
64
+ return new Proxy({}, {
65
+ get: (target, prop, receiver) => {
66
+ if (prop === Symbol.toPrimitive || MQProp.toString) {
67
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
68
+ }
69
+ return Reflect.get(target, prop, receiver);
70
+ }
71
+ });
72
+ };
73
+ }
74
+ return Reflect.get(target, prop, receiver);
75
+ }
76
+ });
77
+ };
78
+ const mq = exports.mq = new Proxy({}, {
79
+ get: (target, prop, receiver) => {
80
+ if (prop === MQProp.shortW || prop === MQProp.width) {
81
+ return heightHandler;
82
+ }
83
+ if (prop === MQProp.shortH || prop === MQProp.height) {
84
+ return widthHandler;
85
+ }
86
+ return Reflect.get(target, prop, receiver);
87
+ }
88
+ });
89
+ //# sourceMappingURL=mq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_core","require","MQSymbol","exports","Symbol","MQProp","getMQValue","value","unistyles","registry","breakpoints","widthHandler","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","shortW","wMin","wMax","Reflect","heightHandler","height","shortH","mq"],"sourceRoot":"../../../src","sources":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IT,IAAI,KAAKhB,MAAM,CAAC2B,MAAM,IAAIX,IAAI,KAAKhB,MAAM,CAAC0B,MAAM,EAAE;MAClD,OAAOpB,YAAY;IACvB;IAEA,OAAOkB,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;EAC9C;AACJ,CAAC,CAAC"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getKeyForUnistylesMediaQuery = void 0;
7
+ const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
8
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
9
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
10
+ const parseMq = mq => {
11
+ const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
12
+ const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
13
+ return {
14
+ width: width ? {
15
+ from: Number(fromW),
16
+ to: Number(toW)
17
+ } : undefined,
18
+ height: height ? {
19
+ from: Number(fromH),
20
+ to: Number(toH)
21
+ } : undefined
22
+ };
23
+ };
24
+ const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
25
+ const isValidMq = parsedMq => {
26
+ const {
27
+ width,
28
+ height
29
+ } = parsedMq;
30
+ if (width && height) {
31
+ return width.from <= width.to && height.from <= height.to;
32
+ }
33
+ if (width) {
34
+ return width.from <= width.to;
35
+ }
36
+ if (height) {
37
+ return height.from <= height.to;
38
+ }
39
+ return false;
40
+ };
41
+ const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
42
+ const {
43
+ width,
44
+ height
45
+ } = parsedMq;
46
+ if (width && height) {
47
+ return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height);
48
+ }
49
+ if (width) {
50
+ return isWithinTheWidth(width, screenSize.width);
51
+ }
52
+ if (height) {
53
+ return isWithinTheHeight(height, screenSize.height);
54
+ }
55
+ return false;
56
+ };
57
+ const isWithinTheWidth = (width, screenWidth) => {
58
+ const {
59
+ from,
60
+ to
61
+ } = width;
62
+ return screenWidth >= from && screenWidth <= to;
63
+ };
64
+ const isWithinTheHeight = (height, screenHeight) => {
65
+ const {
66
+ from,
67
+ to
68
+ } = height;
69
+ return screenHeight >= from && screenHeight <= to;
70
+ };
71
+ const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
72
+ const mq = mediaQueries.find(_ref => {
73
+ let [key] = _ref;
74
+ if (!isUnistylesMq(key)) {
75
+ return false;
76
+ }
77
+ const parsedMq = parseMq(key);
78
+ if (!isValidMq(parsedMq)) {
79
+ return false;
80
+ }
81
+ return isWithinTheWidthAndHeight(parsedMq, screenSize);
82
+ });
83
+ return mq?.at(0);
84
+ };
85
+ exports.getKeyForUnistylesMediaQuery = getKeyForUnistylesMediaQuery;
86
+ //# sourceMappingURL=mqParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at","exports"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CA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@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.normalizeStyles = void 0;
7
7
  var _common = require("./common");
8
- const preprocessor = require('react-native-web/src/exports/StyleSheet/preprocess.js');
9
- const normalizeBoxShadow = styles => {
8
+ var _normalizer = require("./normalizer");
9
+ const normalizeBoxShadow = style => {
10
10
  const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
11
- if (!requiredBoxShadowProperties.every(prop => prop in styles)) {
11
+ if (!requiredBoxShadowProperties.every(prop => prop in style)) {
12
12
  (0, _common.warn)(`can't apply box shadow as you miss at least one of these properties: ${requiredBoxShadowProperties.join(', ')}`);
13
13
  return {
14
14
  shadowColor: undefined,
@@ -18,16 +18,16 @@ const normalizeBoxShadow = styles => {
18
18
  };
19
19
  }
20
20
  return {
21
- boxShadow: preprocessor.createBoxShadowValue(styles),
21
+ boxShadow: _normalizer.preprocessor.createBoxShadowValue(style),
22
22
  shadowColor: undefined,
23
23
  shadowOffset: undefined,
24
24
  shadowOpacity: undefined,
25
25
  shadowRadius: undefined
26
26
  };
27
27
  };
28
- const normalizeTextShadow = styles => {
28
+ const normalizeTextShadow = style => {
29
29
  const requiredTextShadowProperties = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
30
- if (!requiredTextShadowProperties.every(prop => prop in styles)) {
30
+ if (!requiredTextShadowProperties.every(prop => prop in style)) {
31
31
  (0, _common.warn)(`can't apply text shadow as you miss at least one of these properties: ${requiredTextShadowProperties.join(', ')}`);
32
32
  return {
33
33
  textShadowColor: undefined,
@@ -36,20 +36,20 @@ const normalizeTextShadow = styles => {
36
36
  };
37
37
  }
38
38
  return {
39
- textShadow: preprocessor.createTextShadowValue(styles),
39
+ textShadow: _normalizer.preprocessor.createTextShadowValue(style),
40
40
  textShadowColor: undefined,
41
41
  textShadowOffset: undefined,
42
42
  textShadowRadius: undefined
43
43
  };
44
44
  };
45
- const normalizeStyles = styles => {
46
- const normalizedTransform = 'transform' in styles && Array.isArray(styles.transform) ? {
47
- transform: preprocessor.createTransformValue(styles.transform)
45
+ const normalizeStyles = style => {
46
+ const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
47
+ transform: _normalizer.preprocessor.createTransformValue(style.transform)
48
48
  } : {};
49
- const normalizedBoxShadow = 'shadowColor' in styles || 'shadowOffset' in styles || 'shadowOpacity' in styles || 'shadowRadius' in styles ? normalizeBoxShadow(styles) : {};
50
- const normalizedTextShadow = 'textShadowColor' in styles || 'textShadowOffset' in styles || 'textShadowRadius' in styles ? normalizeTextShadow(styles) : {};
49
+ const normalizedBoxShadow = 'shadowColor' in style || 'shadowOffset' in style || 'shadowOpacity' in style || 'shadowRadius' in style ? normalizeBoxShadow(style) : {};
50
+ const normalizedTextShadow = 'textShadowColor' in style || 'textShadowOffset' in style || 'textShadowRadius' in style ? normalizeTextShadow(style) : {};
51
51
  return {
52
- ...styles,
52
+ ...style,
53
53
  ...normalizedTransform,
54
54
  ...normalizedBoxShadow,
55
55
  ...normalizedTextShadow
@@ -1 +1 @@
1
- {"version":3,"names":["_common","require","preprocessor","normalizeBoxShadow","styles","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,MAAMC,YAA0B,GAAGD,OAAO,CAAC,uDAAuD,CAAC;AAuBnG,MAAME,kBAAkB,GAAkBC,MAAS,IAA0B;EACzE,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,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B,oBAAoB,CAACzB,MAAM,CAACwB,SAAS;EAAE,CAAC,GAClE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAI1B,MAAM,IACvB,cAAc,IAAIA,MAAM,IACxB,eAAe,IAAIA,MAAM,IACzB,cAAc,IAAIA,MAAM,GACxBD,kBAAkB,CAACC,MAAM,CAAC,GAAG,CAAC,CAAC;EAEnC,MAAM2B,oBAAoB,GACtB,iBAAiB,IAAI3B,MAAM,IAC3B,kBAAkB,IAAIA,MAAM,IAC5B,kBAAkB,IAAIA,MAAM,GAC5Ba,mBAAmB,CAACb,MAAM,CAAC,GAAG,CAAC,CAAC;EAEpC,OAAO;IACH,GAAGA,MAAM;IACT,GAAGqB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAR,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["_common","require","_normalizer","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","preprocessor","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,MAAME,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC3D,IAAAI,YAAI,EAAE,wEAAuEH,2BAA2B,CAACI,IAAI,CAAC,IAA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Ac,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM4B,oBAAoB,GACtB,iBAAiB,IAAI5B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3Bc,mBAAmB,CAACd,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGsB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAR,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.preprocessor = exports.normalizeNumericValue = exports.normalizeColor = void 0;
7
+ var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ // based on react-native-web normalizer
10
+ // https://github.com/necolas/react-native-web
11
+
12
+ const normalizeColor = function (color) {
13
+ let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
14
+ // If the opacity is 1 there's no need to normalize the color
15
+ if (opacity === 1) {
16
+ return color;
17
+ }
18
+ const integer = (0, _normalizeColors.default)(color);
19
+
20
+ // If the colour is an unknown format, the return value is null
21
+ if (integer === null) {
22
+ return color;
23
+ }
24
+ const hex = integer.toString(16).padStart(8, '0');
25
+ if (hex.length === 8) {
26
+ const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
27
+ return `rgba(${r},${g},${b},${a / 255 * opacity})`;
28
+ }
29
+ return color;
30
+ };
31
+ exports.normalizeColor = normalizeColor;
32
+ const normalizeNumericValue = value => value ? `${value}px` : value;
33
+ exports.normalizeNumericValue = normalizeNumericValue;
34
+ const normalizeTransform = (key, value) => {
35
+ if (key.includes('scale')) {
36
+ return value;
37
+ }
38
+ if (typeof value === 'number') {
39
+ return normalizeNumericValue(value);
40
+ }
41
+ return value;
42
+ };
43
+ const createTextShadowValue = style => {
44
+ // at this point every prop is present
45
+ const {
46
+ textShadowColor,
47
+ textShadowOffset,
48
+ textShadowRadius
49
+ } = style;
50
+ const offsetX = normalizeNumericValue(textShadowOffset.width);
51
+ const offsetY = normalizeNumericValue(textShadowOffset.height);
52
+ const radius = normalizeNumericValue(textShadowRadius);
53
+ const color = normalizeColor(textShadowColor);
54
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
55
+ };
56
+ const createBoxShadowValue = style => {
57
+ // at this point every prop is present
58
+ const {
59
+ shadowColor,
60
+ shadowOffset,
61
+ shadowOpacity,
62
+ shadowRadius
63
+ } = style;
64
+ const offsetX = normalizeNumericValue(shadowOffset.width);
65
+ const offsetY = normalizeNumericValue(shadowOffset.height);
66
+ const radius = normalizeNumericValue(shadowRadius);
67
+ const color = normalizeColor(shadowColor, shadowOpacity);
68
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
69
+ };
70
+ const createTransformValue = transforms => transforms.map(transform => {
71
+ const [key] = Object.keys(transform);
72
+ if (!key) {
73
+ return undefined;
74
+ }
75
+ const value = transform[key];
76
+ switch (key) {
77
+ case 'matrix':
78
+ case 'matrix3d':
79
+ return `${key}(${value.join(',')})`;
80
+ default:
81
+ return `${key}(${normalizeTransform(key, value)})`;
82
+ }
83
+ }).filter(Boolean).join(' ');
84
+ const preprocessor = exports.preprocessor = {
85
+ createTextShadowValue,
86
+ createBoxShadowValue,
87
+ createTransformValue
88
+ };
89
+ //# sourceMappingURL=normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","arguments","length","undefined","integer","normalizeColors","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","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","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["utils/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC7D;EACA,IAAID,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAMK,OAAO,GAAG,IAAAC,wBAAe,EAACN,KAAK,CAAkB;;EAEvD;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMO,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACJ,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACO,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC;IAE/B,OAAQ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C,OAAO,GAAGZ,qBAAqB,CAACiB,YAAY,CAACJ,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGd,qBAAqB,CAACmB,YAAY,CAAC;EAClD,MAAMzC,KAAK,GAAGD,cAAc,CAACuC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGpC,KAAM,EAAC;AACrD,CAAC;AAED,MAAM0C,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D5B,GAAG,CAAC6B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOrB,SAAS;EACpB;EAEA,MAAMmB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmBwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDL,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA5B,OAAA,CAAA4B,YAAA,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -3,81 +3,41 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.proxifyFunction = exports.parseStyle = void 0;
6
+ exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
7
7
  var _breakpoints = require("./breakpoints");
8
8
  var _normalizeStyles = require("./normalizeStyles");
9
9
  var _common = require("./common");
10
- /**
11
- * Proxies a function to parse its return value for custom media queries or breakpoints.
12
- *
13
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
14
- *
15
- * @param {Function} fn - The function to be proxified.
16
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
17
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
18
- * @param breakpointPairs - sorted pairs of breakpoints
19
- *
20
- * @returns {Function} Returns the proxified function
21
- *
22
- * @example
23
- *
24
- * const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
25
- * const screenSize = { width: 250, height: 400 }
26
- * const breakpoints = { sm: 300, md: 600 }
27
- *
28
- * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
29
- * proxifiedFunction() // parsed style based on screenSize and breakpoints
30
- */
31
- const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Proxy(fn, {
32
- apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
10
+ const proxifyFunction = (fn, breakpoint, screenSize, variant) => new Proxy(fn, {
11
+ apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
33
12
  });
34
-
35
- /**
36
- * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
37
- *
38
- * The function processes each key-value pair in the style object. If the value is a function or a valid style (not an object or a 'transform' key),
39
- * it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
40
- *
41
- * @template T - The type of the style object.
42
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
43
- *
44
- * @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
45
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
46
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
47
- * @param breakpointPairs - sorted pairs of breakpoints
48
- *
49
- * @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
50
- *
51
- * @example
52
- *
53
- * const style = { fontSize: { sm: '12px', md: '16px' } }
54
- * const screenSize = { width: 300, height: 400 }
55
- * const breakpoints = { xs: 0, sm: 300, md: 600 }
56
- *
57
- * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
58
- * // { fontSize: '12px' }
59
- */
60
13
  exports.proxifyFunction = proxifyFunction;
61
- const parseStyle = (style, breakpoint, screenSize, breakpointPairs) => {
62
- const entries = Object.entries(style);
14
+ const isPlatformColor = value => {
15
+ if (_common.isIOS) {
16
+ return 'semantic' in value && typeof value.semantic === 'object';
17
+ }
18
+ return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
19
+ };
20
+ exports.isPlatformColor = isPlatformColor;
21
+ const parseStyle = (style, breakpoint, screenSize, variant) => {
22
+ const entries = Object.entries(style || {});
63
23
  const parsedStyles = Object.fromEntries(entries.map(_ref => {
64
24
  let [key, value] = _ref;
65
25
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
66
26
  if (hasNestedProperties) {
67
- return [key, parseStyle(value, breakpoint, screenSize, breakpointPairs)];
27
+ return [key, parseStyle(value, breakpoint, screenSize, variant)];
68
28
  }
69
29
  const isTransform = key === 'transform';
70
30
  if (isTransform && Array.isArray(value)) {
71
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))];
31
+ return [key, value.map(value => parseStyle(value, breakpoint, screenSize, variant))];
72
32
  }
73
33
  const isDynamicFunction = typeof value === 'function';
74
- const isValidStyle = typeof value !== 'object';
34
+ const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
75
35
  if (isDynamicFunction || isValidStyle) {
76
36
  return [key, value];
77
37
  }
78
- return [key, (0, _breakpoints.getValueForBreakpoint)(value, breakpoint, screenSize, breakpointPairs)];
38
+ return [key, (0, _breakpoints.getValueForNestedStyle)(value, variant)];
79
39
  }));
80
- return (0, _common.isWeb)() ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
40
+ return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
81
41
  };
82
42
  exports.parseStyle = parseStyle;
83
43
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","value","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForBreakpoint","isWeb","normalizeStyles"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,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;AAxBAO,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAyBO,MAAMU,UAAU,GAAGA,CACtBE,KAA8B,EAC9BV,UAA4B,EAC5BC,UAAsB,EACtBC,eAA2C,KACvC;EACJ,MAAMS,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,EACHT,UAAU,CAACU,KAAK,EAA6BlB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CACxF;IACL;IAEA,MAAMkB,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,IAAIV,UAAU,CAACU,KAAK,EAAElB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CAAC,CACjF;IACL;IAEA,MAAMqB,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,EACH,IAAAQ,kCAAqB,EACjBP,KAAK,EACLlB,UAAU,EACVC,UAAU,EACVC,eACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAO,IAAAwB,aAAK,EAAC,CAAC,GACR,IAAAC,gCAAe,EAACd,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAJ,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForNestedStyle","isWeb","normalizeStyles"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,EACtBC,OAAgB,KACL,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,OAAO;AACxF,CAAC,CAAC;AAAAO,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAEK,MAAMY,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS,IAAI,gBAAgB,IAAIH,KAAK,IAAI,OAAOA,KAAK,CAACI,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAAAN,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAEM,MAAMF,UAAU,GAAGA,CACtBQ,KAA2B,EAC3BhB,UAA+C,EAC/CC,UAAsB,EACtBC,OAAgB,KACZ;EACJ,MAAMe,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACD,KAAK,IAAI,CAAC,CAAC,CAGzC;EAED,MAAMG,YAAY,GAAGD,MAAM,CACtBE,WAAW,CAACH,OAAO,CACfI,GAAG,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACC,GAAG,EAAEZ,KAAK,CAAC,GAAAW,IAAA;IACd,MAAME,mBAAmB,GAAGD,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB;IAEhF,IAAIC,mBAAmB,EAAE;MACrB,OAAO,CACHD,GAAG,EACHf,UAAU,CAACG,KAAK,EAA0BX,UAAU,EAAEC,UAAU,EAAEC,OAAO,CAAC,CAC7E;IACL;IAEA,MAAMuB,WAAW,GAAGF,GAAG,KAAK,WAAW;IAEvC,IAAIE,WAAW,IAAIC,KAAK,CAACC,OAAO,CAAChB,KAAK,CAAC,EAAE;MACrC,OAAO,CACHY,GAAG,EACHZ,KAAK,CAACU,GAAG,CAACV,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEX,UAAU,EAAEC,UAAU,EAAEC,OAAO,CAAC,CAAC,CACzE;IACL;IAEA,MAAM0B,iBAAiB,GAAG,OAAOjB,KAAK,KAAK,UAAU;IACrD,MAAMkB,YAAY,GAAG,OAAOlB,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC;IAExE,IAAIiB,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACN,GAAG,EAAEZ,KAAK,CAAC;IACvB;IAEA,OAAO,CACHY,GAAG,EACH,IAAAO,mCAAsB,EAClBnB,KAAK,EACLT,OACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAO6B,aAAK,GACN,IAAAC,gCAAe,EAACb,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAV,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getKeyForVariant = void 0;
7
+ const getKeyForVariant = (value, variant) => {
8
+ if (!value.variants) {
9
+ return undefined;
10
+ }
11
+ if (variant && variant in value.variants) {
12
+ return variant;
13
+ }
14
+ if ('default' in value.variants) {
15
+ return 'default';
16
+ }
17
+ return undefined;
18
+ };
19
+ exports.getKeyForVariant = getKeyForVariant;
20
+ //# sourceMappingURL=variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getKeyForVariant","value","variant","variants","undefined","exports"],"sourceRoot":"../../../src","sources":["utils/variants.ts"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAGA,CAACC,KAAkB,EAAEC,OAAgB,KAAmC;EACpG,IAAI,CAACD,KAAK,CAACE,QAAQ,EAAE;IACjB,OAAOC,SAAS;EACpB;EAEA,IAAIF,OAAO,IAAIA,OAAO,IAAID,KAAK,CAACE,QAAQ,EAAE;IACtC,OAAOD,OAAO;EAClB;EAEA,IAAI,SAAS,IAAID,KAAK,CAACE,QAAQ,EAAE;IAC7B,OAAO,SAAS;EACpB;EAEA,OAAOC,SAAS;AACpB,CAAC;AAAAC,OAAA,CAAAL,gBAAA,GAAAA,gBAAA"}