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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. package/README.md +4 -4
  2. package/cxx/UnistylesRuntime.cpp +255 -0
  3. package/cxx/UnistylesRuntime.h +60 -0
  4. package/ios/UnistylesHelpers.h +4 -0
  5. package/ios/UnistylesHelpers.mm +20 -0
  6. package/ios/UnistylesModule.h +10 -0
  7. package/ios/UnistylesModule.mm +158 -0
  8. package/lib/commonjs/common.js +26 -0
  9. package/lib/commonjs/common.js.map +1 -0
  10. package/lib/commonjs/core/UnistyleRegistry.js +38 -0
  11. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
  12. package/lib/commonjs/core/Unistyles.js +31 -0
  13. package/lib/commonjs/core/Unistyles.js.map +1 -0
  14. package/lib/commonjs/core/UnistylesModule.js +9 -0
  15. package/lib/commonjs/core/UnistylesModule.js.map +1 -0
  16. package/lib/commonjs/core/UnistylesRuntime.js +66 -0
  17. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
  18. package/lib/commonjs/core/index.js +13 -0
  19. package/lib/commonjs/core/index.js.map +1 -0
  20. package/lib/commonjs/createStyleSheet.js +14 -0
  21. package/lib/commonjs/createStyleSheet.js.map +1 -0
  22. package/lib/commonjs/global.js +2 -0
  23. package/lib/commonjs/global.js.map +1 -0
  24. package/lib/commonjs/hooks/index.js +10 -3
  25. package/lib/commonjs/hooks/index.js.map +1 -1
  26. package/lib/commonjs/hooks/useInitialTheme.js +17 -0
  27. package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
  28. package/lib/commonjs/hooks/useUnistyles.js +54 -0
  29. package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
  30. package/lib/commonjs/index.js +35 -6
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/types/common.js +2 -0
  33. package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
  34. package/lib/commonjs/types/index.js +26 -0
  35. package/lib/commonjs/types/index.js.map +1 -1
  36. package/lib/commonjs/types/mq.js +6 -0
  37. package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
  38. package/lib/commonjs/types/normalizer.js +6 -0
  39. package/lib/commonjs/types/normalizer.js.map +1 -0
  40. package/lib/commonjs/types/unistyles.js +6 -0
  41. package/lib/commonjs/types/unistyles.js.map +1 -0
  42. package/lib/commonjs/useStyles.js +49 -0
  43. package/lib/commonjs/useStyles.js.map +1 -0
  44. package/lib/commonjs/utils/breakpoints.js +44 -82
  45. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  46. package/lib/commonjs/utils/common.js +10 -3
  47. package/lib/commonjs/utils/common.js.map +1 -1
  48. package/lib/commonjs/utils/index.js +46 -17
  49. package/lib/commonjs/utils/index.js.map +1 -1
  50. package/lib/commonjs/utils/module.d.js +2 -0
  51. package/lib/commonjs/utils/module.d.js.map +1 -0
  52. package/lib/commonjs/utils/mq.js +89 -0
  53. package/lib/commonjs/utils/mq.js.map +1 -0
  54. package/lib/commonjs/utils/mqParser.js +86 -0
  55. package/lib/commonjs/utils/mqParser.js.map +1 -0
  56. package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
  57. package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
  58. package/lib/commonjs/utils/normalizer.js +89 -0
  59. package/lib/commonjs/utils/normalizer.js.map +1 -0
  60. package/lib/commonjs/utils/styles.js +17 -57
  61. package/lib/commonjs/utils/styles.js.map +1 -1
  62. package/lib/commonjs/utils/variants.js +20 -0
  63. package/lib/commonjs/utils/variants.js.map +1 -0
  64. package/lib/module/common.js +22 -0
  65. package/lib/module/common.js.map +1 -0
  66. package/lib/module/core/UnistyleRegistry.js +31 -0
  67. package/lib/module/core/UnistyleRegistry.js.map +1 -0
  68. package/lib/module/core/Unistyles.js +25 -0
  69. package/lib/module/core/Unistyles.js.map +1 -0
  70. package/lib/module/core/UnistylesModule.js +3 -0
  71. package/lib/module/core/UnistylesModule.js.map +1 -0
  72. package/lib/module/core/UnistylesRuntime.js +59 -0
  73. package/lib/module/core/UnistylesRuntime.js.map +1 -0
  74. package/lib/module/core/index.js +2 -0
  75. package/lib/module/core/index.js.map +1 -0
  76. package/lib/module/createStyleSheet.js +7 -0
  77. package/lib/module/createStyleSheet.js.map +1 -0
  78. package/lib/module/global.js +2 -0
  79. package/lib/module/global.js.map +1 -0
  80. package/lib/module/hooks/index.js +2 -1
  81. package/lib/module/hooks/index.js.map +1 -1
  82. package/lib/module/hooks/useInitialTheme.js +10 -0
  83. package/lib/module/hooks/useInitialTheme.js.map +1 -0
  84. package/lib/module/hooks/useUnistyles.js +47 -0
  85. package/lib/module/hooks/useUnistyles.js.map +1 -0
  86. package/lib/module/index.js +13 -2
  87. package/lib/module/index.js.map +1 -1
  88. package/lib/module/types/common.js +2 -0
  89. package/lib/module/types/common.js.map +1 -0
  90. package/lib/module/types/index.js +2 -1
  91. package/lib/module/types/index.js.map +1 -1
  92. package/lib/module/types/mq.js +2 -0
  93. package/lib/module/types/mq.js.map +1 -0
  94. package/lib/module/types/normalizer.js +2 -0
  95. package/lib/module/types/normalizer.js.map +1 -0
  96. package/lib/module/types/unistyles.js +2 -0
  97. package/lib/module/types/unistyles.js.map +1 -0
  98. package/lib/module/useStyles.js +42 -0
  99. package/lib/module/useStyles.js.map +1 -0
  100. package/lib/module/utils/breakpoints.js +43 -82
  101. package/lib/module/utils/breakpoints.js.map +1 -1
  102. package/lib/module/utils/common.js +9 -1
  103. package/lib/module/utils/common.js.map +1 -1
  104. package/lib/module/utils/index.js +6 -2
  105. package/lib/module/utils/index.js.map +1 -1
  106. package/lib/module/utils/module.d.js +2 -0
  107. package/lib/module/utils/module.d.js.map +1 -0
  108. package/lib/module/utils/mq.js +83 -0
  109. package/lib/module/utils/mq.js.map +1 -0
  110. package/lib/module/utils/mqParser.js +79 -0
  111. package/lib/module/utils/mqParser.js.map +1 -0
  112. package/lib/module/utils/normalizeStyles.web.js +13 -13
  113. package/lib/module/utils/normalizeStyles.web.js.map +1 -1
  114. package/lib/module/utils/normalizer.js +79 -0
  115. package/lib/module/utils/normalizer.js.map +1 -0
  116. package/lib/module/utils/styles.js +17 -59
  117. package/lib/module/utils/styles.js.map +1 -1
  118. package/lib/module/utils/variants.js +13 -0
  119. package/lib/module/utils/variants.js.map +1 -0
  120. package/lib/typescript/src/common.d.ts +17 -0
  121. package/lib/typescript/src/common.d.ts.map +1 -0
  122. package/lib/typescript/src/core/UnistyleRegistry.d.ts +15 -0
  123. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
  124. package/lib/typescript/src/core/Unistyles.d.ts +13 -0
  125. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
  126. package/lib/typescript/src/core/UnistylesModule.d.ts +6 -0
  127. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
  128. package/lib/typescript/src/core/UnistylesRuntime.d.ts +24 -0
  129. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
  130. package/lib/typescript/src/core/index.d.ts +2 -0
  131. package/lib/typescript/src/core/index.d.ts.map +1 -0
  132. package/lib/typescript/src/createStyleSheet.d.ts +3 -0
  133. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  134. package/lib/typescript/src/global.d.ts +7 -0
  135. package/lib/typescript/src/global.d.ts.map +1 -0
  136. package/lib/typescript/src/hooks/index.d.ts +2 -1
  137. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  138. package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
  139. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
  140. package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
  141. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
  142. package/lib/typescript/src/index.d.ts +14 -2
  143. package/lib/typescript/src/index.d.ts.map +1 -1
  144. package/lib/typescript/src/types/breakpoints.d.ts +13 -13
  145. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  146. package/lib/typescript/src/types/common.d.ts +3 -0
  147. package/lib/typescript/src/types/common.d.ts.map +1 -0
  148. package/lib/typescript/src/types/core.d.ts +34 -18
  149. package/lib/typescript/src/types/core.d.ts.map +1 -1
  150. package/lib/typescript/src/types/index.d.ts +6 -2
  151. package/lib/typescript/src/types/index.d.ts.map +1 -1
  152. package/lib/typescript/src/types/mq.d.ts +3 -0
  153. package/lib/typescript/src/types/mq.d.ts.map +1 -0
  154. package/lib/typescript/src/types/normalizer.d.ts +20 -0
  155. package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
  156. package/lib/typescript/src/types/unistyles.d.ts +37 -0
  157. package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
  158. package/lib/typescript/src/useStyles.d.ts +10 -0
  159. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  160. package/lib/typescript/src/utils/breakpoints.d.ts +5 -62
  161. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  162. package/lib/typescript/src/utils/common.d.ts +9 -1
  163. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  164. package/lib/typescript/src/utils/index.d.ts +6 -2
  165. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  166. package/lib/typescript/src/utils/mq.d.ts +21 -0
  167. package/lib/typescript/src/utils/mq.d.ts.map +1 -0
  168. package/lib/typescript/src/utils/mqParser.d.ts +3 -0
  169. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
  170. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
  171. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
  172. package/lib/typescript/src/utils/normalizer.d.ts +11 -0
  173. package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
  174. package/lib/typescript/src/utils/styles.d.ts +5 -49
  175. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  176. package/lib/typescript/src/utils/variants.d.ts +3 -0
  177. package/lib/typescript/src/utils/variants.d.ts.map +1 -0
  178. package/package.json +33 -15
  179. package/react-native-unistyles.podspec +22 -0
  180. package/src/common.ts +19 -0
  181. package/src/core/UnistyleRegistry.ts +41 -0
  182. package/src/core/Unistyles.ts +34 -0
  183. package/src/core/UnistylesModule.ts +7 -0
  184. package/src/core/UnistylesRuntime.ts +73 -0
  185. package/src/core/index.ts +1 -0
  186. package/src/createStyleSheet.ts +9 -0
  187. package/src/global.ts +5 -0
  188. package/src/hooks/index.ts +2 -1
  189. package/src/hooks/useInitialTheme.ts +11 -0
  190. package/src/hooks/useUnistyles.ts +55 -0
  191. package/src/index.ts +30 -2
  192. package/src/types/breakpoints.ts +20 -20
  193. package/src/types/common.ts +2 -0
  194. package/src/types/core.ts +42 -24
  195. package/src/types/index.ts +6 -9
  196. package/src/types/mq.ts +3 -0
  197. package/src/types/normalizer.ts +29 -0
  198. package/src/types/unistyles.ts +45 -0
  199. package/src/useStyles.ts +56 -0
  200. package/src/utils/breakpoints.ts +57 -88
  201. package/src/utils/common.ts +10 -1
  202. package/src/utils/index.ts +6 -9
  203. package/src/utils/module.d.ts +3 -0
  204. package/src/utils/mq.ts +106 -0
  205. package/src/utils/mqParser.ts +99 -0
  206. package/src/utils/normalizeStyles.web.ts +21 -42
  207. package/src/utils/normalizer.ts +99 -0
  208. package/src/utils/styles.ts +29 -68
  209. package/src/utils/variants.ts +17 -0
  210. package/lib/commonjs/UnistylesTheme.js +0 -21
  211. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  212. package/lib/commonjs/createUnistyles.js +0 -57
  213. package/lib/commonjs/createUnistyles.js.map +0 -1
  214. package/lib/commonjs/hooks/useDimensions.js +0 -10
  215. package/lib/commonjs/hooks/useDimensions.js.map +0 -1
  216. package/lib/commonjs/hooks/useDimensions.web.js +0 -31
  217. package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
  218. package/lib/commonjs/types/mediaQueries.js +0 -2
  219. package/lib/commonjs/utils/mediaQueries.js +0 -189
  220. package/lib/commonjs/utils/mediaQueries.js.map +0 -1
  221. package/lib/module/UnistylesTheme.js +0 -12
  222. package/lib/module/UnistylesTheme.js.map +0 -1
  223. package/lib/module/createUnistyles.js +0 -50
  224. package/lib/module/createUnistyles.js.map +0 -1
  225. package/lib/module/hooks/useDimensions.js +0 -3
  226. package/lib/module/hooks/useDimensions.js.map +0 -1
  227. package/lib/module/hooks/useDimensions.web.js +0 -24
  228. package/lib/module/hooks/useDimensions.web.js.map +0 -1
  229. package/lib/module/types/mediaQueries.js +0 -2
  230. package/lib/module/utils/mediaQueries.js +0 -176
  231. package/lib/module/utils/mediaQueries.js.map +0 -1
  232. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  233. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  234. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  235. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  236. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  237. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  238. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  239. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  240. package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
  241. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  242. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
  243. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  244. package/src/UnistylesTheme.tsx +0 -17
  245. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  246. package/src/createUnistyles.ts +0 -70
  247. package/src/hooks/useDimensions.ts +0 -4
  248. package/src/hooks/useDimensions.web.ts +0 -30
  249. package/src/types/mediaQueries.ts +0 -10
  250. package/src/utils/mediaQueries.ts +0 -201
