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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) 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/types/variants.js +2 -0
  43. package/lib/commonjs/types/variants.js.map +1 -0
  44. package/lib/commonjs/useStyles.js +49 -0
  45. package/lib/commonjs/useStyles.js.map +1 -0
  46. package/lib/commonjs/utils/breakpoints.js +33 -80
  47. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  48. package/lib/commonjs/utils/common.js +10 -3
  49. package/lib/commonjs/utils/common.js.map +1 -1
  50. package/lib/commonjs/utils/index.js +46 -17
  51. package/lib/commonjs/utils/index.js.map +1 -1
  52. package/lib/commonjs/utils/module.d.js +2 -0
  53. package/lib/commonjs/utils/module.d.js.map +1 -0
  54. package/lib/commonjs/utils/mq.js +89 -0
  55. package/lib/commonjs/utils/mq.js.map +1 -0
  56. package/lib/commonjs/utils/mqParser.js +86 -0
  57. package/lib/commonjs/utils/mqParser.js.map +1 -0
  58. package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
  59. package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
  60. package/lib/commonjs/utils/normalizer.js +89 -0
  61. package/lib/commonjs/utils/normalizer.js.map +1 -0
  62. package/lib/commonjs/utils/styles.js +29 -58
  63. package/lib/commonjs/utils/styles.js.map +1 -1
  64. package/lib/commonjs/utils/variants.js +17 -0
  65. package/lib/commonjs/utils/variants.js.map +1 -0
  66. package/lib/module/common.js +22 -0
  67. package/lib/module/common.js.map +1 -0
  68. package/lib/module/core/UnistyleRegistry.js +31 -0
  69. package/lib/module/core/UnistyleRegistry.js.map +1 -0
  70. package/lib/module/core/Unistyles.js +25 -0
  71. package/lib/module/core/Unistyles.js.map +1 -0
  72. package/lib/module/core/UnistylesModule.js +3 -0
  73. package/lib/module/core/UnistylesModule.js.map +1 -0
  74. package/lib/module/core/UnistylesRuntime.js +59 -0
  75. package/lib/module/core/UnistylesRuntime.js.map +1 -0
  76. package/lib/module/core/index.js +2 -0
  77. package/lib/module/core/index.js.map +1 -0
  78. package/lib/module/createStyleSheet.js +7 -0
  79. package/lib/module/createStyleSheet.js.map +1 -0
  80. package/lib/module/global.js +2 -0
  81. package/lib/module/global.js.map +1 -0
  82. package/lib/module/hooks/index.js +2 -1
  83. package/lib/module/hooks/index.js.map +1 -1
  84. package/lib/module/hooks/useInitialTheme.js +10 -0
  85. package/lib/module/hooks/useInitialTheme.js.map +1 -0
  86. package/lib/module/hooks/useUnistyles.js +47 -0
  87. package/lib/module/hooks/useUnistyles.js.map +1 -0
  88. package/lib/module/index.js +13 -2
  89. package/lib/module/index.js.map +1 -1
  90. package/lib/module/types/common.js +2 -0
  91. package/lib/module/types/common.js.map +1 -0
  92. package/lib/module/types/index.js +2 -1
  93. package/lib/module/types/index.js.map +1 -1
  94. package/lib/module/types/mq.js +2 -0
  95. package/lib/module/types/mq.js.map +1 -0
  96. package/lib/module/types/normalizer.js +2 -0
  97. package/lib/module/types/normalizer.js.map +1 -0
  98. package/lib/module/types/unistyles.js +2 -0
  99. package/lib/module/types/unistyles.js.map +1 -0
  100. package/lib/module/types/variants.js +2 -0
  101. package/lib/module/types/variants.js.map +1 -0
  102. package/lib/module/useStyles.js +42 -0
  103. package/lib/module/useStyles.js.map +1 -0
  104. package/lib/module/utils/breakpoints.js +34 -82
  105. package/lib/module/utils/breakpoints.js.map +1 -1
  106. package/lib/module/utils/common.js +9 -1
  107. package/lib/module/utils/common.js.map +1 -1
  108. package/lib/module/utils/index.js +5 -1
  109. package/lib/module/utils/index.js.map +1 -1
  110. package/lib/module/utils/module.d.js +2 -0
  111. package/lib/module/utils/module.d.js.map +1 -0
  112. package/lib/module/utils/mq.js +83 -0
  113. package/lib/module/utils/mq.js.map +1 -0
  114. package/lib/module/utils/mqParser.js +79 -0
  115. package/lib/module/utils/mqParser.js.map +1 -0
  116. package/lib/module/utils/normalizeStyles.web.js +13 -13
  117. package/lib/module/utils/normalizeStyles.web.js.map +1 -1
  118. package/lib/module/utils/normalizer.js +79 -0
  119. package/lib/module/utils/normalizer.js.map +1 -0
  120. package/lib/module/utils/styles.js +28 -59
  121. package/lib/module/utils/styles.js.map +1 -1
  122. package/lib/module/utils/variants.js +10 -0
  123. package/lib/module/utils/variants.js.map +1 -0
  124. package/lib/typescript/src/common.d.ts +17 -0
  125. package/lib/typescript/src/common.d.ts.map +1 -0
  126. package/lib/typescript/src/core/UnistyleRegistry.d.ts +15 -0
  127. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
  128. package/lib/typescript/src/core/Unistyles.d.ts +13 -0
  129. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
  130. package/lib/typescript/src/core/UnistylesModule.d.ts +6 -0
  131. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
  132. package/lib/typescript/src/core/UnistylesRuntime.d.ts +24 -0
  133. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
  134. package/lib/typescript/src/core/index.d.ts +2 -0
  135. package/lib/typescript/src/core/index.d.ts.map +1 -0
  136. package/lib/typescript/src/createStyleSheet.d.ts +3 -0
  137. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  138. package/lib/typescript/src/global.d.ts +7 -0
  139. package/lib/typescript/src/global.d.ts.map +1 -0
  140. package/lib/typescript/src/hooks/index.d.ts +2 -1
  141. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  142. package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
  143. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
  144. package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
  145. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
  146. package/lib/typescript/src/index.d.ts +14 -2
  147. package/lib/typescript/src/index.d.ts.map +1 -1
  148. package/lib/typescript/src/types/breakpoints.d.ts +12 -13
  149. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  150. package/lib/typescript/src/types/common.d.ts +3 -0
  151. package/lib/typescript/src/types/common.d.ts.map +1 -0
  152. package/lib/typescript/src/types/core.d.ts +28 -18
  153. package/lib/typescript/src/types/core.d.ts.map +1 -1
  154. package/lib/typescript/src/types/index.d.ts +7 -2
  155. package/lib/typescript/src/types/index.d.ts.map +1 -1
  156. package/lib/typescript/src/types/mq.d.ts +3 -0
  157. package/lib/typescript/src/types/mq.d.ts.map +1 -0
  158. package/lib/typescript/src/types/normalizer.d.ts +20 -0
  159. package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
  160. package/lib/typescript/src/types/unistyles.d.ts +37 -0
  161. package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
  162. package/lib/typescript/src/types/variants.d.ts +8 -0
  163. package/lib/typescript/src/types/variants.d.ts.map +1 -0
  164. package/lib/typescript/src/useStyles.d.ts +10 -0
  165. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  166. package/lib/typescript/src/utils/breakpoints.d.ts +5 -62
  167. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  168. package/lib/typescript/src/utils/common.d.ts +9 -1
  169. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  170. package/lib/typescript/src/utils/index.d.ts +5 -1
  171. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  172. package/lib/typescript/src/utils/mq.d.ts +21 -0
  173. package/lib/typescript/src/utils/mq.d.ts.map +1 -0
  174. package/lib/typescript/src/utils/mqParser.d.ts +3 -0
  175. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
  176. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
  177. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
  178. package/lib/typescript/src/utils/normalizer.d.ts +11 -0
  179. package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
  180. package/lib/typescript/src/utils/styles.d.ts +5 -49
  181. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  182. package/lib/typescript/src/utils/variants.d.ts +3 -0
  183. package/lib/typescript/src/utils/variants.d.ts.map +1 -0
  184. package/package.json +33 -15
  185. package/react-native-unistyles.podspec +22 -0
  186. package/src/common.ts +19 -0
  187. package/src/core/UnistyleRegistry.ts +41 -0
  188. package/src/core/Unistyles.ts +34 -0
  189. package/src/core/UnistylesModule.ts +7 -0
  190. package/src/core/UnistylesRuntime.ts +73 -0
  191. package/src/core/index.ts +1 -0
  192. package/src/createStyleSheet.ts +9 -0
  193. package/src/global.ts +5 -0
  194. package/src/hooks/index.ts +2 -1
  195. package/src/hooks/useInitialTheme.ts +11 -0
  196. package/src/hooks/useUnistyles.ts +55 -0
  197. package/src/index.ts +30 -2
  198. package/src/types/breakpoints.ts +21 -20
  199. package/src/types/common.ts +2 -0
  200. package/src/types/core.ts +36 -24
  201. package/src/types/index.ts +7 -9
  202. package/src/types/mq.ts +3 -0
  203. package/src/types/normalizer.ts +29 -0
  204. package/src/types/unistyles.ts +45 -0
  205. package/src/types/variants.ts +11 -0
  206. package/src/useStyles.ts +62 -0
  207. package/src/utils/breakpoints.ts +46 -86
  208. package/src/utils/common.ts +10 -1
  209. package/src/utils/index.ts +5 -8
  210. package/src/utils/module.d.ts +3 -0
  211. package/src/utils/mq.ts +106 -0
  212. package/src/utils/mqParser.ts +99 -0
  213. package/src/utils/normalizeStyles.web.ts +21 -42
  214. package/src/utils/normalizer.ts +99 -0
  215. package/src/utils/styles.ts +46 -70
  216. package/src/utils/variants.ts +13 -0
  217. package/lib/commonjs/UnistylesTheme.js +0 -21
  218. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  219. package/lib/commonjs/createUnistyles.js +0 -57
  220. package/lib/commonjs/createUnistyles.js.map +0 -1
  221. package/lib/commonjs/hooks/useDimensions.js +0 -10
  222. package/lib/commonjs/hooks/useDimensions.js.map +0 -1
  223. package/lib/commonjs/hooks/useDimensions.web.js +0 -31
  224. package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
  225. package/lib/commonjs/types/mediaQueries.js +0 -2
  226. package/lib/commonjs/utils/mediaQueries.js +0 -189
  227. package/lib/commonjs/utils/mediaQueries.js.map +0 -1
  228. package/lib/module/UnistylesTheme.js +0 -12
  229. package/lib/module/UnistylesTheme.js.map +0 -1
  230. package/lib/module/createUnistyles.js +0 -50
  231. package/lib/module/createUnistyles.js.map +0 -1
  232. package/lib/module/hooks/useDimensions.js +0 -3
  233. package/lib/module/hooks/useDimensions.js.map +0 -1
  234. package/lib/module/hooks/useDimensions.web.js +0 -24
  235. package/lib/module/hooks/useDimensions.web.js.map +0 -1
  236. package/lib/module/types/mediaQueries.js +0 -2
  237. package/lib/module/utils/mediaQueries.js +0 -176
  238. package/lib/module/utils/mediaQueries.js.map +0 -1
  239. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  240. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  241. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  242. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  243. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  244. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  245. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  246. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  247. package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
  248. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  249. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
  250. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  251. package/src/UnistylesTheme.tsx +0 -17
  252. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  253. package/src/createUnistyles.ts +0 -70
  254. package/src/hooks/useDimensions.ts +0 -4
  255. package/src/hooks/useDimensions.web.ts +0 -30
  256. package/src/types/mediaQueries.ts +0 -10
  257. package/src/utils/mediaQueries.ts +0 -201
