react-native-unistyles 3.0.0-alpha.41 → 3.0.0-alpha.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. package/README.md +7 -1
  2. package/cxx/common/Constants.h +0 -1
  3. package/cxx/core/UnistylesRegistry.cpp +10 -4
  4. package/cxx/core/UnistylesRegistry.h +1 -1
  5. package/cxx/hybridObjects/HybridShadowRegistry.cpp +2 -2
  6. package/cxx/parser/Parser.cpp +7 -22
  7. package/cxx/parser/Parser.h +0 -1
  8. package/lib/commonjs/components/Display.js +2 -2
  9. package/lib/commonjs/components/Display.js.map +1 -1
  10. package/lib/commonjs/components/Hide.js +2 -2
  11. package/lib/commonjs/components/Hide.js.map +1 -1
  12. package/lib/commonjs/components/Pressable.js +82 -0
  13. package/lib/commonjs/components/Pressable.js.map +1 -0
  14. package/lib/commonjs/components/Pressable.web.js +97 -0
  15. package/lib/commonjs/components/Pressable.web.js.map +1 -0
  16. package/lib/commonjs/components/index.js +7 -0
  17. package/lib/commonjs/components/index.js.map +1 -1
  18. package/lib/commonjs/core/getBoundArgs.js +18 -0
  19. package/lib/commonjs/core/getBoundArgs.js.map +1 -0
  20. package/lib/commonjs/core/getId.js +9 -0
  21. package/lib/commonjs/core/getId.js.map +1 -0
  22. package/lib/commonjs/core/index.js +14 -0
  23. package/lib/commonjs/core/index.js.map +1 -1
  24. package/lib/commonjs/hooks/index.js +13 -0
  25. package/lib/commonjs/hooks/index.js.map +1 -0
  26. package/lib/commonjs/hooks/useMedia.js.map +1 -0
  27. package/lib/commonjs/hooks/useMedia.web.js.map +1 -0
  28. package/lib/commonjs/index.js +8 -1
  29. package/lib/commonjs/index.js.map +1 -1
  30. package/lib/commonjs/mq.js +6 -6
  31. package/lib/commonjs/mq.js.map +1 -1
  32. package/lib/commonjs/specs/ShadowRegistry/index.js +3 -4
  33. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  34. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  35. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
  36. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
  37. package/lib/commonjs/specs/index.web.js +0 -7
  38. package/lib/commonjs/specs/index.web.js.map +1 -1
  39. package/lib/commonjs/utils.js +1 -1
  40. package/lib/commonjs/utils.js.map +1 -1
  41. package/lib/commonjs/web/convert/types.js.map +1 -1
  42. package/lib/commonjs/web/convert/utils.js +1 -1
  43. package/lib/commonjs/web/convert/utils.js.map +1 -1
  44. package/lib/commonjs/web/create.js +10 -2
  45. package/lib/commonjs/web/create.js.map +1 -1
  46. package/lib/commonjs/web/index.js +7 -5
  47. package/lib/commonjs/web/index.js.map +1 -1
  48. package/lib/commonjs/web/listener.js.map +1 -1
  49. package/lib/commonjs/web/runtime.js +7 -7
  50. package/lib/commonjs/web/runtime.js.map +1 -1
  51. package/lib/commonjs/web/shadowRegistry.js +1 -1
  52. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  53. package/lib/commonjs/web/state.js +23 -16
  54. package/lib/commonjs/web/state.js.map +1 -1
  55. package/lib/commonjs/web/utils/common.js +3 -3
  56. package/lib/commonjs/web/utils/common.js.map +1 -1
  57. package/lib/commonjs/web/utils/unistyle.js +2 -4
  58. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  59. package/lib/commonjs/web/{variants/getVariants.js → variants.js} +3 -3
  60. package/lib/commonjs/web/variants.js.map +1 -0
  61. package/lib/module/components/Display.js +1 -1
  62. package/lib/module/components/Display.js.map +1 -1
  63. package/lib/module/components/Hide.js +1 -1
  64. package/lib/module/components/Hide.js.map +1 -1
  65. package/lib/module/components/Pressable.js +76 -0
  66. package/lib/module/components/Pressable.js.map +1 -0
  67. package/lib/module/components/Pressable.web.js +91 -0
  68. package/lib/module/components/Pressable.web.js.map +1 -0
  69. package/lib/module/components/index.js +1 -0
  70. package/lib/module/components/index.js.map +1 -1
  71. package/lib/module/core/getBoundArgs.js +13 -0
  72. package/lib/module/core/getBoundArgs.js.map +1 -0
  73. package/lib/module/core/getId.js +4 -0
  74. package/lib/module/core/getId.js.map +1 -0
  75. package/lib/module/core/index.js +2 -0
  76. package/lib/module/core/index.js.map +1 -1
  77. package/lib/module/hooks/index.js +4 -0
  78. package/lib/module/hooks/index.js.map +1 -0
  79. package/lib/module/hooks/useMedia.js.map +1 -0
  80. package/lib/module/hooks/useMedia.web.js.map +1 -0
  81. package/lib/module/index.js +1 -1
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/mq.js +6 -6
  84. package/lib/module/mq.js.map +1 -1
  85. package/lib/module/specs/ShadowRegistry/index.js +3 -4
  86. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  87. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  88. package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
  89. package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
  90. package/lib/module/specs/index.web.js +0 -1
  91. package/lib/module/specs/index.web.js.map +1 -1
  92. package/lib/module/utils.js +1 -1
  93. package/lib/module/utils.js.map +1 -1
  94. package/lib/module/web/convert/types.js.map +1 -1
  95. package/lib/module/web/convert/utils.js +1 -1
  96. package/lib/module/web/convert/utils.js.map +1 -1
  97. package/lib/module/web/create.js +12 -4
  98. package/lib/module/web/create.js.map +1 -1
  99. package/lib/module/web/index.js +7 -3
  100. package/lib/module/web/index.js.map +1 -1
  101. package/lib/module/web/listener.js.map +1 -1
  102. package/lib/module/web/runtime.js +8 -8
  103. package/lib/module/web/runtime.js.map +1 -1
  104. package/lib/module/web/shadowRegistry.js +1 -1
  105. package/lib/module/web/shadowRegistry.js.map +1 -1
  106. package/lib/module/web/state.js +24 -17
  107. package/lib/module/web/state.js.map +1 -1
  108. package/lib/module/web/utils/common.js +1 -1
  109. package/lib/module/web/utils/common.js.map +1 -1
  110. package/lib/module/web/utils/unistyle.js +1 -2
  111. package/lib/module/web/utils/unistyle.js.map +1 -1
  112. package/lib/module/web/{variants/getVariants.js → variants.js} +3 -3
  113. package/lib/module/web/variants.js.map +1 -0
  114. package/lib/typescript/src/components/Pressable.d.ts +7 -0
  115. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  116. package/lib/typescript/src/components/Pressable.web.d.ts +13 -0
  117. package/lib/typescript/src/components/Pressable.web.d.ts.map +1 -0
  118. package/lib/typescript/src/components/index.d.ts +1 -0
  119. package/lib/typescript/src/components/index.d.ts.map +1 -1
  120. package/lib/typescript/src/core/getBoundArgs.d.ts +2 -0
  121. package/lib/typescript/src/core/getBoundArgs.d.ts.map +1 -0
  122. package/lib/typescript/src/core/getId.d.ts +2 -0
  123. package/lib/typescript/src/core/getId.d.ts.map +1 -0
  124. package/lib/typescript/src/core/index.d.ts +2 -0
  125. package/lib/typescript/src/core/index.d.ts.map +1 -1
  126. package/lib/typescript/src/hooks/index.d.ts +2 -0
  127. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  128. package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -0
  129. package/lib/typescript/src/hooks/useMedia.web.d.ts.map +1 -0
  130. package/lib/typescript/src/index.d.ts +1 -1
  131. package/lib/typescript/src/index.d.ts.map +1 -1
  132. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +1 -1
  133. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
  134. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
  135. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  136. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +1 -0
  137. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  138. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +1 -1
  139. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  140. package/lib/typescript/src/specs/StyleSheet/index.d.ts +3 -2
  141. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  142. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +1 -1
  143. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  144. package/lib/typescript/src/specs/index.web.d.ts +0 -2
  145. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  146. package/lib/typescript/src/types/common.d.ts +1 -0
  147. package/lib/typescript/src/types/common.d.ts.map +1 -1
  148. package/lib/typescript/src/types/index.d.ts +1 -1
  149. package/lib/typescript/src/types/index.d.ts.map +1 -1
  150. package/lib/typescript/src/web/convert/types.d.ts +1 -1
  151. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  152. package/lib/typescript/src/web/create.d.ts +1 -1
  153. package/lib/typescript/src/web/create.d.ts.map +1 -1
  154. package/lib/typescript/src/web/index.d.ts +8 -2
  155. package/lib/typescript/src/web/index.d.ts.map +1 -1
  156. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  157. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  158. package/lib/typescript/src/web/state.d.ts.map +1 -1
  159. package/lib/typescript/src/web/utils/common.d.ts +1 -1
  160. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  161. package/lib/typescript/src/web/utils/unistyle.d.ts +0 -1
  162. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  163. package/lib/typescript/src/web/{variants/getVariants.d.ts → variants.d.ts} +2 -2
  164. package/lib/typescript/src/web/variants.d.ts.map +1 -0
  165. package/package.json +12 -16
  166. package/plugin/common.js +1 -4
  167. package/plugin/import.js +29 -3
  168. package/plugin/index.js +18 -8
  169. package/plugin/ref.js +15 -75
  170. package/plugin/style.js +251 -88
  171. package/src/components/Display.tsx +1 -1
  172. package/src/components/Hide.tsx +1 -1
  173. package/src/components/Pressable.tsx +101 -0
  174. package/src/components/Pressable.web.tsx +103 -0
  175. package/src/components/index.ts +1 -0
  176. package/src/core/getBoundArgs.ts +15 -0
  177. package/src/core/getId.ts +1 -0
  178. package/src/core/index.ts +2 -0
  179. package/src/hooks/index.ts +1 -0
  180. package/src/index.ts +1 -1
  181. package/src/mq.ts +6 -6
  182. package/src/specs/NativePlatform/NativePlatform.nitro.ts +1 -1
  183. package/src/specs/ShadowRegistry/index.ts +5 -6
  184. package/src/specs/ShadowRegistry/types.ts +2 -1
  185. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +1 -1
  186. package/src/specs/StyleSheet/index.ts +3 -2
  187. package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -2
  188. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
  189. package/src/specs/UnistylesRuntime/index.ts +1 -1
  190. package/src/specs/index.web.ts +0 -4
  191. package/src/types/common.ts +1 -0
  192. package/src/types/index.ts +1 -1
  193. package/src/utils.ts +1 -1
  194. package/src/web/convert/types.ts +1 -1
  195. package/src/web/convert/utils.ts +2 -2
  196. package/src/web/create.ts +13 -4
  197. package/src/web/index.ts +7 -3
  198. package/src/web/listener.ts +2 -0
  199. package/src/web/registry.ts +1 -1
  200. package/src/web/runtime.ts +9 -9
  201. package/src/web/shadowRegistry.ts +3 -3
  202. package/src/web/state.ts +36 -17
  203. package/src/web/utils/common.ts +1 -1
  204. package/src/web/utils/unistyle.ts +3 -9
  205. package/src/web/{variants/getVariants.ts → variants.ts} +3 -3
  206. package/lib/commonjs/components/useMedia.js.map +0 -1
  207. package/lib/commonjs/components/useMedia.web.js.map +0 -1
  208. package/lib/commonjs/web/variants/getVariants.js.map +0 -1
  209. package/lib/commonjs/web/variants/index.js +0 -28
  210. package/lib/commonjs/web/variants/index.js.map +0 -1
  211. package/lib/commonjs/web/variants/useVariants.js +0 -59
  212. package/lib/commonjs/web/variants/useVariants.js.map +0 -1
  213. package/lib/module/components/useMedia.js.map +0 -1
  214. package/lib/module/components/useMedia.web.js.map +0 -1
  215. package/lib/module/web/variants/getVariants.js.map +0 -1
  216. package/lib/module/web/variants/index.js +0 -5
  217. package/lib/module/web/variants/index.js.map +0 -1
  218. package/lib/module/web/variants/useVariants.js +0 -54
  219. package/lib/module/web/variants/useVariants.js.map +0 -1
  220. package/lib/typescript/src/components/useMedia.d.ts.map +0 -1
  221. package/lib/typescript/src/components/useMedia.web.d.ts.map +0 -1
  222. package/lib/typescript/src/web/variants/getVariants.d.ts.map +0 -1
  223. package/lib/typescript/src/web/variants/index.d.ts +0 -3
  224. package/lib/typescript/src/web/variants/index.d.ts.map +0 -1
  225. package/lib/typescript/src/web/variants/useVariants.d.ts +0 -3
  226. package/lib/typescript/src/web/variants/useVariants.d.ts.map +0 -1
  227. package/src/web/variants/index.ts +0 -2
  228. package/src/web/variants/useVariants.ts +0 -65
  229. /package/lib/commonjs/{components → hooks}/useMedia.js +0 -0
  230. /package/lib/commonjs/{components → hooks}/useMedia.web.js +0 -0
  231. /package/lib/module/{components → hooks}/useMedia.js +0 -0
  232. /package/lib/module/{components → hooks}/useMedia.web.js +0 -0
  233. /package/lib/typescript/src/{components → hooks}/useMedia.d.ts +0 -0
  234. /package/lib/typescript/src/{components → hooks}/useMedia.web.d.ts +0 -0
  235. /package/src/{components → hooks}/useMedia.ts +0 -0
  236. /package/src/{components → hooks}/useMedia.web.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","useRef","useState","isUnistylesMq","isValidMq","parseMq","useMedia","config","disposeRef","isVisible","setIsVisible","maybeMq","mq","console","error","parsedMq","minWidth","maxWidth","minHeight","maxHeight","mediaQuery","undefined","filter","Boolean","join","media","window","matchMedia","handler","event","matches","addEventListener","current","removeEventListener"],"sourceRoot":"../../../src","sources":["components/useMedia.web.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnD,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEzD,OAAO,MAAMC,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,UAAU,GAAGP,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;EACnC,MAAM,CAACQ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EF;EACA9B,SAAS,CAAC,MAAM,MAAMQ,UAAU,CAACwB,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;EAE/C,OAAO;IACHvB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["deepMergeObjects","hasVariants","value","getVariants","styles","selectedVariants","Object","entries","filter","_key","variants","keys","some","variant","map","key","compoundVariants","variantStyles","flatMap","selectedVariant","selectedVariantStyles","compoundVariantStyles","compoundVariant","conditions","String","mergedVariantStyles"],"sourceRoot":"../../../../src","sources":["web/variants/getVariants.ts"],"mappings":";;AACA,SAASA,gBAAgB,QAAQ,aAAa;AAQ9C,MAAMC,WAAW,GAAsBC,KAAkB,IAAgD,UAAU,IAAIA,KAAK,CAAC,CAAC,CAAC;AAE/H,OAAO,MAAMC,WAAW,GAAGA,CAACC,MAAyC,EAAEC,gBAAqC,KAAK;EAC7G,OAAOC,MAAM,CAACC,OAAO,CAACH,MAAM,CAAC,CACxBI,MAAM,CAACP,WAAW,CAAC,CACnBO,MAAM,CAAC,CAAC,CAACC,IAAI,EAAE;IAAEC;EAAS,CAAC,CAAC,KAAKJ,MAAM,CAACK,IAAI,CAACD,QAAQ,CAAC,CAACE,IAAI,CAACC,OAAO,IAAIA,OAAO,IAAIH,QAAQ,CAAC,CAAC,CAC5FI,GAAG,CAAC,CAAC,CAACC,GAAG,EAAE;IAAEL,QAAQ;IAAEM,gBAAgB,GAAG;EAAG,CAAC,CAAC,KAAK;IACjD,MAAMC,aAAa,GAAGX,MAAM,CAACC,OAAO,CAACG,QAAQ,CAAC,CAACQ,OAAO,CAAC,CAAC,CAACL,OAAO,EAAET,MAAM,CAAC,KAAK;MAC1E,MAAMe,eAAe,GAAGd,gBAAgB,CAACQ,OAAO,CAAC;MACjD,MAAMO,qBAAqB,GAAGhB,MAAM,CAACe,eAAe,CAAC,IAAIf,MAAM,CAAC,SAAS,CAAC;MAE1E,IAAI,CAACgB,qBAAqB,EAAE;QACxB,OAAO,EAAE;MACb;MAEA,OAAOA,qBAAqB;IAChC,CAAC,CAAC;IAEF,MAAMC,qBAAqB,GAAGL,gBAAgB,CAACE,OAAO,CAACI,eAAe,IAAI;MACtE,MAAM;QAAElB,MAAM;QAAE,GAAGmB;MAAW,CAAC,GAAGD,eAAe;MAEjD,IAAIhB,MAAM,CAACC,OAAO,CAACgB,UAAU,CAAC,CAACX,IAAI,CAAC,CAAC,CAACC,OAAO,EAAEX,KAAK,CAAC,KAAKsB,MAAM,CAACnB,gBAAgB,CAACQ,OAAO,CAAC,CAAC,KAAKW,MAAM,CAACtB,KAAK,CAAC,CAAC,EAAE;QAC5G,OAAO,EAAE;MACb;MAEA,OAAOE,MAAM;IACjB,CAAC,CAAC;IAEF,MAAMqB,mBAAmB,GAAGzB,gBAAgB,CAAC,GAAGiB,aAAa,EAAE,GAAGI,qBAAqB,CAAC;IAExF,OAAO,CAACN,GAAG,EAAEU,mBAAmB,CAAC;EACrC,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- export * from './useVariants';