@@ -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","mq"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":"AAEA,SAASA,SAAS,QAAQ,SAAS;AAEnC,OAAO,MAAMC,QAAQ,GAAGC,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,KA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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,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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AAEE;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;IACpDK,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAAC;AACL,CAAC;AAED,MAAMM,mBAAmB,GAAkBZ,MAAS,IAA2B;EAC3E,MAAMa,4BAA4B,GAAG,CACjC,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CACrB;EAED,IAAI,CAACA,4BAA4B,CAACX,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,MAAM,CAAC,EAAE;IAC7DJ,IAAI,CAAE,yEAAwEiB,4BAA4B,CAACT,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAExH,OAAO;MACHU,eAAe,EAAER,SAAS;MAC1BS,gBAAgB,EAAET,SAAS;MAC3BU,gBAAgB,EAAEV;IACtB,CAAC;EACL;EAEA,OAAO;IACHW,UAAU,EAAEpB,YAAY,CAACqB,qBAAqB,CAAClB,MAAM,CAAC;IACtDc,eAAe,EAAER,SAAS;IAC1BS,gBAAgB,EAAET,SAAS;IAC3BU,gBAAgB,EAAEV;EACtB,CAAC;AACL,CAAC;AAED,OAAO,MAAMa,eAAe,GAAkBnB,MAAS,IAAQ;EAC3D,MAAMoB,mBAAmB,GAAI,WAAW,IAAIpB,MAAM,IAAIqB,KAAK,CAACC,OAAO,CAACtB,MAAM,CAACuB,SAAS,CAAC,GAC/E;IAAEA,SAAS,EAAE1B,YAAY,CAAC2B,oBAAoB,CAACxB,MAAM,CAACuB,SAAS;EAAE,CAAC,GAClE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAIzB,MAAM,IACvB,cAAc,IAAIA,MAAM,IACxB,eAAe,IAAIA,MAAM,IACzB,cAAc,IAAIA,MAAM,GACxBD,kBAAkB,CAACC,MAAM,CAAC,GAAG,CAAC,CAAC;EAEnC,MAAM0B,oBAAoB,GACtB,iBAAiB,IAAI1B,MAAM,IAC3B,kBAAkB,IAAIA,MAAM,IAC5B,kBAAkB,IAAIA,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,GAAG,CACjC,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CACrB;EAED,IAAI,CAACA,4BAA4B,CAACX,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC5DH,IAAI,CAAE,yEAAwEgB,4BAA4B,CAACT,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAExH,OAAO;MACHU,eAAe,EAAER,SAAS;MAC1BS,gBAAgB,EAAET,SAAS;MAC3BU,gBAAgB,EAAEV;IACtB,CAAC;EACL;EAEA,OAAO;IACHW,UAAU,EAAEnB,YAAY,CAACoB,qBAAqB,CAAClB,KAAK,CAAC;IACrDc,eAAe,EAAER,SAAS;IAC1BS,gBAAgB,EAAET,SAAS;IAC3BU,gBAAgB,EAAEV;EACtB,CAAC;AACL,CAAC;AAED,OAAO,MAAMa,eAAe,GAAkEnB,KAAQ,IAAQ;EAC1G,MAAMoB,mBAAmB,GAAI,WAAW,IAAIpB,KAAK,IAAIqB,KAAK,CAACC,OAAO,CAACtB,KAAK,CAACuB,SAAS,CAAC,GAC7E;IAAEA,SAAS,EAAEzB,YAAY,CAAC0B,oBAAoB,CAACxB,KAAK,CAACuB,SAAS;EAAE,CAAC,GACjE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAIzB,KAAK,IACtB,cAAc,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM0B,oBAAoB,GACtB,iBAAiB,IAAI1B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3BY,mBAAmB,CAACZ,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGoB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC"}
@@ -0,0 +1,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,CAACH,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACM,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC;IAE/B,OAAQ,QAAOT,CAAE,IAAGC,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YAAY,CAAC;EAClD,MAAMvC,KAAK,GAAGD,cAAc,CAACqC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGlC,KAAM,EAAC;AACrD,CAAC;AAED,MAAMwC,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D3B,GAAG,CAAC4B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOnB,SAAS;EACpB;EAEA,MAAMiB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmBwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDJ,MAAM,CAAC6B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -1,76 +1,34 @@
1
- import { getValueForBreakpoint } from './breakpoints';
1
+ import { getValueForNestedStyle } 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
+ export const proxifyFunction = (fn, breakpoint, screenSize, variant) => new Proxy(fn, {
5
+ apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
28
6
  });
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);
7
+ export const isPlatformColor = value => {
8
+ if (isIOS) {
9
+ return 'semantic' in value && typeof value.semantic === 'object';
10
+ }
11
+ return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
12
+ };
13
+ export const parseStyle = (style, breakpoint, screenSize, variant) => {
14
+ const entries = Object.entries(style || {});
57
15
  const parsedStyles = Object.fromEntries(entries.map(_ref => {
58
16
  let [key, value] = _ref;
59
17
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
60
18
  if (hasNestedProperties) {
61
- return [key, parseStyle(value, breakpoint, screenSize, breakpointPairs)];
19
+ return [key, parseStyle(value, breakpoint, screenSize, variant)];
62
20
  }
63
21
  const isTransform = key === 'transform';
64
22
  if (isTransform && Array.isArray(value)) {
65
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))];
23
+ return [key, value.map(value => parseStyle(value, breakpoint, screenSize, variant))];
66
24
  }
67
25
  const isDynamicFunction = typeof value === 'function';
68
- const isValidStyle = typeof value !== 'object';
26
+ const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
69
27
  if (isDynamicFunction || isValidStyle) {
70
28
  return [key, value];
71
29
  }
72
- return [key, getValueForBreakpoint(value, breakpoint, screenSize, breakpointPairs)];
30
+ return [key, getValueForNestedStyle(value, variant)];
73
31
  }));
