react-native-unistyles 3.0.0-alpha.33 → 3.0.0-alpha.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. package/cxx/common/Helpers.h +24 -2
  2. package/cxx/core/HostStyle.cpp +1 -1
  3. package/cxx/core/UnistyleWrapper.h +31 -1
  4. package/cxx/core/UnistylesMountHook.cpp +1 -1
  5. package/cxx/core/UnistylesMountHook.h +4 -2
  6. package/cxx/core/UnistylesRegistry.cpp +7 -1
  7. package/cxx/hybridObjects/HybridShadowRegistry.cpp +1 -2
  8. package/cxx/hybridObjects/HybridShadowRegistry.h +1 -3
  9. package/cxx/hybridObjects/HybridStyleSheet.cpp +4 -1
  10. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +12 -0
  11. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
  12. package/cxx/parser/Parser.cpp +6 -6
  13. package/cxx/parser/Parser.h +1 -1
  14. package/cxx/shadowTree/ShadowTrafficController.h +2 -0
  15. package/lib/commonjs/components/Display.js +18 -0
  16. package/lib/commonjs/components/Display.js.map +1 -0
  17. package/lib/commonjs/components/Hide.js +18 -0
  18. package/lib/commonjs/components/Hide.js.map +1 -0
  19. package/lib/commonjs/components/index.js +20 -0
  20. package/lib/commonjs/components/index.js.map +1 -0
  21. package/lib/commonjs/components/useMedia.js +59 -0
  22. package/lib/commonjs/components/useMedia.js.map +1 -0
  23. package/lib/commonjs/core/createUnistylesComponent.js +2 -1
  24. package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
  25. package/lib/commonjs/core/createUnistylesComponent.native.js +40 -2
  26. package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
  27. package/lib/commonjs/core/index.js +0 -14
  28. package/lib/commonjs/core/index.js.map +1 -1
  29. package/lib/commonjs/global.js +0 -4
  30. package/lib/commonjs/global.js.map +1 -1
  31. package/lib/commonjs/index.js +12 -14
  32. package/lib/commonjs/index.js.map +1 -1
  33. package/lib/commonjs/mq.js +27 -11
  34. package/lib/commonjs/mq.js.map +1 -2
  35. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +0 -1
  36. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -2
  37. package/lib/commonjs/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +1 -1
  38. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -2
  39. package/lib/commonjs/specs/ShadowRegistry/types.js +0 -4
  40. package/lib/commonjs/specs/ShadowRegistry/types.js.map +1 -1
  41. package/lib/commonjs/specs/StatusBar/index.js.map +1 -2
  42. package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js +4 -2
  43. package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -1
  44. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +3 -1
  45. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -2
  46. package/lib/commonjs/specs/TurboUnistyles/index.js.map +1 -1
  47. package/lib/commonjs/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +1 -1
  48. package/lib/commonjs/specs/index.web.js.map +1 -2
  49. package/lib/commonjs/specs/types.js +10 -10
  50. package/lib/commonjs/specs/types.js.map +1 -1
  51. package/lib/commonjs/types/accessibility.js +9 -9
  52. package/lib/commonjs/types/accessibility.js.map +1 -1
  53. package/lib/commonjs/types/breakpoints.js.map +1 -1
  54. package/lib/commonjs/types/common.js +0 -4
  55. package/lib/commonjs/types/common.js.map +1 -1
  56. package/lib/commonjs/types/core.js.map +1 -1
  57. package/lib/commonjs/types/index.js.map +1 -2
  58. package/lib/commonjs/types/stylesheet.js +2 -1
  59. package/lib/commonjs/types/stylesheet.js.map +1 -2
  60. package/lib/commonjs/web/convert/index.js +7 -1
  61. package/lib/commonjs/web/convert/index.js.map +1 -2
  62. package/lib/commonjs/web/convert/pseudo.js.map +1 -2
  63. package/lib/commonjs/web/convert/shadow.js +5 -1
  64. package/lib/commonjs/web/convert/shadow.js.map +1 -2
  65. package/lib/commonjs/web/convert/style.js.map +1 -2
  66. package/lib/commonjs/web/convert/textShadow.js.map +1 -2
  67. package/lib/commonjs/web/convert/transform.js.map +1 -2
  68. package/lib/commonjs/web/convert/types.js.map +1 -1
  69. package/lib/commonjs/web/convert/utils.js +2 -1
  70. package/lib/commonjs/web/convert/utils.js.map +1 -2
  71. package/lib/commonjs/web/index.js.map +1 -2
  72. package/lib/commonjs/web/listener.js.map +1 -2
  73. package/lib/commonjs/web/mock.js.map +1 -2
  74. package/lib/commonjs/web/runtime.js.map +1 -2
  75. package/lib/commonjs/web/shadowRegistry.js +9 -1
  76. package/lib/commonjs/web/shadowRegistry.js.map +1 -2
  77. package/lib/commonjs/web/state.js +5 -1
  78. package/lib/commonjs/web/utils/common.js +3 -1
  79. package/lib/commonjs/web/utils/common.js.map +1 -2
  80. package/lib/commonjs/web/utils/index.js.map +1 -1
  81. package/lib/commonjs/web/utils/unistyle.js +1 -1
  82. package/lib/commonjs/web/variants/index.js.map +1 -1
  83. package/lib/module/common.js.map +1 -1
  84. package/lib/module/components/Display.js +13 -0
  85. package/lib/module/components/Display.js.map +1 -0
  86. package/lib/module/components/Hide.js +13 -0
  87. package/lib/module/components/Hide.js.map +1 -0
  88. package/lib/module/components/index.js +5 -0
  89. package/lib/module/components/index.js.map +1 -0
  90. package/lib/module/components/useMedia.js +54 -0
  91. package/lib/module/components/useMedia.js.map +1 -0
  92. package/lib/module/core/createUnistylesComponent.js +2 -1
  93. package/lib/module/core/createUnistylesComponent.js.map +1 -1
  94. package/lib/module/core/createUnistylesComponent.native.js +41 -3
  95. package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
  96. package/lib/module/core/index.js +0 -2
  97. package/lib/module/core/index.js.map +1 -1
  98. package/lib/module/global.js +1 -1
  99. package/lib/module/global.js.map +0 -1
  100. package/lib/module/index.js +2 -1
  101. package/lib/module/index.js.map +1 -1
  102. package/lib/module/mq.js +21 -11
  103. package/lib/module/mq.js.map +1 -1
  104. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +0 -1
  105. package/lib/module/specs/NativePlatform/index.js.map +1 -1
  106. package/lib/module/specs/NavigtionBar/UnistylesNavigationBar.nitro.js.map +0 -1
  107. package/lib/module/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +0 -1
  108. package/lib/module/specs/ShadowRegistry/types.js +0 -2
  109. package/lib/module/specs/ShadowRegistry/types.js.map +1 -1
  110. package/lib/module/specs/StatusBar/UnistylesStatusBar.nitro.js.map +1 -1
  111. package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -1
  112. package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +0 -1
  113. package/lib/module/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +0 -1
  114. package/lib/module/specs/index.web.js.map +1 -2
  115. package/lib/module/specs/types.js.map +0 -1
  116. package/lib/module/types/accessibility.js +1 -1
  117. package/lib/module/types/accessibility.js.map +0 -1
  118. package/lib/module/types/breakpoints.js.map +0 -1
  119. package/lib/module/types/common.js +1 -1
  120. package/lib/module/types/common.js.map +0 -1
  121. package/lib/module/types/core.js.map +0 -1
  122. package/lib/module/types/index.js.map +1 -2
  123. package/lib/module/types/stylesheet.js +2 -2
  124. package/lib/module/types/stylesheet.js.map +1 -2
  125. package/lib/module/types/variants.js.map +0 -1
  126. package/lib/module/web/convert/boxShadow.js +4 -1
  127. package/lib/module/web/convert/boxShadow.js.map +1 -2
  128. package/lib/module/web/convert/index.js +7 -1
  129. package/lib/module/web/convert/shadow.js +5 -1
  130. package/lib/module/web/convert/shadow.js.map +1 -2
  131. package/lib/module/web/convert/textShadow.js +4 -1
  132. package/lib/module/web/convert/utils.js +2 -1
  133. package/lib/module/web/convert/utils.js.map +1 -2
  134. package/lib/module/web/create.js +5 -1
  135. package/lib/module/web/create.js.map +1 -2
  136. package/lib/module/web/index.js +2 -1
  137. package/lib/module/web/index.js.map +1 -2
  138. package/lib/module/web/listener.js.map +1 -2
  139. package/lib/module/web/registry.js +3 -1
  140. package/lib/module/web/shadowRegistry.js +9 -1
  141. package/lib/module/web/shadowRegistry.js.map +1 -2
  142. package/lib/module/web/state.js +5 -1
  143. package/lib/module/web/state.js.map +1 -2
  144. package/lib/module/web/utils/common.js +3 -1
  145. package/lib/module/web/utils/common.js.map +1 -2
  146. package/lib/module/web/utils/unistyle.js +1 -1
  147. package/lib/module/web/utils/unistyle.js.map +1 -1
  148. package/lib/module/web/variants/getVariants.js.map +1 -2
  149. package/lib/module/web/variants/index.js.map +1 -1
  150. package/lib/typescript/src/components/Display.d.ts +7 -0
  151. package/lib/typescript/src/components/Display.d.ts.map +1 -0
  152. package/lib/typescript/src/components/Hide.d.ts +7 -0
  153. package/lib/typescript/src/components/Hide.d.ts.map +1 -0
  154. package/lib/typescript/src/components/index.d.ts +3 -0
  155. package/lib/typescript/src/components/index.d.ts.map +1 -0
  156. package/lib/typescript/src/components/useMedia.d.ts +6 -0
  157. package/lib/typescript/src/components/useMedia.d.ts.map +1 -0
  158. package/lib/typescript/src/core/createUnistylesComponent.d.ts +3 -2
  159. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
  160. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +3 -2
  161. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
  162. package/lib/typescript/src/core/index.d.ts +0 -2
  163. package/lib/typescript/src/core/index.d.ts.map +1 -1
  164. package/lib/typescript/src/index.d.ts +2 -1
  165. package/lib/typescript/src/index.d.ts.map +1 -1
  166. package/lib/typescript/src/mq.d.ts +8 -0
  167. package/lib/typescript/src/mq.d.ts.map +1 -1
  168. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -0
  169. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  170. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -0
  171. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +2 -0
  172. package/package.json +1 -1
  173. package/plugin/ref.js +4 -4
  174. package/plugin/style.js +15 -3
  175. package/src/components/Display.tsx +12 -0
  176. package/src/components/Hide.tsx +12 -0
  177. package/src/components/index.ts +2 -0
  178. package/src/components/useMedia.ts +64 -0
  179. package/src/core/createUnistylesComponent.native.tsx +48 -4
  180. package/src/core/createUnistylesComponent.tsx +4 -2
  181. package/src/core/index.ts +0 -2
  182. package/src/index.ts +2 -1
  183. package/src/mq.ts +27 -9
  184. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -0
  185. package/src/web/utils/unistyle.ts +1 -1
  186. package/lib/commonjs/core/useBreakpoint.js +0 -22
  187. package/lib/commonjs/core/useBreakpoint.js.map +0 -1
  188. package/lib/commonjs/core/useBreakpoint.native.js +0 -24
  189. package/lib/commonjs/core/useBreakpoint.native.js.map +0 -1
  190. package/lib/commonjs/core/useTheme.js +0 -22
  191. package/lib/commonjs/core/useTheme.js.map +0 -2
  192. package/lib/commonjs/core/useTheme.native.js +0 -24
  193. package/lib/commonjs/core/useTheme.native.js.map +0 -1
  194. package/lib/commonjs/web/mq.js +0 -23
  195. package/lib/commonjs/web/mq.js.map +0 -1
  196. package/lib/module/core/useBreakpoint.js +0 -17
  197. package/lib/module/core/useBreakpoint.js.map +0 -1
  198. package/lib/module/core/useBreakpoint.native.js +0 -19
  199. package/lib/module/core/useBreakpoint.native.js.map +0 -2
  200. package/lib/module/core/useTheme.js +0 -17
  201. package/lib/module/core/useTheme.js.map +0 -2
  202. package/lib/module/core/useTheme.native.js +0 -19
  203. package/lib/module/core/useTheme.native.js.map +0 -1
  204. package/lib/module/web/mq.js +0 -17
  205. package/lib/module/web/mq.js.map +0 -1
  206. package/lib/typescript/src/core/useBreakpoint.d.ts +0 -2
  207. package/lib/typescript/src/core/useBreakpoint.d.ts.map +0 -1
  208. package/lib/typescript/src/core/useBreakpoint.native.d.ts +0 -2
  209. package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +0 -1
  210. package/lib/typescript/src/core/useTheme.d.ts +0 -3
  211. package/lib/typescript/src/core/useTheme.d.ts.map +0 -1
  212. package/lib/typescript/src/core/useTheme.native.d.ts +0 -3
  213. package/lib/typescript/src/core/useTheme.native.d.ts.map +0 -1
  214. package/lib/typescript/src/web/mq.d.ts +0 -8
  215. package/lib/typescript/src/web/mq.d.ts.map +0 -1
  216. package/src/common.js +0 -4
  217. package/src/core/createUnistylesComponent.js +0 -6
  218. package/src/core/createUnistylesComponent.native.js +0 -31
  219. package/src/core/index.js +0 -3
  220. package/src/core/useBreakpoint.js +0 -14
  221. package/src/core/useBreakpoint.native.js +0 -16
  222. package/src/core/useBreakpoint.native.ts +0 -21
  223. package/src/core/useBreakpoint.ts +0 -18
  224. package/src/core/useTheme.js +0 -14
  225. package/src/core/useTheme.native.js +0 -16
  226. package/src/core/useTheme.native.ts +0 -22
  227. package/src/core/useTheme.ts +0 -19
  228. package/src/global.js +0 -1
  229. package/src/index.js +0 -3
  230. package/src/mq.js +0 -38
  231. package/src/specs/NativePlatform/NativePlatform.nitro.js +0 -19
  232. package/src/specs/NativePlatform/index.js +0 -1
  233. package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.js +0 -1
  234. package/src/specs/NavigtionBar/index.js +0 -9
  235. package/src/specs/ShadowRegistry/ShadowRegistry.nitro.js +0 -1
  236. package/src/specs/ShadowRegistry/index.js +0 -26
  237. package/src/specs/ShadowRegistry/types.js +0 -1
  238. package/src/specs/StatusBar/UnistylesStatusBar.nitro.js +0 -1
  239. package/src/specs/StatusBar/index.js +0 -25
  240. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.js +0 -1
  241. package/src/specs/StyleSheet/index.js +0 -13
  242. package/src/specs/TurboUnistyles/NativeTurboUnistyles.js +0 -2
  243. package/src/specs/TurboUnistyles/index.js +0 -1
  244. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.js +0 -1
  245. package/src/specs/UnistylesRuntime/index.js +0 -20
  246. package/src/specs/index.js +0 -8
  247. package/src/specs/index.web.js +0 -2
  248. package/src/specs/types.js +0 -17
  249. package/src/types/accessibility.js +0 -30
  250. package/src/types/breakpoints.js +0 -1
  251. package/src/types/common.js +0 -1
  252. package/src/types/core.js +0 -1
  253. package/src/types/index.js +0 -1
  254. package/src/types/stylesheet.js +0 -2
  255. package/src/types/variants.js +0 -1
  256. package/src/web/convert/boxShadow.js +0 -59
  257. package/src/web/convert/index.js +0 -56
  258. package/src/web/convert/pseudo.js +0 -131
  259. package/src/web/convert/shadow.js +0 -50
  260. package/src/web/convert/style.js +0 -137
  261. package/src/web/convert/textShadow.js +0 -56
  262. package/src/web/convert/transform.js +0 -65
  263. package/src/web/convert/types.js +0 -2
  264. package/src/web/convert/utils.js +0 -39
  265. package/src/web/create.js +0 -36
  266. package/src/web/index.js +0 -22
  267. package/src/web/listener.js +0 -26
  268. package/src/web/mock.js +0 -21
  269. package/src/web/mq.js +0 -14
  270. package/src/web/mq.ts +0 -17
  271. package/src/web/registry.js +0 -165
  272. package/src/web/runtime.js +0 -160
  273. package/src/web/shadowRegistry.js +0 -96
  274. package/src/web/state.js +0 -68
  275. package/src/web/utils/common.js +0 -79
  276. package/src/web/utils/index.js +0 -2
  277. package/src/web/utils/unistyle.js +0 -72
  278. package/src/web/variants/getVariants.js +0 -26
  279. package/src/web/variants/index.js +0 -2
  280. package/src/web/variants/useVariants.js +0 -50