4
- export * from './getVariants';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/variants/index.ts"],"mappings":";;AAAA,cAAc,eAAe;AAC7B,cAAc,eAAe","ignoreList":[]}
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- import { useMemo, useRef, useState } from 'react';
4
- import { equal, keyInObject, reduceObject } from '../utils';
5
- import { getVariants } from './getVariants';
6
- export const createUseVariants = (styles, setSelectedVariants) => {
7
- const useVariants = selectedVariants => {
8
- const [selectedVariantStylesMap] = useState(() => new Map());
9
- const lastSelectedVariantsRef = useRef();
10
- // Variable that determines if variants have changed and we need to recalculate styles
11
- const variantsChanged = !equal(lastSelectedVariantsRef.current, selectedVariants);
12
- if (variantsChanged) {
13
- lastSelectedVariantsRef.current = selectedVariants;
14
- setSelectedVariants(selectedVariants);
15
- }
16
- const combinedVariantStyles = useMemo(() => {
17
- const result = getVariants(styles, selectedVariants);
18
- result.forEach(([key, value]) => {
19
- selectedVariantStylesMap.set(key, value);
20
- });
21
- return result;
22
- }, [lastSelectedVariantsRef.current]);
23
- combinedVariantStyles.forEach(([key]) => {
24
- const styleEntry = styles[key];
25
- if (!styleEntry) {
26
- return;
27
- }
28
- const selectedVariantStyles = selectedVariantStylesMap.get(key);
29
- Object.defineProperties(styleEntry, reduceObject(selectedVariantStyles ?? {}, value => ({
30
- value,
31
- enumerable: false,
32
- configurable: true
33
- })));
34
-
35
- // Add __uni__variants to static styles
36
- Object.keys(styleEntry).forEach(key => {
37
- if (!key.startsWith('__uni__secrets__')) {
38
- return;
39
- }
40
- const secret = keyInObject(styleEntry, key) ? styleEntry[key] : undefined;
41
- if (!secret) {
42
- return;
43
- }
44
- Object.defineProperty(secret, '__uni__variants', {
45
- value: selectedVariants
46
- });
47
- });
48
- });
49
- };
50
- Object.defineProperty(styles, 'useVariants', {
51
- value: useVariants
52
- });
53
- };
54
- //# sourceMappingURL=useVariants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useMemo","useRef","useState","equal","keyInObject","reduceObject","getVariants","createUseVariants","styles","setSelectedVariants","useVariants","selectedVariants","selectedVariantStylesMap","Map","lastSelectedVariantsRef","variantsChanged","current","combinedVariantStyles","result","forEach","key","value","set","styleEntry","selectedVariantStyles","get","Object","defineProperties","enumerable","configurable","keys","startsWith","secret","undefined","defineProperty"],"sourceRoot":"../../../../src","sources":["web/variants/useVariants.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEjD,SAASC,KAAK,EAAEC,WAAW,EAAEC,YAAY,QAAQ,UAAU;AAC3D,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,iBAAiB,GAAGA,CAACC,MAAyC,EAAEC,mBAA4D,KAAK;EAC1I,MAAMC,WAAW,GAAIC,gBAAqC,IAA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,CAAC,kBAAkB,CAAC,EAAE;UACrC;QACJ;QAEA,MAAMC,MAAM,GAAG5B,WAAW,CAACmB,UAAU,EAAEH,GAAG,CAAC,GAAGG,UAAU,CAACH,GAAG,CAAC,GAAGa,SAAS;QAEzE,IAAI,CAACD,MAAM,EAAE;UACT;QACJ;QAEAN,MAAM,CAACQ,cAAc,CAACF,MAAM,EAAE,iBAAiB,EAAE;UAC7CX,KAAK,EAAEV;QACX,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC;EAEDe,MAAM,CAACQ,cAAc,CAAC1B,MAAM,EAAE,aAAa,EAAE;IACzCa,KAAK,EAAEX;EACX,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMedia.d.ts","sourceRoot":"","sources":["../../../../src/components/useMedia.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,WAAY;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;;CA2D9C,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMedia.web.d.ts","sourceRoot":"","sources":["../../../../src/components/useMedia.web.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,WAAY;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;;CA2C9C,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getVariants.d.ts","sourceRoot":"","sources":["../../../../../src/web/variants/getVariants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAWpE,eAAO,MAAM,WAAW,WAAY,qBAAqB,CAAC,UAAU,CAAC,oBAAoB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,+BA8B3G,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './useVariants';
2
- export * from './getVariants';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/variants/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { ReactNativeStyleSheet, StyleSheet } from '../../types';
2
- export declare const createUseVariants: (styles: ReactNativeStyleSheet<StyleSheet>, setSelectedVariants: (variants: Record<string, any>) => void) => void;
3
- //# sourceMappingURL=useVariants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useVariants.d.ts","sourceRoot":"","sources":["../../../../../src/web/variants/useVariants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIpE,eAAO,MAAM,iBAAiB,WAAY,qBAAqB,CAAC,UAAU,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,SA2DxI,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './useVariants'
2
- export * from './getVariants'
@@ -1,65 +0,0 @@
1
- import { useMemo, useRef, useState } from 'react'
2
- import type { ReactNativeStyleSheet, StyleSheet } from '../../types'
3
- import { equal, keyInObject, reduceObject } from '../utils'
4
- import { getVariants } from './getVariants'
5
-
6
- export const createUseVariants = (styles: ReactNativeStyleSheet<StyleSheet>, setSelectedVariants: (variants: Record<string, any>) => void) => {
7
- const useVariants = (selectedVariants: Record<string, any>) => {
8
- const [selectedVariantStylesMap] = useState(() => new Map<string, Record<string, any>>())
9
- const lastSelectedVariantsRef = useRef<Record<string, any>>()
10
- // Variable that determines if variants have changed and we need to recalculate styles
11
- const variantsChanged = !equal(lastSelectedVariantsRef.current, selectedVariants)
12
-
13
- if (variantsChanged) {
14
- lastSelectedVariantsRef.current = selectedVariants
15
- setSelectedVariants(selectedVariants)
16
- }
17
-
18
- const combinedVariantStyles = useMemo(() => {
19
- const result = getVariants(styles, selectedVariants)
20
-
21
- result.forEach(([key, value]) => {
22
- selectedVariantStylesMap.set(key, value)
23
- })
24
-
25
- return result
26
- }, [lastSelectedVariantsRef.current])
27
-
28
- combinedVariantStyles.forEach(([key]) => {
29
- const styleEntry = styles[key]
30
-
31
- if (!styleEntry) {
32
- return
33
- }
34
-
35
- const selectedVariantStyles = selectedVariantStylesMap.get(key)
36
-
37
- Object.defineProperties(styleEntry, reduceObject(selectedVariantStyles ?? {}, value => ({
38
- value,
39
- enumerable: false,
40
- configurable: true
41
- })))
42
-
43
- // Add __uni__variants to static styles
44
- Object.keys(styleEntry).forEach(key => {
45
- if (!key.startsWith('__uni__secrets__')) {
46
- return
47
- }
48
-
49
- const secret = keyInObject(styleEntry, key) ? styleEntry[key] : undefined
50
-
51
- if (!secret) {
52
- return
53
- }
54
-
55
- Object.defineProperty(secret, '__uni__variants', {
56
- value: selectedVariants
57
- })
58
- })
59
- })
60
- }
61
-
62
- Object.defineProperty(styles, 'useVariants', {
63
- value: useVariants
64
- })
65
- }
File without changes
File without changes
File without changes
File without changes