react-native-unistyles 1.1.1 → 2.0.0-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. package/ios/UnistylesModule.h +10 -0
  2. package/ios/UnistylesModule.mm +108 -0
  3. package/ios/UnistylesRuntime.h +30 -0
  4. package/ios/UnistylesRuntime.mm +191 -0
  5. package/lib/commonjs/UnistyleRegistry.js +37 -0
  6. package/lib/commonjs/UnistyleRegistry.js.map +1 -0
  7. package/lib/commonjs/Unistyles.js +36 -0
  8. package/lib/commonjs/Unistyles.js.map +1 -0
  9. package/lib/commonjs/UnistylesEngine.js +22 -0
  10. package/lib/commonjs/UnistylesEngine.js.map +1 -0
  11. package/lib/commonjs/UnistylesModule.js +9 -0
  12. package/lib/commonjs/UnistylesModule.js.map +1 -0
  13. package/lib/commonjs/UnistylesRuntime.js +52 -0
  14. package/lib/commonjs/UnistylesRuntime.js.map +1 -0
  15. package/lib/commonjs/createStyleSheet.js +14 -0
  16. package/lib/commonjs/createStyleSheet.js.map +1 -0
  17. package/lib/commonjs/global.js +2 -0
  18. package/lib/commonjs/global.js.map +1 -0
  19. package/lib/commonjs/index.js +33 -6
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/types/cxx.js +23 -0
  22. package/lib/commonjs/types/cxx.js.map +1 -0
  23. package/lib/commonjs/types/index.js +11 -0
  24. package/lib/commonjs/types/index.js.map +1 -1
  25. package/lib/commonjs/useInitialTheme.js +13 -0
  26. package/lib/commonjs/useInitialTheme.js.map +1 -0
  27. package/lib/commonjs/useStyles.js +48 -0
  28. package/lib/commonjs/useStyles.js.map +1 -0
  29. package/lib/commonjs/useUnistyles.js +59 -0
  30. package/lib/commonjs/useUnistyles.js.map +1 -0
  31. package/lib/commonjs/utils/breakpoints.js +4 -2
  32. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  33. package/lib/commonjs/utils/styles.js +6 -6
  34. package/lib/commonjs/utils/styles.js.map +1 -1
  35. package/lib/module/UnistyleRegistry.js +30 -0
  36. package/lib/module/UnistyleRegistry.js.map +1 -0
  37. package/lib/module/Unistyles.js +30 -0
  38. package/lib/module/Unistyles.js.map +1 -0
  39. package/lib/module/UnistylesEngine.js +15 -0
  40. package/lib/module/UnistylesEngine.js.map +1 -0
  41. package/lib/module/UnistylesModule.js +3 -0
  42. package/lib/module/UnistylesModule.js.map +1 -0
  43. package/lib/module/UnistylesRuntime.js +45 -0
  44. package/lib/module/UnistylesRuntime.js.map +1 -0
  45. package/lib/module/createStyleSheet.js +7 -0
  46. package/lib/module/createStyleSheet.js.map +1 -0
  47. package/lib/module/global.js +2 -0
  48. package/lib/module/global.js.map +1 -0
  49. package/lib/module/index.js +18 -2
  50. package/lib/module/index.js.map +1 -1
  51. package/lib/module/types/cxx.js +17 -0
  52. package/lib/module/types/cxx.js.map +1 -0
  53. package/lib/module/types/index.js +1 -0
  54. package/lib/module/types/index.js.map +1 -1
  55. package/lib/module/useInitialTheme.js +6 -0
  56. package/lib/module/useInitialTheme.js.map +1 -0
  57. package/lib/module/useStyles.js +42 -0
  58. package/lib/module/useStyles.js.map +1 -0
  59. package/lib/module/useUnistyles.js +52 -0
  60. package/lib/module/useUnistyles.js.map +1 -0
  61. package/lib/module/utils/breakpoints.js +4 -3
  62. package/lib/module/utils/breakpoints.js.map +1 -1
  63. package/lib/module/utils/styles.js +6 -7
  64. package/lib/module/utils/styles.js.map +1 -1
  65. package/lib/typescript/examples/expo/src/App.d.ts.map +1 -1
  66. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts +3 -0
  67. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts.map +1 -0
  68. package/lib/typescript/examples/expo/src/examples/index.d.ts +1 -7
  69. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -1
  70. package/lib/typescript/examples/expo/src/styles/index.d.ts +15 -45
  71. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -1
  72. package/lib/typescript/examples/expo/src/styles/theme.d.ts +17 -1
  73. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -1
  74. package/lib/typescript/src/UnistyleRegistry.d.ts +15 -0
  75. package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -0
  76. package/lib/typescript/src/Unistyles.d.ts +16 -0
  77. package/lib/typescript/src/Unistyles.d.ts.map +1 -0
  78. package/lib/typescript/src/UnistylesEngine.d.ts +8 -0
  79. package/lib/typescript/src/UnistylesEngine.d.ts.map +1 -0
  80. package/lib/typescript/src/UnistylesModule.d.ts +6 -0
  81. package/lib/typescript/src/UnistylesModule.d.ts.map +1 -0
  82. package/lib/typescript/src/UnistylesRuntime.d.ts +56 -0
  83. package/lib/typescript/src/UnistylesRuntime.d.ts.map +1 -0
  84. package/lib/typescript/src/createStyleSheet.d.ts +6 -0
  85. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  86. package/lib/typescript/src/global.d.ts +5 -0
  87. package/lib/typescript/src/global.d.ts.map +1 -0
  88. package/lib/typescript/src/index.d.ts +14 -2
  89. package/lib/typescript/src/index.d.ts.map +1 -1
  90. package/lib/typescript/src/types/breakpoints.d.ts +6 -7
  91. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  92. package/lib/typescript/src/types/core.d.ts +4 -4
  93. package/lib/typescript/src/types/core.d.ts.map +1 -1
  94. package/lib/typescript/src/types/cxx.d.ts +50 -0
  95. package/lib/typescript/src/types/cxx.d.ts.map +1 -0
  96. package/lib/typescript/src/types/index.d.ts +3 -1
  97. package/lib/typescript/src/types/index.d.ts.map +1 -1
  98. package/lib/typescript/src/useInitialTheme.d.ts +3 -0
  99. package/lib/typescript/src/useInitialTheme.d.ts.map +1 -0
  100. package/lib/typescript/src/useStyles.d.ts +46 -0
  101. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  102. package/lib/typescript/src/useUnistyles.d.ts +45 -0
  103. package/lib/typescript/src/useUnistyles.d.ts.map +1 -0
  104. package/lib/typescript/src/utils/breakpoints.d.ts +5 -4
  105. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  106. package/lib/typescript/src/utils/styles.d.ts +4 -3
  107. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  108. package/package.json +11 -8
  109. package/react-native-unistyles.podspec +21 -0
  110. package/src/UnistyleRegistry.ts +39 -0
  111. package/src/Unistyles.ts +41 -0
  112. package/src/UnistylesEngine.ts +15 -0
  113. package/src/UnistylesModule.ts +7 -0
  114. package/src/UnistylesRuntime.ts +58 -0
  115. package/src/createStyleSheet.ts +12 -0
  116. package/src/global.ts +2 -0
  117. package/src/index.ts +30 -2
  118. package/src/types/breakpoints.ts +9 -11
  119. package/src/types/core.ts +6 -6
  120. package/src/types/cxx.ts +61 -0
  121. package/src/types/index.ts +3 -3
  122. package/src/useInitialTheme.ts +7 -0
  123. package/src/useStyles.ts +49 -0
  124. package/src/useUnistyles.ts +67 -0
  125. package/src/utils/breakpoints.ts +16 -14
  126. package/src/utils/styles.ts +16 -18
  127. package/lib/commonjs/UnistylesTheme.js +0 -21
  128. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  129. package/lib/commonjs/createUnistyles.js +0 -57
  130. package/lib/commonjs/createUnistyles.js.map +0 -1
  131. package/lib/module/UnistylesTheme.js +0 -12
  132. package/lib/module/UnistylesTheme.js.map +0 -1
  133. package/lib/module/createUnistyles.js +0 -50
  134. package/lib/module/createUnistyles.js.map +0 -1
  135. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +0 -3
  136. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +0 -1
  137. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +0 -3
  138. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +0 -1
  139. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +0 -7
  140. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +0 -1
  141. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +0 -3
  142. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +0 -1
  143. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +0 -3
  144. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +0 -1
  145. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +0 -3
  146. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +0 -1
  147. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +0 -3
  148. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +0 -1
  149. package/lib/typescript/examples/expo/src/examples/Theme.d.ts +0 -3
  150. package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +0 -1
  151. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  152. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  153. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  154. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  155. package/src/UnistylesTheme.tsx +0 -17
  156. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  157. package/src/createUnistyles.ts +0 -70
