react-native-unistyles 2.0.0-alpha.1 → 2.0.0-alpha.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. package/README.md +4 -4
  2. package/cxx/UnistylesRuntime.cpp +255 -0
  3. package/cxx/UnistylesRuntime.h +60 -0
  4. package/ios/UnistylesHelpers.h +4 -0
  5. package/ios/UnistylesHelpers.mm +20 -0
  6. package/ios/UnistylesModule.h +10 -0
  7. package/ios/UnistylesModule.mm +158 -0
  8. package/lib/commonjs/common.js +26 -0
  9. package/lib/commonjs/common.js.map +1 -0
  10. package/lib/commonjs/core/UnistyleRegistry.js +38 -0
  11. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
  12. package/lib/commonjs/core/Unistyles.js +31 -0
  13. package/lib/commonjs/core/Unistyles.js.map +1 -0
  14. package/lib/commonjs/core/UnistylesModule.js +9 -0
  15. package/lib/commonjs/core/UnistylesModule.js.map +1 -0
  16. package/lib/commonjs/core/UnistylesRuntime.js +66 -0
  17. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
  18. package/lib/commonjs/core/index.js +13 -0
  19. package/lib/commonjs/core/index.js.map +1 -0
  20. package/lib/commonjs/createStyleSheet.js +14 -0
  21. package/lib/commonjs/createStyleSheet.js.map +1 -0
  22. package/lib/commonjs/global.js +2 -0
  23. package/lib/commonjs/global.js.map +1 -0
  24. package/lib/commonjs/hooks/index.js +10 -3
  25. package/lib/commonjs/hooks/index.js.map +1 -1
  26. package/lib/commonjs/hooks/useInitialTheme.js +17 -0
  27. package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
  28. package/lib/commonjs/hooks/useUnistyles.js +54 -0
  29. package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
  30. package/lib/commonjs/index.js +35 -6
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/types/common.js +2 -0
  33. package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
  34. package/lib/commonjs/types/index.js +26 -0
  35. package/lib/commonjs/types/index.js.map +1 -1
  36. package/lib/commonjs/types/mq.js +6 -0
  37. package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
  38. package/lib/commonjs/types/normalizer.js +6 -0
  39. package/lib/commonjs/types/normalizer.js.map +1 -0
  40. package/lib/commonjs/types/unistyles.js +6 -0
  41. package/lib/commonjs/types/unistyles.js.map +1 -0
  42. package/lib/commonjs/useStyles.js +49 -0
  43. package/lib/commonjs/useStyles.js.map +1 -0
  44. package/lib/commonjs/utils/breakpoints.js +44 -82
  45. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  46. package/lib/commonjs/utils/common.js +10 -3
  47. package/lib/commonjs/utils/common.js.map +1 -1
  48. package/lib/commonjs/utils/index.js +46 -17
  49. package/lib/commonjs/utils/index.js.map +1 -1
  50. package/lib/commonjs/utils/module.d.js +2 -0
  51. package/lib/commonjs/utils/module.d.js.map +1 -0
  52. package/lib/commonjs/utils/mq.js +89 -0
  53. package/lib/commonjs/utils/mq.js.map +1 -0
  54. package/lib/commonjs/utils/mqParser.js +86 -0
  55. package/lib/commonjs/utils/mqParser.js.map +1 -0
  56. package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
  57. package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
  58. package/lib/commonjs/utils/normalizer.js +89 -0
  59. package/lib/commonjs/utils/normalizer.js.map +1 -0
  60. package/lib/commonjs/utils/styles.js +17 -57
  61. package/lib/commonjs/utils/styles.js.map +1 -1
  62. package/lib/commonjs/utils/variants.js +20 -0
  63. package/lib/commonjs/utils/variants.js.map +1 -0
  64. package/lib/module/common.js +22 -0
  65. package/lib/module/common.js.map +1 -0
  66. package/lib/module/core/UnistyleRegistry.js +31 -0
  67. package/lib/module/core/UnistyleRegistry.js.map +1 -0
  68. package/lib/module/core/Unistyles.js +25 -0
  69. package/lib/module/core/Unistyles.js.map +1 -0
  70. package/lib/module/core/UnistylesModule.js +3 -0
  71. package/lib/module/core/UnistylesModule.js.map +1 -0
  72. package/lib/module/core/UnistylesRuntime.js +59 -0
  73. package/lib/module/core/UnistylesRuntime.js.map +1 -0
  74. package/lib/module/core/index.js +2 -0
  75. package/lib/module/core/index.js.map +1 -0
  76. package/lib/module/createStyleSheet.js +7 -0
  77. package/lib/module/createStyleSheet.js.map +1 -0
  78. package/lib/module/global.js +2 -0
  79. package/lib/module/global.js.map +1 -0
  80. package/lib/module/hooks/index.js +2 -1
  81. package/lib/module/hooks/index.js.map +1 -1
  82. package/lib/module/hooks/useInitialTheme.js +10 -0
  83. package/lib/module/hooks/useInitialTheme.js.map +1 -0
  84. package/lib/module/hooks/useUnistyles.js +47 -0
  85. package/lib/module/hooks/useUnistyles.js.map +1 -0
  86. package/lib/module/index.js +13 -2
  87. package/lib/module/index.js.map +1 -1
  88. package/lib/module/types/common.js +2 -0
  89. package/lib/module/types/common.js.map +1 -0
  90. package/lib/module/types/index.js +2 -1
  91. package/lib/module/types/index.js.map +1 -1
  92. package/lib/module/types/mq.js +2 -0
  93. package/lib/module/types/mq.js.map +1 -0
  94. package/lib/module/types/normalizer.js +2 -0
  95. package/lib/module/types/normalizer.js.map +1 -0
  96. package/lib/module/types/unistyles.js +2 -0
  97. package/lib/module/types/unistyles.js.map +1 -0
  98. package/lib/module/useStyles.js +42 -0
  99. package/lib/module/useStyles.js.map +1 -0
  100. package/lib/module/utils/breakpoints.js +43 -82
  101. package/lib/module/utils/breakpoints.js.map +1 -1
  102. package/lib/module/utils/common.js +9 -1
  103. package/lib/module/utils/common.js.map +1 -1
  104. package/lib/module/utils/index.js +6 -2
  105. package/lib/module/utils/index.js.map +1 -1
  106. package/lib/module/utils/module.d.js +2 -0
  107. package/lib/module/utils/module.d.js.map +1 -0
  108. package/lib/module/utils/mq.js +83 -0
  109. package/lib/module/utils/mq.js.map +1 -0
  110. package/lib/module/utils/mqParser.js +79 -0
  111. package/lib/module/utils/mqParser.js.map +1 -0
  112. package/lib/module/utils/normalizeStyles.web.js +13 -13
  113. package/lib/module/utils/normalizeStyles.web.js.map +1 -1
  114. package/lib/module/utils/normalizer.js +79 -0
  115. package/lib/module/utils/normalizer.js.map +1 -0
  116. package/lib/module/utils/styles.js +17 -59
  117. package/lib/module/utils/styles.js.map +1 -1
  118. package/lib/module/utils/variants.js +13 -0
  119. package/lib/module/utils/variants.js.map +1 -0
  120. package/lib/typescript/src/common.d.ts +17 -0
  121. package/lib/typescript/src/common.d.ts.map +1 -0
  122. package/lib/typescript/src/core/UnistyleRegistry.d.ts +15 -0
  123. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
  124. package/lib/typescript/src/core/Unistyles.d.ts +13 -0
  125. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
  126. package/lib/typescript/src/core/UnistylesModule.d.ts +6 -0
  127. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
  128. package/lib/typescript/src/core/UnistylesRuntime.d.ts +24 -0
  129. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
  130. package/lib/typescript/src/core/index.d.ts +2 -0
  131. package/lib/typescript/src/core/index.d.ts.map +1 -0
  132. package/lib/typescript/src/createStyleSheet.d.ts +3 -0
  133. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  134. package/lib/typescript/src/global.d.ts +7 -0
  135. package/lib/typescript/src/global.d.ts.map +1 -0
  136. package/lib/typescript/src/hooks/index.d.ts +2 -1
  137. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  138. package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
  139. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
  140. package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
  141. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
  142. package/lib/typescript/src/index.d.ts +14 -2
  143. package/lib/typescript/src/index.d.ts.map +1 -1
  144. package/lib/typescript/src/types/breakpoints.d.ts +13 -13
  145. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  146. package/lib/typescript/src/types/common.d.ts +3 -0
  147. package/lib/typescript/src/types/common.d.ts.map +1 -0
  148. package/lib/typescript/src/types/core.d.ts +34 -18
  149. package/lib/typescript/src/types/core.d.ts.map +1 -1
  150. package/lib/typescript/src/types/index.d.ts +6 -2
  151. package/lib/typescript/src/types/index.d.ts.map +1 -1
  152. package/lib/typescript/src/types/mq.d.ts +3 -0
  153. package/lib/typescript/src/types/mq.d.ts.map +1 -0
  154. package/lib/typescript/src/types/normalizer.d.ts +20 -0
  155. package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
  156. package/lib/typescript/src/types/unistyles.d.ts +37 -0
  157. package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
  158. package/lib/typescript/src/useStyles.d.ts +10 -0
  159. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  160. package/lib/typescript/src/utils/breakpoints.d.ts +5 -62
  161. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  162. package/lib/typescript/src/utils/common.d.ts +9 -1
  163. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  164. package/lib/typescript/src/utils/index.d.ts +6 -2
  165. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  166. package/lib/typescript/src/utils/mq.d.ts +21 -0
  167. package/lib/typescript/src/utils/mq.d.ts.map +1 -0
  168. package/lib/typescript/src/utils/mqParser.d.ts +3 -0
  169. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
  170. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
  171. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
  172. package/lib/typescript/src/utils/normalizer.d.ts +11 -0
  173. package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
  174. package/lib/typescript/src/utils/styles.d.ts +5 -49
  175. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  176. package/lib/typescript/src/utils/variants.d.ts +3 -0
  177. package/lib/typescript/src/utils/variants.d.ts.map +1 -0
  178. package/package.json +33 -15
  179. package/react-native-unistyles.podspec +22 -0
  180. package/src/common.ts +19 -0
  181. package/src/core/UnistyleRegistry.ts +41 -0
  182. package/src/core/Unistyles.ts +34 -0
  183. package/src/core/UnistylesModule.ts +7 -0
  184. package/src/core/UnistylesRuntime.ts +73 -0
  185. package/src/core/index.ts +1 -0
  186. package/src/createStyleSheet.ts +9 -0
  187. package/src/global.ts +5 -0
  188. package/src/hooks/index.ts +2 -1
  189. package/src/hooks/useInitialTheme.ts +11 -0
  190. package/src/hooks/useUnistyles.ts +55 -0
  191. package/src/index.ts +30 -2
  192. package/src/types/breakpoints.ts +20 -20
  193. package/src/types/common.ts +2 -0
  194. package/src/types/core.ts +42 -24
  195. package/src/types/index.ts +6 -9
  196. package/src/types/mq.ts +3 -0
  197. package/src/types/normalizer.ts +29 -0
  198. package/src/types/unistyles.ts +45 -0
  199. package/src/useStyles.ts +56 -0
  200. package/src/utils/breakpoints.ts +57 -88
  201. package/src/utils/common.ts +10 -1
  202. package/src/utils/index.ts +6 -9
  203. package/src/utils/module.d.ts +3 -0
  204. package/src/utils/mq.ts +106 -0
  205. package/src/utils/mqParser.ts +99 -0
  206. package/src/utils/normalizeStyles.web.ts +21 -42
  207. package/src/utils/normalizer.ts +99 -0
  208. package/src/utils/styles.ts +29 -68
  209. package/src/utils/variants.ts +17 -0
  210. package/lib/commonjs/UnistylesTheme.js +0 -21
  211. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  212. package/lib/commonjs/createUnistyles.js +0 -57
  213. package/lib/commonjs/createUnistyles.js.map +0 -1
  214. package/lib/commonjs/hooks/useDimensions.js +0 -10
  215. package/lib/commonjs/hooks/useDimensions.js.map +0 -1
  216. package/lib/commonjs/hooks/useDimensions.web.js +0 -31
  217. package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
  218. package/lib/commonjs/types/mediaQueries.js +0 -2
  219. package/lib/commonjs/utils/mediaQueries.js +0 -189
  220. package/lib/commonjs/utils/mediaQueries.js.map +0 -1
  221. package/lib/module/UnistylesTheme.js +0 -12
  222. package/lib/module/UnistylesTheme.js.map +0 -1
  223. package/lib/module/createUnistyles.js +0 -50
  224. package/lib/module/createUnistyles.js.map +0 -1
  225. package/lib/module/hooks/useDimensions.js +0 -3
  226. package/lib/module/hooks/useDimensions.js.map +0 -1
  227. package/lib/module/hooks/useDimensions.web.js +0 -24
  228. package/lib/module/hooks/useDimensions.web.js.map +0 -1
  229. package/lib/module/types/mediaQueries.js +0 -2
  230. package/lib/module/utils/mediaQueries.js +0 -176
  231. package/lib/module/utils/mediaQueries.js.map +0 -1
  232. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  233. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  234. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  235. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  236. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  237. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  238. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  239. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  240. package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
  241. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  242. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
  243. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  244. package/src/UnistylesTheme.tsx +0 -17
  245. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  246. package/src/createUnistyles.ts +0 -70
  247. package/src/hooks/useDimensions.ts +0 -4
  248. package/src/hooks/useDimensions.web.ts +0 -30
  249. package/src/types/mediaQueries.ts +0 -10
  250. package/src/utils/mediaQueries.ts +0 -201
