react-native-unistyles 3.0.24 → 3.1.1
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 +7 -6
- package/android/src/main/cxx/NativeUnistylesModule.cpp +7 -4
- package/android/src/main/cxx/NativeUnistylesModule.h +9 -3
- package/android/src/main/cxx/cpp-adapter.cpp +1 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +22 -4
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -0
- package/cxx/core/StyleSheetRegistry.cpp +11 -11
- package/cxx/core/StyleSheetRegistry.h +4 -4
- package/cxx/core/UnistylesRegistry.cpp +27 -14
- package/cxx/core/UnistylesRegistry.h +4 -1
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +5 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +2 -14
- package/cxx/hybridObjects/HybridStyleSheet.h +0 -2
- package/ios/UnistylesModuleOnLoad.mm +10 -2
- package/lib/commonjs/components/AdaptiveTheme.js +1 -1
- package/lib/commonjs/components/AdaptiveTheme.js.map +1 -1
- package/lib/commonjs/components/ApplyScopedTheme.js.map +1 -1
- package/lib/commonjs/components/Display.js.map +1 -1
- package/lib/commonjs/components/Hide.js.map +1 -1
- package/lib/commonjs/components/NamedTheme.js +2 -2
- package/lib/commonjs/components/NamedTheme.js.map +1 -1
- package/lib/commonjs/components/ScopedTheme.js.map +1 -1
- package/lib/commonjs/components/native/ActivityIndicator.js.map +1 -1
- package/lib/commonjs/components/native/Animated.js.map +1 -1
- package/lib/commonjs/components/native/FlatList.js.map +1 -1
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/Image.native.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.native.js.map +1 -1
- package/lib/commonjs/components/native/KeyboardAvoidingView.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.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/components/native/RefreshControl.js.map +1 -1
- package/lib/commonjs/components/native/SafeAreaView.js.map +1 -1
- package/lib/commonjs/components/native/ScrollView.js.map +1 -1
- package/lib/commonjs/components/native/SectionList.js.map +1 -1
- package/lib/commonjs/components/native/Switch.js.map +1 -1
- package/lib/commonjs/components/native/Text.js.map +1 -1
- package/lib/commonjs/components/native/TextInput.js.map +1 -1
- package/lib/commonjs/components/native/TouchableHighlight.js.map +1 -1
- package/lib/commonjs/components/native/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/components/native/View.js.map +1 -1
- package/lib/commonjs/components/native/VirtualizedList.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/parseBoxShadow.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js +0 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/useUnistyles.js.map +1 -1
- package/lib/commonjs/core/warn.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +3 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +6 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +0 -1
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mocks.js +28 -8
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js +0 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +0 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +9 -5
- 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.map +1 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +1 -1
- package/lib/commonjs/specs/index.native.js.map +1 -1
- package/lib/commonjs/specs/types.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -1
- package/lib/commonjs/web/convert/object/transform.js.map +1 -1
- package/lib/commonjs/web/convert/pseudo.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -1
- package/lib/commonjs/web/convert/types.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/create.js +1 -5
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/core.js.map +1 -1
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/css/utils.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -0
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js +29 -8
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +1 -2
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +3 -3
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +2 -0
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web/variants.js.map +1 -1
- package/lib/commonjs/web-only/getWebProps.js.map +1 -1
- package/lib/commonjs/web-only/index.js.map +1 -1
- package/lib/module/components/AdaptiveTheme.js +1 -1
- package/lib/module/components/AdaptiveTheme.js.map +1 -1
- package/lib/module/components/ApplyScopedTheme.js.map +1 -1
- package/lib/module/components/Display.js.map +1 -1
- package/lib/module/components/Hide.js.map +1 -1
- package/lib/module/components/NamedTheme.js +2 -2
- package/lib/module/components/NamedTheme.js.map +1 -1
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/components/native/ActivityIndicator.js.map +1 -1
- package/lib/module/components/native/Animated.js.map +1 -1
- package/lib/module/components/native/FlatList.js.map +1 -1
- package/lib/module/components/native/Image.js.map +1 -1
- package/lib/module/components/native/Image.native.js.map +1 -1
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/ImageBackground.native.js.map +1 -1
- package/lib/module/components/native/KeyboardAvoidingView.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.map +1 -1
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/components/native/RefreshControl.js.map +1 -1
- package/lib/module/components/native/SafeAreaView.js.map +1 -1
- package/lib/module/components/native/ScrollView.js.map +1 -1
- package/lib/module/components/native/SectionList.js.map +1 -1
- package/lib/module/components/native/Switch.js.map +1 -1
- package/lib/module/components/native/Text.js.map +1 -1
- package/lib/module/components/native/TextInput.js.map +1 -1
- package/lib/module/components/native/TouchableHighlight.js.map +1 -1
- package/lib/module/components/native/TouchableOpacity.js.map +1 -1
- package/lib/module/components/native/View.js.map +1 -1
- package/lib/module/components/native/VirtualizedList.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/core/parseBoxShadow.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.native.js +0 -1
- package/lib/module/core/useProxifiedUnistyles/listener.native.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/useUnistyles.js.map +1 -1
- package/lib/module/core/warn.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.js +3 -1
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +6 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +0 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks.js +28 -8
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/mq.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.native.js +0 -1
- package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +0 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/useServerUnistyles.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +9 -5
- 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.map +1 -1
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.native.js +1 -1
- package/lib/module/specs/index.native.js.map +1 -1
- package/lib/module/specs/types.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js.map +1 -1
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/convert/object/objectStyle.js.map +1 -1
- package/lib/module/web/convert/object/transform.js.map +1 -1
- package/lib/module/web/convert/pseudo.js.map +1 -1
- package/lib/module/web/convert/shadow/boxShadow.js.map +1 -1
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -1
- package/lib/module/web/convert/shadow/textShadow.js.map +1 -1
- package/lib/module/web/convert/types.js.map +1 -1
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/create.js +2 -6
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/css/core.js.map +1 -1
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/css/utils.js.map +1 -1
- package/lib/module/web/index.js +1 -0
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/listener.js +29 -8
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +1 -2
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +3 -3
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js.map +1 -1
- package/lib/module/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +2 -0
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web/variants.js.map +1 -1
- package/lib/module/web-only/getWebProps.js.map +1 -1
- package/lib/module/web-only/index.js.map +1 -1
- package/lib/typescript/src/__tests__/mocks.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +1 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts +1 -1
- package/lib/typescript/src/components/AdaptiveTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/ApplyScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/Display.d.ts.map +1 -1
- package/lib/typescript/src/components/Hide.d.ts.map +1 -1
- package/lib/typescript/src/components/NamedTheme.d.ts +1 -1
- package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SafeAreaView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
- package/lib/typescript/src/components/native/View.d.ts.map +1 -1
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.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/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/parseBoxShadow.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/types.d.ts +1 -1
- package/lib/typescript/src/core/withUnistyles/types.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/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/types.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -5
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.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/UnistylesStyleSheet.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +3 -3
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +1 -1
- 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/specs/types.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.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.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/objectStyle.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/types.d.ts +2 -2
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- 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/css/core.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts +5 -1
- package/lib/typescript/src/web/listener.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.map +1 -1
- package/lib/typescript/src/web/types.d.ts +1 -1
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/lib/typescript/src/web/variants.d.ts.map +1 -1
- package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -1
- package/lib/typescript/src/web-only/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +36 -42
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +19 -22
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +15 -18
- package/nitrogen/generated/android/unistylesOnLoad.cpp +14 -9
- package/nitrogen/generated/android/unistylesOnLoad.hpp +13 -4
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +0 -1
- package/package.json +43 -44
- package/plugin/index.d.ts +34 -28
- package/plugin/index.js +113 -103
- package/repack-plugin/index.d.ts +2 -2
- package/src/components/AdaptiveTheme.tsx +8 -12
- package/src/components/ApplyScopedTheme.tsx +2 -0
- package/src/components/Display.tsx +2 -3
- package/src/components/Hide.tsx +2 -3
- package/src/components/NamedTheme.tsx +9 -14
- package/src/components/ScopedTheme.tsx +22 -27
- package/src/components/native/ActivityIndicator.tsx +1 -0
- package/src/components/native/Animated.tsx +2 -1
- package/src/components/native/FlatList.tsx +1 -0
- package/src/components/native/Image.native.tsx +1 -0
- package/src/components/native/Image.tsx +11 -7
- package/src/components/native/ImageBackground.native.tsx +1 -0
- package/src/components/native/ImageBackground.tsx +11 -7
- package/src/components/native/KeyboardAvoidingView.tsx +1 -0
- package/src/components/native/NativeText.native.tsx +3 -1
- package/src/components/native/NativeView.native.tsx +3 -1
- package/src/components/native/Pressable.native.tsx +8 -8
- package/src/components/native/Pressable.tsx +25 -20
- package/src/components/native/RefreshControl.tsx +1 -0
- package/src/components/native/SafeAreaView.tsx +1 -0
- package/src/components/native/ScrollView.tsx +1 -0
- package/src/components/native/SectionList.tsx +1 -0
- package/src/components/native/Switch.tsx +1 -0
- package/src/components/native/Text.tsx +1 -0
- package/src/components/native/TextInput.tsx +1 -0
- package/src/components/native/TouchableHighlight.tsx +1 -0
- package/src/components/native/TouchableOpacity.tsx +1 -0
- package/src/components/native/View.tsx +1 -0
- package/src/components/native/VirtualizedList.tsx +1 -0
- package/src/core/createUnistylesElement.native.tsx +4 -2
- package/src/core/createUnistylesElement.tsx +14 -17
- package/src/core/createUnistylesImageBackground.tsx +6 -4
- package/src/core/getClassname.ts +4 -11
- package/src/core/parseBoxShadow.ts +11 -24
- package/src/core/passForwardRef.ts +1 -1
- package/src/core/useProxifiedUnistyles/listener.native.ts +3 -3
- package/src/core/useProxifiedUnistyles/listener.ts +10 -3
- package/src/core/useProxifiedUnistyles/types.ts +2 -2
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +13 -9
- package/src/core/useUnistyles.ts +2 -1
- package/src/core/warn.ts +4 -4
- package/src/core/withUnistyles/types.ts +7 -4
- package/src/core/withUnistyles/withUnistyles.native.tsx +53 -44
- package/src/core/withUnistyles/withUnistyles.tsx +30 -24
- package/src/global.ts +2 -2
- package/src/hooks/useMedia.native.ts +2 -2
- package/src/hooks/useMedia.ts +6 -3
- package/src/index.ts +1 -0
- package/src/mocks.ts +74 -49
- package/src/mq.ts +23 -15
- package/src/reanimated/useAnimatedTheme.native.ts +4 -3
- package/src/reanimated/useAnimatedTheme.ts +6 -2
- package/src/reanimated/variant/types.ts +11 -10
- package/src/reanimated/variant/useAnimatedVariantColor.ts +7 -7
- package/src/reanimated/variant/useUpdateVariantColor.native.ts +10 -6
- package/src/reanimated/variant/useUpdateVariantColor.ts +21 -21
- package/src/server/getServerUnistyles.tsx +11 -4
- package/src/server/index.ts +0 -1
- package/src/server/types.ts +1 -1
- package/src/server/useServerUnistyles.tsx +4 -1
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +30 -27
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.ts +3 -3
- package/src/specs/ShadowRegistry/ShadowRegistry.nitro.ts +1 -1
- package/src/specs/ShadowRegistry/index.ts +35 -29
- package/src/specs/ShadowRegistry/types.ts +9 -10
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.ts +4 -4
- package/src/specs/StatusBar/index.ts +5 -5
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +2 -2
- package/src/specs/StyleSheet/index.ts +32 -27
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -0
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +26 -25
- package/src/specs/UnistylesRuntime/index.ts +20 -20
- package/src/specs/index.native.ts +6 -18
- package/src/specs/types.ts +9 -8
- package/src/types/accessibility.ts +2 -2
- package/src/types/breakpoints.ts +61 -59
- package/src/types/core.ts +17 -17
- package/src/types/index.ts +2 -9
- package/src/types/stylesheet.ts +27 -19
- package/src/types/variants.ts +3 -11
- package/src/utils.ts +16 -16
- package/src/web/convert/index.ts +6 -2
- package/src/web/convert/object/boxShadow.ts +23 -18
- package/src/web/convert/object/filter.ts +30 -13
- package/src/web/convert/object/objectStyle.ts +33 -23
- package/src/web/convert/object/transform.ts +10 -8
- package/src/web/convert/pseudo.ts +2 -2
- package/src/web/convert/shadow/boxShadow.ts +6 -6
- package/src/web/convert/shadow/getShadowBreakpoints.ts +4 -4
- package/src/web/convert/shadow/textShadow.ts +6 -6
- package/src/web/convert/style.ts +25 -25
- package/src/web/convert/types.ts +4 -3
- package/src/web/convert/utils.ts +20 -10
- package/src/web/create.ts +29 -20
- package/src/web/css/core.ts +2 -1
- package/src/web/css/state.ts +11 -8
- package/src/web/css/utils.ts +2 -1
- package/src/web/index.ts +7 -4
- package/src/web/listener.ts +61 -18
- package/src/web/mock.ts +2 -2
- package/src/web/registry.ts +17 -10
- package/src/web/runtime.ts +23 -17
- package/src/web/shadowRegistry.ts +26 -24
- package/src/web/state.ts +23 -16
- package/src/web/types.ts +5 -5
- package/src/web/utils/common.ts +7 -9
- package/src/web/utils/createUnistylesRef.ts +18 -14
- package/src/web/utils/unistyle.ts +53 -34
- package/src/web/variants.ts +19 -11
- package/src/web-only/getWebProps.ts +5 -6
- package/src/web-only/index.ts +0 -1
- package/LICENSE +0 -20
- package/lib/typescript/plugin/src/consts.d.ts +0 -17
- package/lib/typescript/plugin/src/consts.d.ts.map +0 -1
- package/lib/typescript/repack-plugin/src/index.d.ts +0 -18
- package/lib/typescript/repack-plugin/src/index.d.ts.map +0 -1
- package/lib/typescript/repack-plugin/src/loader.d.ts +0 -9
- package/lib/typescript/repack-plugin/src/loader.d.ts.map +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import type { ImageBackground, ImageBackgroundProps } from 'react-native'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
3
5
|
import { UnistylesShadowRegistry } from '../specs'
|
|
4
6
|
import { copyComponentProperties } from '../utils'
|
|
5
7
|
import { passForwardedRef } from './passForwardRef'
|
|
@@ -15,7 +17,7 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
|
|
|
15
17
|
return (
|
|
16
18
|
<Component
|
|
17
19
|
{...props}
|
|
18
|
-
ref={ref => {
|
|
20
|
+
ref={(ref) => {
|
|
19
21
|
return passForwardedRef(
|
|
20
22
|
ref,
|
|
21
23
|
forwardedRef,
|
|
@@ -26,10 +28,10 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
|
|
|
26
28
|
() => {
|
|
27
29
|
// @ts-expect-error - this is hidden from TS
|
|
28
30
|
UnistylesShadowRegistry.remove(ref)
|
|
29
|
-
}
|
|
31
|
+
},
|
|
30
32
|
)
|
|
31
33
|
}}
|
|
32
|
-
imageRef={ref => {
|
|
34
|
+
imageRef={(ref) => {
|
|
33
35
|
// @ts-expect-error web types are not compatible with RN styles
|
|
34
36
|
UnistylesShadowRegistry.add(ref, props.imageStyle)
|
|
35
37
|
|
package/src/core/getClassname.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UnistylesValues } from '../types'
|
|
2
|
+
|
|
2
3
|
import * as unistyles from '../web/services'
|
|
3
4
|
import { checkForAnimated } from '../web/utils'
|
|
4
5
|
|
|
@@ -9,17 +10,9 @@ export const getClassName = (unistyle: UnistylesValues | undefined | Array<Unist
|
|
|
9
10
|
|
|
10
11
|
const flattenedStyles = Array.isArray(unistyle) ? unistyle.flat(Number.POSITIVE_INFINITY) : [unistyle]
|
|
11
12
|
const animatedStyles = flattenedStyles.filter(checkForAnimated)
|
|
12
|
-
const regularStyles = flattenedStyles.filter(style => !checkForAnimated(style))
|
|
13
|
+
const regularStyles = flattenedStyles.filter((style) => !checkForAnimated(style))
|
|
13
14
|
|
|
14
|
-
const { hash, injectedClassName } = unistyles.services.shadowRegistry.addStyles(
|
|
15
|
-
regularStyles,
|
|
16
|
-
forChild
|
|
17
|
-
)
|
|
15
|
+
const { hash, injectedClassName } = unistyles.services.shadowRegistry.addStyles(regularStyles, forChild)
|
|
18
16
|
|
|
19
|
-
return hash
|
|
20
|
-
? [
|
|
21
|
-
{ $$css: true, hash, injectedClassName },
|
|
22
|
-
animatedStyles,
|
|
23
|
-
] as const
|
|
24
|
-
: undefined
|
|
17
|
+
return hash ? ([{ $$css: true, hash, injectedClassName }, animatedStyles] as const) : undefined
|
|
25
18
|
}
|
|
@@ -19,7 +19,7 @@ const parseBoxShadow = (str: string): BoxShadow | undefined => {
|
|
|
19
19
|
// split by space, but not if it's inside of ()
|
|
20
20
|
const parts = str.split(/\s+(?![^(]*\))/)
|
|
21
21
|
const lastIndex = parts.length - 1
|
|
22
|
-
const insetIndex = parts.findIndex(part => part === 'inset')
|
|
22
|
+
const insetIndex = parts.findIndex((part) => part === 'inset')
|
|
23
23
|
|
|
24
24
|
// inset can only be at the start or end
|
|
25
25
|
if (![-1, 0, lastIndex].includes(insetIndex)) {
|
|
@@ -27,19 +27,12 @@ const parseBoxShadow = (str: string): BoxShadow | undefined => {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// if there is no inset, color can only be at the start or end
|
|
30
|
-
const maybeColorsIndexes =
|
|
31
|
-
? [0, lastIndex]
|
|
32
|
-
: insetIndex === lastIndex
|
|
33
|
-
? [0, lastIndex - 1]
|
|
34
|
-
: [1, lastIndex]
|
|
30
|
+
const maybeColorsIndexes =
|
|
31
|
+
insetIndex === -1 ? [0, lastIndex] : insetIndex === lastIndex ? [0, lastIndex - 1] : [1, lastIndex]
|
|
35
32
|
|
|
36
|
-
const colorIndex = maybeColorsIndexes.find(index => !isValue(parts[index])) ?? -1
|
|
37
|
-
const maybeColor = colorIndex !== -1
|
|
38
|
-
|
|
39
|
-
: undefined
|
|
40
|
-
const color = maybeColor && processColor(maybeColor)
|
|
41
|
-
? parts[colorIndex]
|
|
42
|
-
: undefined
|
|
33
|
+
const colorIndex = maybeColorsIndexes.find((index) => !isValue(parts[index])) ?? -1
|
|
34
|
+
const maybeColor = colorIndex !== -1 ? parts[colorIndex] : undefined
|
|
35
|
+
const color = maybeColor && processColor(maybeColor) ? parts[colorIndex] : undefined
|
|
43
36
|
const values = parts.filter((_, index) => index !== colorIndex && index !== insetIndex)
|
|
44
37
|
|
|
45
38
|
// at this point there can be only 4 values
|
|
@@ -53,32 +46,26 @@ const parseBoxShadow = (str: string): BoxShadow | undefined => {
|
|
|
53
46
|
return undefined
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
const blurRadiusValue = isValue(blurRadius)
|
|
57
|
-
? Number.parseFloat(blurRadius as string)
|
|
58
|
-
: undefined
|
|
49
|
+
const blurRadiusValue = isValue(blurRadius) ? Number.parseFloat(blurRadius as string) : undefined
|
|
59
50
|
|
|
60
51
|
if (blurRadiusValue !== undefined && blurRadiusValue < 0) {
|
|
61
52
|
return undefined
|
|
62
53
|
}
|
|
63
54
|
|
|
64
55
|
return {
|
|
65
|
-
inset: insetIndex !== -1
|
|
66
|
-
? true
|
|
67
|
-
: undefined,
|
|
56
|
+
inset: insetIndex !== -1 ? true : undefined,
|
|
68
57
|
offsetX: Number.parseFloat(offsetX as string),
|
|
69
58
|
offsetY: Number.parseFloat(offsetY as string),
|
|
70
59
|
blurRadius: blurRadiusValue ?? 0,
|
|
71
|
-
spreadDistance: spreadRadius
|
|
72
|
-
|
|
73
|
-
: 0,
|
|
74
|
-
color
|
|
60
|
+
spreadDistance: spreadRadius ? Number.parseFloat(spreadRadius as string) : 0,
|
|
61
|
+
color,
|
|
75
62
|
}
|
|
76
63
|
}
|
|
77
64
|
|
|
78
65
|
export const parseBoxShadowString = (str: string): Array<BoxShadow> => {
|
|
79
66
|
const parts = str
|
|
80
67
|
.split(/,(?![^()]*\))/)
|
|
81
|
-
.map(part => part.trim().replace('\n', ''))
|
|
68
|
+
.map((part) => part.trim().replace('\n', ''))
|
|
82
69
|
.filter(Boolean)
|
|
83
70
|
.map(parseBoxShadow)
|
|
84
71
|
.filter(Boolean) as Array<BoxShadow>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StyleSheet, UnistyleDependency } from '../../specs'
|
|
2
1
|
import type { ListenerProps } from './types'
|
|
3
2
|
|
|
3
|
+
import { StyleSheet, UnistyleDependency } from '../../specs'
|
|
4
|
+
|
|
4
5
|
export const listener = ({ dependencies, updateTheme, updateRuntime }: ListenerProps) => {
|
|
5
6
|
const listensToTheme = dependencies.includes(UnistyleDependency.Theme)
|
|
6
|
-
|
|
7
|
-
const dispose = StyleSheet.addChangeListener(changedDependencies => {
|
|
7
|
+
const dispose = StyleSheet.addChangeListener((changedDependencies) => {
|
|
8
8
|
if (listensToTheme && changedDependencies.includes(UnistyleDependency.Theme)) {
|
|
9
9
|
updateTheme()
|
|
10
10
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import type { ListenerProps } from './types'
|
|
2
|
+
|
|
1
3
|
import { UnistyleDependency } from '../../specs'
|
|
2
4
|
import * as unistyles from '../../web/services'
|
|
3
|
-
import type { ListenerProps } from './types'
|
|
4
5
|
|
|
5
6
|
export const listener = ({ dependencies, updateTheme, updateRuntime }: ListenerProps) => {
|
|
6
|
-
const disposeTheme = unistyles.services.listener.addListeners(
|
|
7
|
-
|
|
7
|
+
const disposeTheme = unistyles.services.listener.addListeners(
|
|
8
|
+
dependencies.filter((dependency) => dependency === UnistyleDependency.Theme),
|
|
9
|
+
updateTheme,
|
|
10
|
+
)
|
|
11
|
+
const disposeRuntime = unistyles.services.listener.addListeners(
|
|
12
|
+
dependencies.filter((dependency) => dependency !== UnistyleDependency.Theme),
|
|
13
|
+
(dependency) => updateRuntime(dependency === UnistyleDependency.ThemeName),
|
|
14
|
+
)
|
|
8
15
|
|
|
9
16
|
return () => {
|
|
10
17
|
disposeTheme()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { UnistyleDependency } from '../../specs'
|
|
2
2
|
|
|
3
3
|
export type ListenerProps = {
|
|
4
|
-
updateTheme: VoidFunction
|
|
5
|
-
updateRuntime(themeNameChange: boolean): void
|
|
4
|
+
updateTheme: VoidFunction
|
|
5
|
+
updateRuntime(themeNameChange: boolean): void
|
|
6
6
|
dependencies: Array<UnistyleDependency>
|
|
7
7
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import type { UnistylesTheme } from '../../types'
|
|
4
|
+
|
|
2
5
|
import { type UnistylesMiniRuntime, UnistylesRuntime, UnistylesShadowRegistry } from '../../specs'
|
|
3
6
|
// It's imported that way because of circular dependency
|
|
4
7
|
import { UnistyleDependency } from '../../specs/NativePlatform'
|
|
5
|
-
import type { UnistylesTheme } from '../../types'
|
|
6
8
|
import { listener } from './listener'
|
|
7
9
|
|
|
8
10
|
const getMiniRuntime = (): UnistylesMiniRuntime => {
|
|
@@ -24,11 +26,13 @@ const RTDependencyMap = {
|
|
|
24
26
|
statusBar: UnistyleDependency.StatusBar,
|
|
25
27
|
pixelRatio: UnistyleDependency.PixelRatio,
|
|
26
28
|
themeName: UnistyleDependency.ThemeName,
|
|
27
|
-
rtl: UnistyleDependency.Rtl
|
|
29
|
+
rtl: UnistyleDependency.Rtl,
|
|
28
30
|
} satisfies Partial<Record<keyof UnistylesMiniRuntime, UnistyleDependency>>
|
|
29
31
|
|
|
30
32
|
export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
31
|
-
const [scopedTheme, setScopedTheme] = useState(
|
|
33
|
+
const [scopedTheme, setScopedTheme] = useState(
|
|
34
|
+
forcedTheme ?? (UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme),
|
|
35
|
+
)
|
|
32
36
|
const [dependencies] = useState(() => new Set<number>())
|
|
33
37
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme))
|
|
34
38
|
const [_, runtimeChanged] = useReducer(() => ({}), {})
|
|
@@ -53,7 +57,7 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
runtimeChanged()
|
|
56
|
-
}
|
|
60
|
+
},
|
|
57
61
|
})
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -72,7 +76,7 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
72
76
|
dependencies.add(UnistyleDependency.Theme)
|
|
73
77
|
|
|
74
78
|
return target[prop]
|
|
75
|
-
}
|
|
79
|
+
},
|
|
76
80
|
})
|
|
77
81
|
const proxifiedRuntime = new Proxy(getMiniRuntime(), {
|
|
78
82
|
get: (target, prop) => {
|
|
@@ -88,7 +92,7 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
88
92
|
dependencies.add(UnistyleDependency.Insets)
|
|
89
93
|
|
|
90
94
|
return target[prop as keyof typeof target]
|
|
91
|
-
}
|
|
95
|
+
},
|
|
92
96
|
})
|
|
93
97
|
}
|
|
94
98
|
|
|
@@ -101,7 +105,7 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
return target[prop as keyof typeof target]
|
|
104
|
-
}
|
|
108
|
+
},
|
|
105
109
|
})
|
|
106
110
|
|
|
107
111
|
useLayoutEffect(() => {
|
|
@@ -124,7 +128,7 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
124
128
|
addDependencies: (newDependencies: Array<UnistyleDependency>) => {
|
|
125
129
|
const dependenciesSize = dependencies.size
|
|
126
130
|
|
|
127
|
-
newDependencies.forEach(dependency => {
|
|
131
|
+
newDependencies.forEach((dependency) => {
|
|
128
132
|
dependencies.add(dependency)
|
|
129
133
|
})
|
|
130
134
|
|
|
@@ -135,6 +139,6 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
135
139
|
syncedDependenciesSizeRef.current = dependencies.size
|
|
136
140
|
syncedScopedThemeRef.current = scopedTheme
|
|
137
141
|
reinitListener()
|
|
138
|
-
}
|
|
142
|
+
},
|
|
139
143
|
}
|
|
140
144
|
}
|
package/src/core/useUnistyles.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UnistylesTheme } from '../types'
|
|
2
|
+
|
|
2
3
|
import { useProxifiedUnistyles } from './useProxifiedUnistyles'
|
|
3
4
|
|
|
4
5
|
export const useUnistyles = () => {
|
|
@@ -6,6 +7,6 @@ export const useUnistyles = () => {
|
|
|
6
7
|
|
|
7
8
|
return {
|
|
8
9
|
theme: proxifiedTheme as UnistylesTheme,
|
|
9
|
-
rt: proxifiedRuntime
|
|
10
|
+
rt: proxifiedRuntime,
|
|
10
11
|
}
|
|
11
12
|
}
|
package/src/core/warn.ts
CHANGED
|
@@ -2,12 +2,12 @@ import type { ViewStyle } from 'react-native'
|
|
|
2
2
|
|
|
3
3
|
export const maybeWarnAboutMultipleUnistyles = (style: ViewStyle, displayName = 'Unknown') => {
|
|
4
4
|
if (__DEV__ && style && !Array.isArray(style)) {
|
|
5
|
-
const unistylesKeys = Object
|
|
6
|
-
.keys(style)
|
|
7
|
-
.filter(key => key.startsWith('unistyles_'))
|
|
5
|
+
const unistylesKeys = Object.keys(style).filter((key) => key.startsWith('unistyles_'))
|
|
8
6
|
|
|
9
7
|
if (unistylesKeys.length > 1) {
|
|
10
|
-
console.warn(
|
|
8
|
+
console.warn(
|
|
9
|
+
`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.`,
|
|
10
|
+
)
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { UnistylesMiniRuntime } from '../../specs'
|
|
2
|
-
import type { UnistylesTheme } from '../../types'
|
|
1
|
+
import type { UnistylesMiniRuntime } from '../../specs'
|
|
2
|
+
import type { UnistylesTheme } from '../../types'
|
|
3
3
|
|
|
4
4
|
export const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
|
|
5
5
|
|
|
6
|
-
export type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
|
|
7
|
-
export type Mappings<T = {}> = (
|
|
6
|
+
export type SupportedStyleProps = (typeof SUPPORTED_STYLE_PROPS)[number]
|
|
7
|
+
export type Mappings<T = {}> = (
|
|
8
|
+
theme: UnistylesTheme,
|
|
9
|
+
rt: UnistylesMiniRuntime,
|
|
10
|
+
) => Omit<Partial<T>, SupportedStyleProps> & { key?: string }
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef, useEffect, useRef, type ComponentProps, type ComponentRef, type ComponentType } from 'react'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { UnistylesTheme, UnistylesValues } from '../../types'
|
|
4
|
+
import type { Mappings } from './types'
|
|
5
|
+
|
|
6
|
+
import { type UnistyleDependency, UnistylesShadowRegistry } from '../../specs'
|
|
4
7
|
import { deepMergeObjects } from '../../utils'
|
|
5
8
|
import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
|
|
6
9
|
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
|
7
|
-
import type { Mappings } from './types'
|
|
8
10
|
|
|
9
11
|
// @ts-expect-error
|
|
10
12
|
type GenericComponentProps<P> = ComponentProps<P>
|
|
@@ -12,51 +14,50 @@ type GenericComponentProps<P> = ComponentProps<P>
|
|
|
12
14
|
type GenericComponentRef<T> = ComponentRef<T>
|
|
13
15
|
|
|
14
16
|
type UnistylesSecrets = {
|
|
15
|
-
uni__getStyles: () => Record<string, any
|
|
17
|
+
uni__getStyles: () => Record<string, any>
|
|
16
18
|
uni__dependencies: Array<UnistyleDependency>
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
type MappedSecrets = {
|
|
20
|
-
styles: Record<string, any
|
|
22
|
+
styles: Record<string, any>
|
|
21
23
|
dependencies: Array<UnistyleDependency>
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
export const withUnistyles = <TComponent, TMappings extends GenericComponentProps<TComponent>>(
|
|
26
|
+
export const withUnistyles = <TComponent, TMappings extends GenericComponentProps<TComponent>>(
|
|
27
|
+
Component: TComponent,
|
|
28
|
+
mappings?: Mappings<TMappings>,
|
|
29
|
+
) => {
|
|
25
30
|
type TProps = GenericComponentProps<TComponent>
|
|
26
31
|
type PropsWithUnistyles = Partial<TProps> & {
|
|
27
32
|
uniProps?: Mappings<TProps>
|
|
28
33
|
}
|
|
29
34
|
type UnistyleStyles = {
|
|
30
|
-
style?: UnistylesValues
|
|
35
|
+
style?: UnistylesValues
|
|
31
36
|
contentContainerStyle?: UnistylesValues
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets => {
|
|
35
|
-
const styles = Array.isArray(styleProps)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: {
|
|
50
|
-
uni__getStyles: () => style,
|
|
51
|
-
uni__dependencies: [],
|
|
52
|
-
}
|
|
53
|
-
])
|
|
54
|
-
}, [])
|
|
40
|
+
const styles = Array.isArray(styleProps) ? styleProps.flat() : [styleProps]
|
|
41
|
+
|
|
42
|
+
const secrets: Array<UnistylesSecrets> = styles.filter(Boolean).reduce((acc, style) => {
|
|
43
|
+
const unistyleKey = Object.keys(style).find((key) => key.startsWith('unistyles_'))
|
|
44
|
+
|
|
45
|
+
return acc.concat([
|
|
46
|
+
unistyleKey
|
|
47
|
+
? style[unistyleKey]
|
|
48
|
+
: {
|
|
49
|
+
uni__getStyles: () => style,
|
|
50
|
+
uni__dependencies: [],
|
|
51
|
+
},
|
|
52
|
+
])
|
|
53
|
+
}, [])
|
|
55
54
|
|
|
56
55
|
return {
|
|
57
|
-
styles: secrets.reduce(
|
|
58
|
-
.assign(acc, secret.uni__getStyles()),
|
|
59
|
-
|
|
56
|
+
styles: secrets.reduce(
|
|
57
|
+
(acc, secret) => Object.assign(acc, secret.uni__getStyles()),
|
|
58
|
+
{} as Record<string, any>,
|
|
59
|
+
),
|
|
60
|
+
dependencies: secrets.flatMap((secret) => secret.uni__dependencies),
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -65,42 +66,50 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
|
65
66
|
const NativeComponent = Component as ComponentType
|
|
66
67
|
|
|
67
68
|
// @ts-ignore we don't know the type of the component
|
|
69
|
+
// prettier-ignore
|
|
68
70
|
maybeWarnAboutMultipleUnistyles(narrowedProps.style, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
|
69
71
|
// @ts-ignore we don't know the type of the component
|
|
72
|
+
// prettier-ignore
|
|
70
73
|
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
|
71
74
|
|
|
72
75
|
const scopedTheme = useRef(UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme)
|
|
73
76
|
const { proxifiedRuntime, proxifiedTheme, addDependencies } = useProxifiedUnistyles(scopedTheme.current)
|
|
74
77
|
|
|
78
|
+
// Always track Theme dependency — accessing any property on proxifiedTheme
|
|
79
|
+
// triggers the Proxy get trap which adds Theme to the dependency Set
|
|
80
|
+
void (proxifiedTheme as Record<string, unknown>).__uni
|
|
81
|
+
|
|
75
82
|
useEffect(() => {
|
|
76
83
|
const styleSecrets = getSecrets(narrowedProps.style)
|
|
77
84
|
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)
|
|
78
85
|
|
|
79
|
-
addDependencies(
|
|
86
|
+
addDependencies(
|
|
87
|
+
Array.from(new Set([...styleSecrets.dependencies, ...contentContainerStyleSecrets.dependencies])),
|
|
88
|
+
)
|
|
80
89
|
}, [narrowedProps.style, narrowedProps.contentContainerStyle])
|
|
81
90
|
|
|
82
91
|
const { key: mappingsKey, ...mappingsProps } = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
|
|
83
|
-
const { key: uniPropsKey, ...unistyleProps } = narrowedProps.uniProps
|
|
92
|
+
const { key: uniPropsKey, ...unistyleProps } = narrowedProps.uniProps
|
|
93
|
+
? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime)
|
|
94
|
+
: {}
|
|
84
95
|
|
|
85
96
|
const styleSecrets = getSecrets(narrowedProps.style)
|
|
86
97
|
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)
|
|
87
98
|
|
|
88
99
|
const finalProps = {
|
|
89
100
|
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
|
90
|
-
...narrowedProps.style
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
...(narrowedProps.style
|
|
102
|
+
? {
|
|
103
|
+
style: styleSecrets.styles,
|
|
104
|
+
}
|
|
105
|
+
: {}),
|
|
106
|
+
...(narrowedProps.contentContainerStyle
|
|
107
|
+
? {
|
|
108
|
+
contentContainerStyle: contentContainerStyleSecrets.styles,
|
|
109
|
+
}
|
|
110
|
+
: {}),
|
|
96
111
|
} as any
|
|
97
112
|
|
|
98
|
-
return
|
|
99
|
-
<NativeComponent
|
|
100
|
-
key={uniPropsKey || mappingsKey}
|
|
101
|
-
{...finalProps}
|
|
102
|
-
ref={ref}
|
|
103
|
-
/>
|
|
104
|
-
)
|
|
113
|
+
return <NativeComponent key={uniPropsKey || mappingsKey} {...finalProps} ref={ref} />
|
|
105
114
|
})
|
|
106
115
|
}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import React, { type ComponentType, forwardRef, type ComponentProps, type ComponentRef } from 'react'
|
|
2
|
+
|
|
2
3
|
import type { UnistylesValues } from '../../types'
|
|
4
|
+
import type { Mappings } from './types'
|
|
5
|
+
|
|
3
6
|
import { deepMergeObjects } from '../../utils'
|
|
4
7
|
import { getClassName } from '../getClassname'
|
|
5
8
|
import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
|
|
6
9
|
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
|
7
|
-
import type { Mappings } from './types'
|
|
8
10
|
|
|
9
11
|
// @ts-expect-error
|
|
10
12
|
type GenericComponentProps<T> = ComponentProps<T>
|
|
11
13
|
// @ts-expect-error
|
|
12
14
|
type GenericComponentRef<T> = ComponentRef<T>
|
|
13
15
|
|
|
14
|
-
export const withUnistyles = <TComponent, TMappings extends GenericComponentProps<TComponent>>(
|
|
16
|
+
export const withUnistyles = <TComponent, TMappings extends GenericComponentProps<TComponent>>(
|
|
17
|
+
Component: TComponent,
|
|
18
|
+
mappings?: Mappings<TMappings>,
|
|
19
|
+
) => {
|
|
15
20
|
type TProps = GenericComponentProps<TComponent>
|
|
16
21
|
type PropsWithUnistyles = Partial<TProps> & {
|
|
17
22
|
uniProps?: Mappings<TProps>
|
|
18
23
|
}
|
|
19
24
|
type UnistyleStyles = {
|
|
20
|
-
style?: UnistylesValues
|
|
25
|
+
style?: UnistylesValues
|
|
21
26
|
contentContainerStyle?: UnistylesValues
|
|
22
27
|
}
|
|
23
28
|
|
|
@@ -28,45 +33,46 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
|
28
33
|
const { proxifiedRuntime, proxifiedTheme } = useProxifiedUnistyles()
|
|
29
34
|
|
|
30
35
|
const { key: mappingsKey, ...mappingsProps } = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
|
|
31
|
-
const { key: uniPropsKey, ...unistyleProps } = narrowedProps.uniProps
|
|
36
|
+
const { key: uniPropsKey, ...unistyleProps } = narrowedProps.uniProps
|
|
37
|
+
? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime)
|
|
38
|
+
: {}
|
|
32
39
|
|
|
33
40
|
const emptyStyles = narrowedProps.style
|
|
34
41
|
? Object.fromEntries(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
Object.entries(Object.getOwnPropertyDescriptors(narrowedProps.style))
|
|
43
|
+
.filter(([key]) => !key.startsWith('unistyles') && !key.startsWith('_'))
|
|
44
|
+
.map(([key]) => [key, undefined]),
|
|
45
|
+
)
|
|
39
46
|
: undefined
|
|
40
47
|
|
|
41
48
|
const combinedProps = {
|
|
42
49
|
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
|
43
|
-
...narrowedProps.style
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
...(narrowedProps.style
|
|
51
|
+
? {
|
|
52
|
+
// Override default component styles with undefined values to reset them
|
|
53
|
+
style: emptyStyles,
|
|
54
|
+
}
|
|
55
|
+
: {}),
|
|
56
|
+
...(narrowedProps.contentContainerStyle
|
|
57
|
+
? {
|
|
58
|
+
contentContainerStyle: contentContainerStyleClassNames,
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
50
61
|
} as any
|
|
51
62
|
|
|
52
63
|
// @ts-ignore
|
|
64
|
+
// prettier-ignore
|
|
53
65
|
maybeWarnAboutMultipleUnistyles(narrowedProps.style, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
|
54
66
|
// @ts-ignore
|
|
67
|
+
// prettier-ignore
|
|
55
68
|
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
|
56
69
|
|
|
57
70
|
const NativeComponent = Component as ComponentType
|
|
58
71
|
const [classNames] = styleClassNames ?? []
|
|
59
72
|
|
|
60
73
|
return (
|
|
61
|
-
<div
|
|
62
|
-
|
|
63
|
-
style={{ display: 'contents' }}
|
|
64
|
-
>
|
|
65
|
-
<NativeComponent
|
|
66
|
-
key={uniPropsKey || mappingsKey}
|
|
67
|
-
{...combinedProps}
|
|
68
|
-
ref={ref}
|
|
69
|
-
/>
|
|
74
|
+
<div className={classNames?.hash} style={{ display: 'contents' }}>
|
|
75
|
+
<NativeComponent key={uniPropsKey || mappingsKey} {...combinedProps} ref={ref} />
|
|
70
76
|
</div>
|
|
71
77
|
)
|
|
72
78
|
})
|
package/src/global.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useState } from 'react'
|
|
2
|
+
|
|
2
3
|
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
|
|
3
4
|
import { isUnistylesMq, isValidMq, parseMq } from '../utils'
|
|
4
5
|
|
|
@@ -47,7 +48,6 @@ export const useMedia = (config: { mq: symbol }) => {
|
|
|
47
48
|
}, [config.mq])
|
|
48
49
|
|
|
49
50
|
useLayoutEffect(() => {
|
|
50
|
-
// @ts-expect-error - this is hidden from TS
|
|
51
51
|
const removeChangeListener = StyleSheet.addChangeListener((dependencies: Array<UnistyleDependency>) => {
|
|
52
52
|
if (dependencies.includes(UnistyleDependency.Breakpoints)) {
|
|
53
53
|
setIsVisible(computeIsVisible())
|
|
@@ -60,6 +60,6 @@ export const useMedia = (config: { mq: symbol }) => {
|
|
|
60
60
|
}, [config.mq])
|
|
61
61
|
|
|
62
62
|
return {
|
|
63
|
-
isVisible
|
|
63
|
+
isVisible,
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/hooks/useMedia.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
|
|
2
3
|
import { isUnistylesMq, isValidMq, parseMq } from '../utils'
|
|
3
4
|
|
|
4
5
|
export const useMedia = (config: { mq: symbol }) => {
|
|
@@ -26,8 +27,10 @@ export const useMedia = (config: { mq: symbol }) => {
|
|
|
26
27
|
minWidth !== undefined ? `(min-width: ${minWidth}px)` : undefined,
|
|
27
28
|
maxWidth !== undefined ? `(max-width: ${maxWidth}px)` : undefined,
|
|
28
29
|
minHeight !== undefined ? `(min-height: ${minHeight}px)` : undefined,
|
|
29
|
-
maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined
|
|
30
|
-
]
|
|
30
|
+
maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined,
|
|
31
|
+
]
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join(' and ')
|
|
31
34
|
|
|
32
35
|
const media = window.matchMedia(mediaQuery)
|
|
33
36
|
const handler = (event: MediaQueryListEvent) => setIsVisible(event.matches)
|
|
@@ -42,6 +45,6 @@ export const useMedia = (config: { mq: symbol }) => {
|
|
|
42
45
|
useEffect(() => () => disposeRef.current(), [])
|
|
43
46
|
|
|
44
47
|
return {
|
|
45
|
-
isVisible
|
|
48
|
+
isVisible,
|
|
46
49
|
}
|
|
47
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ if (majorReactVersions === undefined || majorReactVersions < 19) {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { StyleSheet, UnistylesRuntime, StatusBar, NavigationBar } from './specs'
|
|
10
|
+
export { UnistyleDependency } from './specs'
|
|
10
11
|
export { mq } from './mq'
|
|
11
12
|
export type { UnistylesThemes, UnistylesBreakpoints } from './global'
|
|
12
13
|
export { withUnistyles, useUnistyles, createUnistylesElement } from './core'
|