@@ -0,0 +1,49 @@
1
+ import { useMemo } from 'react'
2
+ import { StyleSheet } from 'react-native'
3
+ import { parseStyle, proxifyFunction } from './utils'
4
+ import type { CreateStylesFactory, CustomNamedStyles, ExtractBreakpoints, RemoveKeysWithPrefix } from './types'
5
+ import { useUnistyles } from './useUnistyles'
6
+ import type { UnistylesThemes } from './global'
7
+
8
+ // todo types
9
+ type T = UnistylesThemes[keyof UnistylesThemes]
10
+
11
+ export const useStyles = <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, T>) => {
12
+ const { theme, breakpoint, screenSize } = useUnistyles()
13
+
14
+ if (!stylesheet) {
15
+ return {
16
+ theme,
17
+ breakpoint,
18
+ styles: {} as ExtractBreakpoints<RemoveKeysWithPrefix<ST>>
19
+ }
20
+ }
21
+
22
+ const parsedStyles = useMemo(() => typeof stylesheet === 'function'
23
+ ? stylesheet(theme!)
24
+ : stylesheet, [theme, stylesheet])
25
+
26
+ const dynamicStyleSheet = useMemo(() => Object
27
+ .entries(parsedStyles)
28
+ .reduce((acc, [key, value]) => {
29
+ const style = value as CustomNamedStyles<ST>
30
+
31
+ if (typeof value === 'function') {
32
+ return {
33
+ ...acc,
34
+ [key]: proxifyFunction(value, breakpoint!, screenSize)
35
+ }
36
+ }
37
+
38
+ return StyleSheet.create({
39
+ ...acc,
40
+ [key]: parseStyle<ST>(style, breakpoint!, screenSize)
41
+ })
42
+ }, {} as ST), [breakpoint, screenSize, parsedStyles])
43
+
44
+ return {
45
+ theme,
46
+ breakpoint,
47
+ styles: dynamicStyleSheet as ExtractBreakpoints<RemoveKeysWithPrefix<ST>>
48
+ }
49
+ }
@@ -0,0 +1,67 @@
1
+ import { NativeEventEmitter, NativeModules } from 'react-native'
2
+ import { useEffect, useState } from 'react'
3
+ import type {
4
+ CxxUnistylesBreakpointEvent,
5
+ CxxUnistylesSizeEvent,
6
+ CxxUnistylesThemeEvent,
7
+ UnistylesEvents
8
+ } from './types'
9
+ import { CxxUnistylesEventTypes } from './types'
10
+ import { unistyles } from './Unistyles'
11
+
12
+ const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
13
+
14
+ export const useUnistyles = () => {
15
+ const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.theme))
16
+ const [breakpoint, setBreakpoint] = useState(unistyles.runtime.currentBreakpoint)
17
+ const [screenSize, setScreenSize] = useState({
18
+ width: 0,
19
+ height: 0
20
+ })
21
+
22
+ useEffect(() => {
23
+ const subscription = unistylesEvents.addListener(
24
+ 'onChange',
25
+ (event: UnistylesEvents) => {
26
+ switch (event.type) {
27
+ case CxxUnistylesEventTypes.Theme: {
28
+ const themeEvent = event as CxxUnistylesThemeEvent
29
+
30
+ setTheme(unistyles.runtime.getTheme(themeEvent.payload.currentTheme))
31
+
32
+ return
33
+ }
34
+ case CxxUnistylesEventTypes.Size: {
35
+ const sizeEvent = event as CxxUnistylesSizeEvent
36
+
37
+ setScreenSize({
38
+ width: sizeEvent.payload.width,
39
+ height: sizeEvent.payload.height
40
+ })
41
+ // todo
42
+ // setBreakpoint(unistyles.runtime.currentBreakpoint)
43
+
44
+ return
45
+ }
46
+ case CxxUnistylesEventTypes.Breakpoint: {
47
+ const breakpointEvent = event as CxxUnistylesBreakpointEvent
48
+
49
+ setBreakpoint(breakpointEvent.payload.currentBreakpoint)
50
+
51
+ return
52
+ }
53
+ default:
54
+ return
55
+ }
56
+ }
57
+ )
58
+
59
+ return subscription.remove
60
+ }, [])
61
+
62
+ return {
63
+ theme,
64
+ breakpoint,
65
+ screenSize
66
+ }
67
+ }
@@ -1,6 +1,8 @@
1
+ import { unistyles } from '../Unistyles'
1
2
  import { throwError } from './common'