74
- return isWeb() ? normalizeStyles(parsedStyles) : parsedStyles;
32
+ return isWeb ? normalizeStyles(parsedStyles) : parsedStyles;
75
33
  };
76
34
  //# 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,qB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O,CAACJ,KAAK,CAAC,EAAE;MACrC,OAAO,CACHD,GAAG,EACHC,KAAK,CAACH,GAAG,CAACG,KAAK,IAAIT,UAAU,CAACS,KAAK,EAAEjB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CAAC,CACjF;IACL;IAEA,MAAMoB,iBAAiB,GAAG,OAAOL,KAAK,KAAK,UAAU;IACrD,MAAMM,YAAY,GAAG,OAAON,KAAK,KAAK,QAAQ;IAE9C,IAAIK,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACP,GAAG,EAAEC,KAAK,CAAC;IACvB;IAEA,OAAO,CACHD,GAAG,EACHrB,qBAAqB,CACjBsB,KAAK,EACLjB,UAAU,EACVC,UAAU,EACVC,eACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAOL,KAAK,CAAC,CAAC,GACRD,eAAe,CAACgB,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC"}
1
+ {"version":3,"names":["getValueForNestedStyle","normalizeStyles","isAndroid","isIOS","isWeb","proxifyFunction","fn","breakpoint","screenSize","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,eAAe;AACtD,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,SAAS,EAAEC,KAAK,EAAEC,KAAK,QAAQ,UAAU;AAElD,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,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IAAID,eAAe,CAACC,KAAK,CAAC;IAExE,IAAIe,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACN,GAAG,EAAEV,KAAK,CAAC;IACvB;IAEA,OAAO,CACHU,GAAG,EACH3B,sBAAsB,CAClBiB,KAAK,EACLR,OACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAOL,KAAK,GACNH,eAAe,CAACsB,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const getKeyForVariant = (value, variant) => {
2
+ if (!value.variants) {
3
+ return undefined;
4
+ }
5
+ if (variant && variant in value.variants) {
6
+ return variant;
7
+ }
8
+ if ('default' in value.variants) {
9
+ return 'default';
10
+ }
11
+ return undefined;
12
+ };
13
+ //# sourceMappingURL=variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getKeyForVariant","value","variant","variants","undefined"],"sourceRoot":"../../../src","sources":["utils/variants.ts"],"mappings":"AAEA,OAAO,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"}
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStyleSheet.d.ts","sourceRoot":"","sources":["../../../src/createStyleSheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEhE,eAAO,MAAM,gBAAgB,yDAA0D,cAAc,wCAMpG,CAAA"}
@@ -0,0 +1,7 @@
1
+ export interface UnistylesThemes {
2
+ }
3
+ export interface UnistylesBreakpoints {
4
+ landscape?: number;
5
+ portrait?: number;
6
+ }
7
+ //# sourceMappingURL=global.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/global.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;CAAG;AACnC,MAAM,WAAW,oBAAoB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -1,2 +1,3 @@
1
- export { useDimensions } from './useDimensions';
1
+ export { useInitialTheme } from './useInitialTheme';
2
+ export { useUnistyles } from './useUnistyles';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}