react-native-unistyles 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (396) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +38 -30
  3. package/lib/commonjs/UnistylesTheme.js +21 -0
  4. package/lib/commonjs/UnistylesTheme.js.map +1 -0
  5. package/lib/commonjs/createUnistyles.js +57 -0
  6. package/lib/commonjs/createUnistyles.js.map +1 -0
  7. package/lib/commonjs/hooks/index.js +3 -24
  8. package/lib/commonjs/hooks/index.js.map +1 -1
  9. package/lib/commonjs/hooks/useDimensions.js +10 -0
  10. package/lib/commonjs/hooks/useDimensions.js.map +1 -0
  11. package/lib/commonjs/hooks/useDimensions.web.js +34 -0
  12. package/lib/commonjs/hooks/useDimensions.web.js.map +1 -0
  13. package/lib/commonjs/index.js +6 -63
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/types/index.js +0 -11
  16. package/lib/commonjs/types/index.js.map +1 -1
  17. package/lib/commonjs/types/mediaQueries.js +2 -0
  18. package/lib/commonjs/types/{unistyles.js.map → mediaQueries.js.map} +1 -1
  19. package/lib/commonjs/utils/breakpoints.js +122 -20
  20. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  21. package/lib/commonjs/utils/common.js +20 -0
  22. package/lib/commonjs/utils/common.js.map +1 -0
  23. package/lib/commonjs/utils/index.js +54 -22
  24. package/lib/commonjs/utils/index.js.map +1 -1
  25. package/lib/commonjs/utils/mediaQueries.js +189 -0
  26. package/lib/commonjs/utils/mediaQueries.js.map +1 -0
  27. package/lib/{module/types/common.js.map → commonjs/utils/module.d.js.map} +1 -1
  28. package/lib/commonjs/utils/normalizeStyles.js +10 -0
  29. package/lib/commonjs/utils/normalizeStyles.js.map +1 -0
  30. package/lib/commonjs/{normalizer/normalizeStyle.js → utils/normalizeStyles.web.js} +5 -5
  31. package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -0
  32. package/lib/commonjs/{normalizer → utils}/normalizer.js +3 -2
  33. package/lib/commonjs/utils/normalizer.js.map +1 -0
  34. package/lib/commonjs/utils/styles.js +72 -45
  35. package/lib/commonjs/utils/styles.js.map +1 -1
  36. package/lib/module/UnistylesTheme.js +12 -0
  37. package/lib/module/UnistylesTheme.js.map +1 -0
  38. package/lib/module/createUnistyles.js +50 -0
  39. package/lib/module/createUnistyles.js.map +1 -0
  40. package/lib/module/hooks/index.js +1 -4
  41. package/lib/module/hooks/index.js.map +1 -1
  42. package/lib/module/hooks/useDimensions.js +3 -0
  43. package/lib/module/hooks/useDimensions.js.map +1 -0
  44. package/lib/module/hooks/useDimensions.web.js +27 -0
  45. package/lib/module/hooks/useDimensions.web.js.map +1 -0
  46. package/lib/module/index.js +2 -30
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/types/index.js +0 -1
  49. package/lib/module/types/index.js.map +1 -1
  50. package/lib/module/types/mediaQueries.js +2 -0
  51. package/lib/{commonjs/types/stylesheet.js.map → module/types/mediaQueries.js.map} +1 -1
  52. package/lib/module/utils/breakpoints.js +120 -19
  53. package/lib/module/utils/breakpoints.js.map +1 -1
  54. package/lib/module/utils/common.js +12 -0
  55. package/lib/module/utils/common.js.map +1 -0
  56. package/lib/module/utils/index.js +6 -6
  57. package/lib/module/utils/index.js.map +1 -1
  58. package/lib/module/utils/mediaQueries.js +176 -0
  59. package/lib/module/utils/mediaQueries.js.map +1 -0
  60. package/lib/{commonjs/types/variants.js.map → module/utils/module.d.js.map} +1 -1
  61. package/lib/module/utils/normalizeStyles.js +3 -0
  62. package/lib/module/utils/normalizeStyles.js.map +1 -0
  63. package/lib/module/{normalizer/normalizeStyle.js → utils/normalizeStyles.web.js} +3 -3
  64. package/lib/module/utils/normalizeStyles.web.js.map +1 -0
  65. package/lib/module/{normalizer → utils}/normalizer.js +3 -2
  66. package/lib/module/utils/normalizer.js.map +1 -0
  67. package/lib/module/utils/styles.js +72 -44
  68. package/lib/module/utils/styles.js.map +1 -1
  69. package/lib/typescript/examples/expo/src/App.d.ts +3 -0
  70. package/lib/typescript/examples/expo/src/App.d.ts.map +1 -0
  71. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +3 -0
  72. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +1 -0
  73. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +3 -0
  74. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +1 -0
  75. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +7 -0
  76. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +1 -0
  77. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +3 -0
  78. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +1 -0
  79. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +3 -0
  80. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +1 -0
  81. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +3 -0
  82. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +1 -0
  83. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +3 -0
  84. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +1 -0
  85. package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts +3 -0
  86. package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts.map +1 -0
  87. package/lib/typescript/examples/expo/src/examples/Theme.d.ts +3 -0
  88. package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +1 -0
  89. package/lib/typescript/examples/expo/src/examples/index.d.ts +9 -0
  90. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -0
  91. package/lib/typescript/examples/expo/src/index.d.ts +2 -0
  92. package/lib/typescript/examples/expo/src/index.d.ts.map +1 -0
  93. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +8 -0
  94. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +1 -0
  95. package/lib/typescript/examples/expo/src/styles/index.d.ts +46 -0
  96. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -0
  97. package/lib/typescript/examples/expo/src/styles/theme.d.ts +24 -0
  98. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -0
  99. package/lib/typescript/src/UnistylesTheme.d.ts +9 -0
  100. package/lib/typescript/src/UnistylesTheme.d.ts.map +1 -0
  101. package/lib/typescript/src/createUnistyles.d.ts +10 -0
  102. package/lib/typescript/src/createUnistyles.d.ts.map +1 -0
  103. package/lib/typescript/src/hooks/index.d.ts +1 -4
  104. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  105. package/lib/typescript/src/hooks/useDimensions.d.ts +3 -0
  106. package/lib/typescript/src/hooks/useDimensions.d.ts.map +1 -0
  107. package/lib/typescript/src/hooks/useDimensions.web.d.ts +3 -0
  108. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -0
  109. package/lib/typescript/src/index.d.ts +2 -76
  110. package/lib/typescript/src/index.d.ts.map +1 -1
  111. package/lib/typescript/src/types/breakpoints.d.ts +17 -25
  112. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  113. package/lib/typescript/src/types/core.d.ts +25 -11
  114. package/lib/typescript/src/types/core.d.ts.map +1 -1
  115. package/lib/typescript/src/types/index.d.ts +2 -7
  116. package/lib/typescript/src/types/index.d.ts.map +1 -1
  117. package/lib/typescript/src/types/mediaQueries.d.ts +8 -0
  118. package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -0
  119. package/lib/typescript/src/utils/breakpoints.d.ts +62 -2
  120. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  121. package/lib/typescript/src/utils/common.d.ts +7 -0
  122. package/lib/typescript/src/utils/common.d.ts.map +1 -0
  123. package/lib/typescript/src/utils/index.d.ts +6 -7
  124. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  125. package/lib/typescript/src/utils/mediaQueries.d.ts +130 -0
  126. package/lib/typescript/src/utils/mediaQueries.d.ts.map +1 -0
  127. package/lib/typescript/src/utils/normalizeStyles.d.ts +2 -0
  128. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +1 -0
  129. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +5 -0
  130. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -0
  131. package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
  132. package/lib/typescript/src/utils/styles.d.ts +49 -3
  133. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  134. package/package.json +25 -46
  135. package/src/UnistylesTheme.tsx +17 -0
  136. package/src/__tests__/createUnistyles.spec.tsx +192 -0
  137. package/src/createUnistyles.ts +70 -0
  138. package/src/hooks/index.ts +1 -4
  139. package/src/hooks/useDimensions.ts +4 -0
  140. package/src/hooks/useDimensions.web.ts +34 -0
  141. package/src/index.ts +2 -50
  142. package/src/types/breakpoints.ts +33 -58
  143. package/src/types/core.ts +36 -11
  144. package/src/types/index.ts +7 -12
  145. package/src/types/mediaQueries.ts +10 -0
  146. package/src/utils/breakpoints.ts +124 -28
  147. package/src/utils/common.ts +14 -0
  148. package/src/utils/index.ts +13 -7
  149. package/src/utils/mediaQueries.ts +201 -0
  150. package/src/utils/normalizeStyles.ts +2 -0
  151. package/src/{normalizer/normalizeStyle.ts → utils/normalizeStyles.web.ts} +3 -3
  152. package/src/{normalizer → utils}/normalizer.ts +4 -5
  153. package/src/utils/styles.ts +102 -54
  154. package/android/CMakeLists.txt +0 -27
  155. package/android/build.gradle +0 -75
  156. package/android/src/main/cxx/cpp-adapter.cpp +0 -132
  157. package/android/src/main/java/com/unistyles/UnistylesModule.kt +0 -189
  158. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +0 -18
  159. package/cxx/UnistylesRuntime.cpp +0 -318
  160. package/cxx/UnistylesRuntime.h +0 -74
  161. package/ios/UnistylesHelpers.h +0 -3
  162. package/ios/UnistylesHelpers.mm +0 -5
  163. package/ios/UnistylesModule.h +0 -16
  164. package/ios/UnistylesModule.mm +0 -138
  165. package/ios/platform/Platform_iOS.h +0 -21
  166. package/ios/platform/Platform_iOS.mm +0 -132
  167. package/ios/platform/Platform_macOS.h +0 -20
  168. package/ios/platform/Platform_macOS.mm +0 -83
  169. package/lib/commonjs/common.js +0 -60
  170. package/lib/commonjs/common.js.map +0 -1
  171. package/lib/commonjs/core/UnistyleRegistry.js +0 -94
  172. package/lib/commonjs/core/UnistyleRegistry.js.map +0 -1
  173. package/lib/commonjs/core/Unistyles.js +0 -32
  174. package/lib/commonjs/core/Unistyles.js.map +0 -1
  175. package/lib/commonjs/core/UnistylesModule.js +0 -197
  176. package/lib/commonjs/core/UnistylesModule.js.map +0 -1
  177. package/lib/commonjs/core/UnistylesModule.native.js +0 -9
  178. package/lib/commonjs/core/UnistylesModule.native.js.map +0 -1
  179. package/lib/commonjs/core/UnistylesRuntime.js +0 -140
  180. package/lib/commonjs/core/UnistylesRuntime.js.map +0 -1
  181. package/lib/commonjs/core/index.js +0 -13
  182. package/lib/commonjs/core/index.js.map +0 -1
  183. package/lib/commonjs/createStyleSheet.js +0 -14
  184. package/lib/commonjs/createStyleSheet.js.map +0 -1
  185. package/lib/commonjs/global.js +0 -2
  186. package/lib/commonjs/global.js.map +0 -1
  187. package/lib/commonjs/hooks/useCSS.js +0 -44
  188. package/lib/commonjs/hooks/useCSS.js.map +0 -1
  189. package/lib/commonjs/hooks/useCSS.native.js +0 -9
  190. package/lib/commonjs/hooks/useCSS.native.js.map +0 -1
  191. package/lib/commonjs/hooks/useInitialTheme.js +0 -17
  192. package/lib/commonjs/hooks/useInitialTheme.js.map +0 -1
  193. package/lib/commonjs/hooks/useUnistyles.js +0 -64
  194. package/lib/commonjs/hooks/useUnistyles.js.map +0 -1
  195. package/lib/commonjs/hooks/useVariants.js +0 -14
  196. package/lib/commonjs/hooks/useVariants.js.map +0 -1
  197. package/lib/commonjs/normalizer/index.js +0 -32
  198. package/lib/commonjs/normalizer/index.js.map +0 -1
  199. package/lib/commonjs/normalizer/module.d.js.map +0 -1
  200. package/lib/commonjs/normalizer/normalizeStyle.js.map +0 -1
  201. package/lib/commonjs/normalizer/normalizer.js.map +0 -1
  202. package/lib/commonjs/normalizer/normalizer.macos.js +0 -3
  203. package/lib/commonjs/normalizer/normalizer.macos.js.map +0 -1
  204. package/lib/commonjs/plugins/cssMediaQueriesPlugin.js +0 -14
  205. package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +0 -1
  206. package/lib/commonjs/plugins/index.js +0 -20
  207. package/lib/commonjs/plugins/index.js.map +0 -1
  208. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +0 -12
  209. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +0 -1
  210. package/lib/commonjs/types/common.js +0 -2
  211. package/lib/commonjs/types/common.js.map +0 -1
  212. package/lib/commonjs/types/plugin.js +0 -6
  213. package/lib/commonjs/types/plugin.js.map +0 -1
  214. package/lib/commonjs/types/stylesheet.js +0 -6
  215. package/lib/commonjs/types/unistyles.js +0 -6
  216. package/lib/commonjs/types/variants.js +0 -2
  217. package/lib/commonjs/useStyles.js +0 -47
  218. package/lib/commonjs/useStyles.js.map +0 -1
  219. package/lib/commonjs/utils/cssMediaQuery.js +0 -244
  220. package/lib/commonjs/utils/cssMediaQuery.js.map +0 -1
  221. package/lib/commonjs/utils/generateId.js +0 -15
  222. package/lib/commonjs/utils/generateId.js.map +0 -1
  223. package/lib/commonjs/utils/hash32.js +0 -43
  224. package/lib/commonjs/utils/hash32.js.map +0 -1
  225. package/lib/commonjs/utils/mq.js +0 -38
  226. package/lib/commonjs/utils/mq.js.map +0 -1
  227. package/lib/commonjs/utils/mqParser.js +0 -89
  228. package/lib/commonjs/utils/mqParser.js.map +0 -1
  229. package/lib/commonjs/utils/withPlugins.js +0 -15
  230. package/lib/commonjs/utils/withPlugins.js.map +0 -1
  231. package/lib/module/common.js +0 -53
  232. package/lib/module/common.js.map +0 -1
  233. package/lib/module/core/UnistyleRegistry.js +0 -87
  234. package/lib/module/core/UnistyleRegistry.js.map +0 -1
  235. package/lib/module/core/Unistyles.js +0 -26
  236. package/lib/module/core/Unistyles.js.map +0 -1
  237. package/lib/module/core/UnistylesModule.js +0 -190
  238. package/lib/module/core/UnistylesModule.js.map +0 -1
  239. package/lib/module/core/UnistylesModule.native.js +0 -3
  240. package/lib/module/core/UnistylesModule.native.js.map +0 -1
  241. package/lib/module/core/UnistylesRuntime.js +0 -133
  242. package/lib/module/core/UnistylesRuntime.js.map +0 -1
  243. package/lib/module/core/index.js +0 -2
  244. package/lib/module/core/index.js.map +0 -1
  245. package/lib/module/createStyleSheet.js +0 -7
  246. package/lib/module/createStyleSheet.js.map +0 -1
  247. package/lib/module/global.js +0 -2
  248. package/lib/module/global.js.map +0 -1
  249. package/lib/module/hooks/useCSS.js +0 -37
  250. package/lib/module/hooks/useCSS.js.map +0 -1
  251. package/lib/module/hooks/useCSS.native.js +0 -2
  252. package/lib/module/hooks/useCSS.native.js.map +0 -1
  253. package/lib/module/hooks/useInitialTheme.js +0 -10
  254. package/lib/module/hooks/useInitialTheme.js.map +0 -1
  255. package/lib/module/hooks/useUnistyles.js +0 -57
  256. package/lib/module/hooks/useUnistyles.js.map +0 -1
  257. package/lib/module/hooks/useVariants.js +0 -7
  258. package/lib/module/hooks/useVariants.js.map +0 -1
  259. package/lib/module/normalizer/index.js +0 -3
  260. package/lib/module/normalizer/index.js.map +0 -1
  261. package/lib/module/normalizer/module.d.js.map +0 -1
  262. package/lib/module/normalizer/normalizeStyle.js.map +0 -1
  263. package/lib/module/normalizer/normalizer.js.map +0 -1
  264. package/lib/module/normalizer/normalizer.macos.js +0 -2
  265. package/lib/module/normalizer/normalizer.macos.js.map +0 -1
  266. package/lib/module/plugins/cssMediaQueriesPlugin.js +0 -7
  267. package/lib/module/plugins/cssMediaQueriesPlugin.js.map +0 -1
  268. package/lib/module/plugins/index.js +0 -3
  269. package/lib/module/plugins/index.js.map +0 -1
  270. package/lib/module/plugins/normalizeWebStylesPlugin.js +0 -6
  271. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +0 -1
  272. package/lib/module/types/common.js +0 -2
  273. package/lib/module/types/plugin.js +0 -2
  274. package/lib/module/types/plugin.js.map +0 -1
  275. package/lib/module/types/stylesheet.js +0 -2
  276. package/lib/module/types/stylesheet.js.map +0 -1
  277. package/lib/module/types/unistyles.js +0 -2
  278. package/lib/module/types/unistyles.js.map +0 -1
  279. package/lib/module/types/variants.js +0 -2
  280. package/lib/module/types/variants.js.map +0 -1
  281. package/lib/module/useStyles.js +0 -40
  282. package/lib/module/useStyles.js.map +0 -1
  283. package/lib/module/utils/cssMediaQuery.js +0 -237
  284. package/lib/module/utils/cssMediaQuery.js.map +0 -1
  285. package/lib/module/utils/generateId.js +0 -7
  286. package/lib/module/utils/generateId.js.map +0 -1
  287. package/lib/module/utils/hash32.js +0 -36
  288. package/lib/module/utils/hash32.js.map +0 -1
  289. package/lib/module/utils/mq.js +0 -32
  290. package/lib/module/utils/mq.js.map +0 -1
  291. package/lib/module/utils/mqParser.js +0 -78
  292. package/lib/module/utils/mqParser.js.map +0 -1
  293. package/lib/module/utils/withPlugins.js +0 -8
  294. package/lib/module/utils/withPlugins.js.map +0 -1
  295. package/lib/typescript/src/common.d.ts +0 -46
  296. package/lib/typescript/src/common.d.ts.map +0 -1
  297. package/lib/typescript/src/core/UnistyleRegistry.d.ts +0 -56
  298. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +0 -1
  299. package/lib/typescript/src/core/Unistyles.d.ts +0 -13
  300. package/lib/typescript/src/core/Unistyles.d.ts.map +0 -1
  301. package/lib/typescript/src/core/UnistylesModule.d.ts +0 -19
  302. package/lib/typescript/src/core/UnistylesModule.d.ts.map +0 -1
  303. package/lib/typescript/src/core/UnistylesModule.native.d.ts +0 -6
  304. package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +0 -1
  305. package/lib/typescript/src/core/UnistylesRuntime.d.ts +0 -81
  306. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +0 -1
  307. package/lib/typescript/src/core/index.d.ts +0 -3
  308. package/lib/typescript/src/core/index.d.ts.map +0 -1
  309. package/lib/typescript/src/createStyleSheet.d.ts +0 -8
  310. package/lib/typescript/src/createStyleSheet.d.ts.map +0 -1
  311. package/lib/typescript/src/global.d.ts +0 -7
  312. package/lib/typescript/src/global.d.ts.map +0 -1
  313. package/lib/typescript/src/hooks/useCSS.d.ts +0 -3
  314. package/lib/typescript/src/hooks/useCSS.d.ts.map +0 -1
  315. package/lib/typescript/src/hooks/useCSS.native.d.ts +0 -3
  316. package/lib/typescript/src/hooks/useCSS.native.d.ts.map +0 -1
  317. package/lib/typescript/src/hooks/useInitialTheme.d.ts +0 -3
  318. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +0 -1
  319. package/lib/typescript/src/hooks/useUnistyles.d.ts +0 -14
  320. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +0 -1
  321. package/lib/typescript/src/hooks/useVariants.d.ts +0 -3
  322. package/lib/typescript/src/hooks/useVariants.d.ts.map +0 -1
  323. package/lib/typescript/src/normalizer/index.d.ts +0 -3
  324. package/lib/typescript/src/normalizer/index.d.ts.map +0 -1
  325. package/lib/typescript/src/normalizer/normalizeStyle.d.ts +0 -3
  326. package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +0 -1
  327. package/lib/typescript/src/normalizer/normalizer.d.ts.map +0 -1
  328. package/lib/typescript/src/normalizer/normalizer.macos.d.ts +0 -1
  329. package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +0 -1
  330. package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts +0 -3
  331. package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts.map +0 -1
  332. package/lib/typescript/src/plugins/index.d.ts +0 -3
  333. package/lib/typescript/src/plugins/index.d.ts.map +0 -1
  334. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +0 -3
  335. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +0 -1
  336. package/lib/typescript/src/types/common.d.ts +0 -3
  337. package/lib/typescript/src/types/common.d.ts.map +0 -1
  338. package/lib/typescript/src/types/plugin.d.ts +0 -7
  339. package/lib/typescript/src/types/plugin.d.ts.map +0 -1
  340. package/lib/typescript/src/types/stylesheet.d.ts +0 -40
  341. package/lib/typescript/src/types/stylesheet.d.ts.map +0 -1
  342. package/lib/typescript/src/types/unistyles.d.ts +0 -53
  343. package/lib/typescript/src/types/unistyles.d.ts.map +0 -1
  344. package/lib/typescript/src/types/variants.d.ts +0 -14
  345. package/lib/typescript/src/types/variants.d.ts.map +0 -1
  346. package/lib/typescript/src/useStyles.d.ts +0 -16
  347. package/lib/typescript/src/useStyles.d.ts.map +0 -1
  348. package/lib/typescript/src/utils/cssMediaQuery.d.ts +0 -4
  349. package/lib/typescript/src/utils/cssMediaQuery.d.ts.map +0 -1
  350. package/lib/typescript/src/utils/generateId.d.ts +0 -2
  351. package/lib/typescript/src/utils/generateId.d.ts.map +0 -1
  352. package/lib/typescript/src/utils/hash32.d.ts +0 -2
  353. package/lib/typescript/src/utils/hash32.d.ts.map +0 -1
  354. package/lib/typescript/src/utils/mq.d.ts +0 -26
  355. package/lib/typescript/src/utils/mq.d.ts.map +0 -1
  356. package/lib/typescript/src/utils/mqParser.d.ts +0 -16
  357. package/lib/typescript/src/utils/mqParser.d.ts.map +0 -1
  358. package/lib/typescript/src/utils/withPlugins.d.ts +0 -3
  359. package/lib/typescript/src/utils/withPlugins.d.ts.map +0 -1
  360. package/react-native-unistyles.podspec +0 -22
  361. package/src/__tests__/mocks.ts +0 -24
  362. package/src/common.ts +0 -55
  363. package/src/core/UnistyleRegistry.ts +0 -108
  364. package/src/core/Unistyles.ts +0 -35
  365. package/src/core/UnistylesModule.native.ts +0 -7
  366. package/src/core/UnistylesModule.ts +0 -230
  367. package/src/core/UnistylesRuntime.ts +0 -135
  368. package/src/core/index.ts +0 -2
  369. package/src/createStyleSheet.ts +0 -8
  370. package/src/global.ts +0 -6
  371. package/src/hooks/useCSS.native.ts +0 -3
  372. package/src/hooks/useCSS.ts +0 -51
  373. package/src/hooks/useInitialTheme.ts +0 -11
  374. package/src/hooks/useUnistyles.ts +0 -64
  375. package/src/hooks/useVariants.ts +0 -10
  376. package/src/normalizer/index.ts +0 -2
  377. package/src/normalizer/normalizer.macos.ts +0 -1
  378. package/src/plugins/cssMediaQueriesPlugin.ts +0 -8
  379. package/src/plugins/index.ts +0 -2
  380. package/src/plugins/normalizeWebStylesPlugin.ts +0 -7
  381. package/src/types/common.ts +0 -2
  382. package/src/types/plugin.ts +0 -7
  383. package/src/types/stylesheet.ts +0 -49
  384. package/src/types/unistyles.ts +0 -63
  385. package/src/types/variants.ts +0 -19
  386. package/src/useStyles.ts +0 -60
  387. package/src/utils/cssMediaQuery.ts +0 -268
  388. package/src/utils/generateId.ts +0 -10
  389. package/src/utils/hash32.ts +0 -53
  390. package/src/utils/mq.ts +0 -57
  391. package/src/utils/mqParser.ts +0 -99
  392. package/src/utils/withPlugins.ts +0 -13
  393. /package/lib/commonjs/{normalizer → utils}/module.d.js +0 -0
  394. /package/lib/module/{normalizer → utils}/module.d.js +0 -0
  395. /package/lib/typescript/src/{normalizer → utils}/normalizer.d.ts +0 -0
  396. /package/src/{normalizer → utils}/module.d.ts +0 -0