2
- import type { Breakpoints, ScreenSize, SortedBreakpointEntries } from '../types'
3
+ import type { ScreenSize, MediaQueries } from '../types'
3
4
  import { getKeyForCustomMediaQuery, isMediaQuery } from './mediaQueries'
5
+ import type { UnistylesBreakpoints } from '../global'
4
6
 
5
7
  /**
6
8
  * Sorts the breakpoints object based on its numeric values in ascending order and validates them.
@@ -21,17 +23,17 @@ import { getKeyForCustomMediaQuery, isMediaQuery } from './mediaQueries'
21
23
  * const input = { md: 768, lg: 1024, sm: 0 }
22
24
  * sortAndValidateBreakpoints(input) // returns { sm: 0, md: 768, lg: 1024 }
23
25
  */
24
- export const sortAndValidateBreakpoints = <B extends Breakpoints>(breakpoints: B): B => {
26
+ export const sortAndValidateBreakpoints = (breakpoints: UnistylesBreakpoints): UnistylesBreakpoints => {
25
27
  const sortedPairs = Object
26
28
  .entries(breakpoints)
27
29
  .sort((breakpoint1, breakpoint2) => {
28
30
  const [, value1] = breakpoint1
29
31
  const [, value2] = breakpoint2
30
32
 
31
- return value1 - value2
33
+ return (value1 as number) - (value2 as number)
32
34
  })
33
35
 
34
- const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs)) as B
36
+ const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs)) as UnistylesBreakpoints
35
37
  const breakpointValues = Object.values(sortedBreakpoints)
