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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. package/cxx/UnistylesRuntime.cpp +255 -0
  2. package/cxx/UnistylesRuntime.h +60 -0
  3. package/ios/UnistylesHelpers.h +4 -0
  4. package/ios/UnistylesHelpers.mm +20 -0
  5. package/ios/UnistylesModule.h +10 -0
  6. package/ios/UnistylesModule.mm +158 -0
  7. package/lib/commonjs/common.js +26 -0
  8. package/lib/commonjs/common.js.map +1 -0
  9. package/lib/commonjs/core/UnistyleRegistry.js +38 -0
  10. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
  11. package/lib/commonjs/core/Unistyles.js +31 -0
  12. package/lib/commonjs/core/Unistyles.js.map +1 -0
  13. package/lib/commonjs/core/UnistylesModule.js +9 -0
  14. package/lib/commonjs/core/UnistylesModule.js.map +1 -0
  15. package/lib/commonjs/core/UnistylesRuntime.js +66 -0
  16. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
  17. package/lib/commonjs/core/index.js +13 -0
  18. package/lib/commonjs/core/index.js.map +1 -0
  19. package/lib/commonjs/createStyleSheet.js +14 -0
  20. package/lib/commonjs/createStyleSheet.js.map +1 -0
  21. package/lib/commonjs/global.js +2 -0
  22. package/lib/commonjs/global.js.map +1 -0
  23. package/lib/commonjs/hooks/index.js +10 -3
  24. package/lib/commonjs/hooks/index.js.map +1 -1
  25. package/lib/commonjs/hooks/useInitialTheme.js +17 -0
  26. package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
  27. package/lib/commonjs/hooks/useUnistyles.js +54 -0
  28. package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
  29. package/lib/commonjs/index.js +35 -6
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/commonjs/types/common.js +2 -0
  32. package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
  33. package/lib/commonjs/types/index.js +11 -0
  34. package/lib/commonjs/types/index.js.map +1 -1
  35. package/lib/commonjs/types/mq.js +6 -0
  36. package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
  37. package/lib/commonjs/types/unistyles.js +6 -0
  38. package/lib/commonjs/types/unistyles.js.map +1 -0
  39. package/lib/commonjs/useStyles.js +49 -0
  40. package/lib/commonjs/useStyles.js.map +1 -0
  41. package/lib/commonjs/utils/breakpoints.js +44 -82
  42. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  43. package/lib/commonjs/utils/common.js +6 -1
  44. package/lib/commonjs/utils/common.js.map +1 -1
  45. package/lib/commonjs/utils/index.js +25 -30
  46. package/lib/commonjs/utils/index.js.map +1 -1
  47. package/lib/commonjs/utils/mq.js +89 -0
  48. package/lib/commonjs/utils/mq.js.map +1 -0
  49. package/lib/commonjs/utils/mqParser.js +86 -0
  50. package/lib/commonjs/utils/mqParser.js.map +1 -0
  51. package/lib/commonjs/utils/styles.js +6 -53
  52. package/lib/commonjs/utils/styles.js.map +1 -1
  53. package/lib/commonjs/utils/variants.js +20 -0
  54. package/lib/commonjs/utils/variants.js.map +1 -0
  55. package/lib/module/common.js +22 -0
  56. package/lib/module/common.js.map +1 -0
  57. package/lib/module/core/UnistyleRegistry.js +31 -0
  58. package/lib/module/core/UnistyleRegistry.js.map +1 -0
  59. package/lib/module/core/Unistyles.js +25 -0
  60. package/lib/module/core/Unistyles.js.map +1 -0
  61. package/lib/module/core/UnistylesModule.js +3 -0
  62. package/lib/module/core/UnistylesModule.js.map +1 -0
  63. package/lib/module/core/UnistylesRuntime.js +59 -0
  64. package/lib/module/core/UnistylesRuntime.js.map +1 -0
  65. package/lib/module/core/index.js +2 -0
  66. package/lib/module/core/index.js.map +1 -0
  67. package/lib/module/createStyleSheet.js +7 -0
  68. package/lib/module/createStyleSheet.js.map +1 -0
  69. package/lib/module/global.js +2 -0
  70. package/lib/module/global.js.map +1 -0
  71. package/lib/module/hooks/index.js +2 -1
  72. package/lib/module/hooks/index.js.map +1 -1
  73. package/lib/module/hooks/useInitialTheme.js +10 -0
  74. package/lib/module/hooks/useInitialTheme.js.map +1 -0
  75. package/lib/module/hooks/useUnistyles.js +47 -0
  76. package/lib/module/hooks/useUnistyles.js.map +1 -0
  77. package/lib/module/index.js +13 -2
  78. package/lib/module/index.js.map +1 -1
  79. package/lib/module/types/common.js +2 -0
  80. package/lib/module/types/common.js.map +1 -0
  81. package/lib/module/types/index.js +1 -0
  82. package/lib/module/types/index.js.map +1 -1
  83. package/lib/module/types/mq.js +2 -0
  84. package/lib/module/types/mq.js.map +1 -0
  85. package/lib/module/types/unistyles.js +2 -0
  86. package/lib/module/types/unistyles.js.map +1 -0
  87. package/lib/module/useStyles.js +42 -0
  88. package/lib/module/useStyles.js.map +1 -0
  89. package/lib/module/utils/breakpoints.js +43 -82
  90. package/lib/module/utils/breakpoints.js.map +1 -1
  91. package/lib/module/utils/common.js +5 -0
  92. package/lib/module/utils/common.js.map +1 -1
  93. package/lib/module/utils/index.js +5 -3
  94. package/lib/module/utils/index.js.map +1 -1
  95. package/lib/module/utils/mq.js +83 -0
  96. package/lib/module/utils/mq.js.map +1 -0
  97. package/lib/module/utils/mqParser.js +79 -0
  98. package/lib/module/utils/mqParser.js.map +1 -0
  99. package/lib/module/utils/styles.js +7 -55
  100. package/lib/module/utils/styles.js.map +1 -1
  101. package/lib/module/utils/variants.js +13 -0
  102. package/lib/module/utils/variants.js.map +1 -0
  103. package/lib/typescript/src/common.d.ts +17 -0
  104. package/lib/typescript/src/common.d.ts.map +1 -0
  105. package/lib/typescript/src/core/UnistyleRegistry.d.ts +15 -0
  106. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
  107. package/lib/typescript/src/core/Unistyles.d.ts +13 -0
  108. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
  109. package/lib/typescript/src/core/UnistylesModule.d.ts +6 -0
  110. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
  111. package/lib/typescript/src/core/UnistylesRuntime.d.ts +24 -0
  112. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
  113. package/lib/typescript/src/core/index.d.ts +2 -0
  114. package/lib/typescript/src/core/index.d.ts.map +1 -0
  115. package/lib/typescript/src/createStyleSheet.d.ts +3 -0
  116. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  117. package/lib/typescript/src/global.d.ts +7 -0
  118. package/lib/typescript/src/global.d.ts.map +1 -0
  119. package/lib/typescript/src/hooks/index.d.ts +2 -1
  120. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  121. package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
  122. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
  123. package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
  124. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
  125. package/lib/typescript/src/index.d.ts +14 -2
  126. package/lib/typescript/src/index.d.ts.map +1 -1
  127. package/lib/typescript/src/types/breakpoints.d.ts +12 -13
  128. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  129. package/lib/typescript/src/types/common.d.ts +3 -0
  130. package/lib/typescript/src/types/common.d.ts.map +1 -0
  131. package/lib/typescript/src/types/core.d.ts +34 -18
  132. package/lib/typescript/src/types/core.d.ts.map +1 -1
  133. package/lib/typescript/src/types/index.d.ts +5 -2
  134. package/lib/typescript/src/types/index.d.ts.map +1 -1
  135. package/lib/typescript/src/types/mq.d.ts +3 -0
  136. package/lib/typescript/src/types/mq.d.ts.map +1 -0
  137. package/lib/typescript/src/types/unistyles.d.ts +37 -0
  138. package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
  139. package/lib/typescript/src/useStyles.d.ts +10 -0
  140. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  141. package/lib/typescript/src/utils/breakpoints.d.ts +5 -62
  142. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  143. package/lib/typescript/src/utils/common.d.ts +5 -0
  144. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  145. package/lib/typescript/src/utils/index.d.ts +5 -3
  146. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  147. package/lib/typescript/src/utils/mq.d.ts +21 -0
  148. package/lib/typescript/src/utils/mq.d.ts.map +1 -0
  149. package/lib/typescript/src/utils/mqParser.d.ts +3 -0
  150. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
  151. package/lib/typescript/src/utils/styles.d.ts +4 -49
  152. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  153. package/lib/typescript/src/utils/variants.d.ts +3 -0
  154. package/lib/typescript/src/utils/variants.d.ts.map +1 -0
  155. package/package.json +30 -19
  156. package/react-native-unistyles.podspec +22 -0
  157. package/src/common.ts +19 -0
  158. package/src/core/UnistyleRegistry.ts +41 -0
  159. package/src/core/Unistyles.ts +34 -0
  160. package/src/core/UnistylesModule.ts +7 -0
  161. package/src/core/UnistylesRuntime.ts +73 -0
  162. package/src/core/index.ts +1 -0
  163. package/src/createStyleSheet.ts +9 -0
  164. package/src/global.ts +5 -0
  165. package/src/hooks/index.ts +2 -1
  166. package/src/hooks/useInitialTheme.ts +11 -0
  167. package/src/hooks/useUnistyles.ts +55 -0
  168. package/src/index.ts +30 -2
  169. package/src/types/breakpoints.ts +16 -19
  170. package/src/types/common.ts +2 -0
  171. package/src/types/core.ts +42 -24
  172. package/src/types/index.ts +5 -9
  173. package/src/types/mq.ts +3 -0
  174. package/src/types/unistyles.ts +45 -0
  175. package/src/useStyles.ts +56 -0
  176. package/src/utils/breakpoints.ts +57 -88
  177. package/src/utils/common.ts +6 -0
  178. package/src/utils/index.ts +5 -10
  179. package/src/utils/mq.ts +106 -0
  180. package/src/utils/mqParser.ts +99 -0
  181. package/src/utils/styles.ts +17 -64
  182. package/src/utils/variants.ts +17 -0
  183. package/lib/commonjs/UnistylesTheme.js +0 -21
  184. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  185. package/lib/commonjs/createUnistyles.js +0 -57
  186. package/lib/commonjs/createUnistyles.js.map +0 -1
  187. package/lib/commonjs/hooks/useDimensions.js +0 -10
  188. package/lib/commonjs/hooks/useDimensions.js.map +0 -1
  189. package/lib/commonjs/hooks/useDimensions.web.js +0 -34
  190. package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
  191. package/lib/commonjs/types/mediaQueries.js +0 -2
  192. package/lib/commonjs/utils/mediaQueries.js +0 -189
  193. package/lib/commonjs/utils/mediaQueries.js.map +0 -1
  194. package/lib/module/UnistylesTheme.js +0 -12
  195. package/lib/module/UnistylesTheme.js.map +0 -1
  196. package/lib/module/createUnistyles.js +0 -50
  197. package/lib/module/createUnistyles.js.map +0 -1
  198. package/lib/module/hooks/useDimensions.js +0 -3
  199. package/lib/module/hooks/useDimensions.js.map +0 -1
  200. package/lib/module/hooks/useDimensions.web.js +0 -27
  201. package/lib/module/hooks/useDimensions.web.js.map +0 -1
  202. package/lib/module/types/mediaQueries.js +0 -2
  203. package/lib/module/utils/mediaQueries.js +0 -176
  204. package/lib/module/utils/mediaQueries.js.map +0 -1
  205. package/lib/typescript/examples/expo/src/App.d.ts +0 -3
  206. package/lib/typescript/examples/expo/src/App.d.ts.map +0 -1
  207. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +0 -3
  208. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +0 -1
  209. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +0 -3
  210. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +0 -1
  211. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +0 -7
  212. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +0 -1
  213. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +0 -3
  214. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +0 -1
  215. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +0 -3
  216. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +0 -1
  217. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +0 -3
  218. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +0 -1
  219. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +0 -3
  220. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +0 -1
  221. package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts +0 -3
  222. package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts.map +0 -1
  223. package/lib/typescript/examples/expo/src/examples/Theme.d.ts +0 -3
  224. package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +0 -1
  225. package/lib/typescript/examples/expo/src/examples/index.d.ts +0 -9
  226. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +0 -1
  227. package/lib/typescript/examples/expo/src/index.d.ts +0 -2
  228. package/lib/typescript/examples/expo/src/index.d.ts.map +0 -1
  229. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +0 -8
  230. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +0 -1
  231. package/lib/typescript/examples/expo/src/styles/index.d.ts +0 -46
  232. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +0 -1
  233. package/lib/typescript/examples/expo/src/styles/theme.d.ts +0 -24
  234. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +0 -1
  235. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  236. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  237. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  238. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  239. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  240. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  241. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  242. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  243. package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
  244. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  245. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
  246. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  247. package/src/UnistylesTheme.tsx +0 -17
  248. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  249. package/src/createUnistyles.ts +0 -70
  250. package/src/hooks/useDimensions.ts +0 -4
  251. package/src/hooks/useDimensions.web.ts +0 -34
  252. package/src/types/mediaQueries.ts +0 -10
  253. package/src/utils/mediaQueries.ts +0 -201