@@ -3,16 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "generateReactNativeWebId", {
6
+ var _exportNames = {
7
+ normalizeStyles: true,
8
+ getBreakpointFromScreenWidth: true,
9
+ sortAndValidateBreakpoints: true,
10
+ getValueForBreakpoint: true,
11
+ proxifyFunction: true,
12
+ parseStyle: true,
13
+ isServer: true,
14
+ extractValues: true,
15
+ getKeyForCustomMediaQuery: true,
16
+ isMediaQuery: true,
17
+ isWithinTheHeight: true,
18
+ isWithinTheWidth: true,
19
+ isWithinTheWidthAndHeight: true
20
+ };
21
+ Object.defineProperty(exports, "extractValues", {
7
22
  enumerable: true,
8
23
  get: function () {
9
- return _generateId.generateReactNativeWebId;
24
+ return _mediaQueries.extractValues;
10
25
  }
11
26
  });
12
- Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
27
+ Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
13
28
  enumerable: true,
14
29
  get: function () {
15
- return _mqParser.getKeyForUnistylesMediaQuery;
30
+ return _breakpoints.getBreakpointFromScreenWidth;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, "getKeyForCustomMediaQuery", {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _mediaQueries.getKeyForCustomMediaQuery;
16
37
  }
17
38
  });
18
39
  Object.defineProperty(exports, "getValueForBreakpoint", {
@@ -21,40 +42,40 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
21
42
  return _breakpoints.getValueForBreakpoint;
22
43
  }
23
44
  });
