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
@@ -1,24 +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 _specs = require("../specs");
9
- const useTheme = () => {
10
- const [theme, setTheme] = (0, _react.useState)(_specs.UnistylesRuntime.getTheme());
11
- (0, _react.useEffect)(() => {
12
- const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
13
- if (dependencies.includes(_specs.UnistyleDependency.Theme)) {
14
- setTheme(_specs.UnistylesRuntime.getTheme());
15
- }
16
- });
17
- return () => {
18
- removeChangeListener();
19
- };
20
- }, []);
21
- return theme;
22
- };
23
- exports.useTheme = useTheme;
24
- //# sourceMappingURL=useTheme.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_specs","useTheme","theme","setTheme","useState","UnistylesRuntime","getTheme","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Theme","exports"],"sourceRoot":"../../../src","sources":["core/useTheme.native.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAIO,MAAME,QAAQ,GAAGA,CAAA,KAAsB;EAC1C,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAE/D,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACC,yBAAkB,CAACC,KAAK,CAAC,EAAE;QACjDX,QAAQ,CAACE,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;MACzC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAON,KAAK;AAChB,CAAC;AAAAa,OAAA,CAAAd,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parseMq = exports.isUnistylesMq = void 0;
7
- const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
8
- const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
9
- const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
10
- const parseMq = mq => {
11
- const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
12
- const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
13
- return {
14
- minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
15
- maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
16
- minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
17
- maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH)
18
- };
19
- };
20
- exports.parseMq = parseMq;
21
- const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
22
- exports.isUnistylesMq = isUnistylesMq;
23
- //# sourceMappingURL=mq.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","minWidth","undefined","Number","maxWidth","minHeight","maxHeight","exports","isUnistylesMq","test"],"sourceRoot":"../../../src","sources":["web/mq.js"],"mappings":";;;;;;AAAA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAC7D,MAAMC,OAAO,GAAIC,EAAE,IAAK;EAC3B,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EACpE,OAAO;IACHQ,QAAQ,EAAE,CAACP,KAAK,IAAIC,KAAK,KAAK,UAAU,GAAGO,SAAS,GAAGC,MAAM,CAACR,KAAK,CAAC;IACpES,QAAQ,EAAE,CAACV,KAAK,IAAIE,GAAG,KAAK,UAAU,GAAGM,SAAS,GAAGC,MAAM,CAACP,GAAG,CAAC;IAChES,SAAS,EAAE,CAACP,MAAM,IAAIC,KAAK,KAAK,UAAU,GAAGG,SAAS,GAAGC,MAAM,CAACJ,KAAK,CAAC;IACtEO,SAAS,EAAE,CAACR,MAAM,IAAIE,GAAG,KAAK,UAAU,GAAGE,SAAS,GAAGC,MAAM,CAACH,GAAG;EACrE,CAAC;AACL,CAAC;AAACO,OAAA,CAAAf,OAAA,GAAAA,OAAA;AACK,MAAMgB,aAAa,GAAIf,EAAE,IAAKJ,kBAAkB,CAACoB,IAAI,CAAChB,EAAE,CAAC;AAACc,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- import { useEffect, useState } from 'react';
4
- import { UnistylesRuntime } from '../web';
5
- import { UnistylesListener } from '../web/listener';
6
- import { UnistyleDependency } from '../specs/NativePlatform';
7
- export const useBreakpoint = () => {
8
- const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
9
- useEffect(() => {
10
- const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint));
11
- return () => {
12
- removeChangeListener();
13
- };
14
- }, []);
15
- return breakpoint;
16
- };
17
- //# sourceMappingURL=useBreakpoint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","useState","UnistylesRuntime","UnistylesListener","UnistyleDependency","useBreakpoint","breakpoint","setBreakpoint","removeChangeListener","addListeners","Breakpoints"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,gBAAgB,QAAQ,QAAQ;AACzC,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGN,QAAQ,CAACC,gBAAgB,CAACI,UAAU,CAAC;EAEzEN,SAAS,CAAC,MAAM;IACZ,MAAMQ,oBAAoB,GAAGL,iBAAiB,CAACM,YAAY,CAAC,CAACL,kBAAkB,CAACM,WAAW,CAAC,EAAE,MAAMH,aAAa,CAACL,gBAAgB,CAACI,UAAU,CAAC,CAAC;IAE/I,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,UAAU;AACrB,CAAC","ignoreList":[]}
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- import { useEffect, useState } from 'react';
4
- import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
5
- export const useBreakpoint = () => {
6
- const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
7
- useEffect(() => {
8
- const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
9
- if (dependencies.includes(UnistyleDependency.Breakpoints)) {
10
- setBreakpoint(UnistylesRuntime.breakpoint);
11
- }
12
- });
13
- return () => {
14
- removeChangeListener();
15
- };
16
- }, []);
17
- return breakpoint;
18
- };
19
- //# sourceMappingURL=useBreakpoint.native.js.map
@@ -1,2 +0,0 @@
1
- {"version":3,"names":["useEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","useBreakpoint","breakpoint","setBreakpoint","removeChangeListener","addChangeListener","dependencies","includes","Breakpoints"],"sourceRoot":"../../../src","sources":["core/useBreakpoint.native.js"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAC3E,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGN,QAAQ,CAACG,gBAAgB,CAACE,UAAU,CAAC;EACzEN,SAAS,CAAC,MAAM;IACZ,MAAMQ,oBAAoB,GAAGN,UAAU,CAACO,iBAAiB,CAACC,YAAY,IAAI;MACtE,IAAIA,YAAY,CAACC,QAAQ,CAACR,kBAAkB,CAACS,WAAW,CAAC,EAAE;QACvDL,aAAa,CAACH,gBAAgB,CAACE,UAAU,CAAC;MAC9C;IACJ,CAAC,CAAC;IACF,OAAO,MAAM;MACTE,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EACN,OAAOF,UAAU;AACrB,CAAC","ignoreList":[]}
2
-
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- import { useEffect, useState } from 'react';
4
- import { UnistylesRuntime } from '../web';
5
- import { UnistylesListener } from '../web/listener';
6
- import { UnistyleDependency } from '../specs/NativePlatform';
7
- export const useTheme = () => {
8
- const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
9
- useEffect(() => {
10
- const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()));
11
- return () => {
12
- removeChangeListener();
13
- };
14
- }, []);
15
- return theme;
16
- };
17
- //# sourceMappingURL=useTheme.js.map
@@ -1,2 +0,0 @@
1
- {"version":3,"names":["useEffect","useState","UnistylesRuntime","UnistylesListener","UnistyleDependency","useTheme","theme","setTheme","getTheme","removeChangeListener","addListeners","Theme"],"sourceRoot":"../../../src","sources":["core/useTheme.js"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,gBAAgB,QAAQ,QAAQ;AACzC,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAM;EAC1B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGN,QAAQ,CAACC,gBAAgB,CAACM,QAAQ,CAAC,CAAC,CAAC;EAC/DR,SAAS,CAAC,MAAM;IACZ,MAAMS,oBAAoB,GAAGN,iBAAiB,CAACO,YAAY,CAAC,CAACN,kBAAkB,CAACO,KAAK,CAAC,EAAE,MAAMJ,QAAQ,CAACL,gBAAgB,CAACM,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpI,OAAO,MAAM;MACTC,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EACN,OAAOH,KAAK;AAChB,CAAC","ignoreList":[]}
2
-
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- import { useEffect, useState } from 'react';
4
- import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
5
- export const useTheme = () => {
6
- const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
7
- useEffect(() => {
8
- const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
9
- if (dependencies.includes(UnistyleDependency.Theme)) {
10
- setTheme(UnistylesRuntime.getTheme());
11
- }
12
- });
13
- return () => {
14
- removeChangeListener();
15
- };
16
- }, []);
17
- return theme;
18
- };
19
- //# sourceMappingURL=useTheme.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","useTheme","theme","setTheme","getTheme","removeChangeListener","addChangeListener","dependencies","includes","Theme"],"sourceRoot":"../../../src","sources":["core/useTheme.native.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAI3E,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAsB;EAC1C,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGN,QAAQ,CAACG,gBAAgB,CAACI,QAAQ,CAAC,CAAC,CAAC;EAE/DR,SAAS,CAAC,MAAM;IACZ,MAAMS,oBAAoB,GAAIP,UAAU,CAAyBQ,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACT,kBAAkB,CAACU,KAAK,CAAC,EAAE;QACjDN,QAAQ,CAACH,gBAAgB,CAACI,QAAQ,CAAC,CAAC,CAAC;MACzC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTC,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOH,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
4
- const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
5
- const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
6
- export const parseMq = mq => {
7
- const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
8
- const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
9
- return {
10
- minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
11
- maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
12
- minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
13
- maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH)
14
- };
15
- };
16
- export const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
17
- //# sourceMappingURL=mq.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","minWidth","undefined","Number","maxWidth","minHeight","maxHeight","isUnistylesMq","test"],"sourceRoot":"../../../src","sources":["web/mq.ts"],"mappings":";;AAAA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAEpE,OAAO,MAAMC,OAAO,GAAIC,EAAU,IAAK;EACnC,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHQ,QAAQ,EAAE,CAACP,KAAK,IAAIC,KAAK,KAAK,UAAU,GAAGO,SAAS,GAAGC,MAAM,CAACR,KAAK,CAAC;IACpES,QAAQ,EAAE,CAACV,KAAK,IAAIE,GAAG,KAAK,UAAU,GAAGM,SAAS,GAAGC,MAAM,CAACP,GAAG,CAAC;IAChES,SAAS,EAAE,CAACP,MAAM,IAAIC,KAAK,KAAK,UAAU,GAAGG,SAAS,GAAGC,MAAM,CAACJ,KAAK,CAAC;IACtEO,SAAS,EAAE,CAACR,MAAM,IAAIE,GAAG,KAAK,UAAU,GAAGE,SAAS,GAAGC,MAAM,CAACH,GAAG;EACrE,CAAC;AACL,CAAC;AAED,OAAO,MAAMO,aAAa,GAAId,EAAU,IAAKJ,kBAAkB,CAACmB,IAAI,CAACf,EAAE,CAAC","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export declare const useBreakpoint: () => "portrait" | "landscape" | undefined;
2
- //# sourceMappingURL=useBreakpoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBreakpoint.d.ts","sourceRoot":"","sources":["../../../../src/core/useBreakpoint.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,4CAYzB,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const useBreakpoint: () => "portrait" | "landscape" | undefined;
2
- //# sourceMappingURL=useBreakpoint.native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBreakpoint.native.d.ts","sourceRoot":"","sources":["../../../../src/core/useBreakpoint.native.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,4CAgBzB,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { UnistylesTheme } from '../types';
2
- export declare const useTheme: () => UnistylesTheme;
3
- //# sourceMappingURL=useTheme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../../src/core/useTheme.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,eAAO,MAAM,QAAQ,QAAO,cAY3B,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { UnistylesTheme } from '../types';
2
- export declare const useTheme: () => UnistylesTheme;
3
- //# sourceMappingURL=useTheme.native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTheme.native.d.ts","sourceRoot":"","sources":["../../../../src/core/useTheme.native.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,eAAO,MAAM,QAAQ,QAAO,cAgB3B,CAAA"}
@@ -1,8 +0,0 @@
1
- export declare const parseMq: (mq: string) => {
2
- minWidth: number | undefined;
3
- maxWidth: number | undefined;
4
- minHeight: number | undefined;
5
- maxHeight: number | undefined;
6
- };
7
- export declare const isUnistylesMq: (mq: string) => boolean;
8
- //# sourceMappingURL=mq.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/web/mq.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,OAAQ,MAAM;;;;;CAUjC,CAAA;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,YAAgC,CAAA"}
package/src/common.js DELETED
@@ -1,4 +0,0 @@
1
- import { Platform } from 'react-native';
2
- export const isWeb = Platform.OS === 'web';
3
- export const isIOS = Platform.OS === 'ios';
4
- export const isAndroid = Platform.OS === 'android';
@@ -1,6 +0,0 @@
1
- import React, {} from 'react';
2
- export const createUnistylesComponent = (Component, mappings) => {
3
- return (props) => {
4
- return React.createElement(Component, { ...props });
5
- };
6
- };
@@ -1,31 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
3
- export const createUnistylesComponent = (Component, mappings) => {
4
- return (props) => {
5
- const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
6
- const [, setRt] = useState(0);
7
- useEffect(() => {
8
- const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
9
- const componentDependencies = (props.style?.uni__dependencies || mappings(theme).style?.uni__dependencies);
10
- if (dependencies.includes(UnistyleDependency.Theme) && (!componentDependencies || componentDependencies.includes(UnistyleDependency.Theme))) {
11
- setTheme(UnistylesRuntime.getTheme());
12
- }
13
- if (dependencies.some(dependency => dependency >= 2) && (!componentDependencies || componentDependencies.some(dependency => dependency >= 2))) {
14
- setRt(prevState => prevState + 1);
15
- }
16
- });
17
- return () => {
18
- removeChangeListener();
19
- };
20
- }, []);
21
- const mergedProps = { ...mappings(theme) };
22
- Object.keys(props).forEach(key => {
23
- if (key in mergedProps) {
24
- mergedProps[key] = Object.assign(props[key], mergedProps[key]);
25
- return;
26
- }
27
- mergedProps[key] = props[key];
28
- });
29
- return React.createElement(Component, { ...mergedProps });
30
- };
31
- };
package/src/core/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { useBreakpoint } from './useBreakpoint';
2
- export { useTheme } from './useTheme';
3
- export { createUnistylesComponent } from './createUnistylesComponent';
@@ -1,14 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { UnistylesRuntime } from '../web';
3
- import { UnistylesListener } from '../web/listener';
4
- import { UnistyleDependency } from '../specs/NativePlatform';
5
- export const useBreakpoint = () => {
6
- const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
7
- useEffect(() => {
8
- const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint));
9
- return () => {
10
- removeChangeListener();
11
- };
12
- }, []);
13
- return breakpoint;
14
- };
@@ -1,16 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
3
- export const useBreakpoint = () => {
4
- const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
5
- useEffect(() => {
6
- const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
7
- if (dependencies.includes(UnistyleDependency.Breakpoints)) {
8
- setBreakpoint(UnistylesRuntime.breakpoint);
9
- }
10
- });
11
- return () => {
12
- removeChangeListener();
13
- };
14
- }, []);
15
- return breakpoint;
16
- };
@@ -1,21 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
3
- import type { UnistylesStyleSheet } from '../specs'
4
-
5
- export const useBreakpoint = () => {
6
- const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint)
7
-
8
- useEffect(() => {
9
- const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
10
- if (dependencies.includes(UnistyleDependency.Breakpoints)) {
11
- setBreakpoint(UnistylesRuntime.breakpoint)
12
- }
13
- })
14
-
15
- return () => {
16
- removeChangeListener()
17
- }
18
- }, [])
19
-
20
- return breakpoint
21
- }
@@ -1,18 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { UnistylesRuntime } from '../web'
3
- import { UnistylesListener } from '../web/listener'
4
- import { UnistyleDependency } from '../specs/NativePlatform'
5
-
6
- export const useBreakpoint = () => {
7
- const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint)
8
-
9
- useEffect(() => {
10
- const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint))
11
-
12
- return () => {
13
- removeChangeListener()
14
- }
15
- }, [])
16
-
17
- return breakpoint
18
- }
@@ -1,14 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { UnistylesRuntime } from '../web';
3
- import { UnistylesListener } from '../web/listener';
4
- import { UnistyleDependency } from '../specs/NativePlatform';
5
- export const useTheme = () => {
6
- const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
7
- useEffect(() => {
8
- const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()));
9
- return () => {
10
- removeChangeListener();
11
- };
12
- }, []);
13
- return theme;
14
- };
@@ -1,16 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
3
- export const useTheme = () => {
4
- const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
5
- useEffect(() => {
6
- const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
7
- if (dependencies.includes(UnistyleDependency.Theme)) {
8
- setTheme(UnistylesRuntime.getTheme());
9
- }
10
- });
11
- return () => {
12
- removeChangeListener();
13
- };
14
- }, []);
15
- return theme;
16
- };
@@ -1,22 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
3
- import type { UnistylesStyleSheet } from '../specs'
4
- import type { UnistylesTheme } from '../types'
5
-
6
- export const useTheme = (): UnistylesTheme => {
7
- const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
8
-
9
- useEffect(() => {
10
- const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
11
- if (dependencies.includes(UnistyleDependency.Theme)) {
12
- setTheme(UnistylesRuntime.getTheme())
13
- }
14
- })
15
-
16
- return () => {
17
- removeChangeListener()
18
- }
19
- }, [])
20
-
21
- return theme
22
- }
@@ -1,19 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { UnistylesRuntime } from '../web'
3
- import { UnistylesListener } from '../web/listener'
4
- import { UnistyleDependency } from '../specs/NativePlatform'
5
- import type { UnistylesTheme } from '../types'
6
-
7
- export const useTheme = (): UnistylesTheme => {
8
- const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
9
-
10
- useEffect(() => {
11
- const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()))
12
-
13
- return () => {
14
- removeChangeListener()
15
- }
16
- }, [])
17
-
18
- return theme
19
- }
package/src/global.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/src/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './specs';
2
- export { mq } from './mq';
3
- export { useTheme, useBreakpoint, createUnistylesComponent } from './core';
package/src/mq.js DELETED
@@ -1,38 +0,0 @@
1
- const getMQValue = (value) => {
2
- if (typeof value === 'number') {
3
- return value;
4
- }
5
- if (value === null) {
6
- return 0;
7
- }
8
- // todo take it from js
9
- const breakpoints = {
10
- xs: 0,
11
- sm: 300,
12
- md: 500,
13
- lg: 800,
14
- xl: 1200
15
- };
16
- // @ts-ignore
17
- return breakpoints[value] ?? 0;
18
- };
19
- /**
20
- * Utility to create cross-platform media queries
21
- * @returns - JavaScript symbol to be used in your stylesheet
22
- */
23
- export const mq = {
24
- only: {
25
- width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
26
- height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
27
- },
28
- width: (wMin = 0, wMax = Infinity) => ({
29
- and: {
30
- height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
31
- }
32
- }),
33
- height: (hMin = 0, hMax = Infinity) => ({
34
- and: {
35
- width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
36
- }
37
- })
38
- };
@@ -1,19 +0,0 @@
1
- import {} from '../types';
2
- export var UnistyleDependency;
3
- (function (UnistyleDependency) {
4
- UnistyleDependency[UnistyleDependency["Theme"] = 0] = "Theme";
5
- UnistyleDependency[UnistyleDependency["ThemeName"] = 1] = "ThemeName";
6
- UnistyleDependency[UnistyleDependency["AdaptiveThemes"] = 2] = "AdaptiveThemes";
7
- UnistyleDependency[UnistyleDependency["Breakpoints"] = 3] = "Breakpoints";
8
- UnistyleDependency[UnistyleDependency["Variants"] = 4] = "Variants";
9
- UnistyleDependency[UnistyleDependency["ColorScheme"] = 5] = "ColorScheme";
10
- UnistyleDependency[UnistyleDependency["Dimensions"] = 6] = "Dimensions";
11
- UnistyleDependency[UnistyleDependency["Orientation"] = 7] = "Orientation";
12
- UnistyleDependency[UnistyleDependency["ContentSizeCategory"] = 8] = "ContentSizeCategory";
13
- UnistyleDependency[UnistyleDependency["Insets"] = 9] = "Insets";
14
- UnistyleDependency[UnistyleDependency["PixelRatio"] = 10] = "PixelRatio";
15
- UnistyleDependency[UnistyleDependency["FontScale"] = 11] = "FontScale";
16
- UnistyleDependency[UnistyleDependency["StatusBar"] = 12] = "StatusBar";
17
- UnistyleDependency[UnistyleDependency["NavigationBar"] = 13] = "NavigationBar";
18
- UnistyleDependency[UnistyleDependency["Ime"] = 14] = "Ime";
19
- })(UnistyleDependency || (UnistyleDependency = {}));
@@ -1 +0,0 @@
1
- export { UnistyleDependency } from './NativePlatform.nitro';
@@ -1,9 +0,0 @@
1
- import { processColor } from 'react-native';
2
- export const attachNavigationBarJSMethods = (hybridObject) => {
3
- const privateHybrid = hybridObject;
4
- privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
5
- hybridObject.setBackgroundColor = (color) => {
6
- const parsedColor = processColor(color) ?? 0;
7
- privateHybrid._setBackgroundColor(parsedColor);
8
- };
9
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import { NitroModules } from 'react-native-nitro-modules';
2
- const HybridShadowRegistry = NitroModules.createHybridObject('UnistylesShadowRegistry');
3
- const findShadowNodeForHandle = (handle) => {
4
- const node = handle?.__internalInstanceHandle?.stateNode?.node
5
- ?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node
6
- ?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node;
7
- if (!node) {
8
- // todo extend log with file name / component name
9
- throw new Error('Could not find shadow node for one of your components');
10
- }
11
- return node;
12
- };
13
- HybridShadowRegistry.add = (handle, style, variants, args) => {
14
- // virtualized nodes can be null
15
- if (!handle || !style) {
16
- return;
17
- }
18
- HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
19
- };
20
- HybridShadowRegistry.remove = handle => {
21
- if (!handle) {
22
- return;
23
- }
24
- HybridShadowRegistry.unlink(findShadowNodeForHandle(handle));
25
- };
26
- export const UnistylesShadowRegistry = HybridShadowRegistry;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- import { processColor, StatusBar as NativeStatusBar } from 'react-native';
2
- import { StatusBarStyle } from '../types';
3
- export const attachStatusBarJSMethods = (hybridObject) => {
4
- hybridObject.setStyle = (style, animated) => {
5
- switch (style) {
6
- case StatusBarStyle.Light:
7
- return NativeStatusBar.setBarStyle('light-content', animated);
8
- case StatusBarStyle.Dark:
9
- return NativeStatusBar.setBarStyle('dark-content', animated);
10
- case StatusBarStyle.Default:
11
- return NativeStatusBar.setBarStyle('default', animated);
12
- }
13
- };
14
- const privateHybrid = hybridObject;
15
- privateHybrid._setHidden = hybridObject.setHidden;
16
- hybridObject.setHidden = (isHidden, animation) => {
17
- NativeStatusBar.setHidden(isHidden, animation);
18
- privateHybrid._setHidden(isHidden);
19
- };
20
- privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
21
- hybridObject.setBackgroundColor = (color) => {
22
- const parsedColor = processColor(color) ?? 0;
23
- privateHybrid._setBackgroundColor(parsedColor);
24
- };
25
- };
@@ -1 +0,0 @@
1
- import { UnistyleDependency } from '../NativePlatform';
@@ -1,13 +0,0 @@
1
- import { NitroModules } from 'react-native-nitro-modules';
2
- import { processColor, StyleSheet as NativeStyleSheet } from 'react-native';
3
- const HybridUnistylesStyleSheet = NitroModules
4
- .createHybridObject('UnistylesStyleSheet');
5
- HybridUnistylesStyleSheet.absoluteFillObject = NativeStyleSheet.absoluteFillObject;
6
- HybridUnistylesStyleSheet.absoluteFill = NativeStyleSheet.absoluteFill;
7
- HybridUnistylesStyleSheet.flatten = NativeStyleSheet.flatten;
8
- HybridUnistylesStyleSheet.compose = NativeStyleSheet.compose;
9
- HybridUnistylesStyleSheet.jsMethods = {
10
- processColor
11
- };
12
- HybridUnistylesStyleSheet.init();
13
- export const StyleSheet = HybridUnistylesStyleSheet;
@@ -1,2 +0,0 @@
1
- import { TurboModuleRegistry } from 'react-native';
2
- TurboModuleRegistry.get('Unistyles');
@@ -1 +0,0 @@
1
- import './NativeTurboUnistyles';
@@ -1 +0,0 @@
1
- export {};