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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) 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 +5 -0
  39. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -2
  40. package/lib/commonjs/specs/ShadowRegistry/types.js +0 -4
  41. package/lib/commonjs/specs/ShadowRegistry/types.js.map +1 -1
  42. package/lib/commonjs/specs/StatusBar/index.js.map +1 -2
  43. package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js +4 -2
  44. package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -1
  45. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +3 -1
  46. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -2
  47. package/lib/commonjs/specs/TurboUnistyles/index.js.map +1 -1
  48. package/lib/commonjs/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +1 -1
  49. package/lib/commonjs/specs/index.web.js.map +1 -2
  50. package/lib/commonjs/specs/types.js +10 -10
  51. package/lib/commonjs/specs/types.js.map +1 -1
  52. package/lib/commonjs/types/accessibility.js +9 -9
  53. package/lib/commonjs/types/accessibility.js.map +1 -1
  54. package/lib/commonjs/types/breakpoints.js.map +1 -1
  55. package/lib/commonjs/types/common.js +0 -4
  56. package/lib/commonjs/types/common.js.map +1 -1
  57. package/lib/commonjs/types/core.js.map +1 -1
  58. package/lib/commonjs/types/index.js.map +1 -2
  59. package/lib/commonjs/types/stylesheet.js +2 -1
  60. package/lib/commonjs/types/stylesheet.js.map +1 -2
  61. package/lib/commonjs/web/convert/index.js +7 -1
  62. package/lib/commonjs/web/convert/index.js.map +1 -2
  63. package/lib/commonjs/web/convert/pseudo.js.map +1 -2
  64. package/lib/commonjs/web/convert/shadow.js +5 -1
  65. package/lib/commonjs/web/convert/shadow.js.map +1 -2
  66. package/lib/commonjs/web/convert/style.js.map +1 -2
  67. package/lib/commonjs/web/convert/textShadow.js.map +1 -2
  68. package/lib/commonjs/web/convert/transform.js.map +1 -2
  69. package/lib/commonjs/web/convert/types.js.map +1 -1
  70. package/lib/commonjs/web/convert/utils.js +2 -1
  71. package/lib/commonjs/web/convert/utils.js.map +1 -2
  72. package/lib/commonjs/web/index.js.map +1 -2
  73. package/lib/commonjs/web/listener.js.map +1 -2
  74. package/lib/commonjs/web/mock.js.map +1 -2
  75. package/lib/commonjs/web/runtime.js.map +1 -2
  76. package/lib/commonjs/web/shadowRegistry.js +9 -1
  77. package/lib/commonjs/web/shadowRegistry.js.map +1 -2
  78. package/lib/commonjs/web/state.js +5 -1
  79. package/lib/commonjs/web/utils/common.js +3 -1
  80. package/lib/commonjs/web/utils/common.js.map +1 -2
  81. package/lib/commonjs/web/utils/index.js.map +1 -1
  82. package/lib/commonjs/web/utils/unistyle.js +1 -1
  83. package/lib/commonjs/web/variants/index.js.map +1 -1
  84. package/lib/module/common.js.map +1 -1
  85. package/lib/module/components/Display.js +13 -0
  86. package/lib/module/components/Display.js.map +1 -0
  87. package/lib/module/components/Hide.js +13 -0
  88. package/lib/module/components/Hide.js.map +1 -0
  89. package/lib/module/components/index.js +5 -0
  90. package/lib/module/components/index.js.map +1 -0
  91. package/lib/module/components/useMedia.js +54 -0
  92. package/lib/module/components/useMedia.js.map +1 -0
  93. package/lib/module/core/createUnistylesComponent.js +2 -1
  94. package/lib/module/core/createUnistylesComponent.js.map +1 -1
  95. package/lib/module/core/createUnistylesComponent.native.js +41 -3
  96. package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
  97. package/lib/module/core/index.js +0 -2
  98. package/lib/module/core/index.js.map +1 -1
  99. package/lib/module/global.js +1 -1
  100. package/lib/module/global.js.map +0 -1
  101. package/lib/module/index.js +2 -1
  102. package/lib/module/index.js.map +1 -1
  103. package/lib/module/mq.js +21 -11
  104. package/lib/module/mq.js.map +1 -1
  105. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +0 -1
  106. package/lib/module/specs/NativePlatform/index.js.map +1 -1
  107. package/lib/module/specs/NavigtionBar/UnistylesNavigationBar.nitro.js.map +0 -1
  108. package/lib/module/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +0 -1
  109. package/lib/module/specs/ShadowRegistry/index.js +5 -0
  110. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  111. package/lib/module/specs/ShadowRegistry/types.js +0 -2
  112. package/lib/module/specs/ShadowRegistry/types.js.map +1 -1
  113. package/lib/module/specs/StatusBar/UnistylesStatusBar.nitro.js.map +1 -1
  114. package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -1
  115. package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +0 -1
  116. package/lib/module/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +0 -1
  117. package/lib/module/specs/index.web.js.map +1 -2
  118. package/lib/module/specs/types.js.map +0 -1
  119. package/lib/module/types/accessibility.js +1 -1
  120. package/lib/module/types/accessibility.js.map +0 -1
  121. package/lib/module/types/breakpoints.js.map +0 -1
  122. package/lib/module/types/common.js +1 -1
  123. package/lib/module/types/common.js.map +0 -1
  124. package/lib/module/types/core.js.map +0 -1
  125. package/lib/module/types/index.js.map +1 -2
  126. package/lib/module/types/stylesheet.js +2 -2
  127. package/lib/module/types/stylesheet.js.map +1 -2
  128. package/lib/module/types/variants.js.map +0 -1
  129. package/lib/module/web/convert/boxShadow.js +4 -1
  130. package/lib/module/web/convert/boxShadow.js.map +1 -2
  131. package/lib/module/web/convert/index.js +7 -1
  132. package/lib/module/web/convert/shadow.js +5 -1
  133. package/lib/module/web/convert/shadow.js.map +1 -2
  134. package/lib/module/web/convert/textShadow.js +4 -1
  135. package/lib/module/web/convert/utils.js +2 -1
  136. package/lib/module/web/convert/utils.js.map +1 -2
  137. package/lib/module/web/create.js +5 -1
  138. package/lib/module/web/create.js.map +1 -2
  139. package/lib/module/web/index.js +2 -1
  140. package/lib/module/web/index.js.map +1 -2
  141. package/lib/module/web/listener.js.map +1 -2
  142. package/lib/module/web/registry.js +3 -1
  143. package/lib/module/web/shadowRegistry.js +9 -1
  144. package/lib/module/web/shadowRegistry.js.map +1 -2
  145. package/lib/module/web/state.js +5 -1
  146. package/lib/module/web/state.js.map +1 -2
  147. package/lib/module/web/utils/common.js +3 -1
  148. package/lib/module/web/utils/common.js.map +1 -2
  149. package/lib/module/web/utils/unistyle.js +1 -1
  150. package/lib/module/web/utils/unistyle.js.map +1 -1
  151. package/lib/module/web/variants/getVariants.js.map +1 -2
  152. package/lib/module/web/variants/index.js.map +1 -1
  153. package/lib/typescript/src/components/Display.d.ts +7 -0
  154. package/lib/typescript/src/components/Display.d.ts.map +1 -0
  155. package/lib/typescript/src/components/Hide.d.ts +7 -0
  156. package/lib/typescript/src/components/Hide.d.ts.map +1 -0
  157. package/lib/typescript/src/components/index.d.ts +3 -0
  158. package/lib/typescript/src/components/index.d.ts.map +1 -0
  159. package/lib/typescript/src/components/useMedia.d.ts +6 -0
  160. package/lib/typescript/src/components/useMedia.d.ts.map +1 -0
  161. package/lib/typescript/src/core/createUnistylesComponent.d.ts +3 -2
  162. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
  163. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +3 -2
  164. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
  165. package/lib/typescript/src/core/index.d.ts +0 -2
  166. package/lib/typescript/src/core/index.d.ts.map +1 -1
  167. package/lib/typescript/src/index.d.ts +2 -1
  168. package/lib/typescript/src/index.d.ts.map +1 -1
  169. package/lib/typescript/src/mq.d.ts +8 -0
  170. package/lib/typescript/src/mq.d.ts.map +1 -1
  171. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  172. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +3 -0
  173. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  174. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -0
  175. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  176. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -0
  177. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +2 -0
  178. package/package.json +1 -1
  179. package/plugin/ref.js +4 -4
  180. package/plugin/style.js +15 -3
  181. package/src/components/Display.tsx +12 -0
  182. package/src/components/Hide.tsx +12 -0
  183. package/src/components/index.ts +2 -0
  184. package/src/components/useMedia.ts +64 -0
  185. package/src/core/createUnistylesComponent.native.tsx +48 -4
  186. package/src/core/createUnistylesComponent.tsx +4 -2
  187. package/src/core/index.ts +0 -2
  188. package/src/index.ts +2 -1
  189. package/src/mq.ts +27 -9
  190. package/src/specs/ShadowRegistry/index.ts +5 -0
  191. package/src/specs/ShadowRegistry/types.ts +4 -1
  192. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -0
  193. package/src/web/utils/unistyle.ts +1 -1
  194. package/lib/commonjs/core/useBreakpoint.js +0 -22
  195. package/lib/commonjs/core/useBreakpoint.js.map +0 -1
  196. package/lib/commonjs/core/useBreakpoint.native.js +0 -24
  197. package/lib/commonjs/core/useBreakpoint.native.js.map +0 -1
  198. package/lib/commonjs/core/useTheme.js +0 -22
  199. package/lib/commonjs/core/useTheme.js.map +0 -2
  200. package/lib/commonjs/core/useTheme.native.js +0 -24
  201. package/lib/commonjs/core/useTheme.native.js.map +0 -1
  202. package/lib/commonjs/web/mq.js +0 -23
  203. package/lib/commonjs/web/mq.js.map +0 -1
  204. package/lib/module/core/useBreakpoint.js +0 -17
  205. package/lib/module/core/useBreakpoint.js.map +0 -1
  206. package/lib/module/core/useBreakpoint.native.js +0 -19
  207. package/lib/module/core/useBreakpoint.native.js.map +0 -2
  208. package/lib/module/core/useTheme.js +0 -17
  209. package/lib/module/core/useTheme.js.map +0 -2
  210. package/lib/module/core/useTheme.native.js +0 -19
  211. package/lib/module/core/useTheme.native.js.map +0 -1
  212. package/lib/module/web/mq.js +0 -17
  213. package/lib/module/web/mq.js.map +0 -1
  214. package/lib/typescript/src/core/useBreakpoint.d.ts +0 -2
  215. package/lib/typescript/src/core/useBreakpoint.d.ts.map +0 -1
  216. package/lib/typescript/src/core/useBreakpoint.native.d.ts +0 -2
  217. package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +0 -1
  218. package/lib/typescript/src/core/useTheme.d.ts +0 -3
  219. package/lib/typescript/src/core/useTheme.d.ts.map +0 -1
  220. package/lib/typescript/src/core/useTheme.native.d.ts +0 -3
  221. package/lib/typescript/src/core/useTheme.native.d.ts.map +0 -1
  222. package/lib/typescript/src/web/mq.d.ts +0 -8
  223. package/lib/typescript/src/web/mq.d.ts.map +0 -1
  224. package/src/common.js +0 -4
  225. package/src/core/createUnistylesComponent.js +0 -6
  226. package/src/core/createUnistylesComponent.native.js +0 -31
  227. package/src/core/index.js +0 -3
  228. package/src/core/useBreakpoint.js +0 -14
  229. package/src/core/useBreakpoint.native.js +0 -16
  230. package/src/core/useBreakpoint.native.ts +0 -21
  231. package/src/core/useBreakpoint.ts +0 -18
  232. package/src/core/useTheme.js +0 -14
  233. package/src/core/useTheme.native.js +0 -16
  234. package/src/core/useTheme.native.ts +0 -22
  235. package/src/core/useTheme.ts +0 -19
  236. package/src/global.js +0 -1
  237. package/src/index.js +0 -3
  238. package/src/mq.js +0 -38
  239. package/src/specs/NativePlatform/NativePlatform.nitro.js +0 -19
  240. package/src/specs/NativePlatform/index.js +0 -1
  241. package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.js +0 -1
  242. package/src/specs/NavigtionBar/index.js +0 -9
  243. package/src/specs/ShadowRegistry/ShadowRegistry.nitro.js +0 -1
  244. package/src/specs/ShadowRegistry/index.js +0 -26
  245. package/src/specs/ShadowRegistry/types.js +0 -1
  246. package/src/specs/StatusBar/UnistylesStatusBar.nitro.js +0 -1
  247. package/src/specs/StatusBar/index.js +0 -25
  248. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.js +0 -1
  249. package/src/specs/StyleSheet/index.js +0 -13
  250. package/src/specs/TurboUnistyles/NativeTurboUnistyles.js +0 -2
  251. package/src/specs/TurboUnistyles/index.js +0 -1
  252. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.js +0 -1
  253. package/src/specs/UnistylesRuntime/index.js +0 -20
  254. package/src/specs/index.js +0 -8
  255. package/src/specs/index.web.js +0 -2
  256. package/src/specs/types.js +0 -17
  257. package/src/types/accessibility.js +0 -30
  258. package/src/types/breakpoints.js +0 -1
  259. package/src/types/common.js +0 -1
  260. package/src/types/core.js +0 -1
  261. package/src/types/index.js +0 -1
  262. package/src/types/stylesheet.js +0 -2
  263. package/src/types/variants.js +0 -1
  264. package/src/web/convert/boxShadow.js +0 -59
  265. package/src/web/convert/index.js +0 -56
  266. package/src/web/convert/pseudo.js +0 -131
  267. package/src/web/convert/shadow.js +0 -50
  268. package/src/web/convert/style.js +0 -137
  269. package/src/web/convert/textShadow.js +0 -56
  270. package/src/web/convert/transform.js +0 -65
  271. package/src/web/convert/types.js +0 -2
  272. package/src/web/convert/utils.js +0 -39
  273. package/src/web/create.js +0 -36
  274. package/src/web/index.js +0 -22
  275. package/src/web/listener.js +0 -26
  276. package/src/web/mock.js +0 -21
  277. package/src/web/mq.js +0 -14
  278. package/src/web/mq.ts +0 -17
  279. package/src/web/registry.js +0 -165
  280. package/src/web/runtime.js +0 -160
  281. package/src/web/shadowRegistry.js +0 -96
  282. package/src/web/state.js +0 -68
  283. package/src/web/utils/common.js +0 -79
  284. package/src/web/utils/index.js +0 -2
  285. package/src/web/utils/unistyle.js +0 -72
  286. package/src/web/variants/getVariants.js +0 -26
  287. package/src/web/variants/index.js +0 -2
  288. package/src/web/variants/useVariants.js +0 -50
