react-native-unistyles 3.0.0-beta.1 → 3.0.0-beta.2
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 +4 -4
- package/Unistyles.podspec +7 -1
- package/android/build.gradle +6 -0
- package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -2
- package/cxx/common/Constants.h +2 -0
- package/cxx/core/HostStyle.cpp +12 -7
- package/cxx/core/HostStyle.h +5 -0
- package/cxx/core/UnistyleData.h +3 -3
- package/cxx/core/UnistyleWrapper.h +8 -8
- package/cxx/core/UnistylesRegistry.cpp +23 -30
- package/cxx/core/UnistylesRegistry.h +8 -2
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +108 -12
- package/cxx/hybridObjects/HybridShadowRegistry.h +21 -2
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -0
- package/cxx/parser/Parser.cpp +182 -26
- package/cxx/parser/Parser.h +3 -1
- package/ios/UnistylesModuleOnLoad.mm +2 -2
- package/lib/commonjs/components/ScopedTheme.js +36 -0
- package/lib/commonjs/components/ScopedTheme.js.map +1 -0
- package/lib/commonjs/components/Variants.js +33 -0
- package/lib/commonjs/components/Variants.js.map +1 -0
- package/lib/commonjs/components/index.js +10 -3
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/native/ActivityIndicator.js +10 -0
- package/lib/commonjs/components/native/ActivityIndicator.js.map +1 -0
- package/lib/commonjs/components/native/FlatList.js +10 -0
- package/lib/commonjs/components/native/FlatList.js.map +1 -0
- package/lib/commonjs/components/native/Image.js +10 -0
- package/lib/commonjs/components/native/Image.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +10 -0
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -0
- package/lib/commonjs/components/native/KeyboardAvoidingView.js +10 -0
- package/lib/commonjs/components/native/KeyboardAvoidingView.js.map +1 -0
- package/lib/commonjs/components/{Pressable.web.js → native/Pressable.js} +26 -66
- package/lib/commonjs/components/native/Pressable.js.map +1 -0
- package/lib/commonjs/components/native/Pressable.native.js +48 -0
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -0
- package/lib/commonjs/components/native/RefreshControl.js +10 -0
- package/lib/commonjs/components/native/RefreshControl.js.map +1 -0
- package/lib/commonjs/components/native/ScrollView.js +10 -0
- package/lib/commonjs/components/native/ScrollView.js.map +1 -0
- package/lib/commonjs/components/native/SectionList.js +10 -0
- package/lib/commonjs/components/native/SectionList.js.map +1 -0
- package/lib/commonjs/components/native/Switch.js +10 -0
- package/lib/commonjs/components/native/Switch.js.map +1 -0
- package/lib/commonjs/components/native/Text.js +10 -0
- package/lib/commonjs/components/native/Text.js.map +1 -0
- package/lib/commonjs/components/native/TextInput.js +10 -0
- package/lib/commonjs/components/native/TextInput.js.map +1 -0
- package/lib/commonjs/components/native/TouchableHighlight.js +10 -0
- package/lib/commonjs/components/native/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/native/TouchableOpacity.js +10 -0
- package/lib/commonjs/components/native/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/native/View.js +10 -0
- package/lib/commonjs/components/native/View.js.map +1 -0
- package/lib/commonjs/components/native/VirtualizedList.js +10 -0
- package/lib/commonjs/components/native/VirtualizedList.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +5 -68
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +16 -0
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js +27 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -0
- package/lib/commonjs/core/index.js +20 -6
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/passForwardRef.js +27 -0
- package/lib/commonjs/core/passForwardRef.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/index.js +13 -0
- package/lib/commonjs/core/withUnistyles/index.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/types.js +8 -0
- package/lib/commonjs/core/withUnistyles/types.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/useDependencies.js +81 -0
- package/lib/commonjs/core/withUnistyles/useDependencies.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +88 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +96 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -0
- package/lib/commonjs/hooks/useMedia.js +17 -33
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +60 -0
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -0
- package/lib/commonjs/index.js +33 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +3 -3
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/index.js +14 -40
- package/lib/commonjs/specs/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +54 -0
- package/lib/commonjs/specs/index.native.js.map +1 -0
- package/lib/commonjs/web/create.js +12 -33
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +10 -3
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +3 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +71 -64
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +3 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/ScopedTheme.js +29 -0
- package/lib/module/components/ScopedTheme.js.map +1 -0
- package/lib/module/components/Variants.js +26 -0
- package/lib/module/components/Variants.js.map +1 -0
- package/lib/module/components/index.js +2 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/native/ActivityIndicator.js +6 -0
- package/lib/module/components/native/ActivityIndicator.js.map +1 -0
- package/lib/module/components/native/FlatList.js +6 -0
- package/lib/module/components/native/FlatList.js.map +1 -0
- package/lib/module/components/native/Image.js +6 -0
- package/lib/module/components/native/Image.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +6 -0
- package/lib/module/components/native/ImageBackground.js.map +1 -0
- package/lib/module/components/native/KeyboardAvoidingView.js +6 -0
- package/lib/module/components/native/KeyboardAvoidingView.js.map +1 -0
- package/lib/module/components/native/Pressable.js +69 -0
- package/lib/module/components/native/Pressable.js.map +1 -0
- package/lib/module/components/native/Pressable.native.js +42 -0
- package/lib/module/components/native/Pressable.native.js.map +1 -0
- package/lib/module/components/native/RefreshControl.js +6 -0
- package/lib/module/components/native/RefreshControl.js.map +1 -0
- package/lib/module/components/native/ScrollView.js +6 -0
- package/lib/module/components/native/ScrollView.js.map +1 -0
- package/lib/module/components/native/SectionList.js +6 -0
- package/lib/module/components/native/SectionList.js.map +1 -0
- package/lib/module/components/native/Switch.js +6 -0
- package/lib/module/components/native/Switch.js.map +1 -0
- package/lib/module/components/native/Text.js +6 -0
- package/lib/module/components/native/Text.js.map +1 -0
- package/lib/module/components/native/TextInput.js +6 -0
- package/lib/module/components/native/TextInput.js.map +1 -0
- package/lib/module/components/native/TouchableHighlight.js +6 -0
- package/lib/module/components/native/TouchableHighlight.js.map +1 -0
- package/lib/module/components/native/TouchableOpacity.js +6 -0
- package/lib/module/components/native/TouchableOpacity.js.map +1 -0
- package/lib/module/components/native/View.js +6 -0
- package/lib/module/components/native/View.js.map +1 -0
- package/lib/module/components/native/VirtualizedList.js +6 -0
- package/lib/module/components/native/VirtualizedList.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +5 -66
- package/lib/module/core/createUnistylesComponent.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +10 -0
- package/lib/module/core/createUnistylesElement.js.map +1 -0
- package/lib/module/core/createUnistylesImageBackground.js +21 -0
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -0
- package/lib/module/core/index.js +4 -2
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/passForwardRef.js +22 -0
- package/lib/module/core/passForwardRef.js.map +1 -0
- package/lib/module/core/withUnistyles/index.js +4 -0
- package/lib/module/core/withUnistyles/index.js.map +1 -0
- package/lib/module/core/withUnistyles/types.js +4 -0
- package/lib/module/core/withUnistyles/types.js.map +1 -0
- package/lib/module/core/withUnistyles/useDependencies.js +75 -0
- package/lib/module/core/withUnistyles/useDependencies.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.js +81 -0
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js +89 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -0
- package/lib/module/hooks/useMedia.js +19 -35
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +55 -0
- package/lib/module/hooks/useMedia.native.js.map +1 -0
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +3 -3
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/index.js +2 -8
- package/lib/module/specs/index.js.map +1 -1
- package/lib/module/specs/index.native.js +11 -0
- package/lib/module/specs/index.native.js.map +1 -0
- package/lib/module/web/create.js +13 -34
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/index.js +1 -1
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/registry.js +11 -4
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +3 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +70 -63
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +1 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/ScopedTheme.d.ts +8 -0
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/Variants.d.ts +7 -0
- package/lib/typescript/src/components/Variants.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +2 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts +2 -0
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/native/FlatList.d.ts +2 -0
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Image.d.ts +2 -0
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts +3 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -0
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +2 -0
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -0
- package/lib/typescript/src/components/{Pressable.web.d.ts → native/Pressable.d.ts} +3 -2
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/{Pressable.d.ts → native/Pressable.native.d.ts} +1 -3
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/RefreshControl.d.ts +2 -0
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ScrollView.d.ts +2 -0
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/SectionList.d.ts +2 -0
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Switch.d.ts +2 -0
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Text.d.ts +2 -0
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TextInput.d.ts +2 -0
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts +2 -0
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts +2 -0
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -0
- package/lib/typescript/src/components/native/View.d.ts +2 -0
- package/lib/typescript/src/components/native/View.d.ts.map +1 -0
- package/lib/typescript/src/components/native/VirtualizedList.d.ts +2 -0
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +9 -3
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts +3 -0
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +4 -0
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +4 -2
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts +3 -0
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/index.d.ts +2 -0
- package/lib/typescript/src/core/withUnistyles/index.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/types.d.ts +6 -0
- package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts +13 -0
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +11 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +8 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMedia.d.ts +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts +6 -0
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +7 -2
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +17 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.d.ts +3 -11
- package/lib/typescript/src/specs/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.native.d.ts +12 -0
- package/lib/typescript/src/specs/index.native.d.ts.map +1 -0
- package/lib/typescript/src/web/create.d.ts +1 -1441
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +2 -1441
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +2 -3
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +11 -3
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -2
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +3 -0
- package/package.json +4 -4
- package/plugin/common.js +4 -6
- package/plugin/import.js +63 -26
- package/plugin/index.js +48 -28
- package/plugin/ref.js +0 -234
- package/plugin/style.js +4 -317
- package/plugin/stylesheet.js +25 -10
- package/plugin/variants.js +54 -1
- package/src/components/ScopedTheme.tsx +32 -0
- package/src/components/Variants.tsx +29 -0
- package/src/components/index.ts +2 -1
- package/src/components/native/ActivityIndicator.tsx +4 -0
- package/src/components/native/FlatList.tsx +4 -0
- package/src/components/native/Image.tsx +4 -0
- package/src/components/native/ImageBackground.tsx +4 -0
- package/src/components/native/KeyboardAvoidingView.tsx +4 -0
- package/src/components/native/Pressable.native.tsx +55 -0
- package/src/components/native/Pressable.tsx +98 -0
- package/src/components/native/RefreshControl.tsx +4 -0
- package/src/components/native/ScrollView.tsx +4 -0
- package/src/components/native/SectionList.tsx +4 -0
- package/src/components/native/Switch.tsx +4 -0
- package/src/components/native/Text.tsx +4 -0
- package/src/components/native/TextInput.tsx +4 -0
- package/src/components/native/TouchableHighlight.tsx +4 -0
- package/src/components/native/TouchableOpacity.tsx +4 -0
- package/src/components/native/View.tsx +4 -0
- package/src/components/native/VirtualizedList.tsx +4 -0
- package/src/core/createUnistylesComponent.tsx +6 -76
- package/src/core/createUnistylesElement.tsx +9 -0
- package/src/core/createUnistylesImageBackground.tsx +24 -0
- package/src/core/index.ts +4 -2
- package/src/core/passForwardRef.ts +29 -0
- package/src/core/withUnistyles/index.ts +1 -0
- package/src/core/withUnistyles/types.ts +7 -0
- package/src/core/withUnistyles/useDependencies.ts +93 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +96 -0
- package/src/core/withUnistyles/withUnistyles.tsx +90 -0
- package/src/hooks/useMedia.native.ts +65 -0
- package/src/hooks/useMedia.ts +19 -36
- package/src/index.ts +2 -2
- package/src/specs/ShadowRegistry/index.ts +14 -5
- package/src/specs/ShadowRegistry/types.ts +18 -1
- package/src/specs/index.native.ts +27 -0
- package/src/specs/index.ts +3 -27
- package/src/web/create.ts +14 -32
- package/src/web/index.ts +3 -2
- package/src/web/registry.ts +15 -6
- package/src/web/runtime.ts +3 -1
- package/src/web/shadowRegistry.ts +66 -52
- package/src/web/utils/unistyle.ts +1 -2
- package/lib/commonjs/components/Pressable.js +0 -74
- package/lib/commonjs/components/Pressable.js.map +0 -1
- package/lib/commonjs/components/Pressable.web.js.map +0 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js +0 -82
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +0 -1
- package/lib/commonjs/core/getBoundArgs.js +0 -18
- package/lib/commonjs/core/getBoundArgs.js.map +0 -1
- package/lib/commonjs/core/getId.js +0 -9
- package/lib/commonjs/core/getId.js.map +0 -1
- package/lib/commonjs/hooks/useMedia.web.js +0 -43
- package/lib/commonjs/hooks/useMedia.web.js.map +0 -1
- package/lib/commonjs/specs/index.web.js +0 -17
- package/lib/commonjs/specs/index.web.js.map +0 -1
- package/lib/module/components/Pressable.js +0 -68
- package/lib/module/components/Pressable.js.map +0 -1
- package/lib/module/components/Pressable.web.js +0 -109
- package/lib/module/components/Pressable.web.js.map +0 -1
- package/lib/module/core/createUnistylesComponent.native.js +0 -75
- package/lib/module/core/createUnistylesComponent.native.js.map +0 -1
- package/lib/module/core/getBoundArgs.js +0 -13
- package/lib/module/core/getBoundArgs.js.map +0 -1
- package/lib/module/core/getId.js +0 -4
- package/lib/module/core/getId.js.map +0 -1
- package/lib/module/hooks/useMedia.web.js +0 -38
- package/lib/module/hooks/useMedia.web.js.map +0 -1
- package/lib/module/specs/index.web.js +0 -4
- package/lib/module/specs/index.web.js.map +0 -1
- package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
- package/lib/typescript/src/components/Pressable.web.d.ts.map +0 -1
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +0 -8
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +0 -1
- package/lib/typescript/src/core/getBoundArgs.d.ts +0 -2
- package/lib/typescript/src/core/getBoundArgs.d.ts.map +0 -1
- package/lib/typescript/src/core/getId.d.ts +0 -2
- package/lib/typescript/src/core/getId.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useMedia.web.d.ts +0 -6
- package/lib/typescript/src/hooks/useMedia.web.d.ts.map +0 -1
- package/lib/typescript/src/specs/index.web.d.ts +0 -2
- package/lib/typescript/src/specs/index.web.d.ts.map +0 -1
- package/src/components/Pressable.tsx +0 -89
- package/src/components/Pressable.web.tsx +0 -129
- package/src/core/createUnistylesComponent.native.tsx +0 -83
- package/src/core/getBoundArgs.ts +0 -15
- package/src/core/getId.ts +0 -1
- package/src/hooks/useMedia.web.ts +0 -47
- package/src/specs/index.web.ts +0 -1
@@ -0,0 +1,32 @@
|
|
1
|
+
import React, { useLayoutEffect } from 'react'
|
2
|
+
import type { UnistylesThemes } from '../global'
|
3
|
+
import { UnistylesShadowRegistry } from '../specs'
|
4
|
+
|
5
|
+
type ThemeProps = {
|
6
|
+
name: keyof UnistylesThemes
|
7
|
+
}
|
8
|
+
|
9
|
+
const Apply = ({ name }: { name?: keyof UnistylesThemes }) => {
|
10
|
+
UnistylesShadowRegistry.setScopedTheme(name)
|
11
|
+
|
12
|
+
useLayoutEffect(() => {
|
13
|
+
UnistylesShadowRegistry.setScopedTheme(name)
|
14
|
+
})
|
15
|
+
|
16
|
+
return null
|
17
|
+
}
|
18
|
+
|
19
|
+
export const ScopedTheme: React.FunctionComponent<React.PropsWithChildren<ThemeProps>> = ({ name, children }) => {
|
20
|
+
const previousScopedTheme = UnistylesShadowRegistry.getScopedTheme()
|
21
|
+
const mappedChildren = [
|
22
|
+
<Apply key={name} name={name} />,
|
23
|
+
children,
|
24
|
+
<Apply key='dispose' name={previousScopedTheme} />
|
25
|
+
]
|
26
|
+
|
27
|
+
return (
|
28
|
+
<React.Fragment>
|
29
|
+
{mappedChildren}
|
30
|
+
</React.Fragment>
|
31
|
+
)
|
32
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import React, { useLayoutEffect } from 'react'
|
2
|
+
import { UnistylesShadowRegistry } from '../specs'
|
3
|
+
|
4
|
+
type VariantProps = {
|
5
|
+
variants?: Record<string, string | boolean | undefined>
|
6
|
+
}
|
7
|
+
|
8
|
+
const Apply: React.FunctionComponent<VariantProps> = ({ variants }) => {
|
9
|
+
UnistylesShadowRegistry.selectVariants(variants)
|
10
|
+
|
11
|
+
useLayoutEffect(() => {
|
12
|
+
UnistylesShadowRegistry.selectVariants(variants)
|
13
|
+
})
|
14
|
+
|
15
|
+
return null
|
16
|
+
}
|
17
|
+
export const Variants: React.FunctionComponent<React.PropsWithChildren<VariantProps>> = ({ variants, children }) => {
|
18
|
+
const mappedChildren = [
|
19
|
+
<Apply key='add' variants={variants} />,
|
20
|
+
children,
|
21
|
+
<Apply key='remove' />
|
22
|
+
]
|
23
|
+
|
24
|
+
return (
|
25
|
+
<React.Fragment>
|
26
|
+
{mappedChildren}
|
27
|
+
</React.Fragment>
|
28
|
+
)
|
29
|
+
}
|
package/src/components/index.ts
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
import React, { forwardRef, useRef } from 'react'
|
2
|
+
import { Pressable as NativePressableReactNative } from 'react-native'
|
3
|
+
import type { PressableProps as Props, View } from 'react-native'
|
4
|
+
import { UnistylesShadowRegistry } from '../../specs'
|
5
|
+
import { passForwardedRef } from '../../core'
|
6
|
+
|
7
|
+
type PressableProps = Props & {
|
8
|
+
variants?: Record<string, string | boolean>
|
9
|
+
}
|
10
|
+
|
11
|
+
export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ...props }, forwardedRef) => {
|
12
|
+
const storedRef = useRef<View | null>()
|
13
|
+
|
14
|
+
return (
|
15
|
+
<NativePressableReactNative
|
16
|
+
{...props}
|
17
|
+
ref={ref => {
|
18
|
+
const unistyles = typeof style === 'function'
|
19
|
+
? style({ pressed: false })
|
20
|
+
: style
|
21
|
+
const styles = Array.isArray(unistyles)
|
22
|
+
? unistyles
|
23
|
+
: [unistyles]
|
24
|
+
|
25
|
+
// @ts-expect-error - this is hidden from TS
|
26
|
+
UnistylesShadowRegistry.add(ref, styles)
|
27
|
+
|
28
|
+
storedRef.current = ref
|
29
|
+
|
30
|
+
return passForwardedRef(props, ref, forwardedRef)
|
31
|
+
}}
|
32
|
+
style={state => {
|
33
|
+
UnistylesShadowRegistry.selectVariants(variants)
|
34
|
+
|
35
|
+
const unistyles = typeof style === 'function'
|
36
|
+
? style(state)
|
37
|
+
: style
|
38
|
+
const styles = Array.isArray(unistyles)
|
39
|
+
? unistyles
|
40
|
+
: [unistyles]
|
41
|
+
|
42
|
+
if (storedRef.current) {
|
43
|
+
// @ts-expect-error - this is hidden from TS
|
44
|
+
UnistylesShadowRegistry.remove(storedRef.current)
|
45
|
+
// @ts-expect-error - this is hidden from TS
|
46
|
+
UnistylesShadowRegistry.add(storedRef.current, styles)
|
47
|
+
}
|
48
|
+
|
49
|
+
UnistylesShadowRegistry.selectVariants(undefined)
|
50
|
+
|
51
|
+
return unistyles
|
52
|
+
}}
|
53
|
+
/>
|
54
|
+
)
|
55
|
+
})
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import React, { forwardRef, useRef } from 'react'
|
2
|
+
import { Pressable as NativePressableReactNative } from 'react-native'
|
3
|
+
import type { PressableProps as Props, View, ViewStyle } from 'react-native'
|
4
|
+
import { UnistylesShadowRegistry } from '../../specs'
|
5
|
+
|
6
|
+
type Variants = Record<string, string | boolean | undefined>
|
7
|
+
type WebPressableState = {
|
8
|
+
pressed: boolean,
|
9
|
+
hovered: boolean,
|
10
|
+
focused: boolean
|
11
|
+
}
|
12
|
+
|
13
|
+
type WebPressableStyle = ((state: WebPressableState) => ViewStyle) | ViewStyle
|
14
|
+
|
15
|
+
type PressableProps = Props & {
|
16
|
+
variants?: Variants
|
17
|
+
style?: WebPressableStyle,
|
18
|
+
}
|
19
|
+
|
20
|
+
const initialState: WebPressableState = {
|
21
|
+
pressed: false,
|
22
|
+
hovered: false,
|
23
|
+
focused: false
|
24
|
+
}
|
25
|
+
|
26
|
+
type UpdateStylesProps = {
|
27
|
+
ref: View | null,
|
28
|
+
style: WebPressableStyle,
|
29
|
+
variants?: Variants,
|
30
|
+
state: WebPressableState
|
31
|
+
scopedTheme?: string
|
32
|
+
}
|
33
|
+
|
34
|
+
const extractStyleResult = (style: any) => {
|
35
|
+
return typeof style === 'function'
|
36
|
+
? [style()]
|
37
|
+
: Array.isArray(style)
|
38
|
+
? style.map(style => typeof style === 'function' ? style() : style)
|
39
|
+
: [style]
|
40
|
+
}
|
41
|
+
|
42
|
+
const updateStyles = ({ ref, style, state, scopedTheme, variants }: UpdateStylesProps) => {
|
43
|
+
const styleResult = typeof style === 'function'
|
44
|
+
? style(state)
|
45
|
+
: style
|
46
|
+
const extractedResult = extractStyleResult(styleResult)
|
47
|
+
const previousScopedTheme = UnistylesShadowRegistry.getScopedTheme()
|
48
|
+
const previousVariants = UnistylesShadowRegistry.getVariants()
|
49
|
+
|
50
|
+
UnistylesShadowRegistry.selectVariants(variants as unknown as Variants)
|
51
|
+
UnistylesShadowRegistry.setScopedTheme(scopedTheme as any)
|
52
|
+
|
53
|
+
UnistylesShadowRegistry.add(ref, extractedResult)
|
54
|
+
|
55
|
+
UnistylesShadowRegistry.setScopedTheme(previousScopedTheme)
|
56
|
+
UnistylesShadowRegistry.selectVariants(previousVariants as unknown as Variants)
|
57
|
+
}
|
58
|
+
|
59
|
+
export const Pressable = forwardRef<View, PressableProps>(({ style, ...props }, passedRef) => {
|
60
|
+
const storedRef = useRef<View | null>(null)
|
61
|
+
const scopedTheme = UnistylesShadowRegistry.getScopedTheme()
|
62
|
+
const variants = UnistylesShadowRegistry.getVariants()
|
63
|
+
|
64
|
+
return (
|
65
|
+
<NativePressableReactNative
|
66
|
+
{...props}
|
67
|
+
style={state => {
|
68
|
+
if (!storedRef.current) {
|
69
|
+
return {}
|
70
|
+
}
|
71
|
+
|
72
|
+
updateStyles({
|
73
|
+
ref: storedRef.current,
|
74
|
+
style: style as WebPressableStyle,
|
75
|
+
variants,
|
76
|
+
scopedTheme,
|
77
|
+
state: state as WebPressableState
|
78
|
+
})
|
79
|
+
|
80
|
+
return {}
|
81
|
+
}}
|
82
|
+
ref={ref => {
|
83
|
+
storedRef.current = ref
|
84
|
+
updateStyles({
|
85
|
+
ref,
|
86
|
+
style: style as WebPressableStyle,
|
87
|
+
variants,
|
88
|
+
scopedTheme,
|
89
|
+
state: initialState
|
90
|
+
})
|
91
|
+
|
92
|
+
if (typeof passedRef === 'object' && passedRef !== null) {
|
93
|
+
passedRef.current = ref
|
94
|
+
}
|
95
|
+
}}
|
96
|
+
/>
|
97
|
+
)
|
98
|
+
})
|
@@ -1,84 +1,14 @@
|
|
1
|
-
import
|
1
|
+
import type { ComponentType } from 'react'
|
2
2
|
import type { UnistylesTheme } from '../types'
|
3
|
-
import {
|
4
|
-
import { UnistyleDependency } from '../specs/NativePlatform'
|
5
|
-
import type { PartialBy } from '../types/common'
|
6
|
-
import { UnistylesListener } from '../web/listener'
|
7
|
-
import { UnistylesShadowRegistry } from '../web'
|
8
|
-
import { equal } from '../web/utils'
|
9
|
-
import { deepMergeObjects } from '../utils'
|
3
|
+
import { withUnistyles } from './withUnistyles'
|
10
4
|
|
11
5
|
const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
|
12
|
-
const ALL_DEPENDENCIES = Object.values(UnistyleDependency).filter((dependency): dependency is UnistyleDependency => typeof dependency === 'number')
|
13
6
|
|
14
7
|
type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
const classNames = useMemo(() => {
|
20
|
-
if (!style) {
|
21
|
-
return []
|
22
|
-
}
|
23
|
-
|
24
|
-
const newClassNames = UnistylesShadowRegistry.add(ref, [style], undefined, []) ?? []
|
25
|
-
|
26
|
-
if (equal(oldClassNames.current, newClassNames)) {
|
27
|
-
return oldClassNames.current
|
28
|
-
}
|
29
|
-
|
30
|
-
oldClassNames.current = newClassNames
|
31
|
-
|
32
|
-
return newClassNames
|
33
|
-
}, [style])
|
34
|
-
|
35
|
-
useEffect(() => () => {
|
36
|
-
// Remove styles on unmount
|
37
|
-
if (style) {
|
38
|
-
UnistylesShadowRegistry.add(null, [style], undefined, [])
|
39
|
-
}
|
40
|
-
})
|
41
|
-
|
42
|
-
return classNames
|
43
|
-
}
|
44
|
-
|
9
|
+
/**
|
10
|
+
* @deprecated Use withUnistyles instead
|
11
|
+
*/
|
45
12
|
export const createUnistylesComponent = <TProps extends Record<string, any>, TMappings extends Partial<Omit<TProps, SupportedStyleProps>>>(Component: ComponentType<TProps>, mappings?: (theme: UnistylesTheme) => TMappings) => {
|
46
|
-
return
|
47
|
-
const narrowedProps = props as PartialBy<TProps, keyof TMappings | SupportedStyleProps>
|
48
|
-
const [mappingsProps, setMappingsProps] = useState(mappings?.(UnistylesRuntime.getTheme()))
|
49
|
-
const styleClassNames = useShadowRegistry(narrowedProps.style)
|
50
|
-
const contentContainerStyleClassNames = useShadowRegistry(narrowedProps.contentContainerStyle)
|
51
|
-
|
52
|
-
useEffect(() => {
|
53
|
-
const disposeMappings = UnistylesListener.addListeners(ALL_DEPENDENCIES, () => {
|
54
|
-
if (!mappings) {
|
55
|
-
disposeMappings()
|
56
|
-
|
57
|
-
return
|
58
|
-
}
|
59
|
-
|
60
|
-
return setMappingsProps(mappings(UnistylesRuntime.getTheme()))
|
61
|
-
})
|
62
|
-
|
63
|
-
return () => disposeMappings()
|
64
|
-
}, [mappingsProps, narrowedProps.style])
|
65
|
-
|
66
|
-
const combinedProps = {
|
67
|
-
...deepMergeObjects(props, (mappingsProps ?? {}) as object),
|
68
|
-
...narrowedProps.style ? {
|
69
|
-
style: {
|
70
|
-
$$css: true,
|
71
|
-
'unistyles': styleClassNames.join(' ')
|
72
|
-
},
|
73
|
-
} : {},
|
74
|
-
...narrowedProps.contentContainerStyle ? {
|
75
|
-
style: {
|
76
|
-
$$css: true,
|
77
|
-
'unistyles': contentContainerStyleClassNames.join(' ')
|
78
|
-
},
|
79
|
-
} : {},
|
80
|
-
} as unknown as TProps
|
81
|
-
|
82
|
-
return <Component {...combinedProps} ref={ref} />
|
83
|
-
})
|
13
|
+
return withUnistyles(Component as any, mappings as any)
|
84
14
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { passForwardedRef } from './passForwardRef'
|
3
|
+
|
4
|
+
export const createUnistylesElement = (Component: any) => React.forwardRef((props, forwardedRef) => (
|
5
|
+
<Component
|
6
|
+
{...props}
|
7
|
+
ref={(ref: unknown) => passForwardedRef(props, ref, forwardedRef)}
|
8
|
+
/>
|
9
|
+
))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import type { ImageBackground, ImageBackgroundProps } from 'react-native'
|
3
|
+
import { UnistylesShadowRegistry } from '../specs'
|
4
|
+
import { passForwardedRef } from './passForwardRef'
|
5
|
+
|
6
|
+
export const createUnistylesImageBackground = (Component: typeof ImageBackground) => React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => (
|
7
|
+
<Component
|
8
|
+
{...props}
|
9
|
+
ref={ref => passForwardedRef(props, ref, forwardedRef)}
|
10
|
+
imageRef={ref => {
|
11
|
+
const style = Array.isArray(props.imageStyle)
|
12
|
+
? props.imageStyle
|
13
|
+
: [props.imageStyle]
|
14
|
+
|
15
|
+
// @ts-expect-error - This is hidden from TS
|
16
|
+
UnistylesShadowRegistry.add(ref, style)
|
17
|
+
|
18
|
+
return () => {
|
19
|
+
// @ts-expect-error - This is hidden from TS
|
20
|
+
UnistylesShadowRegistry.remove(ref)
|
21
|
+
}
|
22
|
+
}}
|
23
|
+
/>
|
24
|
+
))
|
package/src/core/index.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
export { createUnistylesComponent } from './createUnistylesComponent'
|
2
|
-
export {
|
3
|
-
export {
|
2
|
+
export { createUnistylesElement } from './createUnistylesElement'
|
3
|
+
export { createUnistylesImageBackground } from './createUnistylesImageBackground'
|
4
|
+
export { withUnistyles } from './withUnistyles'
|
5
|
+
export { passForwardedRef } from './passForwardRef'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { UnistylesShadowRegistry } from '../specs'
|
3
|
+
|
4
|
+
export const passForwardedRef = <T>(
|
5
|
+
props: any,
|
6
|
+
ref: T,
|
7
|
+
forwardedRef: React.ForwardedRef<T>
|
8
|
+
) => {
|
9
|
+
const passForwardedRef = () => {
|
10
|
+
if (typeof forwardedRef === 'function') {
|
11
|
+
return forwardedRef(ref)
|
12
|
+
}
|
13
|
+
|
14
|
+
if (forwardedRef) {
|
15
|
+
forwardedRef.current = ref
|
16
|
+
}
|
17
|
+
|
18
|
+
return () => {}
|
19
|
+
}
|
20
|
+
const forwardedRefReturnFn = passForwardedRef()
|
21
|
+
|
22
|
+
UnistylesShadowRegistry.add(ref, props.style)
|
23
|
+
|
24
|
+
return () => {
|
25
|
+
// @ts-expect-error - This is hidden from TS
|
26
|
+
UnistylesShadowRegistry.remove(ref)
|
27
|
+
forwardedRefReturnFn?.()
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { withUnistyles } from './withUnistyles'
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { UnistylesMiniRuntime } from '../../specs';
|
2
|
+
import type { UnistylesTheme } from '../../types';
|
3
|
+
|
4
|
+
export const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
|
5
|
+
|
6
|
+
export type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
|
7
|
+
export type Mappings<T = {}> = (theme: UnistylesTheme, rt: UnistylesMiniRuntime) => Omit<Partial<T>, SupportedStyleProps>
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import { useEffect, useReducer, useRef, useState } from 'react'
|
2
|
+
import { UnistylesRuntime, UnistylesShadowRegistry, type UnistylesMiniRuntime } from '../../specs'
|
3
|
+
// It's imported that way because of circular dependency
|
4
|
+
import { UnistyleDependency } from '../../specs/NativePlatform'
|
5
|
+
import type { UnistylesTheme } from '../../types'
|
6
|
+
import type { Mappings } from './types'
|
7
|
+
|
8
|
+
const RTDependencyMap = {
|
9
|
+
breakpoint: UnistyleDependency.Breakpoints,
|
10
|
+
colorScheme: UnistyleDependency.ColorScheme,
|
11
|
+
contentSizeCategory: UnistyleDependency.ContentSizeCategory,
|
12
|
+
hasAdaptiveThemes: UnistyleDependency.AdaptiveThemes,
|
13
|
+
insets: UnistyleDependency.Insets,
|
14
|
+
fontScale: UnistyleDependency.FontScale,
|
15
|
+
isLandscape: UnistyleDependency.Orientation,
|
16
|
+
isPortrait: UnistyleDependency.Orientation,
|
17
|
+
navigationBar: UnistyleDependency.NavigationBar,
|
18
|
+
screen: UnistyleDependency.Dimensions,
|
19
|
+
statusBar: UnistyleDependency.StatusBar,
|
20
|
+
pixelRatio: UnistyleDependency.PixelRatio,
|
21
|
+
themeName: UnistyleDependency.ThemeName,
|
22
|
+
} satisfies Partial<Record<keyof UnistylesMiniRuntime, UnistyleDependency>>
|
23
|
+
|
24
|
+
type ListenerProps = {
|
25
|
+
updateTheme: VoidFunction,
|
26
|
+
updateRuntime: VoidFunction,
|
27
|
+
dependencies: Array<UnistyleDependency>
|
28
|
+
}
|
29
|
+
|
30
|
+
export const useDependencies = (listener: (props: ListenerProps) => VoidFunction) => {
|
31
|
+
const scopedTheme = UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
|
32
|
+
const [dependencies] = useState(() => new Set<number>())
|
33
|
+
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme))
|
34
|
+
const [_, runtimeChanged] = useReducer(() => ({}), {})
|
35
|
+
const disposeRef = useRef<VoidFunction>()
|
36
|
+
|
37
|
+
const reinitListener = () => {
|
38
|
+
disposeRef.current?.()
|
39
|
+
disposeRef.current = listener({
|
40
|
+
dependencies: Array.from(dependencies),
|
41
|
+
updateTheme: () => {
|
42
|
+
if (scopedTheme) {
|
43
|
+
return
|
44
|
+
}
|
45
|
+
|
46
|
+
setTheme(UnistylesRuntime.getTheme(scopedTheme))
|
47
|
+
},
|
48
|
+
updateRuntime: () => runtimeChanged()
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
useEffect(() => {
|
53
|
+
reinitListener()
|
54
|
+
|
55
|
+
return () => disposeRef.current?.()
|
56
|
+
}, [dependencies.size])
|
57
|
+
|
58
|
+
return {
|
59
|
+
mappingsCallback: (callback: Mappings) => {
|
60
|
+
const proxifiedTheme = new Proxy(theme, {
|
61
|
+
get: (target, prop) => {
|
62
|
+
dependencies.add(UnistyleDependency.Theme)
|
63
|
+
|
64
|
+
return target[prop]
|
65
|
+
}
|
66
|
+
})
|
67
|
+
const proxifiedRuntime = new Proxy(UnistylesRuntime.miniRuntime, {
|
68
|
+
get: (target, prop) => {
|
69
|
+
if (prop in RTDependencyMap) {
|
70
|
+
dependencies.add(RTDependencyMap[prop as keyof typeof RTDependencyMap])
|
71
|
+
}
|
72
|
+
|
73
|
+
return target[prop as keyof typeof target]
|
74
|
+
}
|
75
|
+
})
|
76
|
+
|
77
|
+
return callback(proxifiedTheme, proxifiedRuntime)
|
78
|
+
},
|
79
|
+
addDependencies: (newDependencies: Array<UnistyleDependency>) => {
|
80
|
+
const dependenciesSize = dependencies.size
|
81
|
+
|
82
|
+
newDependencies.forEach(dependency => {
|
83
|
+
dependencies.add(dependency)
|
84
|
+
})
|
85
|
+
|
86
|
+
if (dependenciesSize === dependencies.size) {
|
87
|
+
return
|
88
|
+
}
|
89
|
+
|
90
|
+
reinitListener()
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|