@@ -0,0 +1,7 @@
1
+ import React, { type PropsWithChildren } from 'react';
2
+ type DisplayProps = {
3
+ mq: symbol;
4
+ } & PropsWithChildren;
5
+ export declare const Display: React.FunctionComponent<DisplayProps>;
6
+ export {};
7
+ //# sourceMappingURL=Display.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Display.d.ts","sourceRoot":"","sources":["../../../../src/components/Display.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAGrD,KAAK,YAAY,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CAAA;AAEtD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,YAAY,CAMzD,CAAA"}
@@ -0,0 +1,7 @@
1
+ import React, { type PropsWithChildren } from 'react';
2
+ type HideProps = {
3
+ mq: symbol;
4
+ } & PropsWithChildren;
5
+ export declare const Hide: React.FunctionComponent<HideProps>;
6
+ export {};
7
+ //# sourceMappingURL=Hide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hide.d.ts","sourceRoot":"","sources":["../../../../src/components/Hide.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAGrD,KAAK,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CAAA;AAEnD,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAMnD,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { Hide } from './Hide';
2
+ export { Display } from './Display';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const useMedia: (config: {
2
+ mq: symbol;
3
+ }) => {
4
+ isVisible: boolean | null;
5
+ };
6
+ //# sourceMappingURL=useMedia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMedia.d.ts","sourceRoot":"","sources":["../../../../src/components/useMedia.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,WAAY;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;;CA2D9C,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import React, { type ComponentProps, type ComponentType } from 'react';
2
2
  import type { UnistylesTheme } from '../types';
