@tamagui/react-native-web-internals 2.7.7 → 3.0.0-beta.643.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/dist/cjs/StyleSheet/compiler/createReactDOMStyle.cjs +151 -136
  2. package/dist/cjs/StyleSheet/compiler/hash.cjs +15 -18
  3. package/dist/cjs/StyleSheet/compiler/hyphenateStyleName.cjs +21 -24
  4. package/dist/cjs/StyleSheet/compiler/index.cjs +295 -321
  5. package/dist/cjs/StyleSheet/compiler/normalizeColor.cjs +20 -23
  6. package/dist/cjs/StyleSheet/compiler/normalizeValueWithProperty.cjs +32 -35
  7. package/dist/cjs/StyleSheet/compiler/resolveShadowValue.cjs +27 -38
  8. package/dist/cjs/StyleSheet/dom/createCSSStyleSheet.cjs +37 -40
  9. package/dist/cjs/StyleSheet/dom/createOrderedCSSStyleSheet.cjs +108 -111
  10. package/dist/cjs/StyleSheet/dom/index.cjs +70 -72
  11. package/dist/cjs/StyleSheet/index.cjs +33 -34
  12. package/dist/cjs/StyleSheet/preprocess.cjs +74 -94
  13. package/dist/cjs/StyleSheet/validate.cjs +72 -75
  14. package/dist/cjs/TextAncestorContext.cjs +15 -18
  15. package/dist/cjs/colorProps.cjs +25 -28
  16. package/dist/cjs/index.cjs +49 -50
  17. package/dist/cjs/modules/AccessibilityUtil/index.cjs +18 -21
  18. package/dist/cjs/modules/AccessibilityUtil/isDisabled.cjs +15 -18
  19. package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.cjs +46 -49
  20. package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.cjs +34 -39
  21. package/dist/cjs/modules/AssetRegistry/index.cjs +18 -19
  22. package/dist/cjs/modules/ImageLoader/index.cjs +135 -141
  23. package/dist/cjs/modules/InteractionManager.cjs +212 -219
  24. package/dist/cjs/modules/Platform/index.cjs +18 -21
  25. package/dist/cjs/modules/TextInputState/index.cjs +55 -58
  26. package/dist/cjs/modules/UIManager/index.cjs +46 -51
  27. package/dist/cjs/modules/canUseDOM.cjs +15 -18
  28. package/dist/cjs/modules/createDOMProps/index.cjs +289 -358
  29. package/dist/cjs/modules/createEventHandle/index.cjs +57 -62
  30. package/dist/cjs/modules/dismissKeyboard/index.cjs +16 -19
  31. package/dist/cjs/modules/forwardedProps/index.cjs +128 -130
  32. package/dist/cjs/modules/getBoundingClientRect/index.cjs +22 -25
  33. package/dist/cjs/modules/invariant.cjs +26 -27
  34. package/dist/cjs/modules/isSelectionValid/index.cjs +22 -25
  35. package/dist/cjs/modules/isWebColor/index.cjs +15 -18
  36. package/dist/cjs/modules/mergeRefs/index.cjs +31 -34
  37. package/dist/cjs/modules/modality/index.cjs +131 -134
  38. package/dist/cjs/modules/multiplyStyleLengthValue/index.cjs +25 -28
  39. package/dist/cjs/modules/normalizeColor/index.cjs +28 -31
  40. package/dist/cjs/modules/pick/index.cjs +24 -27
  41. package/dist/cjs/modules/processColor/index.cjs +28 -36
  42. package/dist/cjs/modules/requestIdleCallback/index.cjs +28 -29
  43. package/dist/cjs/modules/setValueForStyles/dangerousStyleValue.cjs +39 -42
  44. package/dist/cjs/modules/setValueForStyles/index.cjs +31 -34
  45. package/dist/cjs/modules/unitlessNumbers/index.cjs +74 -75
  46. package/dist/cjs/modules/useElementLayout/index.cjs +24 -31
  47. package/dist/cjs/modules/useEvent/index.cjs +40 -43
  48. package/dist/cjs/modules/useHover/index.cjs +113 -118
  49. package/dist/cjs/modules/useLayoutEffect/index.cjs +18 -26
  50. package/dist/cjs/modules/useLocale/index.cjs +33 -43
  51. package/dist/cjs/modules/useLocale/isLocaleRTL.cjs +66 -76
  52. package/dist/cjs/modules/useMergeRefs/index.cjs +19 -29
  53. package/dist/cjs/modules/usePlatformMethods/index.cjs +24 -30
  54. package/dist/cjs/modules/useStable/index.cjs +24 -32
  55. package/dist/cjs/styleTypes.cjs +10 -11
  56. package/dist/cjs/types.cjs +10 -11
  57. package/dist/esm/StyleSheet/compiler/createReactDOMStyle.mjs +137 -119
  58. package/dist/esm/StyleSheet/compiler/createReactDOMStyle.mjs.map +1 -1
  59. package/dist/esm/StyleSheet/compiler/hash.mjs +2 -2
  60. package/dist/esm/StyleSheet/compiler/hyphenateStyleName.mjs +7 -6
  61. package/dist/esm/StyleSheet/compiler/hyphenateStyleName.mjs.map +1 -1
  62. package/dist/esm/StyleSheet/compiler/index.mjs +279 -302
  63. package/dist/esm/StyleSheet/compiler/index.mjs.map +1 -1
  64. package/dist/esm/StyleSheet/compiler/normalizeColor.mjs +7 -5
  65. package/dist/esm/StyleSheet/compiler/normalizeColor.mjs.map +1 -1
  66. package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.mjs +19 -17
  67. package/dist/esm/StyleSheet/compiler/normalizeValueWithProperty.mjs.map +1 -1
  68. package/dist/esm/StyleSheet/compiler/resolveShadowValue.mjs +14 -20
  69. package/dist/esm/StyleSheet/compiler/resolveShadowValue.mjs.map +1 -1
  70. package/dist/esm/StyleSheet/dom/createCSSStyleSheet.mjs +24 -22
  71. package/dist/esm/StyleSheet/dom/createCSSStyleSheet.mjs.map +1 -1
  72. package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.mjs +94 -93
  73. package/dist/esm/StyleSheet/dom/createOrderedCSSStyleSheet.mjs.map +1 -1
  74. package/dist/esm/StyleSheet/dom/index.mjs +57 -54
  75. package/dist/esm/StyleSheet/dom/index.mjs.map +1 -1
  76. package/dist/esm/StyleSheet/index.mjs +18 -17
  77. package/dist/esm/StyleSheet/index.mjs.map +1 -1
  78. package/dist/esm/StyleSheet/preprocess.mjs +58 -75
  79. package/dist/esm/StyleSheet/preprocess.mjs.map +1 -1
  80. package/dist/esm/StyleSheet/validate.mjs +58 -57
  81. package/dist/esm/StyleSheet/validate.mjs.map +1 -1
  82. package/dist/esm/TextAncestorContext.mjs +2 -0
  83. package/dist/esm/TextAncestorContext.mjs.map +1 -1
  84. package/dist/esm/colorProps.mjs +11 -10
  85. package/dist/esm/colorProps.mjs.map +1 -1
  86. package/dist/esm/index.js +22 -15
  87. package/dist/esm/index.mjs +22 -15
  88. package/dist/esm/modules/AccessibilityUtil/index.mjs +5 -3
  89. package/dist/esm/modules/AccessibilityUtil/index.mjs.map +1 -1
  90. package/dist/esm/modules/AccessibilityUtil/isDisabled.mjs +2 -1
  91. package/dist/esm/modules/AccessibilityUtil/isDisabled.mjs.map +1 -1
  92. package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.mjs +33 -31
  93. package/dist/esm/modules/AccessibilityUtil/propsToAccessibilityComponent.mjs.map +1 -1
  94. package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.mjs +20 -21
  95. package/dist/esm/modules/AccessibilityUtil/propsToAriaRole.mjs.map +1 -1
  96. package/dist/esm/modules/AssetRegistry/index.mjs +3 -2
  97. package/dist/esm/modules/AssetRegistry/index.mjs.map +1 -1
  98. package/dist/esm/modules/ImageLoader/index.mjs +120 -124
  99. package/dist/esm/modules/ImageLoader/index.mjs.map +1 -1
  100. package/dist/esm/modules/InteractionManager.mjs +199 -201
  101. package/dist/esm/modules/InteractionManager.mjs.map +1 -1
  102. package/dist/esm/modules/Platform/index.mjs +4 -3
  103. package/dist/esm/modules/Platform/index.mjs.map +1 -1
  104. package/dist/esm/modules/TextInputState/index.mjs +42 -40
  105. package/dist/esm/modules/TextInputState/index.mjs.map +1 -1
  106. package/dist/esm/modules/UIManager/index.mjs +33 -33
  107. package/dist/esm/modules/UIManager/index.mjs.map +1 -1
  108. package/dist/esm/modules/canUseDOM.mjs +1 -0
  109. package/dist/esm/modules/canUseDOM.mjs.map +1 -1
  110. package/dist/esm/modules/createDOMProps/index.mjs +275 -341
  111. package/dist/esm/modules/createDOMProps/index.mjs.map +1 -1
  112. package/dist/esm/modules/createEventHandle/index.mjs +44 -44
  113. package/dist/esm/modules/createEventHandle/index.mjs.map +1 -1
  114. package/dist/esm/modules/dismissKeyboard/index.mjs +3 -1
  115. package/dist/esm/modules/dismissKeyboard/index.mjs.map +1 -1
  116. package/dist/esm/modules/forwardedProps/index.mjs +104 -104
  117. package/dist/esm/modules/forwardedProps/index.mjs.map +1 -1
  118. package/dist/esm/modules/getBoundingClientRect/index.mjs +8 -7
  119. package/dist/esm/modules/getBoundingClientRect/index.mjs.map +1 -1
  120. package/dist/esm/modules/invariant.mjs +11 -10
  121. package/dist/esm/modules/invariant.mjs.map +1 -1
  122. package/dist/esm/modules/isSelectionValid/index.mjs +8 -7
  123. package/dist/esm/modules/isSelectionValid/index.mjs.map +1 -1
  124. package/dist/esm/modules/isWebColor/index.mjs +2 -1
  125. package/dist/esm/modules/isWebColor/index.mjs.map +1 -1
  126. package/dist/esm/modules/mergeRefs/index.mjs +17 -16
  127. package/dist/esm/modules/mergeRefs/index.mjs.map +1 -1
  128. package/dist/esm/modules/modality/index.mjs +115 -115
  129. package/dist/esm/modules/modality/index.mjs.map +1 -1
  130. package/dist/esm/modules/multiplyStyleLengthValue/index.mjs +11 -10
  131. package/dist/esm/modules/multiplyStyleLengthValue/index.mjs.map +1 -1
  132. package/dist/esm/modules/normalizeColor/index.mjs +15 -13
  133. package/dist/esm/modules/normalizeColor/index.mjs.map +1 -1
  134. package/dist/esm/modules/pick/index.mjs +10 -9
  135. package/dist/esm/modules/pick/index.mjs.map +1 -1
  136. package/dist/esm/modules/processColor/index.mjs +12 -10
  137. package/dist/esm/modules/processColor/index.mjs.map +1 -1
  138. package/dist/esm/modules/requestIdleCallback/index.mjs +14 -12
  139. package/dist/esm/modules/requestIdleCallback/index.mjs.map +1 -1
  140. package/dist/esm/modules/setValueForStyles/dangerousStyleValue.mjs +27 -25
  141. package/dist/esm/modules/setValueForStyles/dangerousStyleValue.mjs.map +1 -1
  142. package/dist/esm/modules/setValueForStyles/index.mjs +18 -16
  143. package/dist/esm/modules/setValueForStyles/index.mjs.map +1 -1
  144. package/dist/esm/modules/unitlessNumbers/index.mjs +60 -57
  145. package/dist/esm/modules/unitlessNumbers/index.mjs.map +1 -1
  146. package/dist/esm/modules/useElementLayout/index.mjs +12 -14
  147. package/dist/esm/modules/useElementLayout/index.mjs.map +1 -1
  148. package/dist/esm/modules/useEvent/index.mjs +28 -26
  149. package/dist/esm/modules/useEvent/index.mjs.map +1 -1
  150. package/dist/esm/modules/useHover/index.mjs +101 -101
  151. package/dist/esm/modules/useHover/index.mjs.map +1 -1
  152. package/dist/esm/modules/useLayoutEffect/index.mjs +2 -0
  153. package/dist/esm/modules/useLayoutEffect/index.mjs.map +1 -1
  154. package/dist/esm/modules/useLocale/index.mjs +15 -17
  155. package/dist/esm/modules/useLocale/index.mjs.map +1 -1
  156. package/dist/esm/modules/useLocale/isLocaleRTL.mjs +52 -58
  157. package/dist/esm/modules/useLocale/isLocaleRTL.mjs.map +1 -1
  158. package/dist/esm/modules/useMergeRefs/index.mjs +3 -3
  159. package/dist/esm/modules/useMergeRefs/index.mjs.map +1 -1
  160. package/dist/esm/modules/usePlatformMethods/index.mjs +11 -12
  161. package/dist/esm/modules/usePlatformMethods/index.mjs.map +1 -1
  162. package/dist/esm/modules/useStable/index.mjs +8 -6
  163. package/dist/esm/modules/useStable/index.mjs.map +1 -1
  164. package/dist/esm/styleTypes.mjs +0 -2
  165. package/dist/esm/types.mjs +0 -2
  166. package/package.json +8 -8
  167. package/src/modules/createDOMProps/index.tsx +3 -12
  168. package/src/modules/forwardedProps/index.tsx +0 -1
  169. package/src/modules/mergeRefs/index.tsx +1 -1
  170. package/types/StyleSheet/compiler/createReactDOMStyle.d.ts.map +1 -1
  171. package/types/StyleSheet/compiler/normalizeColor.d.ts.map +1 -1
  172. package/types/StyleSheet/compiler/resolveShadowValue.d.ts.map +1 -1
  173. package/types/StyleSheet/index.d.ts +15 -16
  174. package/types/StyleSheet/index.d.ts.map +1 -1
  175. package/types/StyleSheet/preprocess.d.ts +1 -1
  176. package/types/StyleSheet/preprocess.d.ts.map +1 -1
  177. package/types/colorProps.d.ts.map +1 -1
  178. package/types/modules/AccessibilityUtil/index.d.ts +6 -5
  179. package/types/modules/AccessibilityUtil/index.d.ts.map +1 -1
  180. package/types/modules/AccessibilityUtil/isDisabled.d.ts.map +1 -1
  181. package/types/modules/AccessibilityUtil/propsToAccessibilityComponent.d.ts.map +1 -1
  182. package/types/modules/AccessibilityUtil/propsToAriaRole.d.ts.map +1 -1
  183. package/types/modules/ImageLoader/index.d.ts +1 -1
  184. package/types/modules/ImageLoader/index.d.ts.map +1 -1
  185. package/types/modules/InteractionManager.d.ts +3 -3
  186. package/types/modules/InteractionManager.d.ts.map +1 -1
  187. package/types/modules/Platform/index.d.ts.map +1 -1
  188. package/types/modules/TextInputState/index.d.ts.map +1 -1
  189. package/types/modules/createDOMProps/index.d.ts.map +1 -1
  190. package/types/modules/forwardedProps/index.d.ts +70 -74
  191. package/types/modules/forwardedProps/index.d.ts.map +1 -1
  192. package/types/modules/getBoundingClientRect/index.d.ts.map +1 -1
  193. package/types/modules/isWebColor/index.d.ts.map +1 -1
  194. package/types/modules/multiplyStyleLengthValue/index.d.ts.map +1 -1
  195. package/types/modules/normalizeColor/index.d.ts.map +1 -1
  196. package/types/modules/processColor/index.d.ts.map +1 -1
  197. package/types/modules/requestIdleCallback/index.d.ts +3 -1
  198. package/types/modules/requestIdleCallback/index.d.ts.map +1 -1
  199. package/types/modules/unitlessNumbers/index.d.ts.map +1 -1
  200. package/types/modules/useLayoutEffect/index.d.ts +1 -1
  201. package/types/modules/useLayoutEffect/index.d.ts.map +1 -1
  202. package/dist/cjs/StyleSheet/__tests__/compiler-createReactDOMStyle-test.cjs +0 -265
  203. package/dist/cjs/StyleSheet/__tests__/compiler-test.cjs +0 -419
  204. package/dist/cjs/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.cjs +0 -160
  205. package/dist/cjs/StyleSheet/__tests__/index-test.cjs +0 -436
  206. package/dist/cjs/StyleSheet/__tests__/preprocess-test.cjs +0 -121
  207. package/dist/cjs/StyleSheet/__tests__/validate-test.cjs +0 -51
  208. package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.cjs +0 -57
  209. package/dist/cjs/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.cjs +0 -46
  210. package/dist/cjs/modules/Platform/__tests__/index-test.cjs +0 -56
  211. package/dist/cjs/modules/UIManager/__tests__/index-test.cjs +0 -111
  212. package/dist/cjs/modules/createDOMProps/__tests__/index-test.cjs +0 -177
  213. package/dist/cjs/modules/createEventHandle/__tests__/index-test.cjs +0 -422
  214. package/dist/cjs/modules/mergeRefs/__tests__/index-test.cjs +0 -48
  215. package/dist/cjs/modules/modality/__tests__/index-test.cjs +0 -59
  216. package/dist/cjs/modules/multiplyStyleLengthValue/__tests__/index-test.cjs +0 -38
  217. package/dist/cjs/modules/processColor/__tests__/index-test.cjs +0 -85
  218. package/dist/cjs/modules/useEvent/__tests__/index-test.cjs +0 -490
  219. package/dist/cjs/modules/useHover/__tests__/index-test.cjs +0 -382
  220. package/dist/cjs/modules/useMergeRefs/__tests__/index-test.cjs +0 -125
  221. package/dist/cjs/modules/useStable/__tests__/index-test.cjs +0 -122
  222. package/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.mjs +0 -242
  223. package/dist/esm/StyleSheet/__tests__/compiler-createReactDOMStyle-test.mjs.map +0 -1
  224. package/dist/esm/StyleSheet/__tests__/compiler-test.mjs +0 -420
  225. package/dist/esm/StyleSheet/__tests__/compiler-test.mjs.map +0 -1
  226. package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.mjs +0 -137
  227. package/dist/esm/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.mjs.map +0 -1
  228. package/dist/esm/StyleSheet/__tests__/index-test.mjs +0 -413
  229. package/dist/esm/StyleSheet/__tests__/index-test.mjs.map +0 -1
  230. package/dist/esm/StyleSheet/__tests__/preprocess-test.mjs +0 -122
  231. package/dist/esm/StyleSheet/__tests__/preprocess-test.mjs.map +0 -1
  232. package/dist/esm/StyleSheet/__tests__/validate-test.mjs +0 -52
  233. package/dist/esm/StyleSheet/__tests__/validate-test.mjs.map +0 -1
  234. package/dist/esm/StyleSheet/compiler/hash.mjs.map +0 -1
  235. package/dist/esm/index.js.map +0 -1
  236. package/dist/esm/index.mjs.map +0 -1
  237. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.mjs +0 -34
  238. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.mjs.map +0 -1
  239. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.mjs +0 -23
  240. package/dist/esm/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.mjs.map +0 -1
  241. package/dist/esm/modules/Platform/__tests__/index-test.mjs +0 -33
  242. package/dist/esm/modules/Platform/__tests__/index-test.mjs.map +0 -1
  243. package/dist/esm/modules/UIManager/__tests__/index-test.mjs +0 -88
  244. package/dist/esm/modules/UIManager/__tests__/index-test.mjs.map +0 -1
  245. package/dist/esm/modules/createDOMProps/__tests__/index-test.mjs +0 -154
  246. package/dist/esm/modules/createDOMProps/__tests__/index-test.mjs.map +0 -1
  247. package/dist/esm/modules/createEventHandle/__tests__/index-test.mjs +0 -399
  248. package/dist/esm/modules/createEventHandle/__tests__/index-test.mjs.map +0 -1
  249. package/dist/esm/modules/mergeRefs/__tests__/index-test.mjs +0 -25
  250. package/dist/esm/modules/mergeRefs/__tests__/index-test.mjs.map +0 -1
  251. package/dist/esm/modules/modality/__tests__/index-test.mjs +0 -60
  252. package/dist/esm/modules/modality/__tests__/index-test.mjs.map +0 -1
  253. package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.mjs +0 -15
  254. package/dist/esm/modules/multiplyStyleLengthValue/__tests__/index-test.mjs.map +0 -1
  255. package/dist/esm/modules/processColor/__tests__/index-test.mjs +0 -62
  256. package/dist/esm/modules/processColor/__tests__/index-test.mjs.map +0 -1
  257. package/dist/esm/modules/useEvent/__tests__/index-test.mjs +0 -467
  258. package/dist/esm/modules/useEvent/__tests__/index-test.mjs.map +0 -1
  259. package/dist/esm/modules/useHover/__tests__/index-test.mjs +0 -359
  260. package/dist/esm/modules/useHover/__tests__/index-test.mjs.map +0 -1
  261. package/dist/esm/modules/useMergeRefs/__tests__/index-test.mjs +0 -102
  262. package/dist/esm/modules/useMergeRefs/__tests__/index-test.mjs.map +0 -1
  263. package/dist/esm/modules/useStable/__tests__/index-test.mjs +0 -99
  264. package/dist/esm/modules/useStable/__tests__/index-test.mjs.map +0 -1
  265. package/dist/esm/styleTypes.mjs.map +0 -1
  266. package/dist/esm/types.mjs.map +0 -1
  267. package/src/StyleSheet/__tests__/compiler-createReactDOMStyle-test.tsx +0 -236
  268. package/src/StyleSheet/__tests__/compiler-test.tsx +0 -426
  269. package/src/StyleSheet/__tests__/dom-createOrderedCSSStyleSheet-test.tsx +0 -169
  270. package/src/StyleSheet/__tests__/index-test.tsx +0 -406
  271. package/src/StyleSheet/__tests__/preprocess-test.tsx +0 -107
  272. package/src/StyleSheet/__tests__/validate-test.tsx +0 -42
  273. package/src/modules/AccessibilityUtil/__tests__/propsToAccessibilityComponent-test.tsx +0 -44
  274. package/src/modules/AccessibilityUtil/__tests__/propsToAriaRole-test.tsx +0 -25
  275. package/src/modules/Platform/__tests__/index-test.tsx +0 -45
  276. package/src/modules/UIManager/__tests__/index-test.tsx +0 -87
  277. package/src/modules/createDOMProps/__tests__/index-test.tsx +0 -138
  278. package/src/modules/createEventHandle/__tests__/index-test.tsx +0 -459
  279. package/src/modules/mergeRefs/__tests__/index-test.tsx +0 -32
  280. package/src/modules/modality/__tests__/index-test.tsx +0 -66
  281. package/src/modules/multiplyStyleLengthValue/__tests__/index-test.tsx +0 -23
  282. package/src/modules/processColor/__tests__/index-test.tsx +0 -78
  283. package/src/modules/useEvent/__tests__/index-test.tsx +0 -511
  284. package/src/modules/useHover/__tests__/index-test.tsx +0 -342
  285. package/src/modules/useMergeRefs/__tests__/index-test.tsx +0 -91
  286. package/src/modules/useStable/__tests__/index-test.tsx +0 -101
