react-native-unistyles 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/common.js +3 -1
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +8 -4
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +7 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js +32 -0
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js +46 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js +77 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/commonjs/core/mocks/index.js +27 -0
- package/lib/commonjs/core/mocks/index.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +2 -2
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/useStyles.js +1 -1
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/module/common.js +2 -0
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +9 -5
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +8 -1
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/mocks/UnistylesMockedBridge.js +25 -0
- package/lib/module/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js +39 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js +69 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/module/core/mocks/index.js +4 -0
- package/lib/module/core/mocks/index.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +2 -2
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/useStyles.js +1 -1
- package/lib/module/useStyles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +2 -0
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts +24 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts +21 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts +41 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/index.d.ts +4 -0
- package/lib/typescript/src/core/mocks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -1
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +2 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +2 -0
- package/src/core/UnistyleRegistry.ts +11 -5
- package/src/core/Unistyles.ts +10 -1
- package/src/core/mocks/UnistylesMockedBridge.ts +26 -0
- package/src/core/mocks/UnistylesMockedRegistry.ts +47 -0
- package/src/core/mocks/UnistylesMockedRuntime.ts +92 -0
- package/src/core/mocks/index.ts +3 -0
- package/src/hooks/useUnistyles.ts +2 -2
- package/src/types/breakpoints.ts +2 -1
- package/src/types/stylesheet.ts +2 -1
- package/src/useStyles.ts +1 -1
package/src/types/breakpoints.ts
CHANGED
@@ -2,6 +2,7 @@ import type { ColorValue, OpaqueColorValue } from 'react-native'
|
|
2
2
|
import type { UnistylesTheme } from '../types'
|
3
3
|
import type { BreakpointsOrMediaQueries, ToDeepUnistyles } from './stylesheet'
|
4
4
|
import type { TransformStyles } from './core'
|
5
|
+
import type { UnistylesRuntime } from '../core'
|
5
6
|
|
6
7
|
type ExtractTransformArray<T> = T extends object
|
7
8
|
? { [K in keyof T]: ExtractBreakpoints<T[K]> }
|
@@ -56,6 +57,6 @@ type ParseStyleKeys<T> = T extends object
|
|
56
57
|
? { [K in keyof T]: ParseNestedObject<T[K]> }
|
57
58
|
: never
|
58
59
|
|
59
|
-
export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme) => infer R
|
60
|
+
export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme, runtime: UnistylesRuntime) => infer R
|
60
61
|
? ParseStyleKeys<R>
|
61
62
|
: ParseStyleKeys<T>
|
package/src/types/stylesheet.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
2
2
|
import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core'
|
3
3
|
import type { UnistylesBreakpoints } from '../global'
|
4
|
+
import type { UnistylesRuntime } from '../core'
|
4
5
|
|
5
6
|
// these props are treated differently to nest breakpoints and media queries
|
6
7
|
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset'
|
@@ -46,4 +47,4 @@ export type StyleSheet = {
|
|
46
47
|
[styleName: string]: UnistylesValues | ((...args: any) => UnistylesValues)
|
47
48
|
}
|
48
49
|
|
49
|
-
export type StyleSheetWithSuperPowers = ((theme: UnistylesTheme) => StyleSheet) | StyleSheet
|
50
|
+
export type StyleSheetWithSuperPowers = ((theme: UnistylesTheme, runtime: UnistylesRuntime) => StyleSheet) | StyleSheet
|
package/src/useStyles.ts
CHANGED
@@ -26,7 +26,7 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
|
|
26
26
|
const { theme, layout, plugins } = useUnistyles()
|
27
27
|
const variants = useVariants(variantsMap)
|
28
28
|
const parsedStyles = useMemo(() => typeof stylesheet === 'function'
|
29
|
-
? stylesheet(theme)
|
29
|
+
? stylesheet(theme, unistyles.runtime)
|
30
30
|
: stylesheet, [theme, stylesheet, layout])
|
31
31
|
|
32
32
|
const dynamicStyleSheet = useMemo(() => Object
|