3
- type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<ComponentProps<T>>;
4
- export declare const createUnistylesComponent: <T extends ComponentType<any>>(Component: T, _: Mappings<T>) => (props: ComponentProps<T>) => React.JSX.Element;
3
+ type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<Omit<ComponentProps<T>, typeof SUPPORTED_STYLE_PROPS[number]>>;
4
+ declare const SUPPORTED_STYLE_PROPS: readonly ["style", "contentContainerStyle"];
5
+ export declare const createUnistylesComponent: <T extends ComponentType<any>>(Component: T, _?: Mappings<T>) => (props: ComponentProps<T>) => React.JSX.Element;
5
6
  export {};
6
7
  //# sourceMappingURL=createUnistylesComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createUnistylesComponent.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,KAAK,QAAQ,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AAEnG,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,aAChF,cAAc,CAAC,CAAC,CAAC,sBAGnC,CAAA"}
1
+ {"version":3,"file":"createUnistylesComponent.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,KAAK,QAAQ,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAE/I,QAAA,MAAM,qBAAqB,6CAA8C,CAAA;AAEzE,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,MAAK,QAAQ,CAAC,CAAC,CAAC,aAChF,cAAc,CAAC,CAAC,CAAC,sBAGnC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import React, { type ComponentProps, type ComponentType } from 'react';
2
2
  import type { UnistylesTheme } from '../types';
3
- type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<ComponentProps<T>>;
4
- export declare const createUnistylesComponent: <T extends ComponentType<any>>(Component: T, mappings: Mappings<T>) => (props: ComponentProps<T>) => React.JSX.Element;
3
+ type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<Omit<ComponentProps<T>, typeof SUPPORTED_STYLE_PROPS[number]>>;
4
+ declare const SUPPORTED_STYLE_PROPS: readonly ["style", "contentContainerStyle"];
5
+ export declare const createUnistylesComponent: <T extends ComponentType<any>>(Component: T, mappings?: Mappings<T>) => (props: ComponentProps<T>) => React.JSX.Element;
5
6
  export {};
6
7
  //# sourceMappingURL=createUnistylesComponent.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createUnistylesComponent.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesComponent.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAuB,MAAM,OAAO,CAAA;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,KAAK,QAAQ,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AAEnG,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,YAAY,QAAQ,CAAC,CAAC,CAAC,aACvF,cAAc,CAAC,CAAC,CAAC,sBAoCnC,CAAA"}
1
+ {"version":3,"file":"createUnistylesComponent.native.d.ts","sourceRoot":"","sources":["../../../../src/core/createUnistylesComponent.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAA+B,MAAM,OAAO,CAAA;AACnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,KAAK,QAAQ,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAE/I,QAAA,MAAM,qBAAqB,6CAA8C,CAAA;AAEzE,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,aAAY,QAAQ,CAAC,CAAC,CAAC,aACvF,cAAc,CAAC,CAAC,CAAC,sBA8EnC,CAAA"}
@@ -1,4 +1,2 @@
1
- export { useBreakpoint } from './useBreakpoint';
2
- export { useTheme } from './useTheme';
3
1
  export { createUnistylesComponent } from './createUnistylesComponent';
4
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export * from './specs';
2
2
  export { mq } from './mq';
3
3
  export type { UnistylesThemes, UnistylesBreakpoints } from './global';
4
- export { useTheme, useBreakpoint, createUnistylesComponent } from './core';
4
+ export { createUnistylesComponent } from './core';
5
5
  export type { UnistylesVariants } from './types';
6
+ export * from './components';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAA;AAC1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,QAAQ,CAAA;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,cAAc,cAAc,CAAA"}
@@ -22,5 +22,13 @@ type MQHandler = {
22
22
  * @returns - JavaScript symbol to be used in your stylesheet
23
23
  */
24
24
  export declare const mq: MQHandler;
25
+ export declare const parseMq: (mq: string) => {
26
+ minWidth: number | undefined;
27
+ maxWidth: number | undefined;
28
+ minHeight: number | undefined;
29
+ maxHeight: number | undefined;
30
+ };
31
+ export declare const isUnistylesMq: (mq: string) => boolean;
32
+ export declare const isValidMq: (parsedMQ: ReturnType<typeof parseMq>) => boolean;
25
33
  export {};
26
34
  //# sourceMappingURL=mq.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../src/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,KAAK,OAAO,GAAG,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAElD,KAAK,SAAS,GAAG;IACb,IAAI,EAAE;QACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC5D,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC7C,GAAG,EAAE;YACD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC3D,CAAA;KACJ,CAAC;IACF,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC9C,GAAG,EAAE;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC1D,CAAA;KACJ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,aAAa,OAAQ,MAAM,YAAgC,CAAA;AAExE,eAAO,MAAM,SAAS,aAAc,UAAU,CAAC,OAAO,OAAO,CAAC,YAK7D,CAAA"}
@@ -25,6 +25,7 @@ export interface UnistylesRuntime extends HybridObject<{
25
25
  readonly themeName?: string;
26
26
  readonly contentSizeCategory: string;
27
27
  readonly breakpoint?: string;
28
+ readonly breakpoints: Record<string, number>;
28
29
  readonly insets: Insets;
29
30
  readonly orientation: Orientation;
30
31
  readonly pixelRatio: number;
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesRuntime.nitro.d.ts","sourceRoot":"","sources":["../../../../../src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAC7G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAEnE,KAAK,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AACnD,KAAK,WAAW,GAAG,UAAU,GAAG,WAAW,CAAA;AAG3C,MAAM,WAAW,uBAAwB,SAAQ,0BAA0B;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACvC;AAGD,MAAM,WAAW,oBAAqB,SAAQ,uBAAuB;IACjE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE,sBAAsB,GAAG,0BAA0B,GAAG,sBAAsB,CAAC;IAG3G,QAAQ,CAAC,SAAS,CAAC,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,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IAEtB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAG/C,QAAQ,CAAC,WAAW,EAAE,uBAAuB,CAAA;CAChD"}
@@ -20,6 +20,7 @@ namespace margelo::nitro::unistyles {
20
20
  prototype.registerHybridGetter("themeName", &HybridUnistylesRuntimeSpec::getThemeName);
21
21
  prototype.registerHybridGetter("contentSizeCategory", &HybridUnistylesRuntimeSpec::getContentSizeCategory);
22
22
  prototype.registerHybridGetter("breakpoint", &HybridUnistylesRuntimeSpec::getBreakpoint);
23
+ prototype.registerHybridGetter("breakpoints", &HybridUnistylesRuntimeSpec::getBreakpoints);
23
24
  prototype.registerHybridGetter("insets", &HybridUnistylesRuntimeSpec::getInsets);
24
25
  prototype.registerHybridGetter("orientation", &HybridUnistylesRuntimeSpec::getOrientation);
25
26
  prototype.registerHybridGetter("pixelRatio", &HybridUnistylesRuntimeSpec::getPixelRatio);
@@ -28,6 +28,7 @@ namespace margelo::nitro::unistyles { struct UnistylesCxxMiniRuntime; }
28
28
  #include "Dimensions.hpp"
29
29
  #include <optional>
30
30
  #include <string>
31
+ #include <unordered_map>
31
32
  #include "Insets.hpp"
32
33
  #include "Orientation.hpp"
33
34
  #include "UnistylesCxxMiniRuntime.hpp"
@@ -65,6 +66,7 @@ namespace margelo::nitro::unistyles {
65
66
  virtual std::optional<std::string> getThemeName() = 0;
66
67
  virtual std::string getContentSizeCategory() = 0;
67
68
  virtual std::optional<std::string> getBreakpoint() = 0;
69
+ virtual std::unordered_map<std::string, double> getBreakpoints() = 0;
68
70
  virtual Insets getInsets() = 0;
69
71
  virtual Orientation getOrientation() = 0;
70
72
  virtual double getPixelRatio() = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-alpha.33",
3
+ "version": "3.0.0-alpha.34",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
package/plugin/ref.js CHANGED
@@ -36,7 +36,7 @@ function addRef(t, path, metadata, state) {
36
36
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
37
37
  [
38
38
  t.identifier('ref'),
39
- memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
39
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle || metadata.conditionalExpression,
40
40
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
41
41
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
42
42
  ]
@@ -85,7 +85,7 @@ function overrideRef(t, path, refProp, metadata, state) {
85
85
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
86
86
  [
87
87
  t.identifier(uniqueRefName),
88
- memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
88
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle || metadata.conditionalExpression,
89
89
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
90
90
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
91
91
  ]
@@ -130,7 +130,7 @@ function overrideRef(t, path, refProp, metadata, state) {
130
130
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
131
131
  [
132
132
  t.identifier(userRefName),
133
- memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
133
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle || metadata.conditionalExpression,
134
134
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
135
135
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
136
136
  ]
@@ -192,7 +192,7 @@ function overrideRef(t, path, refProp, metadata, state) {
192
192
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
193
193
  [
194
194
  t.identifier(uniqueRefName),
195
- memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle,
195
+ memberExpressionFromArray(t, metadata.members) || metadata.inlineStyle || metadata.conditionalExpression,
196
196
  t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
197
197
  metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
198
198
  ]
package/plugin/style.js CHANGED
@@ -9,7 +9,8 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
9
9
  {
10
10
  members: members.filter(Boolean),
11
11
  inlineStyle: undefined,
12
- dynamicFunction
12
+ dynamicFunction,
13
+ conditionalExpression: undefined
13
14
  }
14
15
  ]
15
16
  }
@@ -46,7 +47,8 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
46
47
  return partialResult.concat([{
47
48
  members: [],
48
49
  inlineStyle: t.objectExpression(inlineStyles),
49
- dynamicFunction: undefined
50
+ dynamicFunction: undefined,
51
+ conditionalExpression: undefined
50
52
  }])
51
53
  }
52
54
 
@@ -62,7 +64,17 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
62
64
  return [{
63
65
  members: [node.name],
64
66
  inlineStyle: undefined,
65
- dynamicFunction: undefined
67
+ dynamicFunction: undefined,
68
+ conditionalExpression: undefined
69
+ }]
70
+ }
71
+
72
+ if (t.isConditionalExpression(node)) {
73
+ return [{
74
+ members: [],
75
+ inlineStyle: undefined,
76
+ dynamicFunction: undefined,
77
+ conditionalExpression: node
66
78
  }]
67
79
  }
68
80
 
@@ -0,0 +1,12 @@
1
+ import React, { type PropsWithChildren } from 'react'
2
+ import { useMedia } from './useMedia'
3
+
4
+ type DisplayProps = { mq: symbol } & PropsWithChildren
5
+
6
+ export const Display: React.FunctionComponent<DisplayProps> = ({ children, ...props }) => {
7
+ const { isVisible } = useMedia(props)
8
+
9
+ return isVisible
10
+ ? children
11
+ : null
12
+ }
@@ -0,0 +1,12 @@
1
+ import React, { type PropsWithChildren } from 'react'
2
+ import { useMedia } from './useMedia'
3
+
4
+ type HideProps = { mq: symbol } & PropsWithChildren
5
+
6
+ export const Hide: React.FunctionComponent<HideProps> = ({ children, ...props }) => {
7
+ const { isVisible } = useMedia(props)
8
+
9
+ return !isVisible
10
+ ? children
11
+ : null
12
+ }
@@ -0,0 +1,2 @@
1
+ export { Hide } from './Hide'
2
+ export { Display } from './Display'
@@ -0,0 +1,64 @@
1
+ import { useEffect, useLayoutEffect, useState } from 'react'
2
+ import { StyleSheet, UnistyleDependency, UnistylesRuntime, type UnistylesStyleSheet } from '../specs'
3
+ import { isValidMq, parseMq, isUnistylesMq } from '../mq'
4
+
5
+ export const useMedia = (config: { mq: symbol }) => {
6
+ const computeIsVisible = (): boolean => {
7
+ const maybeMq = config.mq as unknown as string
8
+
9
+ if (!isUnistylesMq(maybeMq)) {
10
+ console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`)
11
+
12
+ return false
13
+ }
14
+
15
+ const parsedMq = parseMq(maybeMq)
16
+
17
+ if (!isValidMq(parsedMq)) {
18
+ console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`)
19
+
20
+ return false
21
+ }
22
+
23
+ const { width, height } = UnistylesRuntime.screen
24
+
25
+ if (parsedMq.minWidth !== undefined && width < parsedMq.minWidth) {
26
+ return false
27
+ }
28
+
29
+ if (parsedMq.maxWidth !== undefined && width > parsedMq.maxWidth) {
30
+ return false
31
+ }
32
+
33
+ if (parsedMq.minHeight !== undefined && height < parsedMq.minHeight) {
34
+ return false
35
+ }
36
+
37
+ if (parsedMq.maxHeight !== undefined && height > parsedMq.maxHeight) {
38
+ return false
39
+ }
40
+
41
+ return true
42
+ }
43
+ const [isVisible, setIsVisible] = useState<boolean | null>(computeIsVisible())
44
+
45
+ useEffect(() => {
46
+ setIsVisible(computeIsVisible())
47
+ }, [config.mq])
48
+
49
+ useLayoutEffect(() => {
50
+ const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
51
+ if (dependencies.includes(UnistyleDependency.Breakpoints)) {
52
+ setIsVisible(computeIsVisible())
53
+ }
54
+ })
55
+
56
+ return () => {
57
+ removeChangeListener()
58
+ }
59
+ }, [config.mq])
60
+
61
+ return {
62
+ isVisible
63
+ }
64
+ }
@@ -1,20 +1,55 @@
1
- import React, { type ComponentProps, type ComponentType, useEffect, useState } from 'react'
1
+ import React, { type ComponentProps, type ComponentType, useEffect, useRef, useState } from 'react'
2
2
  import type { UnistylesTheme } from '../types'
3
3
  import { StyleSheet, UnistyleDependency, UnistylesRuntime, type UnistylesStyleSheet } from '../specs'
4
4
 
5
- type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<ComponentProps<T>>
5
+ type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<Omit<ComponentProps<T>, typeof SUPPORTED_STYLE_PROPS[number]>>
6
6
 
7
- export const createUnistylesComponent = <T extends ComponentType<any>>(Component: T, mappings: Mappings<T>) => {
7
+ const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
8
+
9
+ export const createUnistylesComponent = <T extends ComponentType<any>>(Component: T, mappings: Mappings<T> = () => ({})) => {
8
10
  return (props: ComponentProps<T>) => {
9
11
  const [theme, setTheme] = useState<UnistylesTheme>(UnistylesRuntime.getTheme())
10
12
  const [, setRt] = useState(0)
13
+ const stylesRef = useRef<Record<string, any>>({})
14
+ const isForcedRef = useRef(false)
15
+
16
+ if (!isForcedRef.current) {
17
+ SUPPORTED_STYLE_PROPS.forEach(propName => {
18
+ if (props?.[propName]) {
19
+ if (Array.isArray(props[propName])) {
20
+ console.error(`🦄 Unistyles: createUnistylesComponent requires ${propName} to be an object. Please check props for component: ${Component.displayName}`)
21
+ }
22
+
23
+ if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
24
+ console.error(`🦄 Unistyles: createUnistylesComponent received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${Component.displayName}`)
25
+ }
26
+
27
+ stylesRef.current = {
28
+ ...stylesRef.current,
29
+ [propName]: props[propName]
30
+ }
31
+ }
32
+ })
33
+ }
11
34
 
12
35
  useEffect(() => {
13
36
  const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
14
- const componentDependencies = (props.style?.uni__dependencies || mappings(theme).style?.uni__dependencies) as Array<UnistyleDependency>
37
+ const componentDependencies = (props.style?.__proto__.uni__dependencies || mappings(theme).style?.__proto__.uni__dependencies) as Array<UnistyleDependency>
15
38
 
16
39
  if (dependencies.includes(UnistyleDependency.Theme) && (!componentDependencies ||componentDependencies.includes(UnistyleDependency.Theme))) {
17
40
  setTheme(UnistylesRuntime.getTheme())
41
+
42
+ // override with Unistyles styles
43
+ SUPPORTED_STYLE_PROPS.forEach(propName => {
44
+ if (props?.[propName]) {
45
+ stylesRef.current = {
46
+ ...stylesRef.current,
47
+ [propName]: props[propName].__proto__?.getStyle() || props[propName]
48
+ }
49
+ }
50
+ })
51
+
52
+ isForcedRef.current = true
18
53
  }
19
54
 
20
55
  if (dependencies.some(dependency => dependency >= 2) && (!componentDependencies || componentDependencies.some(dependency => dependency >= 2))) {
@@ -39,6 +74,15 @@ export const createUnistylesComponent = <T extends ComponentType<any>>(Component
39
74
  mergedProps[key] = props[key]
40
75
  })
41
76
 
77
+ // override with Unistyles styles
78
+ SUPPORTED_STYLE_PROPS.forEach(propName => {
79
+ if (mergedProps[propName]) {
80
+ mergedProps[propName] = stylesRef.current[propName]
81
+ }
82
+ })
83
+
84
+ isForcedRef.current = false
85
+
42
86
  return <Component {...mergedProps} />
43
87
  }
44
88
  }
@@ -1,9 +1,11 @@
1
1
  import React, { type ComponentProps, type ComponentType } from 'react'
2
2
  import type { UnistylesTheme } from '../types'
3
3
 
4
- type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<ComponentProps<T>>
4
+ type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<Omit<ComponentProps<T>, typeof SUPPORTED_STYLE_PROPS[number]>>
5
5
 
6
- export const createUnistylesComponent = <T extends ComponentType<any>>(Component: T, _: Mappings<T>) => {
6
+ const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
7
+
8
+ export const createUnistylesComponent = <T extends ComponentType<any>>(Component: T, _: Mappings<T> = () => ({})) => {
7
9
  return (props: ComponentProps<T>) => {
8
10
  return <Component {...props} />
9
11
  }
package/src/core/index.ts CHANGED
@@ -1,3 +1 @@
1
- export { useBreakpoint } from './useBreakpoint'
2
- export { useTheme } from './useTheme'
3
1
  export { createUnistylesComponent } from './createUnistylesComponent'
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './specs'
2
2
  export { mq } from './mq'
3
3
  export type { UnistylesThemes, UnistylesBreakpoints } from './global'
4
- export { useTheme, useBreakpoint, createUnistylesComponent } from './core'
4
+ export { createUnistylesComponent } from './core'
5
5
  export type { UnistylesVariants } from './types'
6
+ export * from './components'
package/src/mq.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import type { Nullable } from './types'
2
2
  import type { UnistylesBreakpoints } from './global'
3
+ import { UnistylesRuntime } from './specs'
4
+
5
+ const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
6
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
7
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/
3
8
 
4
9
  type MQValue = keyof UnistylesBreakpoints | number
5
10
 
@@ -29,16 +34,8 @@ const getMQValue = (value: Nullable<MQValue>) => {
29
34
  return 0
30
35
  }
31
36
 
32
- // todo take it from js
33
- const breakpoints = {
34
- xs: 0,
35
- sm: 300,
36
- md: 500,
37
- lg: 800,
38
- xl: 1200
39
- }
37
+ const breakpoints = UnistylesRuntime.breakpoints
40
38
 
41
- // @ts-ignore
42
39
  return breakpoints[value] ?? 0
43
40
  }
44
41
 
@@ -64,3 +61,24 @@ export const mq: MQHandler = {
64
61
  }
65
62
  })
66
63
  }
64
+
65
+ export const parseMq = (mq: string) => {
66
+ const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
67
+ const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
68
+
69
+ return {
70
+ minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
71
+ maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
72
+ minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
73
+ maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH),
74
+ }
75
+ }
76
+
77
+ export const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
78
+
79
+ export const isValidMq = (parsedMQ: ReturnType<typeof parseMq>) => {
80
+ const isWidthValid = parsedMQ.minWidth === undefined || parsedMQ.maxWidth === undefined || parsedMQ.minWidth <= parsedMQ.maxWidth
81
+ const isHeightValid = parsedMQ.minHeight === undefined || parsedMQ.maxHeight === undefined || parsedMQ.minHeight <= parsedMQ.maxHeight
82
+
83
+ return isWidthValid && isHeightValid
84
+ }
@@ -30,6 +30,7 @@ export interface UnistylesRuntime extends HybridObject<{ ios: 'c++', android: 'c
30
30
  readonly themeName?: string,
31
31
  readonly contentSizeCategory: string,
32
32
  readonly breakpoint?: string,
33
+ readonly breakpoints: Record<string, number>,
33
34
  readonly insets: Insets,
34
35
  readonly orientation: Orientation,
35
36
  readonly pixelRatio: number,
@@ -1,7 +1,7 @@
1
1
  import type { UnistyleDependency } from '../../specs/NativePlatform'
2
2
  import { ColorScheme, Orientation } from '../../specs/types'
3
3
  import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
4
- import { isUnistylesMq, parseMq } from '../mq'
4
+ import { isUnistylesMq, parseMq } from '../../mq'
5
5
  import { UnistylesState } from '../state'
6
6
  import { keyInObject, reduceObject } from './common'
7
7
 
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useBreakpoint = void 0;
7
- var _react = require("react");
8
- var _web = require("../web");
9
- var _listener = require("../web/listener");
10
- var _NativePlatform = require("../specs/NativePlatform");
11
- const useBreakpoint = () => {
12
- const [breakpoint, setBreakpoint] = (0, _react.useState)(_web.UnistylesRuntime.breakpoint);
13
- (0, _react.useEffect)(() => {
14
- const removeChangeListener = _listener.UnistylesListener.addListeners([_NativePlatform.UnistyleDependency.Breakpoints], () => setBreakpoint(_web.UnistylesRuntime.breakpoint));
15
- return () => {
16
- removeChangeListener();
17
- };
18
- }, []);
19
- return breakpoint;
20
- };
21
- exports.useBreakpoint = useBreakpoint;
22
- //# sourceMappingURL=useBreakpoint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_web","_listener","_NativePlatform","useBreakpoint","breakpoint","setBreakpoint","useState","UnistylesRuntime","useEffect","removeChangeListener","UnistylesListener","addListeners","UnistyleDependency","Breakpoints","exports"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACO,MAAMI,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAACC,qBAAgB,CAACH,UAAU,CAAC;EACzE,IAAAI,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAGC,2BAAiB,CAACC,YAAY,CAAC,CAACC,kCAAkB,CAACC,WAAW,CAAC,EAAE,MAAMR,aAAa,CAACE,qBAAgB,CAACH,UAAU,CAAC,CAAC;IAC/I,OAAO,MAAM;MACTK,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EACN,OAAOL,UAAU;AACrB,CAAC;AAACU,OAAA,CAAAX,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useBreakpoint = void 0;
7
- var _react = require("react");
8
- var _specs = require("../specs");
9
- const useBreakpoint = () => {
10
- const [breakpoint, setBreakpoint] = (0, _react.useState)(_specs.UnistylesRuntime.breakpoint);
11
- (0, _react.useEffect)(() => {
12
- const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
13
- if (dependencies.includes(_specs.UnistyleDependency.Breakpoints)) {
14
- setBreakpoint(_specs.UnistylesRuntime.breakpoint);
15
- }
16
- });
17
- return () => {
18
- removeChangeListener();
19
- };
20
- }, []);
21
- return breakpoint;
22
- };
23
- exports.useBreakpoint = useBreakpoint;
24
- //# sourceMappingURL=useBreakpoint.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_specs","useBreakpoint","breakpoint","setBreakpoint","useState","UnistylesRuntime","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Breakpoints","exports"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.native.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAACC,uBAAgB,CAACH,UAAU,CAAC;EAEzE,IAAAI,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACC,yBAAkB,CAACC,WAAW,CAAC,EAAE;QACvDV,aAAa,CAACE,uBAAgB,CAACH,UAAU,CAAC;MAC9C;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTK,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,UAAU;AACrB,CAAC;AAAAY,OAAA,CAAAb,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useTheme = void 0;
7
- var _react = require("react");
8
- var _web = require("../web");
9
- var _listener = require("../web/listener");
10
- var _NativePlatform = require("../specs/NativePlatform");
11
- const useTheme = () => {
12
- const [theme, setTheme] = (0, _react.useState)(_web.UnistylesRuntime.getTheme());
13
- (0, _react.useEffect)(() => {
14
- const removeChangeListener = _listener.UnistylesListener.addListeners([_NativePlatform.UnistyleDependency.Theme], () => setTheme(_web.UnistylesRuntime.getTheme()));
15
- return () => {
16
- removeChangeListener();
17
- };
18
- }, []);
19
- return theme;
20
- };
21
- exports.useTheme = useTheme;
22
- //# sourceMappingURL=useTheme.js.map
@@ -1,2 +0,0 @@
1
- {"version":3,"names":["_react","require","_web","_listener","_NativePlatform","useTheme","theme","setTheme","useState","UnistylesRuntime","getTheme","useEffect","removeChangeListener","UnistylesListener","addListeners","UnistyleDependency","Theme","exports"],"sourceRoot":"../../../src","sources":["core/useTheme.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACO,MAAMI,QAAQ,GAAGA,CAAA,KAAM;EAC1B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAC/D,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAGC,2BAAiB,CAACC,YAAY,CAAC,CAACC,kCAAkB,CAACC,KAAK,CAAC,EAAE,MAAMT,QAAQ,CAACE,qBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpI,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EACN,OAAON,KAAK;AAChB,CAAC;AAACW,OAAA,CAAAZ,QAAA,GAAAA,QAAA","ignoreList":[]}
2
-