@@ -1,50 +0,0 @@
1
- import { useContext, useMemo } from 'react';
2
- import { StyleSheet } from 'react-native';
3
- import { UnistylesContext } from './UnistylesTheme';
4
- import { useDimensions } from './hooks';
5
- import { getBreakpointFromScreenWidth, proxifyFunction, parseStyle, sortAndValidateBreakpoints } from './utils';
6
- export const createUnistyles = breakpoints => {
7
- const sortedBreakpoints = sortAndValidateBreakpoints(breakpoints);
8
- const sortedBreakpointEntries = Object.entries(sortedBreakpoints);
9
- return {
10
- createStyleSheet: styles => {
11
- if (typeof styles === 'function') {
12
- return styles;
13
- }
14
- return styles;
15
- },
16
- useStyles: stylesheet => {
17
- const theme = useContext(UnistylesContext);
18
- const screenSize = useDimensions();
19
- const breakpoint = getBreakpointFromScreenWidth(screenSize.width, sortedBreakpointEntries);
20
- if (!stylesheet) {
21
- return {
22
- theme,
23
- breakpoint,
24
- styles: {}
25
- };
26
- }
27
- const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
28
- const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
29
- let [key, value] = _ref;
30
- const style = value;
31
- if (typeof value === 'function') {
32
- return {
33
- ...acc,
34
- [key]: proxifyFunction(value, breakpoint, screenSize, sortedBreakpointEntries)
35
- };
36
- }
37
- return StyleSheet.create({
38
- ...acc,
39
- [key]: parseStyle(style, breakpoint, screenSize, sortedBreakpointEntries)
40
- });
41
- }, {}), [breakpoint, screenSize, parsedStyles]);
42
- return {
43
- theme,
44
- breakpoint,
45
- styles: dynamicStyleSheet
46
- };
47
- }
48
- };
49
- };
50
- //# sourceMappingURL=createUnistyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useContext","useMemo","StyleSheet","UnistylesContext","useDimensions","getBreakpointFromScreenWidth","proxifyFunction","parseStyle","sortAndValidateBreakpoints","createUnistyles","breakpoints","sortedBreakpoints","sortedBreakpointEntries","Object","entries","createStyleSheet","styles","useStyles","stylesheet","theme","screenSize","breakpoint","width","parsedStyles","dynamicStyleSheet","reduce","acc","_ref","key","value","style","create"],"sourceRoot":"../../src","sources":["createUnistyles.ts"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,UAAU,QAAQ,cAAc;AASzC,SAASC,gBAAgB,QAAQ,kB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ACN,CAACE,GAAG,GAAGtB,eAAe,CAAIuB,KAAK,EAAER,UAAU,EAAED,UAAU,EAAER,uBAAuB;UACpF,CAAC;QACL;QAEA,OAAOV,UAAU,CAAC6B,MAAM,CAAC;UACrB,GAAGL,GAAG;UACN,CAACE,GAAG,GAAGrB,UAAU,CAAQuB,KAAK,EAAET,UAAU,EAAED,UAAU,EAAER,uBAAuB;QACnF,CAAC,CAAC;MACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACS,UAAU,EAAED,UAAU,EAAEG,YAAY,CAAC,CAAC;MAEzD,OAAO;QACHJ,KAAK;QACLE,UAAU;QACVL,MAAM,EAAEQ;MACZ,CAAC;IACL;EACJ,CAAC;AACL,CAAC"}
@@ -1,3 +0,0 @@
1
- import { useWindowDimensions } from 'react-native';
2
- export const useDimensions = () => useWindowDimensions();
3
- //# sourceMappingURL=useDimensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useWindowDimensions","useDimensions"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAGlD,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkBD,mBAAmB,CAAC,CAAC"}
@@ -1,24 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react';
2
- export const useDimensions = () => {
3
- const timerRef = useRef();
4
- const [screenSize, setScreenSize] = useState({
5
- width: window.innerWidth,
6
- height: window.innerHeight
7
- });
8
- useEffect(() => {
9
- const handleResize = () => {
10
- clearTimeout(timerRef.current);
11
- timerRef.current = setTimeout(() => setScreenSize({
12
- width: window.innerWidth,
13
- height: window.innerHeight
14
- }), 100);
15
- };
16
- window.addEventListener('resize', handleResize);
17
- return () => {
18
- window.removeEventListener('resize', handleResize);
19
- clearTimeout(timerRef.current);
20
- };
21
- }, []);
22
- return screenSize;
23
- };
24
- //# sourceMappingURL=useDimensions.web.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","useRef","useState","useDimensions","timerRef","screenSize","setScreenSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAGnD,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAGH,MAAM,CAAgC,CAAC;EACxD,MAAM,CAACI,UAAU,EAAEC,aAAa,CAAC,GAAGJ,QAAQ,CAAa;IACrDK,KAAK,EAAEC,MAAM,CAACC,UAAU;IACxBC,MAAM,EAAEF,MAAM,CAACG;EACnB,CAAC,CAAC;EAEFX,SAAS,CAAC,MAAM;IACZ,MAAMY,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;MAE9BV,QAAQ,CAACU,OAAO,GAAGC,UAAU,CAAC,MAAMT,aAAa,CAAC;QAC9CC,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTJ,MAAM,CAACS,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOT,UAAU;AACrB,CAAC"}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=mediaQueries.js.map
@@ -1,176 +0,0 @@
1
- /**
2
- * Extracts numeric values from a coded string.
3
- *
4
- * The function is designed to process strings that have a format like "w[100,200]" or "h[300]".
5
- * It removes characters 'w', 'h', '[', and ']' from the input string and then extracts the numbers.
6
- *
7
- * @param {string} codedValue - The input string to extract values from.
8
- * @returns {Array<number>} An array of extracted numbers. Can contain one or two numbers based on the input format.
9
- *
10
- * @example
11
- * extractValues("w[100,200]") // returns [100, 200]
12
- * extractValues("h[300]") // returns [300]
13
- * extractValues("h[,300]") // returns [0,300]
14
- * extractValues("h[100,]") // returns [100]
15
- */
16
- export const extractValues = codedValue => {
17
- const [lh, rh] = codedValue.replace(/[wh[\]]/g, '').split(',');
18
- return rh ? [Number(lh), Number(rh)] : [Number(lh)];
19
- };
20
-
21
- /**
22
- * Determines if the given screen size matches the specified breakpoint query.
23
- *
24
- * The function checks if the screen size (width and/or height) falls within the range
25
- * specified by the breakpoint query. The query can specify width (using 'w'), height (using 'h'),
26
- * or both.
27
- *
28
- * @param {string} query - The breakpoint query string. Examples: 'w[100,200]', 'h[300]', 'w[100,200]h[300,400]'.
29
- * @param {ScreenSize} screenSize - The screen size to check against the breakpoint query.
30
- * @returns {boolean} True if the screen size matches the breakpoint query, false otherwise.
31
- *
32
- * @example
33
- * const screenSize = { width: 150, height: 350 }
34
- * isWithinBreakpoint('w[100,200]', screenSize) // returns true
35
- * isWithinBreakpoint('h[400]', screenSize) // returns false
36
- */
37
- export const isWithinBreakpoint = (query, screenSize) => {
38
- if (query.includes('w') && query.includes('h')) {
39
- return isWithinTheWidthAndHeight(query, screenSize);
40
- }
41
- if (query.charAt(0) === 'w') {
42
- return isWithinTheWidth(query, screenSize.width);
43
- }
44
- if (query.charAt(0) === 'h') {
45
- return isWithinTheHeight(query, screenSize.height);
46
- }
47
- return false;
48
- };
49
-
50
- /**
51
- * Determines if the given width matches the specified width range in the query.
52
- *
53
- * The function checks if the provided width falls within the range specified by the query.
54
- * The query specifies a width range using a format like 'w[100,200]'. If only one value is provided,
55
- * it's treated as a minimum width.
56
- *
57
- * @param {string} query - The width query string. Examples: 'w[100,200]' or 'w[100]'.
58
- * @param {number} width - The width to check against the query.
59
- * @returns {boolean} True if the width matches the query range, false otherwise.
60
- *
61
- * @example
62
- * isWithinTheWidth('w[100,200]', 150) // returns true
63
- * isWithinTheWidth('w[100]', 50) // returns false
64
- * isWithinTheWidth('w[100]', 150) // returns true
65
- */
66
- export const isWithinTheWidth = (query, width) => {
67
- const [minWidth, maxWidth] = extractValues(query);
68
- if (maxWidth && width >= minWidth && width <= maxWidth) {
69
- return true;
70
- }
71
- return !maxWidth && width >= minWidth;
72
- };
73
-
74
- /**
75
- * Determines if the given height matches the specified height range in the query.
76
- *
77
- * The function checks if the provided height falls within the range specified by the query.
78
- * The query specifies a height range using a format like 'h[100,200]'. If only one value is provided,
79
- * it's treated as a minimum height.
80
- *
81
- * @param {string} query - The height query string. Examples: 'h[100,200]' or 'h[100]'.
82
- * @param {number} height - The height to check against the query.
83
- * @returns {boolean} True if the height matches the query range, false otherwise.
84
- *
85
- * @example
86
- * isWithinTheHeight('h[100,200]', 150) // returns true
87
- * isWithinTheHeight('h[100]', 50) // returns false
88
- * isWithinTheHeight('h[100]', 150) // returns true
89
- */
90
- export const isWithinTheHeight = (query, height) => {
91
- const [minHeight, maxHeight] = extractValues(query);
92
- if (maxHeight && height >= minHeight && height <= maxHeight) {
93
- return true;
94
- }
95
- return !maxHeight && height >= minHeight;
96
- };
97
-
98
- /**
99
- * Determines if the given screen size matches both the specified width and height ranges in the query.
100
- *
101
- * The function checks if the provided screen size (both width and height) falls within the ranges
102
- * specified by the query. The query can specify both width and height using a format like 'w[100,200]:h[300,400]'.
103
- *
104
- * @param {string} query - The combined width and height query string. Example: 'w[100,200]:h[300,400]'.
105
- * @param {ScreenSize} screenSize - The screen size to check against the query.
106
- * @returns {boolean} True if the screen size matches both the width and height ranges in the query, false otherwise.
107
- *
108
- * @example
109
- * const screenSize = { width: 150, height: 350 }
110
- * isWithinTheWidthAndHeight('w[100,200]:h[300,400]', screenSize) // returns true
111
- * isWithinTheWidthAndHeight('w[100,200]:h[400,500]', screenSize) // returns false
112
- */
113
- export const isWithinTheWidthAndHeight = (query, screenSize) => {
114
- const result = query.split(':').filter(Boolean).map(q => isWithinBreakpoint(q, screenSize)).filter(Boolean);
115
- return result.length === 2;
116
- };
117
-
118
- /**
119
- * Checks if the given query string is a valid custom media query.
120
- *
121
- * The valid custom media query formats include:
122
- * - :w[200]
123
- * - :w[0, 200]
124
- * - :w[, 300]
125
- * - :h[200]
126
- * - :h[0, 500]
127
- * - :h[,200]
128
- * - :w[100, 300]:h[200,500]
129
- * - :h[200,500]:w[100, 300]
130
- *
131
- * @param {string} query - The query string to be checked.
132
- * @returns {boolean} Returns `true` if the query is a valid custom media query, otherwise `false`.
133
- * @example
134
- *
135
- * isMediaQuery(':w[200]') // true
136
- * isMediaQuery(':w100]') // false
137
- */
138
- export const isMediaQuery = query => {
139
- const regex = /^(?:(:w\[\d*(?:,\s?\d+)?])?(:h\[\d*(?:,\s?\d+)?])?|(:h\[\d*(?:,\s?\d+)?])?(:w\[\d*(?:,\s?\d+)?])?)$/;
140
- return query.length > 0 && regex.test(query);
141
- };
142
-
143
- /**
144
- * Retrieves the first matching custom media query key based on the provided screen size.
145
- *
146
- * The function processes an array of media queries and returns the first query that matches
147
- * the given screen size. The media queries can be in formats like:
148
- * - w[200]
149
- * - w[0, 200]
150
- * - w[, 300]
151
- * - h[200]
152
- * - h[0, 500]
153
- * - h[,200]
154
- * - w[100, 300]:h[200,500]
155
- * - h[200,500]:w[100, 300]
156
- *
157
- * @param {Array<[string, string | number]>} mediaQueries - An array of tuples containing media query keys and associated values.
158
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
159
- * @returns {string | undefined} Returns the first matching media query key or `undefined` if no match is found.
160
- * @example
161
- *
162
- * const queries = [[':w[200]', 'value1'], [':h[300,500]', 'value2']]
163
- * const size = { width: 250, height: 400 }
164
- * getKeyForCustomMediaQuery(queries, size) // ':w[200]
165
- */
166
- export const getKeyForCustomMediaQuery = (mediaQueries, screenSize) => {
167
- const [matchedQuery] = mediaQueries.flatMap(_ref => {
168
- let [key] = _ref;
169
- if (key.includes('w') && key.includes('h')) {
170
- return isWithinBreakpoint(key, screenSize) ? key : undefined;
171
- }
172
- return key.split(':').filter(Boolean).map(query => isWithinBreakpoint(query, screenSize) ? key : undefined);
173
- }).filter(Boolean);
174
- return matchedQuery;
175
- };
176
- //# sourceMappingURL=mediaQueries.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["extractValues","codedValue","lh","rh","replace","split","Number","isWithinBreakpoint","query","screenSize","includes","isWithinTheWidthAndHeight","charAt","isWithinTheWidth","width","isWithinTheHeight","height","minWidth","maxWidth","minHeight","maxHeight","result","filter","Boolean","map","q","length","isMediaQuery","regex","test","getKeyForCustomMediaQuery","mediaQueries","matchedQuery","flatMap","_ref","key","undefined"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.ts"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAIC,UAAkB,IAAoB;EAChE,MAAM,CAACC,EAAE,EAAEC,EAAE,CAAC,GAAGF,UAAU,CACtBG,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CACvBC,KAAK,CAAC,GAAG,CAAC;EAEf,OAAOF,EAAE,GACH,CAACG,MAAM,CAACJ,EAAE,CAAC,EAAEI,MAAM,CAACH,EAAE,CAAC,CAAC,GACxB,CAACG,MAAM,CAACJ,EAAE,CAAC,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,kBAAkB,GAAGA,CAACC,KAAa,EAAEC,UAAsB,KAAc;EAClF,IAAID,KAAK,CAACE,QAAQ,CAAC,GAAG,CAAC,IAAIF,KAAK,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC5C,OAAOC,yBAAyB,CAACH,KAAK,EAAEC,UAAU,CAAC;EACvD;EAEA,IAAID,KAAK,CAACI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IACzB,OAAOC,gBAA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,9 +0,0 @@
1
- import React from 'react';
2
- import type { PropsWithChildren } from 'react';
3
- interface UnistylesThemeProps extends PropsWithChildren {
4
- theme: any;
5
- }
6
- export declare const UnistylesContext: React.Context<{}>;
7
- export declare const UnistylesTheme: React.FunctionComponent<UnistylesThemeProps>;
8
- export {};
9
- //# sourceMappingURL=UnistylesTheme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UnistylesTheme.d.ts","sourceRoot":"","sources":["../../../src/UnistylesTheme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAA;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAE9C,UAAU,mBAAoB,SAAQ,iBAAiB;IACnD,KAAK,EAAE,GAAG,CAAA;CACb;AAED,eAAO,MAAM,gBAAgB,mBAAoB,CAAA;AAEjD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAOvE,CAAA"}
@@ -1,10 +0,0 @@
1
- import type { Breakpoints, CreateStylesFactory, CustomNamedStyles, ExtractBreakpoints, RemoveKeysWithPrefix } from './types';
2
- export declare const createUnistyles: <B extends Breakpoints, T = {}>(breakpoints: B) => {
3
- createStyleSheet: <S extends CustomNamedStyles<S, B>, X>(styles: S | X | CustomNamedStyles<S, B> | ((theme: T) => X | CustomNamedStyles<X, B>)) => S | X;
4
- useStyles: <ST extends CustomNamedStyles<ST, B>>(stylesheet?: ST | CreateStylesFactory<ST, T> | undefined) => {
5
- theme: T;
6
- breakpoint: keyof B & string;
7
- styles: ExtractBreakpoints<RemoveKeysWithPrefix<ST, B>, B>;
8
- };
9
- };
10
- //# sourceMappingURL=createUnistyles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createUnistyles.d.ts","sourceRoot":"","sources":["../../../src/createUnistyles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAEvB,MAAM,SAAS,CAAA;AAKhB,eAAO,MAAM,eAAe;;;;;;;CAuD3B,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { ScreenSize } from '../types';
2
- export declare const useDimensions: () => ScreenSize;
3
- //# sourceMappingURL=useDimensions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDimensions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,aAAa,QAAO,UAAmC,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { ScreenSize } from '../types';
2
- export declare const useDimensions: () => ScreenSize;
3
- //# sourceMappingURL=useDimensions.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDimensions.web.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDimensions.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,aAAa,QAAO,UA0BhC,CAAA"}
@@ -1,8 +0,0 @@
1
- type Optional<TOptional extends string> = TOptional | '';
2
- type Separator = ',' | ', ';
3
- type MediaQuery = `[${Separator}${bigint}]` | `[${bigint}${Optional<`${Separator}${bigint}`>}]`;
4
- type WidthMediaQuery = `:w${MediaQuery}`;
5
- type HeightMediaQuery = `:h${MediaQuery}`;
6
- export type MediaQueries = `${WidthMediaQuery}${Optional<HeightMediaQuery>}` | `${HeightMediaQuery}${Optional<WidthMediaQuery>}`;
7
- export {};
8
- //# sourceMappingURL=mediaQueries.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../../src/types/mediaQueries.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,SAAS,SAAS,MAAM,IAAI,SAAS,GAAG,EAAE,CAAA;AACxD,KAAK,SAAS,GAAG,GAAG,GAAG,IAAI,CAAA;AAE3B,KAAK,UAAU,GAAG,IAAI,SAAS,GAAG,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,QAAQ,CAAC,GAAG,SAAS,GAAG,MAAM,EAAE,CAAC,GAAG,CAAA;AAC/F,KAAK,eAAe,GAAG,KAAK,UAAU,EAAE,CAAA;AACxC,KAAK,gBAAgB,GAAG,KAAK,UAAU,EAAE,CAAA;AAEzC,MAAM,MAAM,YAAY,GAClB,GAAG,eAAe,GAAG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,GACjD,GAAG,gBAAgB,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAA"}
@@ -1,130 +0,0 @@
1
- import type { ScreenSize } from '../types';
2
- /**
3
- * Extracts numeric values from a coded string.
4
- *
5
- * The function is designed to process strings that have a format like "w[100,200]" or "h[300]".
6
- * It removes characters 'w', 'h', '[', and ']' from the input string and then extracts the numbers.
7
- *
8
- * @param {string} codedValue - The input string to extract values from.
9
- * @returns {Array<number>} An array of extracted numbers. Can contain one or two numbers based on the input format.
10
- *
11
- * @example
12
- * extractValues("w[100,200]") // returns [100, 200]
13
- * extractValues("h[300]") // returns [300]
14
- * extractValues("h[,300]") // returns [0,300]
15
- * extractValues("h[100,]") // returns [100]
16
- */
17
- export declare const extractValues: (codedValue: string) => Array<number>;
18
- /**
19
- * Determines if the given screen size matches the specified breakpoint query.
20
- *
21
- * The function checks if the screen size (width and/or height) falls within the range
22
- * specified by the breakpoint query. The query can specify width (using 'w'), height (using 'h'),
23
- * or both.
24
- *
25
- * @param {string} query - The breakpoint query string. Examples: 'w[100,200]', 'h[300]', 'w[100,200]h[300,400]'.
26
- * @param {ScreenSize} screenSize - The screen size to check against the breakpoint query.
27
- * @returns {boolean} True if the screen size matches the breakpoint query, false otherwise.
28
- *
29
- * @example
30
- * const screenSize = { width: 150, height: 350 }
31
- * isWithinBreakpoint('w[100,200]', screenSize) // returns true
32
- * isWithinBreakpoint('h[400]', screenSize) // returns false
33
- */
34
- export declare const isWithinBreakpoint: (query: string, screenSize: ScreenSize) => boolean;
35
- /**
36
- * Determines if the given width matches the specified width range in the query.
37
- *
38
- * The function checks if the provided width falls within the range specified by the query.
39
- * The query specifies a width range using a format like 'w[100,200]'. If only one value is provided,
40
- * it's treated as a minimum width.
41
- *
42
- * @param {string} query - The width query string. Examples: 'w[100,200]' or 'w[100]'.
43
- * @param {number} width - The width to check against the query.
44
- * @returns {boolean} True if the width matches the query range, false otherwise.
45
- *
46
- * @example
47
- * isWithinTheWidth('w[100,200]', 150) // returns true
48
- * isWithinTheWidth('w[100]', 50) // returns false
49
- * isWithinTheWidth('w[100]', 150) // returns true
50
- */
51
- export declare const isWithinTheWidth: (query: string, width: number) => boolean;
52
- /**
53
- * Determines if the given height matches the specified height range in the query.
54
- *
55
- * The function checks if the provided height falls within the range specified by the query.
56
- * The query specifies a height range using a format like 'h[100,200]'. If only one value is provided,
57
- * it's treated as a minimum height.
58
- *
59
- * @param {string} query - The height query string. Examples: 'h[100,200]' or 'h[100]'.
60
- * @param {number} height - The height to check against the query.
61
- * @returns {boolean} True if the height matches the query range, false otherwise.
62
- *
63
- * @example
64
- * isWithinTheHeight('h[100,200]', 150) // returns true
65
- * isWithinTheHeight('h[100]', 50) // returns false
66
- * isWithinTheHeight('h[100]', 150) // returns true
67
- */
68
- export declare const isWithinTheHeight: (query: string, height: number) => boolean;
69
- /**
70
- * Determines if the given screen size matches both the specified width and height ranges in the query.
71
- *
72
- * The function checks if the provided screen size (both width and height) falls within the ranges
73
- * specified by the query. The query can specify both width and height using a format like 'w[100,200]:h[300,400]'.
74
- *
75
- * @param {string} query - The combined width and height query string. Example: 'w[100,200]:h[300,400]'.
76
- * @param {ScreenSize} screenSize - The screen size to check against the query.
77
- * @returns {boolean} True if the screen size matches both the width and height ranges in the query, false otherwise.
78
- *
79
- * @example
80
- * const screenSize = { width: 150, height: 350 }
81
- * isWithinTheWidthAndHeight('w[100,200]:h[300,400]', screenSize) // returns true
82
- * isWithinTheWidthAndHeight('w[100,200]:h[400,500]', screenSize) // returns false
83
- */
84
- export declare const isWithinTheWidthAndHeight: (query: string, screenSize: ScreenSize) => boolean;
85
- /**
86
- * Checks if the given query string is a valid custom media query.
87
- *
88
- * The valid custom media query formats include:
89
- * - :w[200]
90
- * - :w[0, 200]
91
- * - :w[, 300]
92
- * - :h[200]
93
- * - :h[0, 500]
94
- * - :h[,200]
95
- * - :w[100, 300]:h[200,500]
96
- * - :h[200,500]:w[100, 300]
97
- *
98
- * @param {string} query - The query string to be checked.
99
- * @returns {boolean} Returns `true` if the query is a valid custom media query, otherwise `false`.
100
- * @example
101
- *
102
- * isMediaQuery(':w[200]') // true
103
- * isMediaQuery(':w100]') // false
104
- */
105
- export declare const isMediaQuery: (query: string) => boolean;
106
- /**
107
- * Retrieves the first matching custom media query key based on the provided screen size.
108
- *
109
- * The function processes an array of media queries and returns the first query that matches
110
- * the given screen size. The media queries can be in formats like:
111
- * - w[200]
112
- * - w[0, 200]
113
- * - w[, 300]
114
- * - h[200]
115
- * - h[0, 500]
116
- * - h[,200]
117
- * - w[100, 300]:h[200,500]
118
- * - h[200,500]:w[100, 300]
119
- *
120
- * @param {Array<[string, string | number]>} mediaQueries - An array of tuples containing media query keys and associated values.
121
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
122
- * @returns {string | undefined} Returns the first matching media query key or `undefined` if no match is found.
123
- * @example
124
- *
125
- * const queries = [[':w[200]', 'value1'], [':h[300,500]', 'value2']]
126
- * const size = { width: 250, height: 400 }
127
- * getKeyForCustomMediaQuery(queries, size) // ':w[200]
128
- */
129
- export declare const getKeyForCustomMediaQuery: (mediaQueries: Array<[string, string | number | undefined]>, screenSize: ScreenSize) => string | undefined;
130
- //# sourceMappingURL=mediaQueries.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../../src/utils/mediaQueries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,eAAgB,MAAM,KAAG,MAAM,MAAM,CAQ9D,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,UAAW,MAAM,cAAc,UAAU,KAAG,OAc1E,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,SAAS,MAAM,KAAG,OAQ/D,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,UAAU,MAAM,KAAG,OAQjE,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,UAAW,MAAM,cAAc,UAAU,KAAG,OAQjF,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,OAI5C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,iBAAkB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,cAAc,UAAU,KAAG,MAAM,GAAG,SAevI,CAAA"}
@@ -1,17 +0,0 @@
1
- import React, { createContext } from 'react'
2
- import type { PropsWithChildren } from 'react'
3
-
4
- interface UnistylesThemeProps extends PropsWithChildren {
5
- theme: any
6
- }
7
-
8
- export const UnistylesContext = createContext({})
9
-
10
- export const UnistylesTheme: React.FunctionComponent<UnistylesThemeProps> = ({
11
- theme,
12
- children
13
- }) => (
14
- <UnistylesContext.Provider value={theme}>
15
- {children}
16
- </UnistylesContext.Provider>
17
- )