@@ -1,5 +1,9 @@
1
1
  export { normalizeStyles } from './normalizeStyles';
2
+ export * from './normalizer';
3
+ export { mq, MQSymbol } from './mq';
4
+ export { getKeyForVariant } from './variants';
5
+ export { getKeyForUnistylesMediaQuery } from './mqParser';
2
6
  export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
3
7
  export { proxifyFunction, parseStyle } from './styles';
4
- export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
8
+ export { isServer, Orientation } from './common';
5
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
1
+ {"version":3,"names":["normalizeStyles","mq","MQSymbol","getKeyForVariant","getKeyForUnistylesMediaQuery","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","Orientation"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,EAAE,EAAEC,QAAQ,QAAQ,MAAM;AACnC,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,4BAA4B,QAAQ,YAAY;AACzD,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,UAAU"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=module.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import { unistyles } from '../core';
2
+ export const MQSymbol = Symbol('unistyles-mq');
3
+ var MQProp = /*#__PURE__*/function (MQProp) {
4
+ MQProp["toString"] = "toString";
5
+ MQProp["width"] = "width";
6
+ MQProp["height"] = "height";
7
+ MQProp["shortW"] = "w";
8
+ MQProp["shortH"] = "h";
9
+ return MQProp;
10
+ }(MQProp || {});
11
+ const getMQValue = value => {
12
+ if (typeof value === 'number') {
13
+ return value;
14
+ }
15
+ if (value === null) {
16
+ return 0;
17
+ }
18
+ return unistyles.registry.breakpoints[value] ?? 0;
19
+ };
20
+ const widthHandler = function () {
21
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
22
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
23
+ return new Proxy({}, {
24
+ get: (target, prop, receiver) => {
25
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
26
+ return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
27
+ }
28
+ if (prop === MQProp.width || prop === MQProp.shortW) {
29
+ return function () {
30
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
31
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
32
+ return new Proxy({}, {
33
+ get: (target, prop, receiver) => {
34
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
35
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
36
+ }
37
+ return Reflect.get(target, prop, receiver);
38
+ }
39
+ });
40
+ };
41
+ }
42
+ return Reflect.get(target, prop, receiver);
43
+ }
44
+ });
45
+ };
46
+ const heightHandler = function () {
47
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
48
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
49
+ return new Proxy({}, {
50
+ get: (target, prop, receiver) => {
51
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
52
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
53
+ }
54
+ if (prop === MQProp.height || prop === MQProp.shortH) {
55
+ return function () {
56
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
57
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
58
+ return new Proxy({}, {
59
+ get: (target, prop, receiver) => {
60
+ if (prop === Symbol.toPrimitive || MQProp.toString) {
61
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
62
+ }
63
+ return Reflect.get(target, prop, receiver);
64
+ }
65
+ });
66
+ };
67
+ }
68
+ return Reflect.get(target, prop, receiver);
69
+ }
70
+ });
71
+ };
72
+ export const mq = new Proxy({}, {
73
+ get: (target, prop, receiver) => {
74
+ if (prop === MQProp.shortW || prop === MQProp.width) {
75
+ return heightHandler;
76
+ }
77
+ if (prop === MQProp.shortH || prop === MQProp.height) {
78
+ return widthHandler;
79
+ }
80
+ return Reflect.get(target, prop, receiver);
81
+ }
82
+ });
83
+ //# sourceMappingURL=mq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["unistyles","MQSymbol","Symbol","MQProp","getMQValue","value","registry","breakpoints","widthHandler","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","shortW","wMin","wMax","Reflect","heightHandler","height","shortH","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,IAAIX,IAAI,KAAKf,MAAM,CAACyB,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,79 @@
1
+ const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
2
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
3
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
4
+ const parseMq = mq => {
5
+ const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
6
+ const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
7
+ return {
8
+ width: width ? {
9
+ from: Number(fromW),
10
+ to: Number(toW)
11
+ } : undefined,
12
+ height: height ? {
13
+ from: Number(fromH),
14
+ to: Number(toH)
15
+ } : undefined
16
+ };
17
+ };
18
+ const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
19
+ const isValidMq = parsedMq => {
20
+ const {
21
+ width,
22
+ height
23
+ } = parsedMq;
24
+ if (width && height) {
25
+ return width.from <= width.to && height.from <= height.to;
26
+ }
27
+ if (width) {
28
+ return width.from <= width.to;
29
+ }
30
+ if (height) {
31
+ return height.from <= height.to;
32
+ }
33
+ return false;
34
+ };
35
+ const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
36
+ const {
37
+ width,
38
+ height
39
+ } = parsedMq;
40
+ if (width && height) {
41
+ return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height);
42
+ }
43
+ if (width) {
44
+ return isWithinTheWidth(width, screenSize.width);
45
+ }
46
+ if (height) {
47
+ return isWithinTheHeight(height, screenSize.height);
48
+ }
49
+ return false;
50
+ };
51
+ const isWithinTheWidth = (width, screenWidth) => {
52
+ const {
53
+ from,
54
+ to
55
+ } = width;
56
+ return screenWidth >= from && screenWidth <= to;
57
+ };
58
+ const isWithinTheHeight = (height, screenHeight) => {
59
+ const {
60
+ from,
61
+ to
62
+ } = height;
63
+ return screenHeight >= from && screenHeight <= to;
64
+ };
65
+ export const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
66
+ const mq = mediaQueries.find(_ref => {
67
+ let [key] = _ref;
68
+ if (!isUnistylesMq(key)) {
69
+ return false;
70
+ }
71
+ const parsedMq = parseMq(key);
72
+ if (!isValidMq(parsedMq)) {
73
+ return false;
74
+ }
75
+ return isWithinTheWidthAndHeight(parsedMq, screenSize);
76
+ });
77
+ return mq?.at(0);
78
+ };
79
+ //# 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"],"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,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AACd,MAAM,EAAEY,UAAU,CAACZ,MAAM,CAAC;EACvD;EAEA,OAAO,KAAK;AAChB,CAAC;AAED,MAAMa,gBAAgB,GAAGA,CAACjB,KAAiC,EAAEmB,WAAmB,KAAc;EAC1F,MAAM;IAAEZ,IAAI;IAAEE;EAAG,CAAC,GAAGT,KAA0B;EAE/C,OAAOmB,WAAW,IAAIZ,IAAI,IAAIY,WAAW,IAAIV,EAAE;AACnD,CAAC;AAED,MAAMS,iBAAiB,GAAGA,CAACd,MAAmC,EAAEgB,YAAoB,KAAc;EAC9F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOgB,YAAY,IAAIb,IAAI,IAAIa,YAAY,IAAIX,EAAE;AACrD,CAAC;AAED,OAAO,MAAMY,4BAA4B,GAAGA,CAACC,YAA8B,EAAEN,UAAsB,KAAK;EACpG,MAAMjB,EAAE,GAAGuB,YAAY,CAACC,IAAI,CAACC,IAAA,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"}
@@ -1,8 +1,8 @@
1
1
  import { warn } from './common';