36
38
  const [firstBreakpoint] = breakpointValues
37
39
 
@@ -61,7 +63,7 @@ export const sortAndValidateBreakpoints = <B extends Breakpoints>(breakpoints: B
61
63
  * const breakpoints = { sm: 0, md: 768, lg: 1024 }
62
64
  * getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
63
65
  */
64
- export const getBreakpointFromScreenWidth = <B extends Breakpoints>(width: number, breakpointEntries: SortedBreakpointEntries<B>): keyof B & string => {
66
+ export const getBreakpointFromScreenWidth = (width: number, breakpointEntries: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>): keyof UnistylesBreakpoints & string => {
65
67
  const [key] = breakpointEntries
66
68
  .find(([, value], index, otherBreakpoints) => {
67
69
  const minVal = value
@@ -72,7 +74,7 @@ export const getBreakpointFromScreenWidth = <B extends Breakpoints>(width: numbe
72
74
  }
73
75
 
74
76
  return width >= minVal && width < maxVal
75
- }) as [keyof B & string, number]
77
+ }) as [keyof UnistylesBreakpoints & string, number]
76
78
 
77
79
  return key
78
80
  }
@@ -101,24 +103,23 @@ export const getBreakpointFromScreenWidth = <B extends Breakpoints>(width: numbe
101
103
  *
102
104
  * getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
103
105
  */
104
- export const getValueForBreakpoint = <B extends Breakpoints>(
105
- value: Record<keyof B & string, string | number | undefined>,
106
- breakpoint: keyof B & string,
107
- screenSize: ScreenSize,
108
- breakpointPairs: SortedBreakpointEntries<B>
106
+ export const getValueForBreakpoint = (
107
+ value: Record<keyof UnistylesBreakpoints | MediaQueries, string | number | undefined>,
108
+ breakpoint: keyof UnistylesBreakpoints,
109
+ screenSize: ScreenSize
109
110
  ): string | number | undefined => {
110
111
  // the highest priority is for custom media queries
111
112
  const customMediaQueries = Object
112
113
  .entries(value)
113
114
  .filter(([key]) => isMediaQuery(key))
114
- const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize)
115
+ const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize) as keyof typeof value
115
116
 
116
117
  if (customMediaQueryKey && customMediaQueryKey in value) {
117
118
  return value[customMediaQueryKey]
118
119
  }
119
120
 
120
121
  // if no custom media query, or didn't match, proceed with defined breakpoints
121
- const unifiedKey = breakpoint.toLowerCase()
122
+ const unifiedKey = breakpoint?.toLowerCase() as keyof typeof value
122
123
  const directBreakpoint = value[unifiedKey]
123
124
 
124
125
  // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
@@ -127,6 +128,7 @@ export const getValueForBreakpoint = <B extends Breakpoints>(
127
128
  }
128
129
 
129
130
  // there is no direct hit for breakpoint nor media-query, so let's simulate CSS cascading
131
+ const breakpointPairs = unistyles.runtime.sortedBreakpoints
130
132
  const currentBreakpoint = breakpointPairs
131
133
  .findIndex(([key]) => key === unifiedKey)
132
134
 
@@ -135,6 +137,6 @@ export const getValueForBreakpoint = <B extends Breakpoints>(
135
137
  .map(([key]) => key)
136
138
 
137
139
  return breakpointPairs.length > 0
138
- ? value[availableBreakpoints[availableBreakpoints.length - 1] as keyof B & string]
140
+ ? value[availableBreakpoints[availableBreakpoints.length - 1] as keyof UnistylesBreakpoints & string]
139
141
  : undefined
140
142
  }
@@ -1,7 +1,8 @@
1
- import type { Breakpoints, CustomNamedStyles, ScreenSize, SortedBreakpointEntries } from '../types'
1
+ import type { CustomNamedStyles, ScreenSize } from '../types'
2
2
  import { getValueForBreakpoint } from './breakpoints'
3
3
  import { normalizeStyles } from './normalizeStyles'
4
4
  import { isWeb } from './common'
5
+ import type { UnistylesBreakpoints } from '../global'
5
6
 
6
7
  /**
7
8
  * Proxies a function to parse its return value for custom media queries or breakpoints.
@@ -24,13 +25,12 @@ import { isWeb } from './common'
24
25
  * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
25
26
  * proxifiedFunction() // parsed style based on screenSize and breakpoints
26
27
  */
27
- export const proxifyFunction = <B extends Breakpoints>(
28
- fn: Function, breakpoint: keyof B & string,
29
- screenSize: ScreenSize,
30
- breakpointPairs: SortedBreakpointEntries<B>
28
+ export const proxifyFunction = (
29
+ fn: Function, breakpoint: keyof UnistylesBreakpoints & string,
30
+ screenSize: ScreenSize
31
31
  ): Function => new Proxy(fn, {
32
32
  apply: (target, thisArg, argumentsList) =>
33
- parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
33
+ parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize)
34
34
  })
35
35
 
36
36
  /**
@@ -58,15 +58,14 @@ export const proxifyFunction = <B extends Breakpoints>(
58
58
  * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
59
59
  * // { fontSize: '12px' }
60
60
  */
61
- export const parseStyle = <T, B extends Breakpoints>(
62
- style: CustomNamedStyles<T, B>,
63
- breakpoint: keyof B & string,
64
- screenSize: ScreenSize,
65
- breakpointPairs: SortedBreakpointEntries<B>
61
+ export const parseStyle = <T>(
62
+ style: CustomNamedStyles<T>,
63
+ breakpoint: keyof UnistylesBreakpoints & string,
64
+ screenSize: ScreenSize
66
65
  ): T => {
67
66
  const entries = Object.entries(style) as [[
68
67
  keyof T,
69
- CustomNamedStyles<T, B> | Record<keyof B & string, string | number | undefined>]
68
+ CustomNamedStyles<T> | Record<keyof UnistylesBreakpoints & string, string | number | undefined>]
70
69
  ]
71
70
 
72
71
  const parsedStyles = Object
@@ -77,7 +76,7 @@ export const parseStyle = <T, B extends Breakpoints>(
77
76
  if (hasNestedProperties) {
78
77
  return [
79
78
  key,
80
- parseStyle(value as CustomNamedStyles<T, B>, breakpoint, screenSize, breakpointPairs)
79
+ parseStyle(value as CustomNamedStyles<T>, breakpoint, screenSize)
81
80
  ]
82
81
  }
83
82
 
@@ -86,7 +85,7 @@ export const parseStyle = <T, B extends Breakpoints>(
86
85
  if (isTransform && Array.isArray(value)) {
87
86
  return [
88
87
  key,
89
- value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))
88
+ value.map(value => parseStyle(value, breakpoint, screenSize))
90
89
  ]
91
90
  }
92
91
 
@@ -99,11 +98,10 @@ export const parseStyle = <T, B extends Breakpoints>(
99
98
 
100
99
  return [
101
100
  key,
102
- getValueForBreakpoint<B>(
103
- value as Record<keyof B & string, string | number | undefined>,
101
+ getValueForBreakpoint(
102
+ value as Record<keyof UnistylesBreakpoints & string, string | number | undefined>,
104
103
  breakpoint,
105
- screenSize,
106
- breakpointPairs
104
+ screenSize
107
105
  )
108
106
  ]
109
107
  })
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.UnistylesTheme = exports.UnistylesContext = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
- const UnistylesContext = exports.UnistylesContext = /*#__PURE__*/(0, _react.createContext)({});
11
- const UnistylesTheme = _ref => {
12
- let {
13
- theme,
14
- children
15
- } = _ref;
16
- return /*#__PURE__*/_react.default.createElement(UnistylesContext.Provider, {
17
- value: theme
18
- }, children);
19
- };
20
- exports.UnistylesTheme = UnistylesTheme;
21
- //# sourceMappingURL=UnistylesTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","UnistylesContext","exports","createContext","UnistylesTheme","_ref","theme","children","createElement","Provider","value"],"sourceRoot":"../../src","sources":["UnistylesTheme.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA4C,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAOrC,MAAMY,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,gBAAG,IAAAE,oBAAa,EAAC,CAAC,CAAC,CAAC;AAE1C,MAAMC,cAA4D,GAAGC,IAAA;EAAA,IAAC;IACzEC,KAAK;IACLC;EACJ,CAAC,GAAAF,IAAA;EAAA,oBACG5B,MAAA,CAAAS,OAAA,CAAAsB,aAAA,CAACP,gBAAgB,CAACQ,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GACnCC,QACsB,CAAC;AAAA,CAC/B;AAAAL,OAAA,CAAAE,cAAA,GAAAA,cAAA"}
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createUnistyles = void 0;
7
- var _react = require("react");
8
- var _reactNative = require("react-native");
9
- var _UnistylesTheme = require("./UnistylesTheme");
10
- var _hooks = require("./hooks");
11
- var _utils = require("./utils");
12
- const createUnistyles = breakpoints => {
13
- const sortedBreakpoints = (0, _utils.sortAndValidateBreakpoints)(breakpoints);
14
- const sortedBreakpointEntries = Object.entries(sortedBreakpoints);
15
- return {
16
- createStyleSheet: styles => {
17
- if (typeof styles === 'function') {
18
- return styles;
19
- }
20
- return styles;
21
- },
22
- useStyles: stylesheet => {
23
- const theme = (0, _react.useContext)(_UnistylesTheme.UnistylesContext);
24
- const screenSize = (0, _hooks.useDimensions)();
25
- const breakpoint = (0, _utils.getBreakpointFromScreenWidth)(screenSize.width, sortedBreakpointEntries);
26
- if (!stylesheet) {
27
- return {
28
- theme,
29
- breakpoint,
30
- styles: {}
31
- };
32
- }
33
- const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
34
- const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
35
- let [key, value] = _ref;
36
- const style = value;
37
- if (typeof value === 'function') {
38
- return {
39
- ...acc,
40
- [key]: (0, _utils.proxifyFunction)(value, breakpoint, screenSize, sortedBreakpointEntries)
41
- };
42
- }
43
- return _reactNative.StyleSheet.create({
44
- ...acc,
45
- [key]: (0, _utils.parseStyle)(style, breakpoint, screenSize, sortedBreakpointEntries)
46
- });
47
- }, {}), [breakpoint, screenSize, parsedStyles]);
48
- return {
49
- theme,
50
- breakpoint,
51
- styles: dynamicStyleSheet
52
- };
53
- }
54
- };
55
- };
56
- exports.createUnistyles = createUnistyles;
57
- //# sourceMappingURL=createUnistyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","require","_reactNative","_UnistylesTheme","_hooks","_utils","createUnistyles","breakpoints","sortedBreakpoints","sortAndValidateBreakpoints","sortedBreakpointEntries","Object","entries","createStyleSheet","styles","useStyles","stylesheet","theme","useContext","UnistylesContext","screenSize","useDimensions","breakpoint","getBreakpointFromScreenWidth","width","parsedStyles","useMemo","dynamicStyleSheet","reduce","acc","_ref","key","value","style","proxifyFunction","StyleSheet","create","parseStyle","exports"],"sourceRoot":"../../src","sources":["createUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEO,MAAMK,eAAe,GAAmCC,WAAc,IAAK;EAC9E,MAAMC,iBAAiB,GAAG,IAAAC,iCAA0B,EAACF,WAAW,CAAC;EACjE,MAAMG,uBAAuB,GAAGC,MAAM,CACjCC,OAAO,CAACJ,iBAAiB,CAA+B;EAE7D,OAAO;IACHK,gBAAgB,EAAyCC,MAAqF,IAAY;MACtJ,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;QAC9B,OAAOA,MAAM;MACjB;MAEA,OAAOA,MAAM;IACjB,CAAC;IACDC,SAAS,EAAwCC,UAA4C,IAAK;MAC9F,MAAMC,KAAK,GAAG,IAAAC,iBAAU,EAACC,gCAAgB,CAAM;MAC/C,MAAMC,UAAU,GAAG,IAAAC,oBAAa,EAAC,CAAC;MAClC,MAAMC,UAAU,GAAG,IAAAC,mCAA4B,EAAIH,UAAU,CAACI,KAAK,EAAEd,uBAAuB,CAAC;MAE7F,IAAI,CAACM,UAAU,EAAE;QACb,OAAO;UACHC,KAAK;UACLK,UAAU;UACVR,MAAM,EAAE,CAAC;QACb,CAAC;MACL;MAEA,MAAMW,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOV,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACC,KAAK,CAAC,GACjBD,UAAU,EAAE,CAACC,KAAK,EAAED,UAAU,CAAC,CAAC;MAEtC,MAAMW,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAMf,MAAM,CACzCC,OAAO,CAACa,YAAY,CAAC,CACrBG,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;QAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;QACtB,MAAMG,KAAK,GAAGD,KAAiC;QAE/C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;UAC7B,OAAO;YACH,GAAGH,GAAG;YACN,CAACE,GAAG,GAAG,IAAAG,sBAAe,EAAIF,KAAK,EAAEV,UAAU,EAAEF,UAAU,EAAEV,uBAAuB;UACpF,CAAC;QACL;QAEA,OAAOyB,uBAAU,CAACC,MAAM,CAAC;UACrB,GAAGP,GAAG;UACN,CAACE,GAAG,GAAG,IAAAM,iBAAU,EAAQJ,KAAK,EAAEX,UAAU,EAAEF,UAAU,EAAEV,uBAAuB;QACnF,CAAC,CAAC;MACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACY,UAAU,EAAEF,UAAU,EAAEK,YAAY,CAAC,CAAC;MAEzD,OAAO;QACHR,KAAK;QACLK,UAAU;QACVR,MAAM,EAAEa;MACZ,CAAC;IACL;EACJ,CAAC;AACL,CAAC;AAAAW,OAAA,CAAAhC,eAAA,GAAAA,eAAA"}
@@ -1,12 +0,0 @@
1
- import React, { createContext } from 'react';
2
- export const UnistylesContext = /*#__PURE__*/createContext({});
3
- export const UnistylesTheme = _ref => {
4
- let {
5
- theme,
6
- children
7
- } = _ref;
8
- return /*#__PURE__*/React.createElement(UnistylesContext.Provider, {
9
- value: theme
10
- }, children);
11
- };
12
- //# sourceMappingURL=UnistylesTheme.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","createContext","UnistylesContext","UnistylesTheme","_ref","theme","children","createElement","Provider","value"],"sourceRoot":"../../src","sources":["UnistylesTheme.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,QAAQ,OAAO;AAO5C,OAAO,MAAMC,gBAAgB,gBAAGD,aAAa,CAAC,CAAC,CAAC,CAAC;AAEjD,OAAO,MAAME,cAA4D,GAAGC,IAAA;EAAA,IAAC;IACzEC,KAAK;IACLC;EACJ,CAAC,GAAAF,IAAA;EAAA,oBACGJ,KAAA,CAAAO,aAAA,CAACL,gBAAgB,CAACM,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GACnCC,QACsB,CAAC;AAAA,CAC/B"}
@@ -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,kBAAkB;AACnD,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,4BAA4B,EAAEC,eAAe,EAAEC,UAAU,EAAEC,0BAA0B,QAAQ,SAAS;AAE/G,OAAO,MAAMC,eAAe,GAAmCC,WAAc,IAAK;EAC9E,MAAMC,iBAAiB,GAAGH,0BAA0B,CAACE,WAAW,CAAC;EACjE,MAAME,uBAAuB,GAAGC,MAAM,CACjCC,OAAO,CAACH,iBAAiB,CAA+B;EAE7D,OAAO;IACHI,gBAAgB,EAAyCC,MAAqF,IAAY;MACtJ,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;QAC9B,OAAOA,MAAM;MACjB;MAEA,OAAOA,MAAM;IACjB,CAAC;IACDC,SAAS,EAAwCC,UAA4C,IAAK;MAC9F,MAAMC,KAAK,GAAGnB,UAAU,CAACG,gBAAgB,CAAM;MAC/C,MAAMiB,UAAU,GAAGhB,aAAa,CAAC,CAAC;MAClC,MAAMiB,UAAU,GAAGhB,4BAA4B,CAAIe,UAAU,CAACE,KAAK,EAAEV,uBAAuB,CAAC;MAE7F,IAAI,CAACM,UAAU,EAAE;QACb,OAAO;UACHC,KAAK;UACLE,UAAU;UACVL,MAAM,EAAE,CAAC;QACb,CAAC;MACL;MAEA,MAAMO,YAAY,GAAGtB,OAAO,CAAC,MAAM,OAAOiB,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACC,KAAK,CAAC,GACjBD,UAAU,EAAE,CAACC,KAAK,EAAED,UAAU,CAAC,CAAC;MAEtC,MAAMM,iBAAiB,GAAGvB,OAAO,CAAC,MAAMY,MAAM,CACzCC,OAAO,CAACS,YAAY,CAAC,CACrBE,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;QAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;QACtB,MAAMG,KAAK,GAAGD,KAAiC;QAE/C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;UAC7B,OAAO;YACH,GAAGH,GAAG;YACN,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 React from 'react';
2
- export declare const Breakpoints: React.FunctionComponent;
3
- //# sourceMappingURL=Breakpoints.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Breakpoints.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Breakpoints.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,iBAiB/B,CAAA"}
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const EmptyStyles: React.FunctionComponent;
3
- //# sourceMappingURL=EmptyStyles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EmptyStyles.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/EmptyStyles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,iBAU/B,CAAA"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- type ExtremeProps = {
3
- onToggleTheme: VoidFunction;
4
- };
5
- export declare const Extreme: React.FunctionComponent<ExtremeProps>;
6
- export {};
7
- //# sourceMappingURL=Extreme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Extreme.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Extreme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,KAAK,YAAY,GAAG;IAChB,aAAa,EAAE,YAAY,CAAA;CAC9B,CAAA;AAGD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,YAAY,CAezD,CAAA"}
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const MediaQueries: React.FunctionComponent;
3
- //# sourceMappingURL=MediaQueries.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MediaQueries.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/MediaQueries.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,iBAahC,CAAA"}
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const Memoization: React.FunctionComponent;
3
- //# sourceMappingURL=Memoization.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Memoization.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Memoization.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,iBAY/B,CAAA"}
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const Minimal: React.FunctionComponent;
3
- //# sourceMappingURL=Minimal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Minimal.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Minimal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,iBAU3B,CAAA"}
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const MinimalWithCreateStyleSheet: React.FunctionComponent;
3
- //# sourceMappingURL=MinimalWithCreateStyleSheet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MinimalWithCreateStyleSheet.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/MinimalWithCreateStyleSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,iBAU/C,CAAA"}
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const Theme: React.FunctionComponent;
3
- //# sourceMappingURL=Theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../../../../../examples/expo/src/examples/Theme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,iBAUzB,CAAA"}
@@ -1,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,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
- )