@@ -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 {};
@@ -1,20 +0,0 @@
1
- import { processColor } from 'react-native';
2
- import { NitroModules } from 'react-native-nitro-modules';
3
- import { attachStatusBarJSMethods } from '../StatusBar';
4
- import { attachNavigationBarJSMethods } from '../NavigtionBar';
5
- import { isIOS } from '../../common';
6
- const HybridUnistylesRuntime = NitroModules
7
- .createHybridObject('UnistylesRuntime');
8
- HybridUnistylesRuntime.statusBar = HybridUnistylesRuntime.createHybridStatusBar();
9
- HybridUnistylesRuntime.navigationBar = HybridUnistylesRuntime.createHybridNavigationBar();
10
- HybridUnistylesRuntime._setRootViewBackgroundColor = HybridUnistylesRuntime.setRootViewBackgroundColor;
11
- HybridUnistylesRuntime.setRootViewBackgroundColor = (color) => {
12
- const parsedColor = processColor(color) ?? 0;
13
- HybridUnistylesRuntime._setRootViewBackgroundColor(parsedColor);
14
- };
15
- if (isIOS) {
16
- HybridUnistylesRuntime.setImmersiveMode = (isEnabled) => HybridUnistylesRuntime.statusBar.setHidden(isEnabled, 'fade');
17
- }
18
- attachStatusBarJSMethods(HybridUnistylesRuntime.statusBar);
19
- attachNavigationBarJSMethods(HybridUnistylesRuntime.navigationBar);
20
- export const Runtime = HybridUnistylesRuntime;
@@ -1,8 +0,0 @@
1
- import './TurboUnistyles';
2
- import { Runtime } from './UnistylesRuntime';
3
- import { StyleSheet } from './StyleSheet';
4
- import { UnistylesShadowRegistry } from './ShadowRegistry';
5
- import { StatusBarStyle, ColorScheme, Orientation } from './types';
6
- import { UnistyleDependency } from './NativePlatform';
7
- export { StatusBarStyle, ColorScheme, Orientation, UnistyleDependency };
8
- export { UnistylesShadowRegistry, Runtime as UnistylesRuntime, StyleSheet, };
@@ -1,2 +0,0 @@
1
- export const getSSRUnistyles = () => [];
2
- export * from '../web';
@@ -1,17 +0,0 @@
1
- export var ColorScheme;
2
- (function (ColorScheme) {
3
- ColorScheme["Light"] = "light";
4
- ColorScheme["Dark"] = "dark";
5
- ColorScheme["Unspecified"] = "unspecified";
6
- })(ColorScheme || (ColorScheme = {}));
7
- export var Orientation;
8
- (function (Orientation) {
9
- Orientation["Portrait"] = "portrait";
10
- Orientation["Landscape"] = "landscape";
11
- })(Orientation || (Orientation = {}));
12
- export var StatusBarStyle;
13
- (function (StatusBarStyle) {
14
- StatusBarStyle["Default"] = "default";
15
- StatusBarStyle["Light"] = "light";
16
- StatusBarStyle["Dark"] = "dark";
17
- })(StatusBarStyle || (StatusBarStyle = {}));
@@ -1,30 +0,0 @@
1
- export var IOSContentSizeCategory;
2
- (function (IOSContentSizeCategory) {
3
- IOSContentSizeCategory["AccessibilityExtraExtraExtraLarge"] = "accessibilityExtraExtraExtraLarge";
4
- IOSContentSizeCategory["AccessibilityExtraExtraLarge"] = "accessibilityExtraExtraLarge";
5
- IOSContentSizeCategory["AccessibilityExtraLarge"] = "accessibilityExtraLarge";
6
- IOSContentSizeCategory["AccessibilityLarge"] = "accessibilityLarge";
7
- IOSContentSizeCategory["AccessibilityMedium"] = "accessibilityMedium";
8
- IOSContentSizeCategory["ExtraExtraExtraLarge"] = "xxxLarge";
9
- IOSContentSizeCategory["ExtraExtraLarge"] = "xxLarge";
10
- IOSContentSizeCategory["ExtraLarge"] = "xLarge";
11
- IOSContentSizeCategory["Large"] = "Large";
12
- IOSContentSizeCategory["Medium"] = "Medium";
13
- IOSContentSizeCategory["Small"] = "Small";
14
- IOSContentSizeCategory["ExtraSmall"] = "xSmall";
15
- IOSContentSizeCategory["Unspecified"] = "unspecified";
16
- })(IOSContentSizeCategory || (IOSContentSizeCategory = {}));
17
- export var AndroidContentSizeCategory;
18
- (function (AndroidContentSizeCategory) {
19
- AndroidContentSizeCategory["Small"] = "Small";
20
- AndroidContentSizeCategory["Default"] = "Default";
21
- AndroidContentSizeCategory["Large"] = "Large";
22
- AndroidContentSizeCategory["ExtraLarge"] = "ExtraLarge";
23
- AndroidContentSizeCategory["Huge"] = "Huge";
24
- AndroidContentSizeCategory["ExtraHuge"] = "ExtraHuge";
25
- AndroidContentSizeCategory["ExtraExtraHuge"] = "ExtraExtraHuge";
26
- })(AndroidContentSizeCategory || (AndroidContentSizeCategory = {}));
27
- export var WebContentSizeCategory;
28
- (function (WebContentSizeCategory) {
29
- WebContentSizeCategory["Unspecified"] = "web-unspecified";
30
- })(WebContentSizeCategory || (WebContentSizeCategory = {}));
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/src/types/core.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export { AndroidContentSizeCategory, IOSContentSizeCategory, WebContentSizeCategory } from './accessibility';
@@ -1,2 +0,0 @@
1
- const create = (stylesheet) => stylesheet;
2
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,59 +0,0 @@
1
- import { deepMergeObjects, warn } from '../utils';
2
- import { validateShadow } from './shadow';
3
- import { BOX_SHADOW_STYLES } from './types';
4
- import { extractShadowValue, normalizeColor, normalizeNumericValue } from './utils';
5
- const createBoxShadowValue = (style) => {
6
- // at this point every prop is present
7
- const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
8
- const offsetX = normalizeNumericValue(shadowOffset.width);
9
- const offsetY = normalizeNumericValue(shadowOffset.height);
10
- const radius = normalizeNumericValue(shadowRadius);
11
- const color = normalizeColor(shadowColor, shadowOpacity);
12
- return `${offsetX} ${offsetY} ${radius} ${color}`;
13
- };
14
- export const getBoxShadowStyle = (styles) => {
15
- const missingStyles = BOX_SHADOW_STYLES.filter(key => !(key in styles));
16
- if (missingStyles.length) {
17
- warn(`can't apply box shadow as you miss these properties: ${missingStyles.join(', ')}`);
18
- return {};
19
- }
20
- const breakpointsSet = new Set();
21
- try {
22
- validateShadow(BOX_SHADOW_STYLES, styles, breakpointsSet);
23
- }
24
- catch (error) {
25
- if (typeof error === 'string') {
26
- warn(error);
27
- }
28
- return {};
29
- }
30
- const breakpoints = Array.from(breakpointsSet);
31
- // If no breakpoints were used return styles without media queries
32
- if (breakpoints.length === 0) {
33
- return {
34
- boxShadow: createBoxShadowValue(styles)
35
- };
36
- }
37
- // Create boxShadow for each breakpoint
38
- const breakpointStyles = breakpoints.map(breakpoint => {
39
- const color = extractShadowValue('shadowColor', breakpoint, styles);
40
- const { width, height } = extractShadowValue('shadowOffset', breakpoint, styles);
41
- const radius = extractShadowValue('shadowRadius', breakpoint, styles);
42
- const opacity = extractShadowValue('shadowOpacity', breakpoint, styles);
43
- return {
44
- [breakpoint]: {
45
- boxShadow: createBoxShadowValue({
46
- shadowColor: color,
47
- shadowOffset: {
48
- width,
49
- height
50
- },
51
- shadowRadius: radius,
52
- shadowOpacity: opacity
53
- })
54
- }
55
- };
56
- });
57
- // Merge all breakpoints styles into one
58
- return deepMergeObjects(...breakpointStyles);
59
- };
@@ -1,56 +0,0 @@
1
- import { isPseudo } from './pseudo';
2
- import { getStyle } from './style';
3
- import { deepMergeObjects } from '../utils';
4
- import { getTransformStyle } from './transform';
5
- import { isBoxShadow, isTextShadow, isTransform } from './utils';
6
- import { getTextShadowStyle } from './textShadow';
7
- import { getBoxShadowStyle } from './boxShadow';
8
- export const convertUnistyles = (value) => {
9
- // Flag to mark if textShadow is already created
10
- let hasTextShadow = false;
11
- // Flag to mark if boxShadow is already created
12
- let hasBoxShadow = false;
13
- const stylesArray = Object.entries({
14
- ...value,
15
- ...value._web
16
- }).flatMap(([unistylesKey, unistylesValue]) => {
17
- // Keys to omit
18
- if (['_classNames', '_web', 'variants', 'compoundVariants', 'uni__dependencies', '__unistyles-secrets__'].includes(unistylesKey) || unistylesKey.startsWith('variant-')) {
19
- return [];
20
- }
21
- // Pseudo classes :hover, :before etc.
22
- if (isPseudo(unistylesKey)) {
23
- const flattenValues = convertUnistyles(unistylesValue);
24
- return { [unistylesKey]: flattenValues };
25
- }
26
- // Text shadow
27
- if (isTextShadow(unistylesKey)) {
28
- if (hasTextShadow) {
29
- return [];
30
- }
31
- hasTextShadow = true;
32
- return getTextShadowStyle(value);
33
- }
34
- // Box shadow
35
- if (isBoxShadow(unistylesKey)) {
36
- if (hasBoxShadow) {
37
- return [];
38
- }
39
- hasBoxShadow = true;
40
- return getBoxShadowStyle(value);
41
- }
42
- // Transforms
43
- if (isTransform(unistylesKey, unistylesValue)) {
44
- return getTransformStyle(unistylesValue);
45
- }
46
- // Breakpoints
47
- if (typeof unistylesValue === 'object' && unistylesValue !== null) {
48
- return Object.entries(unistylesValue).map(([breakpointKey, breakpointValue]) => {
49
- return { [breakpointKey]: getStyle(unistylesKey, breakpointValue) };
50
- });
51
- }
52
- // Regular styles
53
- return getStyle(unistylesKey, unistylesValue);
54
- });
55
- return deepMergeObjects(...stylesArray);
56
- };
@@ -1,131 +0,0 @@
1
- export const pseudos = [
2
- '_-moz-broken',
3
- '_-moz-drag-over',
4
- '_-moz-first-node',
5
- '_-moz-handler-blocked',
6
- '_-moz-handler-crashed',
7
- '_-moz-handler-disabled',
8
- '_-moz-last-node',
9
- '_-moz-loading',
10
- '_-moz-locale-dir(ltr)',
11
- '_-moz-locale-dir(rtl)',
12
- '_-moz-only-whitespace',
13
- '_-moz-submit-invalid',
14
- '_-moz-suppressed',
15
- '_-moz-user-disabled',
16
- '_-moz-window-inactive',
17
- '_active',
18
- '_any-link',
19
- '_autofill',
20
- '_blank',
21
- '_buffering',
22
- '_checked',
23
- '_current',
24
- '_default',
25
- '_defined',
26
- '_dir(',
27
- '_disabled',
28
- '_empty',
29
- '_enabled',
30
- '_first',
31
- '_first-child',
32
- '_first-of-type',
33
- '_focus',
34
- '_focus-visible',
35
- '_focus-within',
36
- '_fullscreen',
37
- '_future',
38
- '_has(',
39
- '_host',
40
- '_host-context(',
41
- '_host(',
42
- '_hover',
43
- '_in-range',
44
- '_indeterminate',
45
- '_invalid',
46
- '_is(',
47
- '_lang(',
48
- '_last-child',
49
- '_last-of-type',
50
- '_left',
51
- '_link',
52
- '_local-link',
53
- '_modal',
54
- '_muted',
55
- '_not(',
56
- '_nth-child(',
57
- '_nth-last-child(',
58
- '_nth-last-of-type(',
59
- '_nth-of-type(',
60
- '_only-child',
61
- '_only-of-type',
62
- '_optional',
63
- '_out-of-range',
64
- '_past',
65
- '_paused',
66
- '_picture-in-picture',
67
- '_placeholder-shown',
68
- '_playing',
69
- '_popover-open',
70
- '_read-only',
71
- '_read-write',
72
- '_required',
73
- '_right',
74
- '_scope',
75
- '_seeking',
76
- '_stalled',
77
- '_state(',
78
- '_target',
79
- '_target-within',
80
- '_user-invalid',
81
- '_user-valid',
82
- '_valid',
83
- '_visited',
84
- '_volume-locked',
85
- '_where(',
86
- '_-moz-color-swatch',
87
- '_-moz-focus-inner',
88
- '_-moz-list-bullet',
89
- '_-moz-list-number',
90
- '_-moz-meter-bar',
91
- '_-moz-progress-bar',
92
- '_-moz-range-progress',
93
- '_-moz-range-thumb',
94
- '_-moz-range-track',
95
- '_-webkit-inner-spin-button',
96
- '_-webkit-meter-barDeprecated',
97
- '_-webkit-meter-even-less-good-value',
98
- '_-webkit-meter-inner-element',
99
- '_-webkit-meter-optimum-value',
100
- '_-webkit-meter-suboptimum-value',
101
- '_-webkit-progress-bar',
102
- '_-webkit-progress-inner-element',
103
- '_-webkit-progress-value',
104
- '_-webkit-scrollbar',
105
- '_-webkit-search-cancel-button',
106
- '_-webkit-search-results-button',
107
- '_-webkit-slider-runnable-track',
108
- '_-webkit-slider-thumb',
109
- '_after',
110
- '_backdrop',
111
- '_before',
112
- '_cue',
113
- '_file-selector-button',
114
- '_first-letter',
115
- '_first-line',
116
- '_grammar-error',
117
- '_highlight(',
118
- '_marker',
119
- '_part(',
120
- '_placeholder',
121
- '_selection',
122
- '_slotted(',
123
- '_spelling-error',
124
- '_target-text',
125
- '_view-transition',
126
- '_view-transition-group',
127
- '_view-transition-image-pair',
128
- '_view-transition-new',
129
- '_view-transition-old',
130
- ];
131
- export const isPseudo = (selector) => pseudos.some(pseudo => selector.startsWith(pseudo));
@@ -1,50 +0,0 @@
1
- export const validateShadow = (shadowProperties, styles, breakpoints) => {
2
- // Collect breakpoints
3
- shadowProperties.forEach(key => {
4
- const value = styles[key];
5
- if (typeof value !== 'object') {
6
- return;
7
- }
8
- if (key === 'shadowOffset' || key === 'textShadowOffset') {
9
- const { width, height } = value;
10
- // If shadowOffset.width has breakpoints
11
- if (typeof width === 'object') {
12
- Object.keys(width).forEach(breakpoint => breakpoints.add(breakpoint));
13
- }
14
- // If shadowOffset.height has breakpoints
15
- if (typeof height === 'object') {
16
- Object.keys(height).forEach(breakpoint => breakpoints.add(breakpoint));
17
- }
18
- return;
19
- }
20
- // Collect regular breakpoints
21
- Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
22
- });
23
- // Validate if all breakpoints are present
24
- shadowProperties.forEach(key => {
25
- const value = styles[key];
26
- if (typeof value !== 'object') {
27
- return;
28
- }
29
- if (key === 'shadowOffset' || key === 'textShadowOffset') {
30
- const { width, height } = value;
31
- if (typeof width === 'object') {
32
- const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in width));
33
- if (missingBreakpoints.length) {
34
- throw `missing breakpoints in ${key}.width: ${missingBreakpoints.join(', ')}`;
35
- }
36
- }
37
- if (typeof height === 'object') {
38
- const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in height));
39
- if (missingBreakpoints.length) {
40
- throw `missing breakpoints in ${key}.height: ${missingBreakpoints.join(', ')}`;
41
- }
42
- }
43
- return;
44
- }
45
- const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in value));
46
- if (missingBreakpoints.length) {
47
- throw `missing breakpoints in ${key}: ${missingBreakpoints.join(', ')}`;
48
- }
49
- });
50
- };
@@ -1,137 +0,0 @@
1
- import { keyInObject } from '../utils';
2
- const SKIP_STYLES = [
3
- 'borderCurve',
4
- 'elevation',
5
- 'textAlignVertical',
6
- 'includeFontPadding',
7
- 'overlayColor',
8
- 'tintColor'
9
- ];
10
- const CSS_NUMBER_KEYS = [
11
- 'animationIterationCount',
12
- 'borderImageOutset',
13
- 'borderImageSlice',
14
- 'borderImageWidth',
15
- 'boxFlex',
16
- 'boxFlexGroup',
17
- 'boxOrdinalGroup',
18
- 'columnCount',
19
- 'columns',
20
- 'counterIncrement',
21
- 'counterReset',
22
- 'flex',
23
- 'flexGrow',
24
- 'flexPositive',
25
- 'flexShrink',
26
- 'flexNegative',
27
- 'flexOrder',
28
- 'fontWeight',
29
- 'gridArea',
30
- 'gridColumn',
31
- 'gridColumnEnd',
32
- 'gridColumnSpan',
33
- 'gridColumnStart',
34
- 'gridRow',
35
- 'gridRowEnd',
36
- 'gridRowSpan',
37
- 'gridRowStart',
38
- 'line-clamp',
39
- 'line-height',
40
- 'opacity',
41
- 'order',
42
- 'orphans',
43
- 'tabSize',
44
- 'widows',
45
- 'zIndex',
46
- 'zoom',
47
- 'fillOpacity',
48
- 'floodOpacity',
49
- 'stopOpacity',
50
- 'strokeDasharray',
51
- 'strokeDashoffset',
52
- 'strokeMiterlimit',
53
- 'strokeOpacity',
54
- 'strokeWidth'
55
- ];
56
- const convertMap = {
57
- marginHorizontal: (value) => ({
58
- marginInline: value
59
- }),
60
- marginVertical: (value) => ({
61
- marginBlock: value
62
- }),
63
- paddingHorizontal: (value) => ({
64
- paddingInline: value
65
- }),
66
- paddingVertical: (value) => ({
67
- paddingBlock: value
68
- }),
69
- writingDirection: (value) => ({
70
- direction: value
71
- }),
72
- borderBottomEndRadius: (value) => ({
73
- borderBottomRightRadius: value
74
- }),
75
- borderBottomStartRadius: (value) => ({
76
- borderBottomLeftRadius: value
77
- }),
78
- borderEndColor: (value) => ({
79
- borderInlineEndColor: value
80
- }),
81
- borderStartColor: (value) => ({
82
- borderInlineStartColor: value
83
- }),
84
- borderTopEndRadius: (value) => ({
85
- borderTopRightRadius: value
86
- }),
87
- borderTopStartRadius: (value) => ({
88
- borderTopLeftRadius: value
89
- }),
90
- borderEndWidth: (value) => ({
91
- borderInlineEndWidth: value
92
- }),
93
- borderStartWidth: (value) => ({
94
- borderInlineStartWidth: value
95
- }),
96
- end: (value) => ({
97
- right: value
98
- }),
99
- start: (value) => ({
100
- left: value
101
- }),
102
- marginEnd: (value) => ({
103
- marginRight: value
104
- }),
105
- marginStart: (value) => ({
106
- marginLeft: value
107
- }),
108
- paddingEnd: (value) => ({
109
- paddingRight: value
110
- }),
111
- paddingStart: (value) => ({
112
- paddingLeft: value
113
- }),
114
- transformMatrix: (value) => ({
115
- transform: `matrix(${value.join(', ')})`
116
- }),
117
- resizeMode: (value) => ({
118
- backgroundSize: value
119
- })
120
- };
121
- const convertNumber = (key, value) => {
122
- if (typeof value === 'number') {
123
- return CSS_NUMBER_KEYS.includes(key, value) ? value : `${value}px`;
124
- }
125
- return value;
126
- };
127
- export const getStyle = (key, value) => {
128
- if (SKIP_STYLES.includes(key)) {
129
- return {};
130
- }
131
- if (keyInObject(convertMap, key)) {
132
- return convertMap[key]?.(convertNumber(key, value)) ?? {};
133
- }
134
- return {
135
- [key]: convertNumber(key, value)
136
- };
137
- };