react-native-unistyles 3.0.0-beta.6 → 3.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/android/CMakeLists.txt +2 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +4 -0
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +29 -2
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +4 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +5 -0
- package/cxx/common/Helpers.h +85 -0
- package/cxx/core/HashGenerator.cpp +1 -1
- package/cxx/core/HostUnistyle.cpp +28 -4
- package/cxx/core/HostUnistyle.h +1 -0
- package/cxx/core/UnistyleWrapper.h +6 -6
- package/cxx/core/UnistylesCommitHook.cpp +20 -17
- package/cxx/core/UnistylesMountHook.cpp +2 -2
- package/cxx/core/UnistylesMountHook.h +1 -4
- package/cxx/core/UnistylesRegistry.cpp +8 -6
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +2 -5
- package/cxx/hybridObjects/HybridStyleSheet.cpp +1 -1
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +5 -1
- package/cxx/parser/Parser.cpp +79 -14
- package/cxx/shadowTree/ShadowTrafficController.h +10 -4
- package/cxx/shadowTree/ShadowTreeManager.cpp +38 -35
- package/lib/commonjs/components/native/Animated.js +2 -2
- package/lib/commonjs/components/native/Animated.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js +29 -33
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -1
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js +1 -1
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +17 -10
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +5 -5
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +5 -1
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +5 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +3 -3
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/warn.js +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +2 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +18 -9
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +1 -1
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js +1 -1
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/useServerUnistyles.js +2 -2
- package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +3 -3
- package/lib/commonjs/specs/index.native.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +4 -4
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js +4 -4
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js +3 -3
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/convert/object/transform.js +1 -1
- package/lib/commonjs/web/convert/object/transform.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -1
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +1 -1
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +1 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +1 -1
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +1 -1
- package/lib/commonjs/web/utils/unistyle.js +5 -5
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/native/Animated.js +2 -2
- package/lib/module/components/native/Animated.js.map +1 -1
- package/lib/module/components/native/ImageBackground.js +29 -33
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/NativeText.native.js.map +1 -1
- package/lib/module/components/native/NativeView.native.js.map +1 -1
- package/lib/module/components/native/Pressable.js +1 -1
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +17 -10
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +3 -3
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +5 -1
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +5 -1
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +3 -3
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/warn.js +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.js +2 -2
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +19 -10
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +1 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/mq.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js +1 -1
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/hydrateServerUnistyles.js +1 -1
- package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/module/server/resetServerUnistyles.js +1 -1
- package/lib/module/server/resetServerUnistyles.js.map +1 -1
- package/lib/module/server/useServerUnistyles.js +2 -2
- package/lib/module/server/useServerUnistyles.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +1 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.native.js +4 -4
- package/lib/module/specs/index.native.js.map +1 -1
- package/lib/module/web/convert/index.js +5 -5
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js +2 -2
- package/lib/module/web/convert/object/boxShadow.js.map +1 -1
- package/lib/module/web/convert/object/filter.js +3 -3
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/convert/object/transform.js +1 -1
- package/lib/module/web/convert/object/transform.js.map +1 -1
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/index.js +1 -1
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/registry.js +1 -1
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +1 -1
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js +1 -1
- package/lib/module/web/utils/unistyle.js +5 -5
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +2 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts +1 -1
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +5 -5
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.native.d.ts +4 -4
- package/lib/typescript/src/specs/index.native.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -2
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +1 -1
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +5 -5
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts +2 -2
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +1 -1
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +19 -19
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +1 -17
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/unistylesOnLoad.kt +35 -0
- package/nitrogen/generated/android/unistyles+autolinking.cmake +16 -0
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +2 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -1
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +3 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +2 -3
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +18 -18
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
- package/nitrogen/generated/shared/c++/Dimensions.hpp +2 -1
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/Insets.hpp +2 -1
- package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +2 -1
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +2 -1
- package/package.json +31 -19
- package/plugin/index.d.ts +51 -18
- package/plugin/index.js +791 -189
- package/src/components/native/Animated.tsx +2 -2
- package/src/components/native/ImageBackground.tsx +6 -7
- package/src/components/native/NativeText.native.tsx +1 -1
- package/src/components/native/NativeView.native.tsx +1 -1
- package/src/components/native/Pressable.native.tsx +22 -12
- package/src/components/native/Pressable.tsx +1 -1
- package/src/core/createUnistylesElement.native.tsx +6 -1
- package/src/core/createUnistylesElement.tsx +3 -3
- package/src/core/createUnistylesImageBackground.tsx +6 -1
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +4 -4
- package/src/core/warn.ts +1 -1
- package/src/core/withUnistyles/withUnistyles.native.tsx +47 -19
- package/src/core/withUnistyles/withUnistyles.tsx +4 -4
- package/src/hooks/useMedia.native.ts +1 -1
- package/src/mq.ts +1 -1
- package/src/server/getServerUnistyles.tsx +1 -1
- package/src/server/hydrateServerUnistyles.ts +1 -1
- package/src/server/resetServerUnistyles.ts +1 -1
- package/src/server/useServerUnistyles.tsx +2 -2
- package/src/specs/ShadowRegistry/index.ts +1 -0
- package/src/specs/StatusBar/index.ts +1 -1
- package/src/specs/StyleSheet/index.ts +3 -3
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
- package/src/specs/UnistylesRuntime/index.ts +5 -5
- package/src/specs/index.native.ts +4 -4
- package/src/types/breakpoints.ts +2 -2
- package/src/types/core.ts +1 -1
- package/src/types/stylesheet.ts +5 -5
- package/src/web/convert/index.ts +5 -5
- package/src/web/convert/object/boxShadow.ts +2 -2
- package/src/web/convert/object/filter.ts +3 -3
- package/src/web/convert/object/transform.ts +2 -2
- package/src/web/convert/types.ts +1 -1
- package/src/web/convert/utils.ts +2 -2
- package/src/web/create.ts +1 -1
- package/src/web/index.ts +3 -3
- package/src/web/registry.ts +2 -2
- package/src/web/runtime.ts +2 -2
- package/src/web/shadowRegistry.ts +2 -2
- package/src/web/state.ts +4 -4
- package/src/web/utils/common.ts +1 -1
- package/src/web/utils/unistyle.ts +6 -6
- package/plugin/common.js +0 -142
- package/plugin/consts.js +0 -63
- package/plugin/exotic.js +0 -54
- package/plugin/import.js +0 -51
- package/plugin/ref.js +0 -11
- package/plugin/stylesheet.js +0 -239
- package/plugin/variants.js +0 -66
@@ -1,10 +1,10 @@
|
|
1
1
|
import { Animated as RNAnimated } from 'react-native'
|
2
|
-
import { View } from './View'
|
3
|
-
import { Text } from './Text'
|
4
2
|
import { FlatList } from './FlatList'
|
5
3
|
import { Image } from './Image'
|
6
4
|
import { ScrollView } from './ScrollView'
|
7
5
|
import { SectionList } from './SectionList'
|
6
|
+
import { Text } from './Text'
|
7
|
+
import { View } from './View'
|
8
8
|
|
9
9
|
export const Animated = {
|
10
10
|
...RNAnimated,
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { ImageBackground as NativeImageBackground } from 'react-native'
|
3
2
|
import { forwardRef } from 'react'
|
4
|
-
import type
|
3
|
+
import { type ImageStyle, ImageBackground as NativeImageBackground, type StyleProp, type ViewStyle } from 'react-native'
|
5
4
|
import { getClassName } from '../../core'
|
6
|
-
import {
|
7
|
-
import { UnistylesShadowRegistry } from '../../web'
|
5
|
+
import type { UnistylesValues } from '../../types'
|
8
6
|
import { copyComponentProperties } from '../../utils'
|
7
|
+
import { UnistylesShadowRegistry } from '../../web'
|
8
|
+
import { isServer } from '../../web/utils'
|
9
9
|
|
10
10
|
type Props = {
|
11
11
|
style?: UnistylesValues
|
@@ -19,11 +19,10 @@ const UnistylesImageBackground = forwardRef<unknown, Props>((props, forwardedRef
|
|
19
19
|
const imageClassNames = getClassName(props.imageStyle)
|
20
20
|
|
21
21
|
return (
|
22
|
-
// @ts-expect-error - RN types are not compatible with RNW styles
|
23
22
|
<NativeImageBackground
|
24
23
|
{...props}
|
25
|
-
style={styleClassNames}
|
26
|
-
imageStyle={imageClassNames}
|
24
|
+
style={styleClassNames as StyleProp<ViewStyle>}
|
25
|
+
imageStyle={imageClassNames as StyleProp<ImageStyle>}
|
27
26
|
ref={isServer() ? undefined : ref => {
|
28
27
|
if (!ref) {
|
29
28
|
// @ts-expect-error hidden from TS
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { forwardRef, useLayoutEffect, useRef } from 'react'
|
2
2
|
import { Pressable as NativePressableReactNative } from 'react-native'
|
3
3
|
import type { PressableProps as Props, View } from 'react-native'
|
4
|
-
import { UnistylesShadowRegistry } from '../../specs'
|
5
4
|
import { passForwardedRef } from '../../core'
|
5
|
+
import { UnistylesShadowRegistry } from '../../specs'
|
6
6
|
|
7
7
|
type PressableProps = Props & {
|
8
8
|
variants?: Record<string, string | boolean>
|
@@ -11,7 +11,7 @@ type PressableProps = Props & {
|
|
11
11
|
const getStyles = (styleProps: Record<string, any> = {}) => {
|
12
12
|
const unistyleKey = Object
|
13
13
|
.keys(styleProps)
|
14
|
-
.find(key => key.startsWith('
|
14
|
+
.find(key => key.startsWith('unistyles_'))
|
15
15
|
|
16
16
|
if (!unistyleKey) {
|
17
17
|
return styleProps
|
@@ -20,12 +20,13 @@ const getStyles = (styleProps: Record<string, any> = {}) => {
|
|
20
20
|
return {
|
21
21
|
// styles without C++ state
|
22
22
|
...styleProps[unistyleKey].uni__getStyles(),
|
23
|
-
[unistyleKey]: styleProps[unistyleKey]
|
23
|
+
[unistyleKey]: styleProps[unistyleKey]
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
27
27
|
export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ...props }, forwardedRef) => {
|
28
|
-
const storedRef = useRef<View | null>()
|
28
|
+
const storedRef = useRef<View | null>(null)
|
29
|
+
const scopedTheme = UnistylesShadowRegistry.getScopedTheme()
|
29
30
|
|
30
31
|
useLayoutEffect(() => {
|
31
32
|
return () => {
|
@@ -40,22 +41,28 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ..
|
|
40
41
|
<NativePressableReactNative
|
41
42
|
{...props}
|
42
43
|
ref={ref => {
|
43
|
-
const
|
44
|
-
|
45
|
-
:
|
46
|
-
|
47
|
-
// @ts-expect-error - this is hidden from TS
|
48
|
-
UnistylesShadowRegistry.add(ref, unistyles)
|
44
|
+
const isPropStyleAFunction = typeof style === 'function'
|
45
|
+
const unistyles = isPropStyleAFunction
|
46
|
+
? style.call(style, { pressed: false })
|
47
|
+
: getStyles(style as unknown as Record<string, any>)
|
49
48
|
|
50
49
|
if (ref) {
|
51
50
|
storedRef.current = ref
|
52
51
|
}
|
53
52
|
|
53
|
+
// @ts-expect-error - this is hidden from TS
|
54
|
+
UnistylesShadowRegistry.add(storedRef.current, unistyles)
|
55
|
+
|
54
56
|
return passForwardedRef(props, ref, forwardedRef)
|
55
57
|
}}
|
56
58
|
style={state => {
|
57
|
-
const
|
58
|
-
|
59
|
+
const isPropStyleAFunction = typeof style === 'function'
|
60
|
+
const previousScopedTheme = UnistylesShadowRegistry.getScopedTheme()
|
61
|
+
|
62
|
+
UnistylesShadowRegistry.setScopedTheme(scopedTheme)
|
63
|
+
|
64
|
+
const unistyles = isPropStyleAFunction
|
65
|
+
? style.call(style, state)
|
59
66
|
: getStyles(style as unknown as Record<string, any>)
|
60
67
|
|
61
68
|
if (!storedRef.current) {
|
@@ -64,9 +71,12 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ..
|
|
64
71
|
|
65
72
|
// @ts-expect-error - this is hidden from TS
|
66
73
|
UnistylesShadowRegistry.remove(storedRef.current)
|
74
|
+
|
67
75
|
// @ts-expect-error - this is hidden from TS
|
68
76
|
UnistylesShadowRegistry.add(storedRef.current, unistyles)
|
69
77
|
|
78
|
+
UnistylesShadowRegistry.setScopedTheme(previousScopedTheme)
|
79
|
+
|
70
80
|
return unistyles
|
71
81
|
}}
|
72
82
|
/>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React, { forwardRef } from 'react'
|
2
2
|
import { Pressable as NativePressableReactNative } from 'react-native'
|
3
3
|
import type { PressableProps as Props, View } from 'react-native'
|
4
|
+
import { getClassName } from '../../core'
|
4
5
|
import { UnistylesShadowRegistry } from '../../specs'
|
5
6
|
import type { UnistylesValues } from '../../types'
|
6
|
-
import { getClassName } from '../../core'
|
7
7
|
import { isServer } from '../../web/utils'
|
8
8
|
|
9
9
|
type Variants = Record<string, string | boolean | undefined>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { useLayoutEffect, useRef } from 'react'
|
2
2
|
import { UnistylesShadowRegistry } from '../specs'
|
3
|
+
import { copyComponentProperties } from '../utils'
|
3
4
|
import { passForwardedRef } from './passForwardRef'
|
4
5
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
5
|
-
import { copyComponentProperties } from '../utils'
|
6
6
|
|
7
7
|
const getNativeRef = (Component: any, ref: any) => {
|
8
8
|
switch (Component.name) {
|
@@ -42,6 +42,11 @@ export const createUnistylesElement = (Component: any) => {
|
|
42
42
|
|
43
43
|
// @ts-ignore we don't know the type of the component
|
44
44
|
maybeWarnAboutMultipleUnistyles(props.style, Component.displayName)
|
45
|
+
|
46
|
+
return () => {
|
47
|
+
// @ts-ignore
|
48
|
+
UnistylesShadowRegistry.remove(ref)
|
49
|
+
}
|
45
50
|
}}
|
46
51
|
/>
|
47
52
|
)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import type { UnistylesValues } from '../types'
|
3
|
-
import {
|
4
|
-
import { isServer } from '../web/utils'
|
3
|
+
import { copyComponentProperties } from '../utils'
|
5
4
|
import { UnistylesShadowRegistry } from '../web'
|
5
|
+
import { isServer } from '../web/utils'
|
6
|
+
import { getClassName } from './getClassname'
|
6
7
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
7
|
-
import { copyComponentProperties } from '../utils'
|
8
8
|
|
9
9
|
type ComponentProps = {
|
10
10
|
style?: UnistylesValues | Array<UnistylesValues>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React, { useLayoutEffect, useRef } from 'react'
|
2
2
|
import type { Image, ImageBackground, ImageBackgroundProps } from 'react-native'
|
3
3
|
import { UnistylesShadowRegistry } from '../specs'
|
4
|
+
import { copyComponentProperties } from '../utils'
|
4
5
|
import { passForwardedRef } from './passForwardRef'
|
5
6
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
6
|
-
import { copyComponentProperties } from '../utils'
|
7
7
|
|
8
8
|
export const createUnistylesImageBackground = (Component: typeof ImageBackground) => {
|
9
9
|
const UnistylesImageBackground = React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => {
|
@@ -32,6 +32,11 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
|
|
32
32
|
return () => {
|
33
33
|
// @ts-ignore
|
34
34
|
UnistylesShadowRegistry.remove(ref)
|
35
|
+
|
36
|
+
if (storedImageRef.current) {
|
37
|
+
// @ts-ignore
|
38
|
+
UnistylesShadowRegistry.remove(storedImageRef.current)
|
39
|
+
}
|
35
40
|
}
|
36
41
|
}}
|
37
42
|
imageRef={ref => {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useEffect, useReducer, useRef, useState } from 'react'
|
2
|
-
import { UnistylesRuntime, UnistylesShadowRegistry
|
2
|
+
import { type UnistylesMiniRuntime, UnistylesRuntime, UnistylesShadowRegistry } from '../../specs'
|
3
3
|
// It's imported that way because of circular dependency
|
4
4
|
import { UnistyleDependency } from '../../specs/NativePlatform'
|
5
5
|
import type { UnistylesTheme } from '../../types'
|
@@ -26,12 +26,12 @@ const RTDependencyMap = {
|
|
26
26
|
themeName: UnistyleDependency.ThemeName,
|
27
27
|
} satisfies Partial<Record<keyof UnistylesMiniRuntime, UnistyleDependency>>
|
28
28
|
|
29
|
-
export const useProxifiedUnistyles = () => {
|
30
|
-
const scopedTheme = UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
|
29
|
+
export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
30
|
+
const scopedTheme = forcedTheme ?? UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
|
31
31
|
const [dependencies] = useState(() => new Set<number>())
|
32
32
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme))
|
33
33
|
const [_, runtimeChanged] = useReducer(() => ({}), {})
|
34
|
-
const disposeRef = useRef<VoidFunction>()
|
34
|
+
const disposeRef = useRef<VoidFunction>(undefined)
|
35
35
|
|
36
36
|
const reinitListener = () => {
|
37
37
|
disposeRef.current?.()
|
package/src/core/warn.ts
CHANGED
@@ -4,7 +4,7 @@ export const maybeWarnAboutMultipleUnistyles = (style: ViewStyle, displayName =
|
|
4
4
|
if (__DEV__ && style && !Array.isArray(style)) {
|
5
5
|
const unistylesKeys = Object
|
6
6
|
.keys(style)
|
7
|
-
.filter(key => key.startsWith('
|
7
|
+
.filter(key => key.startsWith('unistyles_'))
|
8
8
|
|
9
9
|
if (unistylesKeys.length > 1) {
|
10
10
|
console.warn(`Unistyles: we detected style object with ${unistylesKeys.length} unistyles styles. This might cause no updates or unpredictable behavior. Please check style prop for "${displayName}" and use array syntax instead of object syntax.`)
|
@@ -1,32 +1,59 @@
|
|
1
|
-
import React, { forwardRef, useEffect, type ComponentType } from 'react'
|
2
|
-
import type
|
1
|
+
import React, { forwardRef, useEffect, type ComponentType, useRef } from 'react'
|
2
|
+
import { type UnistyleDependency, UnistylesShadowRegistry } from '../../specs'
|
3
|
+
import type { UnistylesTheme } from '../../types'
|
3
4
|
import type { PartialBy } from '../../types/common'
|
4
5
|
import { deepMergeObjects } from '../../utils'
|
5
|
-
import type { Mappings, SupportedStyleProps } from './types'
|
6
|
-
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
7
6
|
import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
|
7
|
+
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
8
|
+
import type { Mappings, SupportedStyleProps } from './types'
|
8
9
|
|
9
10
|
// @ts-expect-error
|
10
11
|
type GenericComponentProps<P> = ComponentProps<P>
|
11
12
|
// @ts-expect-error
|
12
13
|
type GenericComponentRef<T> = ComponentRef<T>
|
13
14
|
|
15
|
+
type UnistylesSecrets = {
|
16
|
+
uni__getStyles: () => Record<string, any>,
|
17
|
+
uni__dependencies: Array<UnistyleDependency>
|
18
|
+
}
|
19
|
+
|
20
|
+
type MappedSecrets = {
|
21
|
+
styles: Record<string, any>,
|
22
|
+
dependencies: Array<UnistyleDependency>
|
23
|
+
}
|
24
|
+
|
14
25
|
export const withUnistyles = <TComponent, TMappings extends GenericComponentProps<TComponent>>(Component: TComponent, mappings?: Mappings<TMappings>) => {
|
15
26
|
type TProps = GenericComponentProps<TComponent>
|
16
27
|
type PropsWithUnistyles = PartialBy<TProps, keyof TMappings | SupportedStyleProps> & {
|
17
28
|
uniProps?: Mappings<TProps>
|
18
29
|
}
|
19
|
-
const getSecrets = (styleProps: Record<string, any> = {}):
|
20
|
-
const
|
21
|
-
.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets => {
|
31
|
+
const styles = Array.isArray(styleProps)
|
32
|
+
? styleProps.flat()
|
33
|
+
: [styleProps]
|
34
|
+
|
35
|
+
const secrets: Array<UnistylesSecrets> = styles
|
36
|
+
.filter(Boolean)
|
37
|
+
.reduce((acc, style) => {
|
38
|
+
const unistyleKey = Object
|
39
|
+
.keys(style)
|
40
|
+
.find(key => key.startsWith('unistyles_'))
|
41
|
+
|
42
|
+
return acc.concat([
|
43
|
+
unistyleKey
|
44
|
+
? style[unistyleKey]
|
45
|
+
: {
|
46
|
+
uni__getStyles: () => styleProps,
|
47
|
+
uni__dependencies: [],
|
48
|
+
}
|
49
|
+
])
|
50
|
+
}, [])
|
51
|
+
|
52
|
+
return {
|
53
|
+
styles: secrets.reduce((acc, secret) => Object
|
54
|
+
.assign(acc, secret.uni__getStyles()), {} as Record<string, any>),
|
55
|
+
dependencies: secrets.flatMap(secret => secret.uni__dependencies),
|
56
|
+
}
|
30
57
|
}
|
31
58
|
|
32
59
|
return forwardRef<GenericComponentRef<TComponent>, PropsWithUnistyles>((props, ref) => {
|
@@ -38,13 +65,14 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
38
65
|
// @ts-ignore we don't know the type of the component
|
39
66
|
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
40
67
|
|
41
|
-
const
|
68
|
+
const scopedTheme = useRef(UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme)
|
69
|
+
const { proxifiedRuntime, proxifiedTheme, addDependencies } = useProxifiedUnistyles(scopedTheme.current)
|
42
70
|
|
43
71
|
useEffect(() => {
|
44
72
|
const styleSecrets = getSecrets(narrowedProps.style)
|
45
73
|
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)
|
46
74
|
|
47
|
-
addDependencies(Array.from(new Set([...styleSecrets.
|
75
|
+
addDependencies(Array.from(new Set([...styleSecrets.dependencies, ...contentContainerStyleSecrets.dependencies])))
|
48
76
|
}, [narrowedProps.style, narrowedProps.contentContainerStyle])
|
49
77
|
|
50
78
|
const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
|
@@ -56,10 +84,10 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
56
84
|
const finalProps = {
|
57
85
|
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
58
86
|
...narrowedProps.style ? {
|
59
|
-
style: styleSecrets.
|
87
|
+
style: styleSecrets.styles,
|
60
88
|
} : {},
|
61
89
|
...narrowedProps.contentContainerStyle ? {
|
62
|
-
contentContainerStyle: contentContainerStyleSecrets.
|
90
|
+
contentContainerStyle: contentContainerStyleSecrets.styles,
|
63
91
|
} : {},
|
64
92
|
} as any
|
65
93
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React, { type ComponentType, forwardRef, type ComponentProps, type ComponentRef } from 'react'
|
2
|
+
import type { UnistylesValues } from '../../types'
|
2
3
|
import type { PartialBy } from '../../types/common'
|
3
4
|
import { deepMergeObjects } from '../../utils'
|
4
|
-
import type { Mappings, SupportedStyleProps } from './types'
|
5
|
-
import type { UnistylesValues } from '../../types'
|
6
5
|
import { getClassName } from '../getClassname'
|
7
|
-
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
8
6
|
import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
|
7
|
+
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
8
|
+
import type { Mappings, SupportedStyleProps } from './types'
|
9
9
|
|
10
10
|
// @ts-expect-error
|
11
11
|
type GenericComponentProps<T> = ComponentProps<T>
|
@@ -37,7 +37,7 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
37
37
|
style: styleClassNames,
|
38
38
|
} : {},
|
39
39
|
...narrowedProps.contentContainerStyle ? {
|
40
|
-
|
40
|
+
contentContainerStyle: contentContainerStyleClassNames,
|
41
41
|
} : {},
|
42
42
|
} as any
|
43
43
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useEffect, useLayoutEffect, useState } from 'react'
|
2
|
+
import { isUnistylesMq, isValidMq, parseMq } from '../mq'
|
2
3
|
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
|
3
|
-
import { isValidMq, parseMq, isUnistylesMq } from '../mq'
|
4
4
|
|
5
5
|
export const useMedia = (config: { mq: symbol }) => {
|
6
6
|
const computeIsVisible = (): boolean => {
|
package/src/mq.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { Nullable } from './types'
|
2
1
|
import type { UnistylesBreakpoints } from './global'
|
3
2
|
import { UnistylesRuntime } from './specs'
|
3
|
+
import type { Nullable } from './types'
|
4
4
|
|
5
5
|
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
6
6
|
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import { StyleSheet } from 'react-native'
|
3
|
-
import { error, isServer } from '../web/utils'
|
4
3
|
import { UnistylesWeb } from '../web'
|
4
|
+
import { error, isServer } from '../web/utils'
|
5
5
|
import { DefaultServerUnistylesSettings, type ServerUnistylesSettings } from './types'
|
6
6
|
|
7
7
|
export const getServerUnistyles = ({ includeRNWStyles = true }: ServerUnistylesSettings = DefaultServerUnistylesSettings) => {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React, { useRef } from 'react'
|
2
2
|
import { isServer } from '../web/utils'
|
3
|
-
import { DefaultServerUnistylesSettings, type ServerUnistylesSettings } from './types'
|
4
3
|
import { getServerUnistyles } from './getServerUnistyles'
|
5
|
-
import { resetServerUnistyles } from './resetServerUnistyles'
|
6
4
|
import { hydrateServerUnistyles } from './hydrateServerUnistyles'
|
5
|
+
import { resetServerUnistyles } from './resetServerUnistyles'
|
6
|
+
import { DefaultServerUnistylesSettings, type ServerUnistylesSettings } from './types'
|
7
7
|
|
8
8
|
export const useServerUnistyles = (settings: ServerUnistylesSettings = DefaultServerUnistylesSettings): React.ReactNode | null => {
|
9
9
|
const isServerInserted = useRef(false)
|
@@ -45,6 +45,7 @@ HybridShadowRegistry.add = (handle, styles) => {
|
|
45
45
|
.filter(style => !style?.initial?.updater)
|
46
46
|
.filter(style => style && Object.keys(style).length > 0)
|
47
47
|
.flat()
|
48
|
+
.filter(Boolean)
|
48
49
|
|
49
50
|
if (filteredStyles.length > 0) {
|
50
51
|
HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { StatusBar as NativeStatusBar } from 'react-native'
|
2
|
-
import type { UnistylesStatusBar as UnistylesStatusBarSpec } from './UnistylesStatusBar.nitro'
|
3
2
|
import { StatusBarStyle } from '../types'
|
3
|
+
import type { UnistylesStatusBar as UnistylesStatusBarSpec } from './UnistylesStatusBar.nitro'
|
4
4
|
|
5
5
|
export type StatusBarHiddenAnimation = 'none' | 'fade' | 'slide'
|
6
6
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
import { processColor, StyleSheet as NativeStyleSheet } from 'react-native'
|
1
|
+
import { StyleSheet as NativeStyleSheet, processColor } from 'react-native'
|
3
2
|
import type { StyleSheet as NativeStyleSheetType } from 'react-native'
|
4
|
-
import
|
3
|
+
import { NitroModules } from 'react-native-nitro-modules'
|
5
4
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../../global'
|
6
5
|
import type { CreateUnistylesStyleSheet } from '../../types'
|
6
|
+
import type { UnistylesStyleSheet as UnistylesStyleSheetSpec } from './UnistylesStyleSheet.nitro'
|
7
7
|
|
8
8
|
type UnistylesThemeSettings = {
|
9
9
|
initialTheme: (() => keyof UnistylesThemes) | keyof UnistylesThemes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules'
|
2
|
-
import type { AppBreakpoint, AppThemeName, Dimensions, Insets } from '../types'
|
3
2
|
import type { AndroidContentSizeCategory, IOSContentSizeCategory, WebContentSizeCategory } from '../../types'
|
4
3
|
import type { UnistylesNativeMiniRuntime } from '../NativePlatform'
|
4
|
+
import type { AppBreakpoint, AppThemeName, Dimensions, Insets } from '../types'
|
5
5
|
|
6
6
|
type ColorScheme = 'light' | 'dark' | 'unspecified'
|
7
7
|
type Orientation = 'portrait' | 'landscape'
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { processColor } from 'react-native'
|
2
2
|
import { NitroModules } from 'react-native-nitro-modules'
|
3
|
-
import type { UnistylesRuntime as UnistylesRuntimeSpec, UnistylesMiniRuntime } from './UnistylesRuntime.nitro'
|
4
|
-
import type { AppBreakpoint, AppTheme, AppThemeName, Color, ColorScheme, Orientation } from '../types'
|
5
|
-
import { attachStatusBarJSMethods, type UnistylesStatusBar } from '../StatusBar'
|
6
|
-
import type { UnistylesNavigationBar } from '../NavigtionBar'
|
7
|
-
import type { AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesTheme } from '../../types'
|
8
3
|
import { isIOS } from '../../common'
|
9
4
|
import type { UnistylesThemes } from '../../global'
|
5
|
+
import type { AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesTheme } from '../../types'
|
6
|
+
import type { UnistylesNavigationBar } from '../NavigtionBar'
|
7
|
+
import { type UnistylesStatusBar, attachStatusBarJSMethods } from '../StatusBar'
|
8
|
+
import type { AppBreakpoint, AppTheme, AppThemeName, Color, ColorScheme, Orientation } from '../types'
|
9
|
+
import type { UnistylesMiniRuntime, UnistylesRuntime as UnistylesRuntimeSpec } from './UnistylesRuntime.nitro'
|
10
10
|
|
11
11
|
export interface UnistylesRuntimePrivate extends Omit<UnistylesRuntimeSpec, 'setRootViewBackgroundColor'> {
|
12
12
|
readonly colorScheme: ColorScheme,
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import './TurboUnistyles'
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { UnistyleDependency } from './NativePlatform'
|
4
|
+
import { UnistylesShadowRegistry } from './ShadowRegistry'
|
4
5
|
import { StyleSheet } from './StyleSheet'
|
5
6
|
import type { UnistylesStyleSheet } from './StyleSheet'
|
6
|
-
import {
|
7
|
+
import { Runtime } from './UnistylesRuntime'
|
7
8
|
import type { UnistylesMiniRuntime } from './UnistylesRuntime'
|
8
|
-
import {
|
9
|
-
import { UnistyleDependency } from './NativePlatform'
|
9
|
+
import { ColorScheme, Orientation, StatusBarStyle } from './types'
|
10
10
|
|
11
11
|
export {
|
12
12
|
StatusBarStyle,
|
package/src/types/breakpoints.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { ColorValue, OpaqueColorValue } from 'react-native'
|
2
|
-
import type { BreakpointsOrMediaQueries, ToDeepUnistyles } from './stylesheet'
|
3
|
-
import type { TransformStyles } from './core'
|
4
2
|
import type { SafeReturnType } from './common'
|
3
|
+
import type { TransformStyles } from './core'
|
4
|
+
import type { BreakpointsOrMediaQueries, ToDeepUnistyles } from './stylesheet'
|
5
5
|
|
6
6
|
type ExtractTransformArray<T> = T extends object
|
7
7
|
? { [K in keyof T]: ExtractBreakpoints<T[K]> }
|
package/src/types/core.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
1
2
|
import type {
|
2
3
|
MatrixTransform,
|
3
4
|
PerspectiveTransform,
|
@@ -13,7 +14,6 @@ import type {
|
|
13
14
|
TranslateXTransform,
|
14
15
|
TranslateYTransform
|
15
16
|
} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'
|
16
|
-
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
17
17
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
|
18
18
|
|
19
19
|
export type ShadowOffset = {
|
package/src/types/stylesheet.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
1
|
+
import type { CSSProperties } from 'react'
|
2
|
+
import type { BoxShadowValue, FilterFunction, ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
3
3
|
import type { UnistylesBreakpoints } from '../global'
|
4
4
|
import type { UnistylesMiniRuntime } from '../specs'
|
5
|
+
import type { Pseudo } from '../web/convert/pseudo'
|
5
6
|
import type { ReactNativeStyleSheet } from './breakpoints'
|
7
|
+
import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core'
|
6
8
|
import type { ExtractVariantNames } from './variants'
|
7
|
-
import type { CSSProperties } from 'react'
|
8
|
-
import type { Pseudo } from '../web/convert/pseudo'
|
9
9
|
|
10
10
|
// these props are treated differently to nest breakpoints and media queries
|
11
11
|
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset' | 'boxShadow' | 'filter'
|
@@ -62,7 +62,7 @@ export type UnistylesValues = FlatUnistylesValues & {
|
|
62
62
|
} & VariantsAndCompoundVariants & {
|
63
63
|
[propName in NestedKeys]?: UnistyleNestedStyles[propName]
|
64
64
|
} & {
|
65
|
-
_web?: CSSProperties & CustomClassName & {
|
65
|
+
_web?: ToDeepUnistyles<CSSProperties> & CustomClassName & {
|
66
66
|
[propName in Pseudo]?: ToDeepUnistyles<CSSProperties>
|
67
67
|
}
|
68
68
|
}
|
package/src/web/convert/index.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { UnistylesValues } from '../../types'
|
2
|
+
import { deepMergeObjects } from '../../utils'
|
3
|
+
import { getBoxShadow, getFilterStyle, getTransformStyle } from './object'
|
2
4
|
import { isPseudo } from './pseudo'
|
5
|
+
import { getBoxShadowStyle, getTextShadowStyle } from './shadow'
|
3
6
|
import { getStyle } from './style'
|
4
|
-
import {
|
5
|
-
import { getTransformStyle, getBoxShadow, getFilterStyle } from './object'
|
6
|
-
import { isShadow, isFilter, isTextShadow, isTransform, isBoxShadow } from './utils'
|
7
|
-
import { getTextShadowStyle, getBoxShadowStyle } from './shadow'
|
7
|
+
import { isBoxShadow, isFilter, isShadow, isTextShadow, isTransform } from './utils'
|
8
8
|
|
9
9
|
export const convertUnistyles = (value: UnistylesValues) => {
|
10
10
|
// Flag to mark if textShadow is already created
|
@@ -17,7 +17,7 @@ export const convertUnistyles = (value: UnistylesValues) => {
|
|
17
17
|
...value._web
|
18
18
|
}).flatMap(([unistylesKey, unistylesValue]) => {
|
19
19
|
// Keys to omit
|
20
|
-
if (['_classNames', '_web', 'variants', 'compoundVariants', 'uni__dependencies'
|
20
|
+
if (['_classNames', '_web', 'variants', 'compoundVariants', 'uni__dependencies'].includes(unistylesKey) || unistylesKey.startsWith('unistyles_')) {
|
21
21
|
return []
|
22
22
|
}
|
23
23
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { BoxShadowValue } from 'react-native'
|
2
|
-
import { normalizeNumericValue } from '../utils'
|
3
|
-
import { keyInObject } from '../../utils'
|
4
2
|
import { deepMergeObjects } from '../../../utils'
|
3
|
+
import { keyInObject } from '../../utils'
|
4
|
+
import { normalizeNumericValue } from '../utils'
|
5
5
|
|
6
6
|
const createBoxShadowValue = (style: BoxShadowValue) => {
|
7
7
|
const { offsetX, offsetY, blurRadius = 0, spreadDistance = 0, color = '#000', inset } = style
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { DropShadowValue } from 'react-native'
|
2
|
+
import { isUnistylesMq } from '../../../mq'
|
3
|
+
import { UnistylesWeb } from '../../index'
|
2
4
|
import { hyphenate } from '../../utils'
|
3
5
|
import type { Filters } from '../types'
|
4
|
-
import { getObjectStyle } from './objectStyle'
|
5
6
|
import { normalizeColor, normalizeNumericValue } from '../utils'
|
6
|
-
import {
|
7
|
-
import { UnistylesWeb } from '../../index'
|
7
|
+
import { getObjectStyle } from './objectStyle'
|
8
8
|
|
9
9
|
const getDropShadowStyle = (dropShadow: DropShadowValue) => {
|
10
10
|
const { offsetX = 0, offsetY = 0, standardDeviation = 0, color = '#000' } = dropShadow
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { getObjectStyle } from './objectStyle'
|
2
|
-
import { normalizeNumericValue } from '../utils'
|
3
1
|
import type { TransformStyles } from '../../../types/core'
|
2
|
+
import { normalizeNumericValue } from '../utils'
|
3
|
+
import { getObjectStyle } from './objectStyle'
|
4
4
|
|
5
5
|
const normalizeTransform = (key: string, value: any) => {
|
6
6
|
if (key.includes('scale')) {
|