react-native-unistyles 3.0.23 → 3.1.0
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/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/Equatable.kt +1 -2
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +22 -4
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +18 -5
- 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 +15 -2
- 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 +16 -3
- 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 +33 -14
- 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/README.md +0 -172
- 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
|
@@ -4,24 +4,29 @@ import { keyInObject } from '../../utils'
|
|
|
4
4
|
type Styles = Record<string, any>
|
|
5
5
|
type Normalize<TStyles extends Styles> = (key: keyof TStyles, value: TStyles[keyof TStyles]) => any
|
|
6
6
|
|
|
7
|
-
const createStylesValue = <TStyles extends Styles>(styles: Array<TStyles>, normalize: Normalize<TStyles>) =>
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const createStylesValue = <TStyles extends Styles>(styles: Array<TStyles>, normalize: Normalize<TStyles>) =>
|
|
8
|
+
styles
|
|
9
|
+
.map((style) => {
|
|
10
|
+
const [key] = Object.keys(style)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (!key) {
|
|
13
|
+
return undefined
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return normalize(key, style[key])
|
|
17
|
+
})
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.join(' ')
|
|
19
20
|
|
|
20
|
-
export const getObjectStyle = <TStyles extends Styles>(
|
|
21
|
+
export const getObjectStyle = <TStyles extends Styles>(
|
|
22
|
+
styles: Array<TStyles>,
|
|
23
|
+
styleKey: string,
|
|
24
|
+
normalize: Normalize<TStyles>,
|
|
25
|
+
) => {
|
|
21
26
|
const breakpoints = new Set<string>()
|
|
22
27
|
const normalStyles: Array<TStyles> = []
|
|
23
28
|
|
|
24
|
-
styles.forEach(style => {
|
|
29
|
+
styles.forEach((style) => {
|
|
25
30
|
const [property] = Object.keys(style)
|
|
26
31
|
|
|
27
32
|
if (!property) {
|
|
@@ -31,7 +36,7 @@ export const getObjectStyle = <TStyles extends Styles>(styles: Array<TStyles>, s
|
|
|
31
36
|
const value = style[property]
|
|
32
37
|
|
|
33
38
|
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
34
|
-
Object.keys(value ?? {}).forEach(breakpoint => breakpoints.add(breakpoint))
|
|
39
|
+
Object.keys(value ?? {}).forEach((breakpoint) => breakpoints.add(breakpoint))
|
|
35
40
|
|
|
36
41
|
return
|
|
37
42
|
}
|
|
@@ -39,8 +44,8 @@ export const getObjectStyle = <TStyles extends Styles>(styles: Array<TStyles>, s
|
|
|
39
44
|
normalStyles.push(style)
|
|
40
45
|
})
|
|
41
46
|
|
|
42
|
-
const breakpointStyles = Array.from(breakpoints).flatMap(breakpoint => {
|
|
43
|
-
const stylesPerBreakpoint = styles.flatMap(style => {
|
|
47
|
+
const breakpointStyles = Array.from(breakpoints).flatMap((breakpoint) => {
|
|
48
|
+
const stylesPerBreakpoint = styles.flatMap((style) => {
|
|
44
49
|
const [property] = Object.keys(style)
|
|
45
50
|
|
|
46
51
|
if (!property) {
|
|
@@ -56,14 +61,19 @@ export const getObjectStyle = <TStyles extends Styles>(styles: Array<TStyles>, s
|
|
|
56
61
|
return []
|
|
57
62
|
}) as Array<TStyles>
|
|
58
63
|
|
|
59
|
-
return [
|
|
60
|
-
|
|
61
|
-
[
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
[breakpoint]: {
|
|
67
|
+
[styleKey]: createStylesValue(stylesPerBreakpoint, normalize),
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
]
|
|
64
71
|
})
|
|
65
72
|
|
|
66
|
-
return deepMergeObjects<Record<string, any>>(
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
return deepMergeObjects<Record<string, any>>(
|
|
74
|
+
{
|
|
75
|
+
[styleKey]: createStylesValue(normalStyles, normalize),
|
|
76
|
+
},
|
|
77
|
+
...breakpointStyles,
|
|
78
|
+
)
|
|
69
79
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TransformStyles } from '../../../types/core'
|
|
2
|
+
|
|
2
3
|
import { normalizeNumericValue } from '../utils'
|
|
3
4
|
import { getObjectStyle } from './objectStyle'
|
|
4
5
|
|
|
@@ -14,11 +15,12 @@ const normalizeTransform = (key: string, value: any) => {
|
|
|
14
15
|
return value
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export const getTransformStyle = (transforms: Array<TransformStyles>) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
18
|
+
export const getTransformStyle = (transforms: Array<TransformStyles>) =>
|
|
19
|
+
getObjectStyle(transforms, 'transform', (key, value) => {
|
|
20
|
+
switch (key) {
|
|
21
|
+
case 'matrix':
|
|
22
|
+
return `${key}(${(value as Array<number>).join(',')})`
|
|
23
|
+
default:
|
|
24
|
+
return `${key}(${normalizeTransform(key, value)})`
|
|
25
|
+
}
|
|
26
|
+
})
|
|
@@ -101,8 +101,8 @@ type AddDynamicSelector<T extends string> = T extends `${infer U}(` ? `${U}(${st
|
|
|
101
101
|
|
|
102
102
|
export type Pseudo = AddDynamicSelector<(typeof pseudoClasses)[number] | (typeof pseudoElements)[number]>
|
|
103
103
|
|
|
104
|
-
export const isPseudoClass = (selector: string) => pseudoClasses.some(pseudo => selector.startsWith(pseudo))
|
|
104
|
+
export const isPseudoClass = (selector: string) => pseudoClasses.some((pseudo) => selector.startsWith(pseudo))
|
|
105
105
|
|
|
106
|
-
export const isPseudoElement = (selector: string) => pseudoElements.some(pseudo => selector.startsWith(pseudo))
|
|
106
|
+
export const isPseudoElement = (selector: string) => pseudoElements.some((pseudo) => selector.startsWith(pseudo))
|
|
107
107
|
|
|
108
108
|
export const isPseudo = (selector: string) => isPseudoClass(selector) || isPseudoElement(selector)
|
|
@@ -19,12 +19,12 @@ export const getBoxShadowStyle = (styles: Record<string, any>) => {
|
|
|
19
19
|
// If no breakpoints were used return styles without media queries
|
|
20
20
|
if (breakpoints.length === 0) {
|
|
21
21
|
return {
|
|
22
|
-
boxShadow: createBoxShadowValue(styles as BoxShadow)
|
|
22
|
+
boxShadow: createBoxShadowValue(styles as BoxShadow),
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Create boxShadow for each breakpoint
|
|
27
|
-
const breakpointStyles = breakpoints.map(breakpoint => {
|
|
27
|
+
const breakpointStyles = breakpoints.map((breakpoint) => {
|
|
28
28
|
const color = extractShadowValue('shadowColor', breakpoint, styles)
|
|
29
29
|
const { width, height } = extractShadowValue('shadowOffset', breakpoint, styles)
|
|
30
30
|
const radius = extractShadowValue('shadowRadius', breakpoint, styles)
|
|
@@ -36,12 +36,12 @@ export const getBoxShadowStyle = (styles: Record<string, any>) => {
|
|
|
36
36
|
shadowColor: color,
|
|
37
37
|
shadowOffset: {
|
|
38
38
|
width,
|
|
39
|
-
height
|
|
39
|
+
height,
|
|
40
40
|
},
|
|
41
41
|
shadowRadius: radius,
|
|
42
|
-
shadowOpacity: opacity
|
|
43
|
-
})
|
|
44
|
-
}
|
|
42
|
+
shadowOpacity: opacity,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
45
|
}
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -3,7 +3,7 @@ import type { ShadowOffset } from '../types'
|
|
|
3
3
|
export const getShadowBreakpoints = (shadowProperties: ReadonlyArray<string>, styles: Record<string, any>) => {
|
|
4
4
|
const breakpoints = new Set<string>()
|
|
5
5
|
|
|
6
|
-
shadowProperties.forEach(key => {
|
|
6
|
+
shadowProperties.forEach((key) => {
|
|
7
7
|
const value = styles[key]
|
|
8
8
|
|
|
9
9
|
if (typeof value !== 'object') {
|
|
@@ -15,19 +15,19 @@ export const getShadowBreakpoints = (shadowProperties: ReadonlyArray<string>, st
|
|
|
15
15
|
|
|
16
16
|
// If shadowOffset.width has breakpoints
|
|
17
17
|
if (typeof width === 'object') {
|
|
18
|
-
Object.keys(width).forEach(breakpoint => breakpoints.add(breakpoint))
|
|
18
|
+
Object.keys(width).forEach((breakpoint) => breakpoints.add(breakpoint))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// If shadowOffset.height has breakpoints
|
|
22
22
|
if (typeof height === 'object') {
|
|
23
|
-
Object.keys(height).forEach(breakpoint => breakpoints.add(breakpoint))
|
|
23
|
+
Object.keys(height).forEach((breakpoint) => breakpoints.add(breakpoint))
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
return
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// Collect regular breakpoints
|
|
30
|
-
Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint))
|
|
30
|
+
Object.keys(value).forEach((breakpoint) => breakpoints.add(breakpoint))
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
return Array.from(breakpoints)
|
|
@@ -19,12 +19,12 @@ export const getTextShadowStyle = (styles: Record<string, any>) => {
|
|
|
19
19
|
// If no breakpoints were used return styles without media queries
|
|
20
20
|
if (breakpoints.length === 0) {
|
|
21
21
|
return {
|
|
22
|
-
textShadow: createTextShadowValue(styles as TextShadow)
|
|
22
|
+
textShadow: createTextShadowValue(styles as TextShadow),
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Create textShadow for each breakpoint
|
|
27
|
-
const breakpointStyles = breakpoints.map(breakpoint => {
|
|
27
|
+
const breakpointStyles = breakpoints.map((breakpoint) => {
|
|
28
28
|
const color = extractShadowValue('textShadowColor', breakpoint, styles)
|
|
29
29
|
const { width, height } = extractShadowValue('textShadowOffset', breakpoint, styles)
|
|
30
30
|
const radius = extractShadowValue('textShadowRadius', breakpoint, styles)
|
|
@@ -35,11 +35,11 @@ export const getTextShadowStyle = (styles: Record<string, any>) => {
|
|
|
35
35
|
textShadowColor: color,
|
|
36
36
|
textShadowOffset: {
|
|
37
37
|
width,
|
|
38
|
-
height
|
|
38
|
+
height,
|
|
39
39
|
},
|
|
40
|
-
textShadowRadius: radius
|
|
41
|
-
})
|
|
42
|
-
}
|
|
40
|
+
textShadowRadius: radius,
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
45
|
|
package/src/web/convert/style.ts
CHANGED
|
@@ -6,7 +6,7 @@ const SKIP_STYLES = new Set([
|
|
|
6
6
|
'textAlignVertical',
|
|
7
7
|
'includeFontPadding',
|
|
8
8
|
'overlayColor',
|
|
9
|
-
'tintColor'
|
|
9
|
+
'tintColor',
|
|
10
10
|
])
|
|
11
11
|
|
|
12
12
|
const CSS_NUMBER_KEYS = new Set([
|
|
@@ -54,73 +54,73 @@ const CSS_NUMBER_KEYS = new Set([
|
|
|
54
54
|
'strokeMiterlimit',
|
|
55
55
|
'strokeOpacity',
|
|
56
56
|
'strokeWidth',
|
|
57
|
-
'aspectRatio'
|
|
57
|
+
'aspectRatio',
|
|
58
58
|
])
|
|
59
59
|
|
|
60
60
|
const convertMap = {
|
|
61
61
|
marginHorizontal: (value: number) => ({
|
|
62
|
-
marginInline: value
|
|
62
|
+
marginInline: value,
|
|
63
63
|
}),
|
|
64
64
|
marginVertical: (value: number) => ({
|
|
65
|
-
marginBlock: value
|
|
65
|
+
marginBlock: value,
|
|
66
66
|
}),
|
|
67
67
|
paddingHorizontal: (value: number) => ({
|
|
68
|
-
paddingInline: value
|
|
68
|
+
paddingInline: value,
|
|
69
69
|
}),
|
|
70
70
|
paddingVertical: (value: number) => ({
|
|
71
|
-
paddingBlock: value
|
|
71
|
+
paddingBlock: value,
|
|
72
72
|
}),
|
|
73
73
|
writingDirection: (value: string) => ({
|
|
74
|
-
direction: value
|
|
74
|
+
direction: value,
|
|
75
75
|
}),
|
|
76
76
|
borderBottomEndRadius: (value: number) => ({
|
|
77
|
-
borderBottomRightRadius: value
|
|
77
|
+
borderBottomRightRadius: value,
|
|
78
78
|
}),
|
|
79
79
|
borderBottomStartRadius: (value: number) => ({
|
|
80
|
-
borderBottomLeftRadius: value
|
|
80
|
+
borderBottomLeftRadius: value,
|
|
81
81
|
}),
|
|
82
82
|
borderEndColor: (value: string) => ({
|
|
83
|
-
borderInlineEndColor: value
|
|
83
|
+
borderInlineEndColor: value,
|
|
84
84
|
}),
|
|
85
85
|
borderStartColor: (value: string) => ({
|
|
86
|
-
borderInlineStartColor: value
|
|
86
|
+
borderInlineStartColor: value,
|
|
87
87
|
}),
|
|
88
88
|
borderTopEndRadius: (value: number) => ({
|
|
89
|
-
borderTopRightRadius: value
|
|
89
|
+
borderTopRightRadius: value,
|
|
90
90
|
}),
|
|
91
91
|
borderTopStartRadius: (value: number) => ({
|
|
92
|
-
borderTopLeftRadius: value
|
|
92
|
+
borderTopLeftRadius: value,
|
|
93
93
|
}),
|
|
94
94
|
borderEndWidth: (value: number) => ({
|
|
95
|
-
borderInlineEndWidth: value
|
|
95
|
+
borderInlineEndWidth: value,
|
|
96
96
|
}),
|
|
97
97
|
borderStartWidth: (value: number) => ({
|
|
98
|
-
borderInlineStartWidth: value
|
|
98
|
+
borderInlineStartWidth: value,
|
|
99
99
|
}),
|
|
100
100
|
end: (value: number) => ({
|
|
101
|
-
right: value
|
|
101
|
+
right: value,
|
|
102
102
|
}),
|
|
103
103
|
start: (value: number) => ({
|
|
104
|
-
left: value
|
|
104
|
+
left: value,
|
|
105
105
|
}),
|
|
106
106
|
marginEnd: (value: number) => ({
|
|
107
|
-
marginRight: value
|
|
107
|
+
marginRight: value,
|
|
108
108
|
}),
|
|
109
109
|
marginStart: (value: number) => ({
|
|
110
|
-
marginLeft: value
|
|
110
|
+
marginLeft: value,
|
|
111
111
|
}),
|
|
112
112
|
paddingEnd: (value: number) => ({
|
|
113
|
-
paddingRight: value
|
|
113
|
+
paddingRight: value,
|
|
114
114
|
}),
|
|
115
115
|
paddingStart: (value: number) => ({
|
|
116
|
-
paddingLeft: value
|
|
116
|
+
paddingLeft: value,
|
|
117
117
|
}),
|
|
118
118
|
transformMatrix: (value: Array<number>) => ({
|
|
119
|
-
transform: `matrix(${value.join(', ')})
|
|
119
|
+
transform: `matrix(${value.join(', ')})`,
|
|
120
120
|
}),
|
|
121
121
|
resizeMode: (value: string) => ({
|
|
122
|
-
backgroundSize: value
|
|
123
|
-
})
|
|
122
|
+
backgroundSize: value,
|
|
123
|
+
}),
|
|
124
124
|
} as Record<PropertyKey, (value: any) => Record<string, any>>
|
|
125
125
|
|
|
126
126
|
const convertNumber = (key: string, value: any) => {
|
|
@@ -141,6 +141,6 @@ export const getStyle = (key: string, value: any) => {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
return {
|
|
144
|
-
[key]: convertNumber(key, value)
|
|
144
|
+
[key]: convertNumber(key, value),
|
|
145
145
|
}
|
|
146
146
|
}
|
package/src/web/convert/types.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { FilterFunction, TextStyle, ViewStyle } from 'react-native'
|
|
2
|
+
|
|
2
3
|
import type { UnionToIntersection } from '../../types'
|
|
3
4
|
import type { ToDeepUnistyles } from '../../types/stylesheet'
|
|
4
5
|
|
|
5
|
-
export type ShadowOffset = ToDeepUnistyles<{ width: number
|
|
6
|
+
export type ShadowOffset = ToDeepUnistyles<{ width: number; height: number }>
|
|
6
7
|
|
|
7
8
|
export const TEXT_SHADOW_STYLES = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'] as const
|
|
8
9
|
|
|
9
|
-
export type TextShadow = Required<Pick<TextStyle, typeof TEXT_SHADOW_STYLES[number]>>
|
|
10
|
+
export type TextShadow = Required<Pick<TextStyle, (typeof TEXT_SHADOW_STYLES)[number]>>
|
|
10
11
|
|
|
11
12
|
export const BOX_SHADOW_STYLES = ['shadowColor', 'shadowRadius', 'shadowOpacity', 'shadowOffset'] as const
|
|
12
13
|
|
|
13
|
-
export type BoxShadow = Required<Pick<ViewStyle, typeof BOX_SHADOW_STYLES[number]>>
|
|
14
|
+
export type BoxShadow = Required<Pick<ViewStyle, (typeof BOX_SHADOW_STYLES)[number]>>
|
|
14
15
|
|
|
15
16
|
export type AllShadow = TextShadow & BoxShadow
|
|
16
17
|
|
package/src/web/convert/utils.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
+
import type { BoxShadowValue } from 'react-native'
|
|
2
|
+
|
|
1
3
|
// based on react-native-web normalizer
|
|
2
4
|
// https://github.com/necolas/react-native-web
|
|
3
5
|
/// <reference path="module.d.ts" />
|
|
4
6
|
import normalizeColors from '@react-native/normalize-colors'
|
|
5
|
-
|
|
7
|
+
|
|
6
8
|
import type { TransformStyles } from '../../types/core'
|
|
9
|
+
|
|
7
10
|
import { type AllShadow, type AllShadowKeys, BOX_SHADOW_STYLES, type Filters, TEXT_SHADOW_STYLES } from './types'
|
|
8
11
|
|
|
9
|
-
export const isTransform = (key: string, value: any): value is Array<TransformStyles> =>
|
|
12
|
+
export const isTransform = (key: string, value: any): value is Array<TransformStyles> =>
|
|
13
|
+
key === 'transform' && Array.isArray(value)
|
|
10
14
|
|
|
11
|
-
export const isTextShadow = (key: string) => TEXT_SHADOW_STYLES.includes(key as typeof TEXT_SHADOW_STYLES[number])
|
|
15
|
+
export const isTextShadow = (key: string) => TEXT_SHADOW_STYLES.includes(key as (typeof TEXT_SHADOW_STYLES)[number])
|
|
12
16
|
|
|
13
|
-
export const isShadow = (key: string) => BOX_SHADOW_STYLES.includes(key as typeof BOX_SHADOW_STYLES[number])
|
|
17
|
+
export const isShadow = (key: string) => BOX_SHADOW_STYLES.includes(key as (typeof BOX_SHADOW_STYLES)[number])
|
|
14
18
|
|
|
15
19
|
export const isFilter = (key: string, value: any): value is Array<Filters> => key === 'filter' && Array.isArray(value)
|
|
16
20
|
|
|
17
|
-
export const isBoxShadow = (key: string, value: any): value is Array<BoxShadowValue> =>
|
|
21
|
+
export const isBoxShadow = (key: string, value: any): value is Array<BoxShadowValue> =>
|
|
22
|
+
key === 'boxShadow' && Array.isArray(value)
|
|
18
23
|
|
|
19
|
-
export const normalizeNumericValue = (value: number | string) =>
|
|
24
|
+
export const normalizeNumericValue = (value: number | string) =>
|
|
25
|
+
value && typeof value === 'number' ? `${value}px` : value
|
|
20
26
|
|
|
21
27
|
export const normalizeColor = (color: string, opacity = 1) => {
|
|
22
28
|
// If the opacity is 1 there's no need to normalize the color
|
|
@@ -36,8 +42,8 @@ export const normalizeColor = (color: string, opacity = 1) => {
|
|
|
36
42
|
if (hex.length === 8) {
|
|
37
43
|
const [r = 0, g = 0, b = 0, a = 1] = hex
|
|
38
44
|
.split(/(?=(?:..)*$)/)
|
|
39
|
-
.map(x => Number.parseInt(x, 16))
|
|
40
|
-
.filter(num => !Number.isNaN(num))
|
|
45
|
+
.map((x) => Number.parseInt(x, 16))
|
|
46
|
+
.filter((num) => !Number.isNaN(num))
|
|
41
47
|
|
|
42
48
|
return `rgba(${r},${g},${b},${(a / 255) * opacity})`
|
|
43
49
|
}
|
|
@@ -45,7 +51,11 @@ export const normalizeColor = (color: string, opacity = 1) => {
|
|
|
45
51
|
return color
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
export const extractShadowValue = <TKey extends AllShadowKeys>(
|
|
54
|
+
export const extractShadowValue = <TKey extends AllShadowKeys>(
|
|
55
|
+
key: TKey,
|
|
56
|
+
breakpoint: string,
|
|
57
|
+
styles: any,
|
|
58
|
+
): AllShadow[TKey] => {
|
|
49
59
|
const value = styles[key]
|
|
50
60
|
|
|
51
61
|
if (key === 'textShadowOffset' || key === 'shadowOffset') {
|
|
@@ -53,7 +63,7 @@ export const extractShadowValue = <TKey extends AllShadowKeys>(key: TKey, breakp
|
|
|
53
63
|
|
|
54
64
|
return {
|
|
55
65
|
width: typeof width === 'object' ? width[breakpoint] : width,
|
|
56
|
-
height: typeof height === 'object' ? height[breakpoint] : height
|
|
66
|
+
height: typeof height === 'object' ? height[breakpoint] : height,
|
|
57
67
|
} as AllShadow[TKey]
|
|
58
68
|
}
|
|
59
69
|
|
package/src/web/create.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet'
|
|
2
|
+
|
|
2
3
|
import * as unistyles from './services'
|
|
3
|
-
import { assignSecrets,
|
|
4
|
+
import { assignSecrets, isServer, removeInlineStyles } from './utils'
|
|
4
5
|
|
|
5
6
|
type Variants = Record<string, string | boolean | undefined>
|
|
6
7
|
|
|
7
|
-
export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet
|
|
8
|
-
if (!id) {
|
|
9
|
-
throw error('Unistyles is not initialized correctly. Please add babel plugin to your babel config.')
|
|
10
|
-
}
|
|
11
|
-
|
|
8
|
+
export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => {
|
|
12
9
|
// For SSR
|
|
13
10
|
if (!unistyles.services.state.isInitialized && !isServer()) {
|
|
14
11
|
const config = window?.__UNISTYLES_STATE__?.config
|
|
@@ -17,21 +14,30 @@ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, id?: s
|
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
const computedStylesheet = unistyles.services.registry.getComputedStylesheet(stylesheet)
|
|
20
|
-
const addSecrets = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const addSecrets = (
|
|
18
|
+
value: any,
|
|
19
|
+
key: string,
|
|
20
|
+
args = undefined as Array<any> | undefined,
|
|
21
|
+
variants = {} as Variants,
|
|
22
|
+
) =>
|
|
23
|
+
assignSecrets(value, {
|
|
24
|
+
__uni__key: key,
|
|
25
|
+
__uni__stylesheet: stylesheet,
|
|
26
|
+
__uni__args: args,
|
|
27
|
+
__stylesheetVariants: variants,
|
|
28
|
+
})
|
|
26
29
|
|
|
27
30
|
const createStyleSheetStyles = (variants?: Variants) => {
|
|
28
31
|
const stylesEntries = Object.entries(computedStylesheet).map(([key, value]) => {
|
|
29
32
|
if (typeof value === 'function') {
|
|
30
|
-
return [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
return [
|
|
34
|
+
key,
|
|
35
|
+
(...args: Array<any>) => {
|
|
36
|
+
const result = removeInlineStyles(value(...args))
|
|
37
|
+
|
|
38
|
+
return addSecrets(result, key, args, variants)
|
|
39
|
+
},
|
|
40
|
+
]
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
return [key, addSecrets(removeInlineStyles(value), key, undefined, variants)]
|
|
@@ -40,9 +46,12 @@ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, id?: s
|
|
|
40
46
|
return Object.fromEntries(stylesEntries.concat([useVariants]))
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
const useVariants = [
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const useVariants = [
|
|
50
|
+
'useVariants',
|
|
51
|
+
(variants: Variants) => {
|
|
52
|
+
return createStyleSheetStyles(variants)
|
|
53
|
+
},
|
|
54
|
+
]
|
|
46
55
|
|
|
47
56
|
return createStyleSheetStyles()
|
|
48
57
|
}
|
package/src/web/css/core.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { CSSState } from './state'
|
|
2
|
+
|
|
1
3
|
import { isPseudoClass } from '../convert/pseudo'
|
|
2
4
|
import { getMediaQuery } from '../utils'
|
|
3
|
-
import type { CSSState } from './state'
|
|
4
5
|
|
|
5
6
|
export const convertToCSS = (hash: string, value: Record<string, any>, state: CSSState) => {
|
|
6
7
|
Object.entries(value).forEach(([styleKey, styleValue]) => {
|
package/src/web/css/state.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { UnistylesValues } from '../../types'
|
|
2
|
-
import { convertUnistyles } from '../convert'
|
|
3
2
|
import type { UnistylesServices } from '../types'
|
|
3
|
+
|
|
4
|
+
import { convertUnistyles } from '../convert'
|
|
4
5
|
import { hyphenate, isServer } from '../utils'
|
|
5
6
|
import { convertToCSS } from './core'
|
|
6
7
|
|
|
@@ -12,7 +13,7 @@ type SetProps = {
|
|
|
12
13
|
propertyKey: string
|
|
13
14
|
value: any
|
|
14
15
|
}
|
|
15
|
-
type HydrateState = Array<[
|
|
16
|
+
type HydrateState = Array<[string, Array<[string, Array<[string, any]>]>]>
|
|
16
17
|
|
|
17
18
|
const safeGetMap = (map: Map<string, Map<string, any>>, key: string) => {
|
|
18
19
|
const nextLevelMap = map.get(key)
|
|
@@ -76,7 +77,9 @@ export class CSSState {
|
|
|
76
77
|
|
|
77
78
|
const convertToCSS = (key: string, value: any, prev = '-') => {
|
|
78
79
|
if (typeof value === 'object' && value !== null) {
|
|
79
|
-
Object.entries(value).forEach(([nestedKey, nestedValue]) =>
|
|
80
|
+
Object.entries(value).forEach(([nestedKey, nestedValue]) =>
|
|
81
|
+
convertToCSS(nestedKey, nestedValue, `${prev}-${key}`),
|
|
82
|
+
)
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
if (typeof value === 'string') {
|
|
@@ -94,10 +97,10 @@ export class CSSState {
|
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
remove = (hash: string) => {
|
|
97
|
-
this.mainMap.forEach(styles => {
|
|
100
|
+
this.mainMap.forEach((styles) => {
|
|
98
101
|
styles.delete(hash)
|
|
99
102
|
})
|
|
100
|
-
this.mqMap.forEach(styles => {
|
|
103
|
+
this.mqMap.forEach((styles) => {
|
|
101
104
|
styles.delete(hash)
|
|
102
105
|
})
|
|
103
106
|
this.recreate()
|
|
@@ -153,9 +156,9 @@ export class CSSState {
|
|
|
153
156
|
className,
|
|
154
157
|
Array.from(style.entries()).map(([property, value]) => {
|
|
155
158
|
return [property, value]
|
|
156
|
-
})
|
|
159
|
+
}),
|
|
157
160
|
]
|
|
158
|
-
})
|
|
161
|
+
}),
|
|
159
162
|
]
|
|
160
163
|
}) as HydrateState
|
|
161
164
|
}
|
|
@@ -177,7 +180,7 @@ export class CSSState {
|
|
|
177
180
|
propertyKey,
|
|
178
181
|
value,
|
|
179
182
|
mediaQuery,
|
|
180
|
-
isMq
|
|
183
|
+
isMq,
|
|
181
184
|
})
|
|
182
185
|
})
|
|
183
186
|
})
|
package/src/web/css/utils.ts
CHANGED
package/src/web/index.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { StyleSheet as RNStyleSheet } from 'react-native'
|
|
2
|
+
|
|
2
3
|
import type { UnistylesShadowRegistry as NativeUnistylesShadowRegistry } from '../specs/ShadowRegistry'
|
|
3
4
|
import type { StyleSheet as NativeStyleSheet } from '../specs/StyleSheet'
|
|
4
5
|
import type { Runtime as NativeUnistylesRuntime } from '../specs/UnistylesRuntime'
|
|
6
|
+
|
|
5
7
|
import { create } from './create'
|
|
6
8
|
import * as unistyles from './services'
|
|
7
9
|
|
|
8
10
|
export const StyleSheet = {
|
|
9
11
|
configure: unistyles.services.state.init,
|
|
10
12
|
create: create,
|
|
13
|
+
addChangeListener: unistyles.services.listener.addChangeListener,
|
|
11
14
|
absoluteFill: {
|
|
12
15
|
position: 'absolute',
|
|
13
16
|
left: 0,
|
|
@@ -20,15 +23,15 @@ export const StyleSheet = {
|
|
|
20
23
|
left: 0,
|
|
21
24
|
top: 0,
|
|
22
25
|
right: 0,
|
|
23
|
-
bottom: 0
|
|
26
|
+
bottom: 0,
|
|
24
27
|
},
|
|
25
28
|
compose: (a: object, b: object) => RNStyleSheet.compose(a, b),
|
|
26
29
|
flatten: (...styles: Array<object>) => RNStyleSheet.flatten(...styles),
|
|
27
|
-
hairlineWidth: 1
|
|
30
|
+
hairlineWidth: 1,
|
|
28
31
|
} as unknown as typeof NativeStyleSheet
|
|
29
32
|
|
|
30
33
|
export const UnistylesRuntime = unistyles.services.runtime as unknown as typeof NativeUnistylesRuntime
|
|
31
|
-
export const UnistylesShadowRegistry = unistyles.services
|
|
34
|
+
export const UnistylesShadowRegistry = unistyles.services
|
|
35
|
+
.shadowRegistry as unknown as typeof NativeUnistylesShadowRegistry
|
|
32
36
|
|
|
33
37
|
export * from './mock'
|
|
34
|
-
|