@@ -5,71 +5,64 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var _exportNames = {
7
7
  normalizeStyles: true,
8
+ mq: true,
9
+ MQSymbol: true,
10
+ getKeyForVariant: true,
11
+ getKeyForUnistylesMediaQuery: true,
8
12
  getBreakpointFromScreenWidth: true,
9
13
  sortAndValidateBreakpoints: true,
10
- getValueForBreakpoint: true,
14
+ getValueForNestedStyle: true,
11
15
  proxifyFunction: true,
12
16
  parseStyle: true,
13
17
  isServer: true,
14
- extractValues: true,
15
- getKeyForCustomMediaQuery: true,
16
- isMediaQuery: true,
17
- isWithinTheHeight: true,
18
- isWithinTheWidth: true,
19
- isWithinTheWidthAndHeight: true
18
+ Orientation: true
20
19
  };
21
- Object.defineProperty(exports, "extractValues", {
20
+ Object.defineProperty(exports, "MQSymbol", {
22
21
  enumerable: true,
23
22
  get: function () {
24
- return _mediaQueries.extractValues;
23
+ return _mq.MQSymbol;
25
24
  }
26
25
  });
27
- Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
28
- enumerable: true,
29
- get: function () {
30
- return _breakpoints.getBreakpointFromScreenWidth;
31
- }
32
- });
33
- Object.defineProperty(exports, "getKeyForCustomMediaQuery", {
26
+ Object.defineProperty(exports, "Orientation", {
34
27
  enumerable: true,
35
28
  get: function () {
36
- return _mediaQueries.getKeyForCustomMediaQuery;
29
+ return _common.Orientation;
37
30
  }
38
31
  });
39
- Object.defineProperty(exports, "getValueForBreakpoint", {
32
+ Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
40
33
  enumerable: true,
41
34
  get: function () {
42
- return _breakpoints.getValueForBreakpoint;
35
+ return _breakpoints.getBreakpointFromScreenWidth;
43
36
  }
44
37
  });
45
- Object.defineProperty(exports, "isMediaQuery", {
38
+ Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
46
39
  enumerable: true,
47
40
  get: function () {
48
- return _mediaQueries.isMediaQuery;
41
+ return _mqParser.getKeyForUnistylesMediaQuery;
49
42
  }
50
43
  });
51
- Object.defineProperty(exports, "isServer", {
44
+ Object.defineProperty(exports, "getKeyForVariant", {
52
45
  enumerable: true,
53
46
  get: function () {
54
- return _common.isServer;
47
+ return _variants.getKeyForVariant;
55
48
  }
56
49
  });
57
- Object.defineProperty(exports, "isWithinTheHeight", {
50
+ Object.defineProperty(exports, "getValueForNestedStyle", {
58
51
  enumerable: true,
59
52
  get: function () {
60
- return _mediaQueries.isWithinTheHeight;
53
+ return _breakpoints.getValueForNestedStyle;
61
54
  }
62
55
  });
63
- Object.defineProperty(exports, "isWithinTheWidth", {
56
+ Object.defineProperty(exports, "isServer", {
64
57
  enumerable: true,
65
58
  get: function () {
66
- return _mediaQueries.isWithinTheWidth;
59
+ return _common.isServer;
67
60
  }
68
61
  });
69
- Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
62
+ Object.defineProperty(exports, "mq", {
70
63
  enumerable: true,
71
64
  get: function () {
72
- return _mediaQueries.isWithinTheWidthAndHeight;
65
+ return _mq.mq;
73
66
  }
74
67
  });
75
68
  Object.defineProperty(exports, "normalizeStyles", {
@@ -109,8 +102,10 @@ Object.keys(_normalizer).forEach(function (key) {
109
102
  }
110
103
  });
111
104
  });
105
+ var _mq = require("./mq");
106
+ var _variants = require("./variants");
107
+ var _mqParser = require("./mqParser");
112
108
  var _breakpoints = require("./breakpoints");
113
109
  var _styles = require("./styles");
114
110
  var _common = require("./common");
115
- var _mediaQueries = require("./mediaQueries");
116
111
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_breakpoints","_styles","_common","_mediaQueries"],"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,YAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,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,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":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGE,MAAM,CAAC,cAAc,CAAC;AAAA,IAyBzCC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA,EAANA,MAAM;AAQX,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOC,eAAS,CAACC,QAAQ,CAACC,WAAW,CAACH,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;AAED,MAAMI,YAAY,GAAG,SAAAA,CAAA;EAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;EAAA,OAAK,IAAIC,KAAK,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QAAQ,CAAC;YAC9C;UACJ,CAAC,CAAC;QAAA;MACN;MAEA,OAAOO,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;IAC9C;EACJ,CAAC,CAAC;AAAA;AAEK,MAAMW,EAAE,GAAA9B,OAAA,CAAA8B,EAAA,GAAG,IAAIf,KAAK,CAAC,CAAC,CAAC,EAAe;EACzCC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;IAC7B,IAAID,IAAI,KAAKhB,MAAM,CAACqB,MAAM,IAAIL,IAAI,KAAKhB,MAAM,CAACoB,KAAK,EAAE;MACjD,OAAOK,aAAa;IACxB;IAEA,IAAIT,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,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,IAAI,EAAEC,MAAM,CAACH,KAAK,CAAC;MACnBI,EAAE,EAAED,MAAM,CAACF,GAAG;IAClB,CAAC,GAAGI;EACR,CAAC;AACL,CAAC;AAED,MAAMC,aAAa,GAAIZ,EAAU,IAAKJ,kBAAkB,CAACiB,IAAI,CAACb,EAAE,CAAC;AAEjE,MAAMc,SAAS,GAAIC,QAA2B,IAAK;EAC/C,MAAM;IAAEd,KAAK;IAAEI;EAAO,CAAC,GAAGU,QAAQ;EAElC,IAAId,KAAK,IAAII,MAAM,EAAE;IACjB,OAAOJ,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACS,EAAE,IAAIL,MAAM,CAACG,IAAI,IAAIH,MAAM,CAACK,EAAE;EAC7D;EAE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AAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IAC/B,IAAI,CAACb,aAAa,CAACc,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMX,QAAQ,GAAGhB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACZ,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAC,OAAA,CAAAN,4BAAA,GAAAA,4BAAA"}
@@ -7,29 +7,8 @@ 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
13
  exports.proxifyFunction = proxifyFunction;
35
14
  const isPlatformColor = value => {
@@ -38,51 +17,25 @@ const isPlatformColor = value => {
38
17
  }
39
18
  return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
40
19
  };
41
-
42
- /**
43
- * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
44
- *
45
- * 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),
46
- * it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
47
- *
48
- * @template T - The type of the style object.
49
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
50
- *
51
- * @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
52
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
53
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
54
- * @param breakpointPairs - sorted pairs of breakpoints
55
- *
56
- * @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
57
- *
58
- * @example
59
- *
60
- * const style = { fontSize: { sm: '12px', md: '16px' } }
61
- * const screenSize = { width: 300, height: 400 }
62
- * const breakpoints = { xs: 0, sm: 300, md: 600 }
63
- *
64
- * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
65
- * // { fontSize: '12px' }
66
- */
67
20
  exports.isPlatformColor = isPlatformColor;
68
- const parseStyle = (style, breakpoint, screenSize, breakpointPairs) => {
21
+ const parseStyle = (style, breakpoint, screenSize, variant) => {
69
22
  const entries = Object.entries(style || {});
70
23
  const parsedStyles = Object.fromEntries(entries.map(_ref => {
71
24
  let [key, value] = _ref;
72
25
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
73
26
  if (hasNestedProperties) {
74
- return [key, parseStyle(value, breakpoint, screenSize, breakpointPairs)];
27
+ return [key, parseStyle(value, breakpoint, screenSize, variant)];
75
28
  }
76
29
  const isTransform = key === 'transform';
77
30
  if (isTransform && Array.isArray(value)) {
78
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))];
31
+ return [key, value.map(value => parseStyle(value, breakpoint, screenSize, variant))];
79
32
  }
80
33
  const isDynamicFunction = typeof value === 'function';
81
34
  const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
82
35
  if (isDynamicFunction || isValidStyle) {
83
36
  return [key, value];
84
37
  }
85
- return [key, (0, _breakpoints.getValueForBreakpoint)(value, breakpoint, screenSize, breakpointPairs)];
38
+ return [key, (0, _breakpoints.getValueForNestedStyle)(value, variant)];
86
39
  }));
87
40
  return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
88
41
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","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","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,K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C,OAAO,CACHY,GAAG,EACHZ,KAAK,CAACU,GAAG,CAACV,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEX,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CAAC,CACjF;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,kCAAqB,EACjBnB,KAAK,EACLX,UAAU,EACVC,UAAU,EACVC,eACJ,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"}
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,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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"}
@@ -0,0 +1,22 @@
1
+ export let CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
2
+ CxxUnistylesEventTypes["Theme"] = "theme";
3
+ CxxUnistylesEventTypes["Layout"] = "layout";
4
+ return CxxUnistylesEventTypes;
5
+ }({});
6
+ export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
7
+ UnistylesError["RuntimeUnavailable"] = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE";
8
+ UnistylesError["ThemeNotFound"] = "UNISTYLES_ERROR_THEME_NOT_FOUND";
9
+ UnistylesError["ThemeNotRegistered"] = "UNISTYLES_ERROR_THEME_NOT_REGISTERED";
10
+ UnistylesError["ThemesCannotBeEmpty"] = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY";
11
+ UnistylesError["BreakpointsCannotBeEmpty"] = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY";
12
+ UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
13
+ return UnistylesError;
14
+ }({});
15
+
16
+ // todo to string?
17
+ export let ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
18
+ ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
19
+ ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
20
+ return ScreenOrientation;
21
+ }({});
22
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CxxUnistylesEventTypes","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAKlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;;AAS1B;AACA,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
@@ -0,0 +1,31 @@
1
+ export class UnistyleRegistry {
2
+ config = {};
3
+ themeNames = [];
4
+ themes = {};
5
+ breakpoints = {};
6
+ sortedBreakpointPairs = [];
7
+ constructor(unistylesBridge) {
8
+ this.unistylesBridge = unistylesBridge;
9
+ }
10
+ addThemes = themes => {
11
+ this.themes = themes;
12
+ const keys = Object.keys(themes);
13
+ this.unistylesBridge.themes = keys;
14
+ this.themeNames = keys;
15
+ return this;
16
+ };
17
+ addBreakpoints = breakpoints => {
18
+ this.breakpoints = breakpoints;
19
+ this.unistylesBridge.useBreakpoints(breakpoints);
20
+ this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
21
+ return this;
22
+ };
23
+ addConfig = config => {
24
+ this.config = config;
25
+ if (config.adaptiveThemes) {
26
+ this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
27
+ }
28
+ return this;
29
+ };
30
+ }
31
+ //# sourceMappingURL=UnistyleRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO,IAAI;EACf,CAAC;EAEME,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACK,cAAc,CAACR,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMQ,SAAS,GAAIZ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACa,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACd,MAAM,CAACa,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;AACL"}
@@ -0,0 +1,25 @@
1
+ import { UnistylesModule } from './UnistylesModule';
2
+ import { UnistylesRuntime } from './UnistylesRuntime';
3
+ import { UnistyleRegistry } from './UnistyleRegistry';
4
+ import { UnistylesError } from '../common';
5
+ class Unistyles {
6
+ constructor() {
7
+ const isInstalled = UnistylesModule?.install() ?? false;
8
+ if (!isInstalled) {
9
+ throw new Error(UnistylesError.RuntimeUnavailable);
10
+ }
11
+
12
+ // @ts-ignore
13
+ this._bridge = global.__UNISTYLES__;
14
+ this._registry = new UnistyleRegistry(this._bridge);
15
+ this._runtime = new UnistylesRuntime(this._bridge, this._registry);
16
+ }
17
+ get registry() {
18
+ return this._registry;
19
+ }
20
+ get runtime() {
21
+ return this._runtime;
22
+ }
23
+ }
24
+ export const unistyles = new Unistyles();
25
+ //# sourceMappingURL=Unistyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","_runtime","registry","runtime","unistyles"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,QAAQ,WAAW;AAE1C,MAAMC,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGN,eAAe,EAAEO,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACL,cAAc,CAACM,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIX,gBAAgB,CAAC,IAAI,CAACQ,OAAO,CAAC;IACnD,IAAI,CAACI,QAAQ,GAAG,IAAIb,gBAAgB,CAAC,IAAI,CAACS,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;EACtE;EAEA,IAAWE,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACF,SAAS;EACzB;EAEA,IAAWG,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACF,QAAQ;EACxB;AACJ;AAEA,OAAO,MAAMG,SAAS,GAAG,IAAIb,SAAS,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { NativeModules } from 'react-native';
2
+ export const UnistylesModule = NativeModules?.Unistyles;
3
+ //# sourceMappingURL=UnistylesModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
@@ -0,0 +1,59 @@
1
+ import { ScreenOrientation, UnistylesError } from '../common';
2
+ export class UnistylesRuntime {
3
+ constructor(unistylesBridge, registry) {
4
+ this.unistylesBridge = unistylesBridge;
5
+ this.registry = registry;
6
+ }
7
+ get colorScheme() {
8
+ return this.unistylesBridge.colorScheme;
9
+ }
10
+ get hasAdaptiveThemes() {
11
+ return this.unistylesBridge.hasAdaptiveThemes;
12
+ }
13
+ get sortedBreakpoints() {
14
+ return this.registry.sortedBreakpointPairs;
15
+ }
16
+ get themeName() {
17
+ return this.unistylesBridge.themeName;
18
+ }
19
+ get breakpoint() {
20
+ return this.unistylesBridge.breakpoint;
21
+ }
22
+ get screen() {
23
+ return {
24
+ width: this.unistylesBridge.screenWidth,
25
+ height: this.unistylesBridge.screenHeight
26
+ };
27
+ }
28
+ get orientation() {
29
+ const {
30
+ width,
31
+ height
32
+ } = this.screen;
33
+ if (width > height) {
34
+ return ScreenOrientation.Landscape;
35
+ }
36
+ return ScreenOrientation.Portrait;
37
+ }
38
+ setTheme = name => {
39
+ if (this.hasTheme(name)) {
40
+ this.unistylesBridge.useTheme(name);
41
+ return true;
42
+ }
43
+ throw new Error(UnistylesError.ThemeNotRegistered);
44
+ };
45
+ getTheme = forName => {
46
+ if (this.registry.themeNames.length === 0) {
47
+ return {};
48
+ }
49
+ if (!this.hasTheme(forName)) {
50
+ throw new Error(UnistylesError.ThemeNotFound);
51
+ }
52
+ return this.registry.themes[forName];
53
+ };
54
+ setAdaptiveThemes = enable => {
55
+ this.unistylesBridge.useAdaptiveThemes(enable);
56
+ };
57
+ hasTheme = name => name in this.registry.themes;
58
+ }
59
+ //# sourceMappingURL=UnistylesRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,QAA0B,EAAE;IAAA,KAAtED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,QAA0B,GAA1BA,QAA0B;EAAG;EAE3F,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,QAAQ,CAACI,qBAAqB;EAC9C;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACN,eAAe,CAACM,SAAS;EACzC;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACP,eAAe,CAACO,UAAU;EAC1C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACT,eAAe,CAACU,WAAW;MACvCC,MAAM,EAAE,IAAI,CAACX,eAAe,CAACY;IACjC,CAAC;EACL;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,MAAM;MAAEJ,KAAK;MAAEE;IAAO,CAAC,GAAG,IAAI,CAACH,MAAM;IAErC,IAAIC,KAAK,GAAGE,MAAM,EAAE;MAChB,OAAOf,iBAAiB,CAACkB,SAAS;IACtC;IAEA,OAAOlB,iBAAiB,CAACmB,QAAQ;EACrC;EAEOC,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAI,IAAI,CAACC,QAAQ,CAACD,IAAI,CAAC,EAAE;MACrB,IAAI,CAACjB,eAAe,CAACmB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,MAAM,IAAIG,KAAK,CAACvB,cAAc,CAACwB,kBAAkB,CAAC;EACtD,CAAC;EAEMC,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,IAAI,CAACtB,QAAQ,CAACuB,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;MACvC,OAAO,CAAC,CAAC;IACb;IAEA,IAAI,CAAC,IAAI,CAACP,QAAQ,CAACK,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIH,KAAK,CAACvB,cAAc,CAAC6B,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAACzB,QAAQ,CAAC0B,MAAM,CAACJ,OAAO,CAAC;EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC7B,eAAe,CAAC8B,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOX,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAChB,QAAQ,CAAC0B,MAAM;AACpF"}
@@ -0,0 +1,2 @@
1
+ export { unistyles } from './Unistyles';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["unistyles"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa"}
@@ -0,0 +1,7 @@
1
+ export const createStyleSheet = styles => {
2
+ if (typeof styles === 'function') {
3
+ return styles;
4
+ }
5
+ return styles;
6
+ };
7
+ //# sourceMappingURL=createStyleSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStyleSheet","styles"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAUC,MAA4F,IAAY;EAC3I,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM;EACjB;EAEA,OAAOA,MAAM;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":""}
@@ -1,2 +1,3 @@
1
- export { useDimensions } from './useDimensions';
1
+ export { useInitialTheme } from './useInitialTheme';
2
+ export { useUnistyles } from './useUnistyles';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useDimensions"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB"}
1
+ {"version":3,"names":["useInitialTheme","useUnistyles"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,gBAAgB"}