24
- Object.defineProperty(exports, "isPlatformColor", {
45
+ Object.defineProperty(exports, "isMediaQuery", {
25
46
  enumerable: true,
26
47
  get: function () {
27
- return _styles.isPlatformColor;
48
+ return _mediaQueries.isMediaQuery;
28
49
  }
29
50
  });
30
- Object.defineProperty(exports, "isUnistylesMq", {
51
+ Object.defineProperty(exports, "isServer", {
31
52
  enumerable: true,
32
53
  get: function () {
33
- return _mqParser.isUnistylesMq;
54
+ return _common.isServer;
34
55
  }
35
56
  });
36
- Object.defineProperty(exports, "isValidMq", {
57
+ Object.defineProperty(exports, "isWithinTheHeight", {
37
58
  enumerable: true,
38
59
  get: function () {
39
- return _mqParser.isValidMq;
60
+ return _mediaQueries.isWithinTheHeight;
40
61
  }
41
62
  });
42
- Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
63
+ Object.defineProperty(exports, "isWithinTheWidth", {
43
64
  enumerable: true,
44
65
  get: function () {
45
- return _mqParser.isWithinTheWidthAndHeight;
66
+ return _mediaQueries.isWithinTheWidth;
46
67
  }
47
68
  });
48
- Object.defineProperty(exports, "mq", {
69
+ Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
49
70
  enumerable: true,
50
71
  get: function () {
51
- return _mq.mq;
72
+ return _mediaQueries.isWithinTheWidthAndHeight;
52
73
  }
53
74
  });
54
- Object.defineProperty(exports, "parseMq", {
75
+ Object.defineProperty(exports, "normalizeStyles", {
55
76
  enumerable: true,
56
77
  get: function () {
57
- return _mqParser.parseMq;
78
+ return _normalizeStyles.normalizeStyles;
58
79
  }
59
80
  });
60
81
  Object.defineProperty(exports, "parseStyle", {
@@ -69,16 +90,27 @@ Object.defineProperty(exports, "proxifyFunction", {
69
90
  return _styles.proxifyFunction;
70
91
  }
71
92
  });
72
- Object.defineProperty(exports, "withPlugins", {
93
+ Object.defineProperty(exports, "sortAndValidateBreakpoints", {
73
94
  enumerable: true,
74
95
  get: function () {
75
- return _withPlugins.withPlugins;
96
+ return _breakpoints.sortAndValidateBreakpoints;
76
97
  }
77
98
  });
78
- var _mq = require("./mq");
79
- var _mqParser = require("./mqParser");
99
+ var _normalizeStyles = require("./normalizeStyles");
100
+ var _normalizer = require("./normalizer");
101
+ Object.keys(_normalizer).forEach(function (key) {
102
+ if (key === "default" || key === "__esModule") return;
103
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
104
+ if (key in exports && exports[key] === _normalizer[key]) return;
105
+ Object.defineProperty(exports, key, {
106
+ enumerable: true,
107
+ get: function () {
108
+ return _normalizer[key];
109
+ }
110
+ });
111
+ });
80
112
  var _breakpoints = require("./breakpoints");
81
113
  var _styles = require("./styles");
82
- var _withPlugins = require("./withPlugins");
83
- var _generateId = require("./generateId");
114
+ var _common = require("./common");
115
+ var _mediaQueries = require("./mediaQueries");
84
116
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins","_generateId"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA"}
1
+ {"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_breakpoints","_styles","_common","_mediaQueries"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,YAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA"}
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isWithinTheWidthAndHeight = exports.isWithinTheWidth = exports.isWithinTheHeight = exports.isWithinBreakpoint = exports.isMediaQuery = exports.getKeyForCustomMediaQuery = exports.extractValues = void 0;
7
+ /**
8
+ * Extracts numeric values from a coded string.
9
+ *
10
+ * The function is designed to process strings that have a format like "w[100,200]" or "h[300]".
11
+ * It removes characters 'w', 'h', '[', and ']' from the input string and then extracts the numbers.
12
+ *
13
+ * @param {string} codedValue - The input string to extract values from.
14
+ * @returns {Array<number>} An array of extracted numbers. Can contain one or two numbers based on the input format.
15
+ *
16
+ * @example
17
+ * extractValues("w[100,200]") // returns [100, 200]
18
+ * extractValues("h[300]") // returns [300]
19
+ * extractValues("h[,300]") // returns [0,300]
20
+ * extractValues("h[100,]") // returns [100]
21
+ */
22
+ const extractValues = codedValue => {
23
+ const [lh, rh] = codedValue.replace(/[wh[\]]/g, '').split(',');
24
+ return rh ? [Number(lh), Number(rh)] : [Number(lh)];
25
+ };
26
+
27
+ /**
28
+ * Determines if the given screen size matches the specified breakpoint query.
29
+ *
30
+ * The function checks if the screen size (width and/or height) falls within the range
31
+ * specified by the breakpoint query. The query can specify width (using 'w'), height (using 'h'),
32
+ * or both.
33
+ *
34
+ * @param {string} query - The breakpoint query string. Examples: 'w[100,200]', 'h[300]', 'w[100,200]h[300,400]'.
35
+ * @param {ScreenSize} screenSize - The screen size to check against the breakpoint query.
36
+ * @returns {boolean} True if the screen size matches the breakpoint query, false otherwise.
37
+ *
38
+ * @example
39
+ * const screenSize = { width: 150, height: 350 }
40
+ * isWithinBreakpoint('w[100,200]', screenSize) // returns true
41
+ * isWithinBreakpoint('h[400]', screenSize) // returns false
42
+ */
43
+ exports.extractValues = extractValues;
44
+ const isWithinBreakpoint = (query, screenSize) => {
45
+ if (query.includes('w') && query.includes('h')) {
46
+ return isWithinTheWidthAndHeight(query, screenSize);
47
+ }
48
+ if (query.charAt(0) === 'w') {
49
+ return isWithinTheWidth(query, screenSize.width);
50
+ }
51
+ if (query.charAt(0) === 'h') {
52
+ return isWithinTheHeight(query, screenSize.height);
53
+ }
54
+ return false;
55
+ };
56
+
57
+ /**
58
+ * Determines if the given width matches the specified width range in the query.
59
+ *
60
+ * The function checks if the provided width falls within the range specified by the query.
61
+ * The query specifies a width range using a format like 'w[100,200]'. If only one value is provided,
62
+ * it's treated as a minimum width.
63
+ *
64
+ * @param {string} query - The width query string. Examples: 'w[100,200]' or 'w[100]'.
65
+ * @param {number} width - The width to check against the query.
66
+ * @returns {boolean} True if the width matches the query range, false otherwise.
67
+ *
68
+ * @example
69
+ * isWithinTheWidth('w[100,200]', 150) // returns true
70
+ * isWithinTheWidth('w[100]', 50) // returns false
71
+ * isWithinTheWidth('w[100]', 150) // returns true
72
+ */
73
+ exports.isWithinBreakpoint = isWithinBreakpoint;
74
+ const isWithinTheWidth = (query, width) => {
75
+ const [minWidth, maxWidth] = extractValues(query);
76
+ if (maxWidth && width >= minWidth && width <= maxWidth) {
77
+ return true;
78
+ }
79
+ return !maxWidth && width >= minWidth;
80
+ };
81
+
82
+ /**
83
+ * Determines if the given height matches the specified height range in the query.
84
+ *
85
+ * The function checks if the provided height falls within the range specified by the query.
86
+ * The query specifies a height range using a format like 'h[100,200]'. If only one value is provided,
87
+ * it's treated as a minimum height.
88
+ *
89
+ * @param {string} query - The height query string. Examples: 'h[100,200]' or 'h[100]'.
90
+ * @param {number} height - The height to check against the query.
91
+ * @returns {boolean} True if the height matches the query range, false otherwise.
92
+ *
93
+ * @example
94
+ * isWithinTheHeight('h[100,200]', 150) // returns true
95
+ * isWithinTheHeight('h[100]', 50) // returns false
96
+ * isWithinTheHeight('h[100]', 150) // returns true
97
+ */
98
+ exports.isWithinTheWidth = isWithinTheWidth;
99
+ const isWithinTheHeight = (query, height) => {
100
+ const [minHeight, maxHeight] = extractValues(query);
101
+ if (maxHeight && height >= minHeight && height <= maxHeight) {
102
+ return true;
103
+ }
104
+ return !maxHeight && height >= minHeight;
105
+ };
106
+
107
+ /**
108
+ * Determines if the given screen size matches both the specified width and height ranges in the query.
109
+ *
110
+ * The function checks if the provided screen size (both width and height) falls within the ranges
111
+ * specified by the query. The query can specify both width and height using a format like 'w[100,200]:h[300,400]'.
112
+ *
113
+ * @param {string} query - The combined width and height query string. Example: 'w[100,200]:h[300,400]'.
114
+ * @param {ScreenSize} screenSize - The screen size to check against the query.
115
+ * @returns {boolean} True if the screen size matches both the width and height ranges in the query, false otherwise.
116
+ *
117
+ * @example
118
+ * const screenSize = { width: 150, height: 350 }
119
+ * isWithinTheWidthAndHeight('w[100,200]:h[300,400]', screenSize) // returns true
120
+ * isWithinTheWidthAndHeight('w[100,200]:h[400,500]', screenSize) // returns false
121
+ */
122
+ exports.isWithinTheHeight = isWithinTheHeight;
123
+ const isWithinTheWidthAndHeight = (query, screenSize) => {
124
+ const result = query.split(':').filter(Boolean).map(q => isWithinBreakpoint(q, screenSize)).filter(Boolean);
125
+ return result.length === 2;
126
+ };
127
+
128
+ /**
129
+ * Checks if the given query string is a valid custom media query.
130
+ *
131
+ * The valid custom media query formats include:
132
+ * - :w[200]
133
+ * - :w[0, 200]
134
+ * - :w[, 300]
135
+ * - :h[200]
136
+ * - :h[0, 500]
137
+ * - :h[,200]
138
+ * - :w[100, 300]:h[200,500]
139
+ * - :h[200,500]:w[100, 300]
140
+ *
141
+ * @param {string} query - The query string to be checked.
142
+ * @returns {boolean} Returns `true` if the query is a valid custom media query, otherwise `false`.
143
+ * @example
144
+ *
145
+ * isMediaQuery(':w[200]') // true
146
+ * isMediaQuery(':w100]') // false
147
+ */
148
+ exports.isWithinTheWidthAndHeight = isWithinTheWidthAndHeight;
149
+ const isMediaQuery = query => {
150
+ const regex = /^(?:(:w\[\d*(?:,\s?\d+)?])?(:h\[\d*(?:,\s?\d+)?])?|(:h\[\d*(?:,\s?\d+)?])?(:w\[\d*(?:,\s?\d+)?])?)$/;
151
+ return query.length > 0 && regex.test(query);
152
+ };
153
+
154
+ /**
155
+ * Retrieves the first matching custom media query key based on the provided screen size.
156
+ *
157
+ * The function processes an array of media queries and returns the first query that matches
158
+ * the given screen size. The media queries can be in formats like:
159
+ * - w[200]
160
+ * - w[0, 200]
161
+ * - w[, 300]
162
+ * - h[200]
163
+ * - h[0, 500]
164
+ * - h[,200]
165
+ * - w[100, 300]:h[200,500]
166
+ * - h[200,500]:w[100, 300]
167
+ *
168
+ * @param {Array<[string, string | number]>} mediaQueries - An array of tuples containing media query keys and associated values.
169
+ * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
170
+ * @returns {string | undefined} Returns the first matching media query key or `undefined` if no match is found.
171
+ * @example
172
+ *
173
+ * const queries = [[':w[200]', 'value1'], [':h[300,500]', 'value2']]
174
+ * const size = { width: 250, height: 400 }
175
+ * getKeyForCustomMediaQuery(queries, size) // ':w[200]
176
+ */
177
+ exports.isMediaQuery = isMediaQuery;
178
+ const getKeyForCustomMediaQuery = (mediaQueries, screenSize) => {
179
+ const [matchedQuery] = mediaQueries.flatMap(_ref => {
180
+ let [key] = _ref;
181
+ if (key.includes('w') && key.includes('h')) {
182
+ return isWithinBreakpoint(key, screenSize) ? key : undefined;
183
+ }
184
+ return key.split(':').filter(Boolean).map(query => isWithinBreakpoint(query, screenSize) ? key : undefined);
185
+ }).filter(Boolean);
186
+ return matchedQuery;
187
+ };
188
+ exports.getKeyForCustomMediaQuery = getKeyForCustomMediaQuery;
189
+ //# sourceMappingURL=mediaQueries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["extractValues","codedValue","lh","rh","replace","split","Number","exports","isWithinBreakpoint","query","screenSize","includes","isWithinTheWidthAndHeight","charAt","isWithinTheWidth","width","isWithinTheHeight","height","minWidth","maxWidth","minHeight","maxHeight","result","filter","Boolean","map","q","length","isMediaQuery","regex","test","getKeyForCustomMediaQuery","mediaQueries","matchedQuery","flatMap","_ref","key","undefined"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAIC,UAAkB,IAAoB;EAChE,MAAM,CAACC,EAAE,EAAEC,EAAE,CAAC,GAAGF,UAAU,CAC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rB,KAAK,CAAC;AAChD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAtBAF,OAAA,CAAAqB,YAAA,GAAAA,YAAA;AAuBO,MAAMG,yBAAyB,GAAGA,CAACC,YAA0D,EAAEtB,UAAsB,KAAyB;EACjJ,MAAM,CAACuB,YAAY,CAAC,GAAGD,YAAY,CAC9BE,OAAO,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IACX,IAAIC,GAAG,CAACzB,QAAQ,CAAC,GAAG,CAAC,IAAIyB,GAAG,CAACzB,QAAQ,CAAC,GAAG,CAAC,EAAE;MACxC,OAAOH,kBAAkB,CAAC4B,GAAG,EAAE1B,UAAU,CAAC,GAAG0B,GAAG,GAAGC,SAAS;IAChE;IAEA,OAAOD,GAAG,CACL/B,KAAK,CAAC,GAAG,CAAC,CACVkB,MAAM,CAACC,OAAO,CAAC,CACfC,GAAG,CAAChB,KAAK,IAAID,kBAAkB,CAACC,KAAK,EAAEC,UAAU,CAAC,GAAG0B,GAAG,GAAGC,SAAS,CAAC;EAC9E,CAAC,CAAC,CACDd,MAAM,CAACC,OAAO,CAAC;EAEpB,OAAOS,YAAY;AACvB,CAAC;AAAA1B,OAAA,CAAAwB,yBAAA,GAAAA,yBAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/common.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeStyles = void 0;
7
+ // nothing to do here
8
+ const normalizeStyles = styles => styles;
9
+ exports.normalizeStyles = normalizeStyles;
10
+ //# sourceMappingURL=normalizeStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeStyles","styles","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,eAAe,GAAOC,MAAS,IAAKA,MAAW;AAAAC,OAAA,CAAAF,eAAA,GAAAA,eAAA"}
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.normalizeStyle = void 0;
6
+ exports.normalizeStyles = void 0;
7
+ var _common = require("./common");
7
8
  var _normalizer = require("./normalizer");
8
- var _common = require("../common");
9
9
  const normalizeBoxShadow = style => {
10
10
  const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
11
11
  if (!requiredBoxShadowProperties.every(prop => prop in style)) {
@@ -42,7 +42,7 @@ const normalizeTextShadow = style => {
42
42
  textShadowRadius: undefined
43
43
  };
44
44
  };
45
- const normalizeStyle = style => {
45
+ const normalizeStyles = style => {
46
46
  const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
47
47
  transform: _normalizer.preprocessor.createTransformValue(style.transform)
48
48
  } : {};
@@ -55,5 +55,5 @@ const normalizeStyle = style => {
55
55
  ...normalizedTextShadow
56
56
  };
57
57
  };
58
- exports.normalizeStyle = normalizeStyle;
59
- //# sourceMappingURL=normalizeStyle.js.map
58
+ exports.normalizeStyles = normalizeStyles;
59
+ //# sourceMappingURL=normalizeStyles.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_common","require","_normalizer","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","preprocessor","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.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IAC3BW,gBAAgB,EAAEX;EACtB,CAAC;AACL,CAAC;AAEM,MAAMc,eAAe,GAAkErB,KAAQ,IAAQ;EAC1G,MAAMsB,mBAAmB,GAAI,WAAW,IAAItB,KAAK,IAAIuB,KAAK,CAACC,OAAO,CAACxB,KAAK,CAACyB,SAAS,CAAC,GAC7E;IAAEA,SAAS,EAAEb,wBAAY,CAACc,oBAAoB,CAAC1B,KAAK,CAACyB,SAAS;EAAE,CAAC,GACjE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAI3B,KAAK,IACtB,cAAc,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM4B,oBAAoB,GACtB,iBAAiB,IAAI5B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3Bc,mBAAmB,CAACd,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGsB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAR,eAAA,GAAAA,eAAA"}
@@ -9,14 +9,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
9
9
  // based on react-native-web normalizer
10
10
  // https://github.com/necolas/react-native-web
11
11
 
12
- const normalizeColor = (color, opacity = 1) => {
12
+ const normalizeColor = function (color) {
13
+ let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
13
14
  // If the opacity is 1 there's no need to normalize the color
14
15
  if (opacity === 1) {
15
16
  return color;
16
17
  }
17
18
  const integer = (0, _normalizeColors.default)(color);
18
19
 
19
- // If the color is an unknown format, the return value is null
20
+ // If the colour is an unknown format, the return value is null
20
21
  if (integer === null) {
21
22
  return color;
22
23
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","arguments","length","undefined","integer","normalizeColors","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["utils/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC7D;EACA,IAAID,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAMK,OAAO,GAAG,IAAAC,wBAAe,EAACN,KAAK,CAAkB;;EAEvD;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMO,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACJ,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACO,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC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Y;IAAEC,aAAa;IAAEC;EAAa,CAAC,GAAGb,KAAK;EACxE,MAAMI,OAAO,GAAGV,qBAAqB,CAACiB,YAAY,CAACN,KAAK,CAAC;EACzD,MAAMC,OAAO,GAAGZ,qBAAqB,CAACiB,YAAY,CAACJ,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGd,qBAAqB,CAACmB,YAAY,CAAC;EAClD,MAAMzC,KAAK,GAAGD,cAAc,CAACuC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGpC,KAAM,EAAC;AACrD,CAAC;AAED,MAAM0C,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D5B,GAAG,CAAC6B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOrB,SAAS;EACpB;EAEA,MAAMmB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmBwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDL,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA5B,OAAA,CAAA4B,YAAA,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -5,10 +5,31 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
7
7
  var _breakpoints = require("./breakpoints");
8
- var _common = require("../common");
9
- var _withPlugins = require("./withPlugins");
10
- const proxifyFunction = (key, fn, variant) => new Proxy(fn, {
11
- apply: (target, thisArg, argumentsList) => (0, _withPlugins.withPlugins)(key, parseStyle(target.apply(thisArg, argumentsList), variant))
8
+ var _normalizeStyles = require("./normalizeStyles");
9
+ var _common = require("./common");
10
+ /**
11
+ * Proxies a function to parse its return value for custom media queries or breakpoints.
12
+ *
13
+ * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
14
+ *
15
+ * @param {Function} fn - The function to be proxified.
16
+ * @param {keyof B & string} breakpoint - The breakpoint name to check against.
17
+ * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
18
+ * @param breakpointPairs - sorted pairs of breakpoints
19
+ *
20
+ * @returns {Function} Returns the proxified function
21
+ *
22
+ * @example
23
+ *
24
+ * const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
25
+ * const screenSize = { width: 250, height: 400 }
26
+ * const breakpoints = { sm: 300, md: 600 }
27
+ *
28
+ * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
29
+ * proxifiedFunction() // parsed style based on screenSize and breakpoints
30
+ */
31
+ const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Proxy(fn, {
32
+ apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
12
33
  });
13
34
  exports.proxifyFunction = proxifyFunction;
14
35
  const isPlatformColor = value => {
@@ -17,47 +38,53 @@ const isPlatformColor = value => {
17
38
  }
18
39
  return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
19
40
  };
20
- exports.isPlatformColor = isPlatformColor;
21
- const parseStyle = (style, variant = {}, parseMediaQueries = true) => Object.entries(style || {}).reduce((acc, [key, value]) => {
22
- // nested objects
23
- if (key === 'shadowOffset' || key === 'textShadowOffset') {
24
- acc[key] = parseStyle(value, variant);
25
- return acc;
26
- }
27
-
28
- // transforms
29
- if (key === 'transform' && Array.isArray(value)) {
30
- acc[key] = value.map(value => parseStyle(value, variant));
31
- return acc;
32
- }
33
-
34
- // values or platform colors
35
- if (typeof value !== 'object' || isPlatformColor(value)) {
36
- acc[key] = value;
37
- return acc;
38
- }
39
- if (key === 'variants') {
40
- return {
41
- ...acc,
42
- ...Object.keys(value).reduce((acc, key) => ({
43
- ...acc,
44
- // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
45
- ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
46
- }), {})
47
- };
48
- }
49
41
 
50
- // don't parse media queries and breakpoints
51
- if (!parseMediaQueries) {
52
- return {
53
- ...acc,
54
- [key]: value
55
- };
56
- }
57
- return {
58
- ...acc,
59
- [key]: (0, _breakpoints.getValueForBreakpoint)(value)
60
- };
61
- }, {});
42
+ /**
43
+ * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
44
+ *
45
+ * The function processes each key-value pair in the style object. If the value is a function or a valid style (not an object or a 'transform' key),
46
+ * it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
47
+ *
48
+ * @template T - The type of the style object.
49
+ * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
50
+ *
51
+ * @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
52
+ * @param {keyof B & string} breakpoint - The breakpoint name to check against.
53
+ * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
54
+ * @param breakpointPairs - sorted pairs of breakpoints
55
+ *
56
+ * @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
57
+ *
58
+ * @example
59
+ *
60
+ * const style = { fontSize: { sm: '12px', md: '16px' } }
61
+ * const screenSize = { width: 300, height: 400 }
62
+ * const breakpoints = { xs: 0, sm: 300, md: 600 }
63
+ *
64
+ * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
65
+ * // { fontSize: '12px' }
66
+ */
67
+ exports.isPlatformColor = isPlatformColor;
68
+ const parseStyle = (style, breakpoint, screenSize, breakpointPairs) => {
69
+ const entries = Object.entries(style || {});
70
+ const parsedStyles = Object.fromEntries(entries.map(_ref => {
71
+ let [key, value] = _ref;
72
+ const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
73
+ if (hasNestedProperties) {
74
+ return [key, parseStyle(value, breakpoint, screenSize, breakpointPairs)];
75
+ }
76
+ const isTransform = key === 'transform';
77
+ if (isTransform && Array.isArray(value)) {
78
+ return [key, value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))];
79
+ }
80
+ const isDynamicFunction = typeof value === 'function';
81
+ const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
82
+ if (isDynamicFunction || isValidStyle) {
83
+ return [key, value];
84
+ }
85
+ return [key, (0, _breakpoints.getValueForBreakpoint)(value, breakpoint, screenSize, breakpointPairs)];
86
+ }));
87
+ return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
88
+ };
62
89
  exports.parseStyle = parseStyle;
63
90
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAK,IAAAC,wBAAW,EAACR,GAAG,EAAES,UAAU,CAACJ,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AAItB,GAAG,KAAK,UAAU,EAAE;IACpB,OAAO;MACH,GAAGsB,GAAG;MACN,GAAIH,MAAM,CACLO,IAAI,CAACd,KAAK,CAAC,CACXS,MAAM,CAAC,CAACC,GAAG,EAAEtB,GAAG,MAAM;QACnB,GAAGsB,GAAG;QACN;QACA,GAAGb,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAKY,KAAK,CAAEZ,GAAG,CAAC,CAAC2B,OAAO,IAAI,CAAC,CAAC;MAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;EACL;;EAEA;EACA,IAAI,CAACT,iBAAiB,EAAE;IACpB,OAAO;MACH,GAAGI,GAAG;MACN,CAACtB,GAAG,GAAGY;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGU,GAAG;IACN,CAACtB,GAAG,GAAG,IAAA4B,kCAAqB,EAAChB,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForBreakpoint","isWeb","normalizeStyles"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,eAAe,GAAGA,CAC3BC,EAA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C,eAAe,CAAC,CACxF;IACL;IAEA,MAAMuB,WAAW,GAAGF,GAAG,KAAK,WAAW;IAEvC,IAAIE,WAAW,IAAIC,KAAK,CAACC,OAAO,CAAChB,KAAK,CAAC,EAAE;MACrC,OAAO,CACHY,GAAG,EACHZ,KAAK,CAACU,GAAG,CAACV,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEX,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CAAC,CACjF;IACL;IAEA,MAAM0B,iBAAiB,GAAG,OAAOjB,KAAK,KAAK,UAAU;IACrD,MAAMkB,YAAY,GAAG,OAAOlB,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC;IAExE,IAAIiB,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACN,GAAG,EAAEZ,KAAK,CAAC;IACvB;IAEA,OAAO,CACHY,GAAG,EACH,IAAAO,kCAAqB,EACjBnB,KAAK,EACLX,UAAU,EACVC,UAAU,EACVC,eACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAO6B,aAAK,GACN,IAAAC,gCAAe,EAACb,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAV,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
@@ -0,0 +1,12 @@
1
+ import React, { createContext } from 'react';
2
+ export const UnistylesContext = /*#__PURE__*/createContext({});
3
+ export const UnistylesTheme = _ref => {
4
+ let {
5
+ theme,
6
+ children
7
+ } = _ref;
8
+ return /*#__PURE__*/React.createElement(UnistylesContext.Provider, {
9
+ value: theme
10
+ }, children);
11
+ };
12
+ //# sourceMappingURL=UnistylesTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","UnistylesContext","UnistylesTheme","_ref","theme","children","createElement","Provider","value"],"sourceRoot":"../../src","sources":["UnistylesTheme.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,QAAQ,OAAO;AAO5C,OAAO,MAAMC,gBAAgB,gBAAGD,aAAa,CAAC,CAAC,CAAC,CAAC;AAEjD,OAAO,MAAME,cAA4D,GAAGC,IAAA;EAAA,IAAC;IACzEC,KAAK;IACLC;EACJ,CAAC,GAAAF,IAAA;EAAA,oBACGJ,KAAA,CAAAO,aAAA,CAACL,gBAAgB,CAACM,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GACnCC,QACsB,CAAC;AAAA,CAC/B"}
@@ -0,0 +1,50 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import { UnistylesContext } from './UnistylesTheme';
4
+ import { useDimensions } from './hooks';
5
+ import { getBreakpointFromScreenWidth, proxifyFunction, parseStyle, sortAndValidateBreakpoints } from './utils';
6
+ export const createUnistyles = breakpoints => {
7
+ const sortedBreakpoints = sortAndValidateBreakpoints(breakpoints);
8
+ const sortedBreakpointEntries = Object.entries(sortedBreakpoints);
9
+ return {
10
+ createStyleSheet: styles => {
11
+ if (typeof styles === 'function') {
12
+ return styles;
13
+ }
14
+ return styles;
15
+ },
16
+ useStyles: stylesheet => {
17
+ const theme = useContext(UnistylesContext);
18
+ const screenSize = useDimensions();
19
+ const breakpoint = getBreakpointFromScreenWidth(screenSize.width, sortedBreakpointEntries);
20
+ if (!stylesheet) {
21
+ return {
22
+ theme,
23
+ breakpoint,
24
+ styles: {}
25
+ };
26
+ }
27
+ const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
28
+ const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
29
+ let [key, value] = _ref;
30
+ const style = value;
31
+ if (typeof value === 'function') {
32
+ return {
33
+ ...acc,
34
+ [key]: proxifyFunction(value, breakpoint, screenSize, sortedBreakpointEntries)
35
+ };
36
+ }
37
+ return StyleSheet.create({
38
+ ...acc,
39
+ [key]: parseStyle(style, breakpoint, screenSize, sortedBreakpointEntries)
40
+ });
41
+ }, {}), [breakpoint, screenSize, parsedStyles]);
42
+ return {
43
+ theme,
44
+ breakpoint,
45
+ styles: dynamicStyleSheet
46
+ };
47
+ }
48
+ };
49
+ };
50
+ //# sourceMappingURL=createUnistyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useContext","useMemo","StyleSheet","UnistylesContext","useDimensions","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","createUnistyles","breakpoints","sortedBreakpoints","sortedBreakpointEntries","Object","entries","createStyleSheet","styles","useStyles","stylesheet","theme","screenSize","breakpoint","width","parsedStyles","dynamicStyleSheet","reduce","acc","_ref","key","value","style","create"],"sourceRoot":"../../src","sources":["createUnistyles.ts"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,UAAU,QAAQ,cAAc;AASzC,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,4BAA4B,EAAEC,eAAe,EAAEC,UAAU,EAAEC,0BAA0B,QAAQ,SAAS;AAE/G,OAAO,MAAMC,eAAe,GAAmCC,WAAc,IAAK;EAC9E,MAAMC,iBAAiB,GAAGH,0BAA0B,CAACE,WAAW,CAAC;EACjE,MAAME,uBAAuB,GAAGC,MAAM,CACjCC,OAAO,CAACH,iBAAiB,CAA+B;EAE7D,OAAO;IACHI,gBAAgB,EAAyCC,MAAqF,IAAY;MACtJ,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;QAC9B,OAAOA,MAAM;MACjB;MAEA,OAAOA,MAAM;IACjB,CAAC;IACDC,SAAS,EAAwCC,UAA4C,IAAK;MAC9F,MAAMC,KAAK,GAAGnB,UAAU,CAACG,gBAAgB,CAAM;MAC/C,MAAMiB,UAAU,GAAGhB,aAAa,CAAC,CAAC;MAClC,MAAMiB,UAAU,GAAGhB,4BAA4B,CAAIe,UAAU,CAACE,KAAK,EAAEV,uBAAuB,CAAC;MAE7F,IAAI,CAACM,UAAU,EAAE;QACb,OAAO;UACHC,KAA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