2
- const preprocessor = require('react-native-web/src/exports/StyleSheet/preprocess.js');
3
- const normalizeBoxShadow = styles => {
2
+ import { preprocessor } from './normalizer';
3
+ const normalizeBoxShadow = style => {
4
4
  const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
5
- if (!requiredBoxShadowProperties.every(prop => prop in styles)) {
5
+ if (!requiredBoxShadowProperties.every(prop => prop in style)) {
6
6
  warn(`can't apply box shadow as you miss at least one of these properties: ${requiredBoxShadowProperties.join(', ')}`);
7
7
  return {
8
8
  shadowColor: undefined,
@@ -12,16 +12,16 @@ const normalizeBoxShadow = styles => {
12
12
  };
13
13
  }
14
14
  return {
15
- boxShadow: preprocessor.createBoxShadowValue(styles),
15
+ boxShadow: preprocessor.createBoxShadowValue(style),
16
16
  shadowColor: undefined,
17
17
  shadowOffset: undefined,
18
18
  shadowOpacity: undefined,
19
19
  shadowRadius: undefined
20
20
  };
21
21
  };
22
- const normalizeTextShadow = styles => {
22
+ const normalizeTextShadow = style => {
23
23
  const requiredTextShadowProperties = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
24
- if (!requiredTextShadowProperties.every(prop => prop in styles)) {
24
+ if (!requiredTextShadowProperties.every(prop => prop in style)) {
25
25
  warn(`can't apply text shadow as you miss at least one of these properties: ${requiredTextShadowProperties.join(', ')}`);
26
26
  return {
27
27
  textShadowColor: undefined,
@@ -30,20 +30,20 @@ const normalizeTextShadow = styles => {
30
30
  };
31
31
  }
32
32
  return {
33
- textShadow: preprocessor.createTextShadowValue(styles),
33
+ textShadow: preprocessor.createTextShadowValue(style),
34
34
  textShadowColor: undefined,
35
35
  textShadowOffset: undefined,
36
36
  textShadowRadius: undefined
37
37
  };
38
38
  };
39
- export const normalizeStyles = styles => {
40
- const normalizedTransform = 'transform' in styles && Array.isArray(styles.transform) ? {
41
- transform: preprocessor.createTransformValue(styles.transform)
39
+ export const normalizeStyles = style => {
40
+ const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
41
+ transform: preprocessor.createTransformValue(style.transform)
42
42
  } : {};
43
- const normalizedBoxShadow = 'shadowColor' in styles || 'shadowOffset' in styles || 'shadowOpacity' in styles || 'shadowRadius' in styles ? normalizeBoxShadow(styles) : {};
44
- const normalizedTextShadow = 'textShadowColor' in styles || 'textShadowOffset' in styles || 'textShadowRadius' in styles ? normalizeTextShadow(styles) : {};
43
+ const normalizedBoxShadow = 'shadowColor' in style || 'shadowOffset' in style || 'shadowOpacity' in style || 'shadowRadius' in style ? normalizeBoxShadow(style) : {};
44
+ const normalizedTextShadow = 'textShadowColor' in style || 'textShadowOffset' in style || 'textShadowRadius' in style ? normalizeTextShadow(style) : {};
45
45
  return {
46
- ...styles,
46
+ ...style,
47
47
  ...normalizedTransform,
48
48
  ...normalizedBoxShadow,
49
49
  ...normalizedTextShadow
@@ -1 +1 @@
1
- {"version":3,"names":["warn","preprocessor","require","normalizeBoxShadow","styles","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,UAAU;AAE/B,MAAMC,YAA0B,GAAGC,OAAO,CAAC,uDAAuD,CAAC;AAuBnG,MAAMC,kBAAkB,GAAkBC,MAAS,IAA0B;EACzE,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,MAAM,CAAC,EAAE;IAC5DJ,IAAI,CAAE,wEAAuEK,2BAA2B,CAACG,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEb,YAAY,CAACc,oBAAoB,CAACX,MAAM,CAAC;IACp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,MAAM,GAC5BY,mBAAmB,CAACZ,MAAM,CAAC,GAAG,CAAC,CAAC;EAEpC,OAAO;IACH,GAAGA,MAAM;IACT,GAAGoB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC"}
1
+ {"version":3,"names":["warn","preprocessor","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,SAASC,YAAY,QAAQ,cAAc;AAG3C,MAAMC,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;IAC3DH,IAAI,CAAE,wEAAuEI,2BAA2B,CAACG,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEZ,YAAY,CAACa,oBAAoB,CAACX,KAAK,CAAC;IACnDK,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAAC;AACL,CAAC;AAED,MAAMM,mBAAmB,GAA0BZ,KAAQ,IAA2B;EAClF,MAAMa,4BAA4B,GAA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,79 @@
1
+ // based on react-native-web normalizer
2
+ // https://github.com/necolas/react-native-web
3
+ import normalizeColors from '@react-native/normalize-colors';
4
+ export const normalizeColor = function (color) {
5
+ let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6
+ // If the opacity is 1 there's no need to normalize the color
7
+ if (opacity === 1) {
8
+ return color;
9
+ }
10
+ const integer = normalizeColors(color);
11
+
12
+ // If the colour is an unknown format, the return value is null
13
+ if (integer === null) {
14
+ return color;
15
+ }
16
+ const hex = integer.toString(16).padStart(8, '0');
17
+ if (hex.length === 8) {
18
+ const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
19
+ return `rgba(${r},${g},${b},${a / 255 * opacity})`;
20
+ }
21
+ return color;
22
+ };
23
+ export const normalizeNumericValue = value => value ? `${value}px` : value;
24
+ const normalizeTransform = (key, value) => {
25
+ if (key.includes('scale')) {
26
+ return value;
27
+ }
28
+ if (typeof value === 'number') {
29
+ return normalizeNumericValue(value);
30
+ }
31
+ return value;
32
+ };
33
+ const createTextShadowValue = style => {
34
+ // at this point every prop is present
35
+ const {
36
+ textShadowColor,
37
+ textShadowOffset,
38
+ textShadowRadius
39
+ } = style;
40
+ const offsetX = normalizeNumericValue(textShadowOffset.width);
41
+ const offsetY = normalizeNumericValue(textShadowOffset.height);
42
+ const radius = normalizeNumericValue(textShadowRadius);
43
+ const color = normalizeColor(textShadowColor);
44
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
45
+ };
46
+ const createBoxShadowValue = style => {
47
+ // at this point every prop is present
48
+ const {
49
+ shadowColor,
50
+ shadowOffset,
51
+ shadowOpacity,
52
+ shadowRadius
53
+ } = style;
54
+ const offsetX = normalizeNumericValue(shadowOffset.width);
55
+ const offsetY = normalizeNumericValue(shadowOffset.height);
56
+ const radius = normalizeNumericValue(shadowRadius);
57
+ const color = normalizeColor(shadowColor, shadowOpacity);
58
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
59
+ };
60
+ const createTransformValue = transforms => transforms.map(transform => {
61
+ const [key] = Object.keys(transform);
62
+ if (!key) {
63
+ return undefined;
64
+ }
65
+ const value = transform[key];
66
+ switch (key) {
67
+ case 'matrix':
68
+ case 'matrix3d':
69
+ return `${key}(${value.join(',')})`;
70
+ default:
71
+ return `${key}(${normalizeTransform(key, value)})`;
72
+ }
73
+ }).filter(Boolean).join(' ');
74
+ export const preprocessor = {
75
+ createTextShadowValue,
76
+ createBoxShadowValue,
77
+ createTransformValue
78
+ };
79
+ //# sourceMappingURL=normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeColors","normalizeColor","color","opacity","arguments","length","undefined","integer","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","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":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,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,GAAGP,eAAe,CAACE,KAAK,CAAkB;;EAEvD;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMM,GAAG,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,C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getValueForBreakpoint } from './breakpoints';
2
2
  import { normalizeStyles } from './normalizeStyles';
3
- import { isWeb } from './common';
4
-
5
- /**
6
- * Proxies a function to parse its return value for custom media queries or breakpoints.
7
- *
8
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
9
- *
10
- * @param {Function} fn - The function to be proxified.
11
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
12
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
13
- * @param breakpointPairs - sorted pairs of breakpoints
14
- *
15
- * @returns {Function} Returns the proxified function
16
- *
17
- * @example
18
- *
19
- * const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
20
- * const screenSize = { width: 250, height: 400 }
21
- * const breakpoints = { sm: 300, md: 600 }
22
- *
23
- * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
24
- * proxifiedFunction() // parsed style based on screenSize and breakpoints
25
- */
26
- export const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Proxy(fn, {
27
- apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
3
+ import { isAndroid, isIOS, isWeb } from './common';
4
+ import { getKeyForVariant } from './variants';
5
+ export const proxifyFunction = (fn, breakpoint, screenSize, variant) => new Proxy(fn, {
6
+ apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
28
7
  });
29
-
30
- /**
31
- * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
32
- *
33
- * 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),
34
- * it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
35
- *
36
- * @template T - The type of the style object.
37
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
38
- *
39
- * @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
40
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
41
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
42
- * @param breakpointPairs - sorted pairs of breakpoints
43
- *
44
- * @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
45
- *
46
- * @example
47
- *
48
- * const style = { fontSize: { sm: '12px', md: '16px' } }
49
- * const screenSize = { width: 300, height: 400 }
50
- * const breakpoints = { xs: 0, sm: 300, md: 600 }
51
- *
52
- * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
53
- * // { fontSize: '12px' }
54
- */
55
- export const parseStyle = (style, breakpoint, screenSize, breakpointPairs) => {
56
- const entries = Object.entries(style);
57
- const parsedStyles = Object.fromEntries(entries.map(_ref => {
8
+ export const isPlatformColor = value => {
9
+ if (isIOS) {
10
+ return 'semantic' in value && typeof value.semantic === 'object';
11
+ }
12
+ return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
13
+ };
14
+ export const parseStyle = (style, breakpoint, screenSize, variant) => {
15
+ const entries = Object.entries(style || {}).map(_ref => {
58
16
  let [key, value] = _ref;
17
+ if (key !== 'variants') {
18
+ return [key, value];
19
+ }
20
+ const variantKey = getKeyForVariant(value, variant);
21
+ if (!variantKey) {
22
+ return undefined;
23
+ }
24
+ return Object.entries(value[variantKey]).flat();
25
+ }).filter(Boolean);
26
+ const parsedStyles = Object.fromEntries(entries.map(_ref2 => {
27
+ let [key, value] = _ref2;
59
28
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
60
29
  if (hasNestedProperties) {
61
- return [key, parseStyle(value, breakpoint, screenSize, breakpointPairs)];
30
+ return [key, parseStyle(value, breakpoint, screenSize, variant)];
62
31
  }
63
32
  const isTransform = key === 'transform';
64
33
  if (isTransform && Array.isArray(value)) {
65
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))];
34
+ return [key, value.map(value => parseStyle(value, breakpoint, screenSize, variant))];
66
35
  }
67
36
  const isDynamicFunction = typeof value === 'function';
68
- const isValidStyle = typeof value !== 'object';
37
+ const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
69
38
  if (isDynamicFunction || isValidStyle) {
70
39
  return [key, value];
71
40
  }
72
- return [key, getValueForBreakpoint(value, breakpoint, screenSize, breakpointPairs)];
41
+ return [key, getValueForBreakpoint(value)];
73
42
  }));
74
- return isWeb() ? normalizeStyles(parsedStyles) : parsedStyles;
43
+ return isWeb ? normalizeStyles(parsedStyles) : parsedStyles;
75
44
  };
76
45
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getValueForBreakpoint","normalizeStyles","isWeb","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","Proxy","apply","target","thisArg","argumentsList","parseStyle","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","value","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,UAAU;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA4B,EAC1CC,UAAsB,EACtBC,eAA2C,KAChC,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,UAAU,EAAEC,UAAU,EAAEC,eAAe;AAChG,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMM,UAAU,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KeyForVariant","proxifyFunction","fn","breakpoint","screenSize","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","entries","Object","map","_ref","key","variantKey","undefined","flat","filter","Boolean","parsedStyles","fromEntries","_ref2","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,SAAS,EAAEC,KAAK,EAAEC,KAAK,QAAQ,UAAU;AAClD,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAO,MAAMC,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;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIf,KAAK,EAAE;IACP,OAAO,UAAU,IAAIe,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOjB,SAAS,IAAI,gBAAgB,IAAIgB,KAAK,IAAI,OAAOA,KAAK,CAACE,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAED,OAAO,MAAMJ,UAAU,GAAGA,CACtBK,KAA2B,EAC3Bb,UAA+C,EAC/CC,UAAsB,EACtBC,OAAgB,KACZ;EACJ,MAAMY,OAAO,GAAIC,MAAM,CAClBD,OAAO,CAACD,KAAK,IAAI,CAAC,CAAC,CAAC,CACpBG,GAAG,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACC,GAAG,EAAER,KAA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,OAAO,CACHQ,GAAG,EACH1B,qBAAqB,CAACkB,KAAoB,CAAC,CAC9C;EACL,CAAC,CACL,CAAC;EAEL,OAAOd,KAAK,GACNH,eAAe,CAAC+B,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC"}
@@ -0,0 +1,10 @@
1
+ export const getKeyForVariant = (value, variant) => {
2
+ if (variant && variant in value) {
3
+ return variant;
4
+ }
5
+ if ('default' in value) {
6
+ return 'default';
7
+ }
8
+ return undefined;
9
+ };
10
+ //# sourceMappingURL=variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getKeyForVariant","value","variant","undefined"],"sourceRoot":"../../../src","sources":["utils/variants.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAGA,CAACC,KAAkB,EAAEC,OAAgB,KAAuB;EACxF,IAAIA,OAAO,IAAIA,OAAO,IAAID,KAAK,EAAE;IAC7B,OAAOC,OAAO;EAClB;EAEA,IAAI,SAAS,IAAID,KAAK,EAAE;IACpB,OAAO,SAAS;EACpB;EAEA,OAAOE,SAAS;AACpB,CAAC"}
@@ -0,0 +1,17 @@
1
+ export declare enum CxxUnistylesEventTypes {
2
+ Theme = "theme",
3
+ Layout = "layout"
4
+ }
5
+ export declare enum UnistylesError {
6
+ RuntimeUnavailable = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE",
7
+ ThemeNotFound = "UNISTYLES_ERROR_THEME_NOT_FOUND",
8
+ ThemeNotRegistered = "UNISTYLES_ERROR_THEME_NOT_REGISTERED",
9
+ ThemesCannotBeEmpty = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY",
10
+ BreakpointsCannotBeEmpty = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY",
11
+ BreakpointsMustStartFromZero = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO"
12
+ }
13
+ export declare enum ScreenOrientation {
14
+ Portrait = 1,
15
+ Landscape = 2
16
+ }
17
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAAA,oBAAY,sBAAsB;IAC9B,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,wCAAwC;IAC1D,aAAa,oCAAoC;IACjD,kBAAkB,yCAAyC;IAC3D,mBAAmB,2CAA2C;IAC9D,wBAAwB,gDAAgD;IACxE,4BAA4B,qDAAqD;CACpF;AAGD,oBAAY,iBAAiB;IACzB,QAAQ,IAAI;IACZ,SAAS,IAAI;CAChB"}
@@ -0,0 +1,15 @@
1
+ import type { UnistylesBridge, UnistylesConfig } from '../types';
2
+ import type { UnistylesBreakpoints, UnistylesThemes } from '../global';
3
+ export declare class UnistyleRegistry {
4
+ private unistylesBridge;
5
+ config: UnistylesConfig;
6
+ themeNames: Array<keyof UnistylesThemes>;
7
+ themes: UnistylesThemes;
8
+ breakpoints: UnistylesBreakpoints;
9
+ sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
10
+ constructor(unistylesBridge: UnistylesBridge);
11
+ addThemes: (themes: UnistylesThemes) => this;
12
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => this;
13
+ addConfig: (config: UnistylesConfig) => this;
14
+ }
15
+ //# sourceMappingURL=UnistyleRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEtE,qBAAa,gBAAgB;IAOb,OAAO,CAAC,eAAe;IAN5B,MAAM,EAAE,eAAe,CAAK;IAC5B,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe,UAS1C;IAEM,cAAc,gBAAiB,oBAAoB,UAMzD;IAEM,SAAS,WAAY,eAAe,UAQ1C;CACJ"}
@@ -0,0 +1,13 @@
1
+ import { UnistylesRuntime } from './UnistylesRuntime';
2
+ import { UnistyleRegistry } from './UnistyleRegistry';
3
+ declare class Unistyles {
4
+ private _runtime;
5
+ private _registry;
6
+ private _bridge;
7
+ constructor();
8
+ get registry(): UnistyleRegistry;
9
+ get runtime(): UnistylesRuntime;
10
+ }
11
+ export declare const unistyles: Unistyles;
12
+ export {};
13
+ //# sourceMappingURL=Unistyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Unistyles.d.ts","sourceRoot":"","sources":["../../../../src/core/Unistyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIrD,cAAM,SAAS;IACX,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,OAAO,CAAiB;;IAehC,IAAW,QAAQ,qBAElB;IAED,IAAW,OAAO,qBAEjB;CACJ;AAED,eAAO,MAAM,SAAS,WAAkB,CAAA"}
@@ -0,0 +1,6 @@
1
+ type UnistylesNativeModule = {
2
+ install(): boolean;
3
+ };
4
+ export declare const UnistylesModule: UnistylesNativeModule;
5
+ export {};
6
+ //# sourceMappingURL=UnistylesModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG;IACzB,OAAO,IAAI,OAAO,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,uBAAoD,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { ScreenOrientation } from '../common';
2
+ import type { UnistylesBridge } from '../types';
3
+ import type { UnistylesThemes } from '../global';
4
+ import type { UnistyleRegistry } from './UnistyleRegistry';
5
+ export declare class UnistylesRuntime {
6
+ private unistylesBridge;
7
+ private registry;
8
+ constructor(unistylesBridge: UnistylesBridge, registry: UnistyleRegistry);
9
+ get colorScheme(): import("../types").ColorSchemeName;
10
+ get hasAdaptiveThemes(): boolean;
11
+ get sortedBreakpoints(): [keyof import("../global").UnistylesBreakpoints, number | undefined][];
12
+ get themeName(): never;
13
+ get breakpoint(): keyof import("../global").UnistylesBreakpoints;
14
+ get screen(): {
15
+ width: number;
16
+ height: number;
17
+ };
18
+ get orientation(): ScreenOrientation;
19
+ setTheme: (name: keyof UnistylesThemes) => boolean;
20
+ getTheme: (forName: keyof UnistylesThemes) => never;
21
+ setAdaptiveThemes: (enable: boolean) => void;
22
+ private hasTheme;
23
+ }
24
+ //# sourceMappingURL=UnistylesRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,WAAW,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,QAAQ;gBAAlD,eAAe,EAAE,eAAe,EAAU,QAAQ,EAAE,gBAAgB;IAExF,IAAW,WAAW,uCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,iBAAiB,2EAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,mDAEpB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,sBAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,aAQ7C;IAEM,QAAQ,YAAa,MAAM,eAAe,WAUhD;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAED,OAAO,CAAC,QAAQ,CAAgE;CACnF"}
@@ -0,0 +1,2 @@
1
+ export { unistyles } from './Unistyles';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { CustomNamedStyles, UnistylesTheme } from './types';
2
+ export declare const createStyleSheet: <S, X>(styles: S | X | CustomNamedStyles<S> | ((theme: UnistylesTheme) => X | CustomNamedStyles<X>)) => S | X;
3
+ //# sourceMappingURL=createStyleSheet.d.ts.map