@@ -1,169 +0,0 @@
1
- /**
2
- * Copyright (c) Nicolas Gallagher.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import createOrderedCSSStyleSheet from '../dom/createOrderedCSSStyleSheet'
9
-
10
- const insertStyleElement = () => {
11
- const element = document.createElement('style')
12
- const head = document.head
13
- head.insertBefore(element, head.firstChild)
14
- return element
15
- }
16
-
17
- const removeStyleElement = (element) => {
18
- document.head.removeChild(element)
19
- }
20
-
21
- describe('createOrderedCSSStyleSheet', () => {
22
- describe('#insert', () => {
23
- test('insertion order for same group', () => {
24
- const sheet = createOrderedCSSStyleSheet()
25
-
26
- expect(sheet.getTextContent()).toMatchInlineSnapshot('""')
27
-
28
- sheet.insert('.a {}', 0)
29
- expect(sheet.getTextContent()).toMatchInlineSnapshot(`
30
- "[stylesheet-group=\\"0\\"]{}
31
- .a {}"
32
- `)
33
-
34
- sheet.insert('.b {}', 0)
35
- expect(sheet.getTextContent()).toMatchInlineSnapshot(`
36
- "[stylesheet-group=\\"0\\"]{}
37
- .a {}
38
- .b {}"
39
- `)
40
-
41
- sheet.insert('.c {}', 0)
42
- expect(sheet.getTextContent()).toMatchInlineSnapshot(`
43
- "[stylesheet-group=\\"0\\"]{}
44
- .a {}
45
- .b {}
46
- .c {}"
47
- `)
48
- })
49
-
50
- test('deduplication for same group', () => {
51
- const sheet = createOrderedCSSStyleSheet()
52
-
53
- sheet.insert('.a {}', 0)
54
- sheet.insert('.a {}', 0)
55
- sheet.insert('.a {}', 0)
56
-
57
- expect(sheet.getTextContent()).toMatchInlineSnapshot(`
58
- "[stylesheet-group=\\"0\\"]{}
59
- .a {}"
60
- `)
61
- })
62
-
63
- test('order for same group', () => {
64
- const sheet = createOrderedCSSStyleSheet()
65
-
66
- sheet.insert('.c {}', 0)
67
- sheet.insert('.b {}', 0)
68
- sheet.insert('.a {}', 0)
69
-
70
- expect(sheet.getTextContent()).toMatchInlineSnapshot(`
71
- "[stylesheet-group=\\"0\\"]{}
72
- .a {}
73
- .b {}
74
- .c {}"
75
- `)
76
- })
77
-
78
- test('insertion order for different groups', () => {
79
- const sheet = createOrderedCSSStyleSheet()
80
-
81
- sheet.insert('.nine-1 {}', 9.9)
82
- sheet.insert('.nine-2 {}', 9.9)
83
- sheet.insert('.three {}', 3)
84
- sheet.insert('.one {}', 1)
85
- sheet.insert('.two {}', 2.2)
86
- sheet.insert('.four-1 {}', 4)
87
- sheet.insert('.four-2 {}', 4)
88
- sheet.insert('.twenty {}', 20)
89
- sheet.insert('.ten {}', 10)
90
- sheet.insert('.twenty-point2 {}', 20.2)
91
-
92
- expect(sheet.getTextContent()).toMatchInlineSnapshot(`
93
- "[stylesheet-group=\\"1\\"]{}
94
- .one {}
95
- [stylesheet-group=\\"2.2\\"]{}
96
- .two {}
97
- [stylesheet-group=\\"3\\"]{}
98
- .three {}
99
- [stylesheet-group=\\"4\\"]{}
100
- .four-1 {}
101
- .four-2 {}
102
- [stylesheet-group=\\"9.9\\"]{}
103
- .nine-1 {}
104
- .nine-2 {}
105
- [stylesheet-group=\\"10\\"]{}
106
- .ten {}
107
- [stylesheet-group=\\"20\\"]{}
108
- .twenty {}
109
- [stylesheet-group=\\"20.2\\"]{}
110
- .twenty-point2 {}"
111
- `)
112
- })
113
- })
114
-
115
- describe('client-side hydration', () => {
116
- let element
117
-
118
- beforeEach(() => {
119
- if (element != null) {
120
- removeStyleElement(element)
121
- }
122
- element = insertStyleElement()
123
- })
124
-
125
- test('from SSR CSS', () => {
126
- // Setup SSR CSS
127
- const serverSheet = createOrderedCSSStyleSheet()
128
- serverSheet.insert('.one { width: 10px; }', 1)
129
- serverSheet.insert('.two-1 { height: 20px; }', 2)
130
- serverSheet.insert('.two-2 { color: red; }', 2)
131
- serverSheet.insert('@keyframes anim { 0% { opacity: 1; } }', 2)
132
- const textContent = serverSheet.getTextContent()
133
-
134
- // Add SSR CSS to client style sheet
135
- element.appendChild(document.createTextNode(textContent))
136
- const clientSheet = createOrderedCSSStyleSheet(element.sheet)
137
- expect(clientSheet.getTextContent()).toMatchInlineSnapshot(`
138
- "[stylesheet-group=\\"1\\"] {}
139
- .one {width: 10px;}
140
- [stylesheet-group=\\"2\\"] {}
141
- .two-1 {height: 20px;}
142
- .two-2 {color: red;}
143
- @keyframes anim {
144
- 0% {opacity: 1;}
145
- }"
146
- `)
147
- })
148
-
149
- test('works when the group marker is in single quotes', () => {
150
- // Setup SSR CSS
151
- const serverSheet = createOrderedCSSStyleSheet()
152
- serverSheet.insert('.a { color: red }', 0)
153
- serverSheet.insert('.b { color: red }', 1)
154
- const textContent = serverSheet.getTextContent().replace(/"/g, "'")
155
-
156
- // Add SSR CSS to client style sheet
157
- element.appendChild(document.createTextNode(textContent))
158
- const clientSheet = createOrderedCSSStyleSheet(element.sheet)
159
- clientSheet.insert('.c { color: red }', 0)
160
- expect(clientSheet.getTextContent()).toMatchInlineSnapshot(`
161
- "[stylesheet-group='0'] {}
162
- .a {color: red;}
163
- .c { color: red }
164
- [stylesheet-group='1'] {}
165
- .b {color: red;}"
166
- `)
167
- })
168
- })
169
- })
@@ -1,406 +0,0 @@
1
- /**
2
- * Copyright (c) Nicolas Gallagher.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import StyleSheet from '../index'
9
-
10
- describe('StyleSheet', () => {
11
- // test this first because subsequent 'create' calls will change the snapshot
12
- test('getSheet', () => {
13
- expect(StyleSheet.getSheet()).toMatchInlineSnapshot(`
14
- {
15
- "id": "react-native-stylesheet",
16
- "textContent": "[stylesheet-group=\\"0\\"]{}
17
- body{margin:0;}
18
- button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}
19
- html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);}
20
- input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-webkit-search-results-button,input::-webkit-search-results-decoration{display:none;}
21
- [stylesheet-group=\\"2.2\\"]{}
22
- .r-bottom-1p0dtai{bottom:0px;}
23
- .r-left-1d2f490{left:0px;}
24
- .r-position-u8s1d{position:absolute;}
25
- .r-right-zchlnj{right:0px;}
26
- .r-top-ipm5af{top:0px;}",
27
- }
28
- `)
29
- })
30
-
31
- test('absoluteFill', () => {
32
- expect(StyleSheet.absoluteFill).toMatchInlineSnapshot(`
33
- {
34
- "bottom": 0,
35
- "left": 0,
36
- "position": "absolute",
37
- "right": 0,
38
- "top": 0,
39
- }
40
- `)
41
- })
42
-
43
- test('absoluteFillObject', () => {
44
- expect(StyleSheet.absoluteFillObject).toMatchInlineSnapshot(`
45
- {
46
- "bottom": 0,
47
- "left": 0,
48
- "position": "absolute",
49
- "right": 0,
50
- "top": 0,
51
- }
52
- `)
53
- })
54
-
55
- test('compose', () => {
56
- expect(StyleSheet.compose(1, 2)).toEqual([1, 2])
57
- expect(StyleSheet.compose(1, null)).toBe(1)
58
- expect(StyleSheet.compose(null, 2)).toBe(2)
59
- })
60
-
61
- describe('create', () => {
62
- test('returns original style objects', () => {
63
- const style = StyleSheet.create({ root: { position: 'absolute' } })
64
- expect(style.root).toMatchInlineSnapshot(`
65
- {
66
- "position": "absolute",
67
- }
68
- `)
69
- })
70
-
71
- test('e2e resolves to classname', () => {
72
- const style = StyleSheet.create({ root: { position: 'absolute' } })
73
- expect(StyleSheet(style.root)).toMatchInlineSnapshot(`
74
- [
75
- "r-position-u8s1d",
76
- null,
77
- ]
78
- `)
79
- })
80
-
81
- test('e2e flattens shadow style properties', () => {
82
- const style = StyleSheet.create({
83
- root: {
84
- shadowColor: 'rgba(50,60,70,0.5)',
85
- shadowOffset: { width: 1, height: 2 },
86
- shadowOpacity: 0.5,
87
- shadowRadius: 3,
88
- textShadowColor: 'rgba(50,60,70,0.50)',
89
- textShadowOffset: { width: 5, height: 10 },
90
- textShadowRadius: 15,
91
- },
92
- })
93
- expect(StyleSheet(style.root)).toMatchInlineSnapshot(`
94
- [
95
- "r-boxShadow-o3ayyy r-textShadow-1x2q051",
96
- null,
97
- ]
98
- `)
99
- })
100
- })
101
-
102
- describe('flatten', () => {
103
- test('should merge style objects', () => {
104
- const style = StyleSheet.flatten([{ opacity: 1 }, { order: 2 }])
105
- expect(style).toMatchInlineSnapshot(`
106
- {
107
- "opacity": 1,
108
- "order": 2,
109
- }
110
- `)
111
- })
112
-
113
- test('should override style properties', () => {
114
- const style = StyleSheet.flatten([
115
- { backgroundColor: '#000', order: 1 },
116
- { backgroundColor: '#023c69', order: null },
117
- ])
118
- expect(style).toMatchInlineSnapshot(`
119
- {
120
- "backgroundColor": "#023c69",
121
- "order": null,
122
- }
123
- `)
124
- })
125
-
126
- test('should overwrite properties with `undefined`', () => {
127
- const style = StyleSheet.flatten([
128
- { backgroundColor: '#000' },
129
- { backgroundColor: undefined },
130
- ])
131
- expect(style).toMatchInlineSnapshot(`
132
- {
133
- "backgroundColor": undefined,
134
- }
135
- `)
136
- })
137
-
138
- test('should not fail on falsy values', () => {
139
- expect(() => StyleSheet.flatten([null, false, undefined])).not.toThrow()
140
- })
141
-
142
- test('should recursively flatten arrays', () => {
143
- const style = StyleSheet.flatten([
144
- null,
145
- [],
146
- [{ order: 2 }, { opacity: 1 }],
147
- { order: 3 },
148
- ])
149
- expect(style).toMatchInlineSnapshot(`
150
- {
151
- "opacity": 1,
152
- "order": 3,
153
- }
154
- `)
155
- })
156
- })
157
-
158
- test('hairlineWidth', () => {
159
- expect(Number.isInteger(StyleSheet.hairlineWidth) === true).toBeTruthy()
160
- })
161
-
162
- describe('resolve', () => {
163
- test('empty', () => {
164
- expect(StyleSheet()).toMatchInlineSnapshot(`
165
- [
166
- "",
167
- null,
168
- ]
169
- `)
170
- expect(StyleSheet({})).toMatchInlineSnapshot(`
171
- [
172
- "",
173
- null,
174
- ]
175
- `)
176
- expect(StyleSheet([])).toMatchInlineSnapshot(`
177
- [
178
- "",
179
- null,
180
- ]
181
- `)
182
- })
183
-
184
- test('transforms compiled object to className', () => {
185
- expect(
186
- StyleSheet([
187
- {
188
- $$css: true,
189
- position: 'position-absolute',
190
- opacity: 'opacity-05',
191
- width: 'width-200',
192
- },
193
- ])
194
- ).toMatchInlineSnapshot(`
195
- [
196
- "position-absolute opacity-05 width-200",
197
- null,
198
- ]
199
- `)
200
- })
201
-
202
- test('transforms array of compiled objects to className', () => {
203
- expect(
204
- StyleSheet([
205
- {
206
- $$css: true,
207
- borderWidth: 'borderWidth-0',
208
- borderColor: 'borderColor-red',
209
- display: 'display-flex',
210
- width: 'width-100',
211
- },
212
- {
213
- $$css: true,
214
- position: 'position-absolute',
215
- opacity: 'opacity-05',
216
- },
217
- [
218
- {
219
- $$css: true,
220
- width: 'width-200',
221
- },
222
- ],
223
- ])
224
- ).toMatchInlineSnapshot(`
225
- [
226
- "borderWidth-0 borderColor-red display-flex position-absolute opacity-05 width-200",
227
- null,
228
- ]
229
- `)
230
- })
231
-
232
- test('dedupes class names and inline styles', () => {
233
- const styleACompiled = {
234
- $$css: true,
235
- backgroundColor: 'backgroundColor-red',
236
- display: 'display-block',
237
- }
238
- const styleBCompiled = {
239
- $$css: true,
240
- backgroundColor: 'backgroundColor-green',
241
- color: 'color-green',
242
- }
243
- const styleBInline = {
244
- backgroundColor: 'rgba(0,0,255,1.00)',
245
- color: null,
246
- }
247
-
248
- const [className1, inlineStyle1] = StyleSheet([
249
- styleACompiled,
250
- styleBCompiled,
251
- styleBInline,
252
- ])
253
- expect(className1).toBe('display-block')
254
- expect(inlineStyle1).toEqual({ backgroundColor: 'rgba(0,0,255,1.00)' })
255
-
256
- const [className2, inlineStyle2] = StyleSheet([
257
- styleACompiled,
258
- styleBInline,
259
- styleBCompiled,
260
- ])
261
- expect(className2).toBe('display-block backgroundColor-green color-green')
262
- expect(inlineStyle2).toEqual(null)
263
- })
264
-
265
- test('long form inline style properties take precedence over static shorthand properties', () => {
266
- const styles1 = StyleSheet.create({
267
- test: { paddingHorizontal: '40px' },
268
- })
269
- const inlineStyle1 = { padding: '8px', paddingHorizontal: '40px' }
270
- expect(StyleSheet([styles1.test, inlineStyle1])).toMatchInlineSnapshot(`
271
- [
272
- "",
273
- {
274
- "paddingBottom": "8px",
275
- "paddingLeft": "40px",
276
- "paddingRight": "40px",
277
- "paddingTop": "8px",
278
- },
279
- ]
280
- `)
281
-
282
- const styles2 = StyleSheet.create({ test: { marginVertical: '40px' } })
283
- const inlineStyle2 = { margin: '8px', marginVertical: '40px' }
284
- expect(StyleSheet([styles2.test, inlineStyle2])).toMatchInlineSnapshot(`
285
- [
286
- "",
287
- {
288
- "marginBottom": "40px",
289
- "marginLeft": "8px",
290
- "marginRight": "8px",
291
- "marginTop": "40px",
292
- },
293
- ]
294
- `)
295
- })
296
-
297
- test('polyfills logical styles', () => {
298
- const inlineA = { start: '12.34%' }
299
- const inlineB = { textAlign: 'start' }
300
- const inlineC = { marginEnd: 10 }
301
-
302
- const a = StyleSheet.create({ x: { ...inlineA } }).x
303
- const b = StyleSheet.create({ x: { ...inlineB } }).x
304
- const c = StyleSheet.create({ x: { ...inlineC } }).x
305
- const writingDirection = 'rtl'
306
-
307
- // inline styles
308
- const inlineStyle = [inlineA, inlineB, inlineC]
309
- expect(StyleSheet(inlineStyle)).toMatchInlineSnapshot(`
310
- [
311
- "",
312
- {
313
- "left": "12.34%",
314
- "marginRight": "10px",
315
- "textAlign": "left",
316
- },
317
- ]
318
- `)
319
- expect(StyleSheet(inlineStyle, { writingDirection })).toMatchInlineSnapshot(`
320
- [
321
- "",
322
- {
323
- "marginLeft": "10px",
324
- "right": "12.34%",
325
- "textAlign": "right",
326
- },
327
- ]
328
- `)
329
- expect(
330
- StyleSheet(
331
- [inlineStyle, { marginLeft: 1, marginEnd: 0, marginStart: 0, marginRight: 11 }],
332
- { writingDirection }
333
- )
334
- ).toMatchInlineSnapshot(`
335
- [
336
- "",
337
- {
338
- "marginLeft": "0px",
339
- "marginRight": "0px",
340
- "right": "12.34%",
341
- "textAlign": "right",
342
- },
343
- ]
344
- `)
345
- expect(
346
- StyleSheet([inlineStyle, { marginEnd: null, marginLeft: 11 }], {
347
- writingDirection,
348
- })
349
- ).toMatchInlineSnapshot(`
350
- [
351
- "",
352
- {
353
- "marginLeft": "11px",
354
- "right": "12.34%",
355
- "textAlign": "right",
356
- },
357
- ]
358
- `)
359
-
360
- // static styles
361
- const staticStyle = [a, b, c]
362
- expect(StyleSheet(staticStyle)).toMatchInlineSnapshot(`
363
- [
364
- "r-left-2s0hu9 r-textAlign-fdjqy7 r-marginRight-zso239",
365
- null,
366
- ]
367
- `)
368
- expect(StyleSheet(staticStyle, { writingDirection })).toMatchInlineSnapshot(`
369
- [
370
- "r-right-1bnbe1j r-textAlign-1ff274t r-marginLeft-1n0xq6e",
371
- null,
372
- ]
373
- `)
374
- // logical wins
375
- expect(
376
- StyleSheet(
377
- [staticStyle, { marginLeft: 1, marginEnd: 0, marginStart: 0, marginRight: 11 }],
378
- {
379
- writingDirection,
380
- }
381
- )
382
- ).toMatchInlineSnapshot(`
383
- [
384
- "r-right-1bnbe1j r-textAlign-1ff274t",
385
- {
386
- "marginLeft": "0px",
387
- "marginRight": "0px",
388
- },
389
- ]
390
- `)
391
- // logical can be nulled
392
- expect(
393
- StyleSheet([staticStyle, { marginEnd: null, marginLeft: 11 }], {
394
- writingDirection,
395
- })
396
- ).toMatchInlineSnapshot(`
397
- [
398
- "r-right-1bnbe1j r-textAlign-1ff274t",
399
- {
400
- "marginLeft": "11px",
401
- },
402
- ]
403
- `)
404
- })
405
- })
406
- })
@@ -1,107 +0,0 @@
1
- /**
2
- * Copyright (c) Nicolas Gallagher.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { preprocess } from '../preprocess'
9
-
10
- describe('StyleSheet/preprocess', () => {
11
- describe('preprocesses multiple shadow styles into a single declaration', () => {
12
- test('shadowColor only', () => {
13
- expect(preprocess({ shadowColor: 'red' })).toEqual({
14
- boxShadow: '0px 0px 0px rgba(255,0,0,1.00)',
15
- })
16
- })
17
-
18
- test('shadowColor and shadowOpacity only', () => {
19
- expect(preprocess({ shadowColor: 'red', shadowOpacity: 0.5 })).toEqual({
20
- boxShadow: '0px 0px 0px rgba(255,0,0,0.50)',
21
- })
22
- })
23
-
24
- test('shadowOffset only', () => {
25
- expect(preprocess({ shadowOffset: { width: 1, height: 2 } })).toEqual({
26
- boxShadow: '1px 2px 0px rgba(0,0,0,1.00)',
27
- })
28
- })
29
-
30
- test('shadowRadius only', () => {
31
- expect(preprocess({ shadowRadius: 5 })).toEqual({
32
- boxShadow: '0px 0px 5px rgba(0,0,0,1.00)',
33
- })
34
- })
35
-
36
- test('shadowOffset, shadowRadius, shadowColor', () => {
37
- expect(
38
- preprocess({
39
- shadowColor: 'rgba(50,60,70,0.5)',
40
- shadowOffset: { width: 1, height: 2 },
41
- shadowOpacity: 0.5,
42
- shadowRadius: 3,
43
- })
44
- ).toEqual({
45
- boxShadow: '1px 2px 3px rgba(50,60,70,0.25)',
46
- })
47
- })
48
- })
49
-
50
- describe('preprocesses multiple textShadow styles into a single declaration', () => {
51
- test('textShadowColor only', () => {
52
- expect(preprocess({ textShadowColor: 'red' })).toEqual({})
53
- })
54
-
55
- test('textShadowOffset only', () => {
56
- expect(preprocess({ textShadowOffset: { width: 1, height: 2 } })).toEqual({})
57
- })
58
-
59
- test('textShadowRadius only', () => {
60
- expect(preprocess({ textShadowRadius: 5 })).toEqual({})
61
- })
62
-
63
- test('textShadowColor and textShadowOffset only', () => {
64
- expect(
65
- preprocess({
66
- textShadowColor: 'red',
67
- textShadowOffset: { width: 0, height: 0 },
68
- })
69
- ).toEqual({})
70
- expect(
71
- preprocess({
72
- textShadowColor: 'red',
73
- textShadowOffset: { width: -1, height: 0 },
74
- })
75
- ).toEqual({
76
- textShadow: '-1px 0px 0px rgba(255,0,0,1.00)',
77
- })
78
- expect(
79
- preprocess({
80
- textShadowColor: 'red',
81
- textShadowOffset: { width: 1, height: 2 },
82
- })
83
- ).toEqual({
84
- textShadow: '1px 2px 0px rgba(255,0,0,1.00)',
85
- })
86
- })
87
-
88
- test('textShadowColor and textShadowRadius only', () => {
89
- expect(preprocess({ textShadowColor: 'red', textShadowRadius: 0 })).toEqual({})
90
- expect(preprocess({ textShadowColor: 'red', textShadowRadius: 5 })).toEqual({
91
- textShadow: '0px 0px 5px rgba(255,0,0,1.00)',
92
- })
93
- })
94
-
95
- test('textShadowColor, textShadowOffset, textShadowRadius', () => {
96
- expect(
97
- preprocess({
98
- textShadowColor: 'rgba(50,60,70,0.50)',
99
- textShadowOffset: { width: 5, height: 10 },
100
- textShadowRadius: 15,
101
- })
102
- ).toEqual({
103
- textShadow: '5px 10px 15px rgba(50,60,70,0.50)',
104
- })
105
- })
106
- })
107
- })