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,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { useEffect, useReducer, useRef, useState } from 'react';
|
4
|
+
import { UnistylesRuntime, UnistylesShadowRegistry } from '../../specs';
|
5
|
+
// It's imported that way because of circular dependency
|
6
|
+
import { UnistyleDependency } from '../../specs/NativePlatform';
|
7
|
+
const RTDependencyMap = {
|
8
|
+
breakpoint: UnistyleDependency.Breakpoints,
|
9
|
+
colorScheme: UnistyleDependency.ColorScheme,
|
10
|
+
contentSizeCategory: UnistyleDependency.ContentSizeCategory,
|
11
|
+
hasAdaptiveThemes: UnistyleDependency.AdaptiveThemes,
|
12
|
+
insets: UnistyleDependency.Insets,
|
13
|
+
fontScale: UnistyleDependency.FontScale,
|
14
|
+
isLandscape: UnistyleDependency.Orientation,
|
15
|
+
isPortrait: UnistyleDependency.Orientation,
|
16
|
+
navigationBar: UnistyleDependency.NavigationBar,
|
17
|
+
screen: UnistyleDependency.Dimensions,
|
18
|
+
statusBar: UnistyleDependency.StatusBar,
|
19
|
+
pixelRatio: UnistyleDependency.PixelRatio,
|
20
|
+
themeName: UnistyleDependency.ThemeName
|
21
|
+
};
|
22
|
+
export const useDependencies = listener => {
|
23
|
+
const scopedTheme = UnistylesShadowRegistry.getScopedTheme();
|
24
|
+
const [dependencies] = useState(() => new Set());
|
25
|
+
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme));
|
26
|
+
const [_, runtimeChanged] = useReducer(() => ({}), {});
|
27
|
+
const disposeRef = useRef();
|
28
|
+
const reinitListener = () => {
|
29
|
+
disposeRef.current?.();
|
30
|
+
disposeRef.current = listener({
|
31
|
+
dependencies: Array.from(dependencies),
|
32
|
+
updateTheme: () => {
|
33
|
+
if (scopedTheme) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
setTheme(UnistylesRuntime.getTheme(scopedTheme));
|
37
|
+
},
|
38
|
+
updateRuntime: () => runtimeChanged()
|
39
|
+
});
|
40
|
+
};
|
41
|
+
useEffect(() => {
|
42
|
+
reinitListener();
|
43
|
+
return () => disposeRef.current?.();
|
44
|
+
}, [dependencies.size]);
|
45
|
+
return {
|
46
|
+
mappingsCallback: callback => {
|
47
|
+
const proxifiedTheme = new Proxy(theme, {
|
48
|
+
get: (target, prop) => {
|
49
|
+
dependencies.add(UnistyleDependency.Theme);
|
50
|
+
return target[prop];
|
51
|
+
}
|
52
|
+
});
|
53
|
+
const proxifiedRuntime = new Proxy(UnistylesRuntime.miniRuntime, {
|
54
|
+
get: (target, prop) => {
|
55
|
+
if (prop in RTDependencyMap) {
|
56
|
+
dependencies.add(RTDependencyMap[prop]);
|
57
|
+
}
|
58
|
+
return target[prop];
|
59
|
+
}
|
60
|
+
});
|
61
|
+
return callback(proxifiedTheme, proxifiedRuntime);
|
62
|
+
},
|
63
|
+
addDependencies: newDependencies => {
|
64
|
+
const dependenciesSize = dependencies.size;
|
65
|
+
newDependencies.forEach(dependency => {
|
66
|
+
dependencies.add(dependency);
|
67
|
+
});
|
68
|
+
if (dependenciesSize === dependencies.size) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
reinitListener();
|
72
|
+
}
|
73
|
+
};
|
74
|
+
};
|
75
|
+
//# sourceMappingURL=useDependencies.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useEffect","useReducer","useRef","useState","UnistylesRuntime","UnistylesShadowRegistry","UnistyleDependency","RTDependencyMap","breakpoint","Breakpoints","colorScheme","ColorScheme","contentSizeCategory","ContentSizeCategory","hasAdaptiveThemes","AdaptiveThemes","insets","Insets","fontScale","FontScale","isLandscape","Orientation","isPortrait","navigationBar","NavigationBar","screen","Dimensions","statusBar","StatusBar","pixelRatio","PixelRatio","themeName","ThemeName","useDependencies","listener","scopedTheme","getScopedTheme","dependencies","Set","theme","setTheme","getTheme","_","runtimeChanged","disposeRef","reinitListener","current","Array","from","updateTheme","updateRuntime","size","mappingsCallback","callback","proxifiedTheme","Proxy","get","target","prop","add","Theme","proxifiedRuntime","miniRuntime","addDependencies","newDependencies","dependenciesSize","forEach","dependency"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/useDependencies.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,gBAAgB,EAAEC,uBAAuB,QAAmC,aAAa;AAClG;AACA,SAASC,kBAAkB,QAAQ,4BAA4B;AAI/D,MAAMC,eAAe,GAAG;EACpBC,UAAU,EAAEF,kBAAkB,CAACG,WAAW;EAC1CC,WAAW,EAAEJ,kBAAkB,CAACK,WAAW;EAC3CC,mBAAmB,EAAEN,kBAAkB,CAACO,mBAAmB;EAC3DC,iBAAiB,EAAER,kBAAkB,CAACS,cAAc;EACpDC,MAAM,EAAEV,kBAAkB,CAACW,MAAM;EACjCC,SAAS,EAAEZ,kBAAkB,CAACa,SAAS;EACvCC,WAAW,EAAEd,kBAAkB,CAACe,WAAW;EAC3CC,UAAU,EAAEhB,kBAAkB,CAACe,WAAW;EAC1CE,aAAa,EAAEjB,kBAAkB,CAACkB,aAAa;EAC/CC,MAAM,EAAEnB,kBAAkB,CAACoB,UAAU;EACrCC,SAAS,EAAErB,kBAAkB,CAACsB,SAAS;EACvCC,UAAU,EAAEvB,kBAAkB,CAACwB,UAAU;EACzCC,SAAS,EAAEzB,kBAAkB,CAAC0B;AAClC,CAA2E;AAQ3E,OAAO,MAAMC,eAAe,GAAIC,QAAgD,IAAK;EACjF,MAAMC,WAAW,GAAG9B,uBAAuB,CAAC+B,cAAc,CAAC,CAAmB;EAC9E,MAAM,CAACC,YAAY,CAAC,GAAGlC,QAAQ,CAAC,MAAM,IAAImC,GAAG,CAAS,CAAC,CAAC;EACxD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGrC,QAAQ,CAACC,gBAAgB,CAACqC,QAAQ,CAACN,WA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D,IAAI,CAAiC,CAAC;UAC3E;UAEA,OAAOD,MAAM,CAACC,IAAI,CAAwB;QAC9C;MACJ,CAAC,CAAC;MAEF,OAAOL,QAAQ,CAACC,cAAc,EAAEO,gBAAgB,CAAC;IACrD,CAAC;IACDE,eAAe,EAAGC,eAA0C,IAAK;MAC7D,MAAMC,gBAAgB,GAAG5B,YAAY,CAACc,IAAI;MAE1Ca,eAAe,CAACE,OAAO,CAACC,UAAU,IAAI;QAClC9B,YAAY,CAACsB,GAAG,CAACQ,UAAU,CAAC;MAChC,CAAC,CAAC;MAEF,IAAIF,gBAAgB,KAAK5B,YAAY,CAACc,IAAI,EAAE;QACxC;MACJ;MAEAN,cAAc,CAAC,CAAC;IACpB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import React, { useEffect, useState, forwardRef, useRef, useMemo } from 'react';
|
4
|
+
import { UnistylesListener } from '../../web/listener';
|
5
|
+
import { UnistylesShadowRegistry } from '../../web';
|
6
|
+
import { equal } from '../../web/utils';
|
7
|
+
import { deepMergeObjects } from '../../utils';
|
8
|
+
import { useDependencies } from './useDependencies';
|
9
|
+
import { UnistyleDependency } from '../../specs/NativePlatform';
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
11
|
+
const useShadowRegistry = style => {
|
12
|
+
const [ref] = useState(document.createElement('div'));
|
13
|
+
const oldClassNames = useRef([]);
|
14
|
+
const classNames = useMemo(() => {
|
15
|
+
if (!style) {
|
16
|
+
return [];
|
17
|
+
}
|
18
|
+
const newClassNames = UnistylesShadowRegistry.add(ref, [style]) ?? [];
|
19
|
+
if (equal(oldClassNames.current, newClassNames)) {
|
20
|
+
return oldClassNames.current;
|
21
|
+
}
|
22
|
+
oldClassNames.current = newClassNames;
|
23
|
+
return newClassNames;
|
24
|
+
}, [style]);
|
25
|
+
useEffect(() => () => {
|
26
|
+
// Remove styles on unmount
|
27
|
+
if (style) {
|
28
|
+
UnistylesShadowRegistry.add(null, [style]);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
return classNames;
|
32
|
+
};
|
33
|
+
|
34
|
+
// @ts-expect-error
|
35
|
+
|
36
|
+
// @ts-expect-error
|
37
|
+
|
38
|
+
export const withUnistyles = (Component, mappings) => {
|
39
|
+
return /*#__PURE__*/forwardRef((props, ref) => {
|
40
|
+
const narrowedProps = props;
|
41
|
+
const styleClassNames = useShadowRegistry(narrowedProps.style);
|
42
|
+
const contentContainerStyleClassNames = useShadowRegistry(narrowedProps.contentContainerStyle);
|
43
|
+
const {
|
44
|
+
mappingsCallback
|
45
|
+
} = useDependencies(({
|
46
|
+
dependencies,
|
47
|
+
updateTheme,
|
48
|
+
updateRuntime
|
49
|
+
}) => {
|
50
|
+
const disposeTheme = UnistylesListener.addListeners(dependencies.filter(dependency => dependency === UnistyleDependency.Theme), updateTheme);
|
51
|
+
const disposeRuntime = UnistylesListener.addListeners(dependencies.filter(dependency => dependency !== UnistyleDependency.Theme), updateRuntime);
|
52
|
+
return () => {
|
53
|
+
disposeTheme();
|
54
|
+
disposeRuntime();
|
55
|
+
};
|
56
|
+
});
|
57
|
+
const mappingsProps = mappings ? mappingsCallback(mappings) : {};
|
58
|
+
const unistyleProps = narrowedProps.uniProps ? mappingsCallback(narrowedProps.uniProps) : {};
|
59
|
+
const combinedProps = {
|
60
|
+
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
61
|
+
...(narrowedProps.style ? {
|
62
|
+
style: {
|
63
|
+
$$css: true,
|
64
|
+
'unistyles': styleClassNames.join(' ')
|
65
|
+
}
|
66
|
+
} : {}),
|
67
|
+
...(narrowedProps.contentContainerStyle ? {
|
68
|
+
style: {
|
69
|
+
$$css: true,
|
70
|
+
'unistyles': contentContainerStyleClassNames.join(' ')
|
71
|
+
}
|
72
|
+
} : {})
|
73
|
+
};
|
74
|
+
const NativeComponent = Component;
|
75
|
+
return /*#__PURE__*/_jsx(NativeComponent, {
|
76
|
+
...combinedProps,
|
77
|
+
ref: ref
|
78
|
+
});
|
79
|
+
});
|
80
|
+
};
|
81
|
+
//# sourceMappingURL=withUnistyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","forwardRef","useRef","useMemo","UnistylesListener","UnistylesShadowRegistry","equal","deepMergeObjects","useDependencies","UnistyleDependency","jsx","_jsx","useShadowRegistry","style","ref","document","createElement","oldClassNames","classNames","newClassNames","add","current","withUnistyles","Component","mappings","props","narrowedProps","styleClassNames","contentContainerStyleClassNames","contentContainerStyle","mappingsCallback","dependencies","updateTheme","updateRuntime","disposeTheme","addListeners","filter","dependency","Theme","disposeRuntime","mappingsProps","unistyleProps","uniProps","combinedProps","$$css","join","NativeComponent"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/withUnistyles.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAsBC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAAgD,OAAO;AAE3I,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,uBAAuB,QAAQ,WAAW;AACnD,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,gBAAgB,QAAQ,aAAa;AAE9C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,kBAAkB,QAAQ,4BAA4B;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAG/D,MAAMC,iBAAiB,GAAIC,KAA2B,IAAK;EACvD,MAAM,CAACC,GAAG,CAAC,GAAGd,QAAQ,CAACe,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC,CAAC;EACrD,MAAMC,aAAa,GAAGf,MAAM,CAAgB,EAAE,CAAC;EAC/C,MAAMgB,UAAU,GAAGf,OAAO,CAAC,MAAM;IAC7B,IAAI,CAACU,KAAK,EAAE;MACR,OAAO,EAAE;IACb;IAEA,MAAMM,aAAa,GAAGd,uBAAuB,CAACe,GAAG,CAACN,GAAG,EAAE,CAACD,KAAK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AC;MACpB,CAAC;IACL,CAAC,CAAC;IACF,MAAMC,aAAa,GAAGhB,QAAQ,GAAGM,gBAAgB,CAACN,QAAQ,CAAC,GAAG,CAAC,CAAC;IAChE,MAAMiB,aAAa,GAAGf,aAAa,CAACgB,QAAQ,GAAGZ,gBAAgB,CAACJ,aAAa,CAACgB,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE5F,MAAMC,aAAa,GAAG;MAClB,GAAGpC,gBAAgB,CAACiC,aAAa,EAAEC,aAAa,EAAEhB,KAAK,CAAC;MACxD,IAAGC,aAAa,CAACb,KAAK,GAAG;QACrBA,KAAK,EAAE;UACH+B,KAAK,EAAE,IAAI;UACX,WAAW,EAAEjB,eAAe,CAACkB,IAAI,CAAC,GAAG;QACzC;MACJ,CAAC,GAAG,CAAC,CAAC;MACN,IAAGnB,aAAa,CAACG,qBAAqB,GAAG;QACrChB,KAAK,EAAE;UACH+B,KAAK,EAAE,IAAI;UACX,WAAW,EAAEhB,+BAA+B,CAACiB,IAAI,CAAC,GAAG;QACzD;MACJ,CAAC,GAAG,CAAC,CAAC;IACV,CAAQ;IAER,MAAMC,eAAe,GAAGvB,SAA0B;IAElD,oBAAOZ,IAAA,CAACmC,eAAe;MAAA,GAAKH,aAAa;MAAE7B,GAAG,EAAEA;IAAI,CAAE,CAAC;EAC3D,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import React, { forwardRef, useEffect, useRef } from 'react';
|
4
|
+
import { StyleSheet, UnistyleDependency } from '../../specs';
|
5
|
+
import { deepMergeObjects } from '../../utils';
|
6
|
+
import { SUPPORTED_STYLE_PROPS } from './types';
|
7
|
+
import { useDependencies } from './useDependencies';
|
8
|
+
|
9
|
+
// @ts-expect-error
|
10
|
+
|
11
|
+
// @ts-expect-error
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
export const withUnistyles = (Component, mappings) => {
|
14
|
+
return /*#__PURE__*/forwardRef((props, ref) => {
|
15
|
+
const narrowedProps = props;
|
16
|
+
const stylesRef = useRef({});
|
17
|
+
const isForcedRef = useRef(false);
|
18
|
+
const NativeComponent = Component;
|
19
|
+
if (!isForcedRef.current) {
|
20
|
+
SUPPORTED_STYLE_PROPS.forEach(propName => {
|
21
|
+
if (narrowedProps?.[propName]) {
|
22
|
+
if (Array.isArray(narrowedProps[propName])) {
|
23
|
+
console.error(`🦄 Unistyles: withUnistyles requires ${propName} to be an object. Please check props for component: ${NativeComponent.displayName}`);
|
24
|
+
}
|
25
|
+
|
26
|
+
// @ts-expect-error - this is hidden from TS
|
27
|
+
if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
|
28
|
+
console.error(`🦄 Unistyles: withUnistyles received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${NativeComponent.displayName}`);
|
29
|
+
}
|
30
|
+
stylesRef.current = {
|
31
|
+
...stylesRef.current,
|
32
|
+
[propName]: narrowedProps[propName]
|
33
|
+
};
|
34
|
+
}
|
35
|
+
});
|
36
|
+
}
|
37
|
+
const {
|
38
|
+
mappingsCallback,
|
39
|
+
addDependencies
|
40
|
+
} = useDependencies(({
|
41
|
+
dependencies,
|
42
|
+
updateTheme,
|
43
|
+
updateRuntime
|
44
|
+
}) => {
|
45
|
+
const listensToTheme = dependencies.includes(UnistyleDependency.Theme);
|
46
|
+
// @ts-expect-error - this is hidden from TS
|
47
|
+
const dispose = StyleSheet.addChangeListener(changedDependencies => {
|
48
|
+
if (listensToTheme && changedDependencies.includes(UnistyleDependency.Theme)) {
|
49
|
+
updateTheme();
|
50
|
+
}
|
51
|
+
if (changedDependencies.some(dependency => dependencies.includes(dependency))) {
|
52
|
+
SUPPORTED_STYLE_PROPS.forEach(propName => {
|
53
|
+
if (narrowedProps?.[propName]) {
|
54
|
+
stylesRef.current = {
|
55
|
+
...stylesRef.current,
|
56
|
+
// @ts-expect-error - this is hidden from TS
|
57
|
+
[propName]: props[propName].__proto__?.getStyle?.() || props[propName]
|
58
|
+
};
|
59
|
+
isForcedRef.current = true;
|
60
|
+
}
|
61
|
+
});
|
62
|
+
updateRuntime();
|
63
|
+
}
|
64
|
+
});
|
65
|
+
return () => dispose();
|
66
|
+
});
|
67
|
+
useEffect(() => {
|
68
|
+
const styleDependencies = narrowedProps.style?.__proto__.uni__dependencies ?? [];
|
69
|
+
const contentContainerStyleDependencies = narrowedProps.contentContainerStyle?.__proto__.uni__dependencies ?? [];
|
70
|
+
addDependencies([...styleDependencies, ...contentContainerStyleDependencies]);
|
71
|
+
}, [narrowedProps.style, narrowedProps.contentContainerStyle]);
|
72
|
+
const mappingProps = mappings ? mappingsCallback(mappings) : {};
|
73
|
+
const unistyleProps = narrowedProps.uniProps ? mappingsCallback(narrowedProps.uniProps) : {};
|
74
|
+
const finalProps = deepMergeObjects(mappingProps, unistyleProps, props);
|
75
|
+
|
76
|
+
// override with Unistyles styles
|
77
|
+
SUPPORTED_STYLE_PROPS.forEach(propName => {
|
78
|
+
if (finalProps[propName]) {
|
79
|
+
finalProps[propName] = stylesRef.current[propName];
|
80
|
+
}
|
81
|
+
});
|
82
|
+
isForcedRef.current = false;
|
83
|
+
return /*#__PURE__*/_jsx(NativeComponent, {
|
84
|
+
...finalProps,
|
85
|
+
ref: ref
|
86
|
+
});
|
87
|
+
});
|
88
|
+
};
|
89
|
+
//# sourceMappingURL=withUnistyles.native.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useEffect","useRef","StyleSheet","UnistyleDependency","deepMergeObjects","SUPPORTED_STYLE_PROPS","useDependencies","jsx","_jsx","withUnistyles","Component","mappings","props","ref","narrowedProps","stylesRef","isForcedRef","NativeComponent","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","__proto__","getStyle","mappingsCallback","addDependencies","dependencies","updateTheme","updateRuntime","listensToTheme","includes","Theme","dispose","addChangeListener","changedDependencies","some","dependency","styleDependencies","style","uni__dependencies","contentContainerStyleDependencies","contentContainerStyle","mappingProps","unistyleProps","uniProps","finalProps"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/withUnistyles.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAA4B,OAAO;AAChF,SAASC,UAAU,EAAEC,kBAAkB,QAAQ,aAAa;AAE5D,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,qBAAqB,QAAQ,SAAS;AAE/C,SAASC,eAAe,QAAQ,mBAAmB;;AAEnD;;AAEA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGA,OAAO,MAAMC,aAAa,GAAGA,CAAkEC,SAAqB,EAAEC,QAA8B,KAAK;EAMrJ,oBAAOZ,UAAU,CAAsD,CAACa,KAAK,EAAEC,GAAG,KAAK;IACnF,MAAMC,aAAa,GAAGF,KAA2B;IACjD,MAAMG,SAAS,GAAGd,MAAM,CAAsB,CAAC,CAAC,CAAC;IACjD,MAAMe,WAAW,GAAGf,MAAM,CAAC,KAAK,CAAC;IACjC,MAAMgB,eAAe,GAAGP,SAA0B;IAElD,IAAI,CAACM,WAAW,CAACE,OAAO,EAAE;MACtBb,qBAAqB,CAACc,OAAO,CAACC,QAAQ,IAAI;QACtC,IAAIN,aAAa,GAAGM,QAAQ,CAAC,EAAE;UAC3B,IAAIC,KAAK,CAACC,OAAO,CAACR,aAAa,CAACM,QAAQ,CAAC,CAAC,EAAE;YACxCG,OAAO,CAACC,KAAK,CAAC,wCAAwCJ,QAAQ,uDAAuDH,eAAe,CAACQ,WAAW,EAAE,CAAC;UACvJ;;UAEA;UACA,IAAIb,KAAK,CAACQ,QAAQ,CAAC,CAACM,gBAAgB,IAAI,CAACd,KAAK,CAACQ,QAAQ,CAAC,CAACO,SAAS,EAAEC,QAAQ,EAAE;YAC1EL,OAAO,CAACC,KAAK,CAAC,4JAA4JP,eAAe,CAACQ,WAAW,EAAE,CAAC;UAC5M;UAEAV,SAAS,CAACG,OAAO,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AAMC,iCAAiC,GAAG/B,aAAa,CAACgC,qBAAqB,EAAEnB,SAAS,CAACiB,iBAAiB,IAAI,EAA+B;MAE7Id,eAAe,CAAC,CAAC,GAAGY,iBAAiB,EAAE,GAAGG,iCAAiC,CAAC,CAAC;IACjF,CAAC,EAAE,CAAC/B,aAAa,CAAC6B,KAAK,EAAE7B,aAAa,CAACgC,qBAAqB,CAAC,CAAC;IAE9D,MAAMC,YAAY,GAAGpC,QAAQ,GAAGkB,gBAAgB,CAAClB,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAMqC,aAAa,GAAGlC,aAAa,CAACmC,QAAQ,GAAGpB,gBAAgB,CAACf,aAAa,CAACmC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC5F,MAAMC,UAAU,GAAG9C,gBAAgB,CAAsB2C,YAAY,EAAEC,aAAa,EAAEpC,KAAK,CAAC;;IAE5F;IACAP,qBAAqB,CAACc,OAAO,CAACC,QAAQ,IAAI;MACtC,IAAI8B,UAAU,CAAC9B,QAAQ,CAAC,EAAE;QACtB8B,UAAU,CAAC9B,QAAQ,CAAC,GAAGL,SAAS,CAACG,OAAO,CAACE,QAAQ,CAAC;MACtD;IACJ,CAAC,CAAC;IAEFJ,WAAW,CAACE,OAAO,GAAG,KAAK;IAE3B,oBAAOV,IAAA,CAACS,eAAe;MAAA,GAAKiC,UAAU;MAAYrC,GAAG,EAAEA;IAAI,CAAE,CAAC;EAClE,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import { useEffect,
|
4
|
-
import {
|
5
|
-
import { isValidMq, parseMq, isUnistylesMq } from '../mq';
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
4
|
+
import { isUnistylesMq, isValidMq, parseMq } from '../mq';
|
6
5
|
export const useMedia = config => {
|
7
|
-
const
|
6
|
+
const disposeRef = useRef(() => {});
|
7
|
+
const [isVisible, setIsVisible] = useState(() => {
|
8
8
|
const maybeMq = config.mq;
|
9
9
|
if (!isUnistylesMq(maybeMq)) {
|
10
10
|
console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`);
|
@@ -16,37 +16,21 @@ export const useMedia = config => {
|
|
16
16
|
return false;
|
17
17
|
}
|
18
18
|
const {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
return true;
|
35
|
-
};
|
36
|
-
const [isVisible, setIsVisible] = useState(computeIsVisible());
|
37
|
-
useEffect(() => {
|
38
|
-
setIsVisible(computeIsVisible());
|
39
|
-
}, [config.mq]);
|
40
|
-
useLayoutEffect(() => {
|
41
|
-
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
42
|
-
if (dependencies.includes(UnistyleDependency.Breakpoints)) {
|
43
|
-
setIsVisible(computeIsVisible());
|
44
|
-
}
|
45
|
-
});
|
46
|
-
return () => {
|
47
|
-
removeChangeListener();
|
48
|
-
};
|
49
|
-
}, [config.mq]);
|
19
|
+
minWidth,
|
20
|
+
maxWidth,
|
21
|
+
minHeight,
|
22
|
+
maxHeight
|
23
|
+
} = parsedMq;
|
24
|
+
const mediaQuery = [minWidth !== undefined ? `(min-width: ${minWidth}px)` : undefined, maxWidth !== undefined ? `(max-width: ${maxWidth}px)` : undefined, minHeight !== undefined ? `(min-height: ${minHeight}px)` : undefined, maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined].filter(Boolean).join(' and ');
|
25
|
+
const media = window.matchMedia(mediaQuery);
|
26
|
+
const handler = event => setIsVisible(event.matches);
|
27
|
+
media.addEventListener('change', handler);
|
28
|
+
disposeRef.current = () => media.removeEventListener('change', handler);
|
29
|
+
return media.matches;
|
30
|
+
});
|
31
|
+
|
32
|
+
// Unmount
|
33
|
+
useEffect(() => () => disposeRef.current(), []);
|
50
34
|
return {
|
51
35
|
isVisible
|
52
36
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","isUnistylesMq","isValidMq","parseMq","useMedia","config","disposeRef","isVisible","setIsVisible","maybeMq","mq","console","error","parsedMq","minWidth","maxWidth","minHeight","maxHeight","mediaQuery","undefined","filter","Boolean","join","media","window","matchMedia","handler","event","matches","addEventListener","current","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useMedia.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnD,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEzD,OAAO,MAAMC,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,UAAU,GAAGP,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;EACnC,MAAM,CAACQ,SAAS,EAAEC,YAAY,CAAC,GAAGR,QAAQ,CAAC,MAAM;IAC7C,MAAMS,OAAO,GAAGJ,MAAM,CAACK,EAAuB;IAE9C,IAAI,CAACT,aAAa,CAACQ,OAAO,CAAC,EAAE;MACzBE,OAAO,CAACC,KAAK,CAAC,sCAAsCH,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMI,QAAQ,GAAGV,OAAO,CAACM,OAAO,CAAC;IAEjC,IAAI,CAACP,SAAS,CAACW,QAAQ,CAAC,EAAE;MACtBF,OAAO,CAACC,KAAK,CAAC,oEAAoEH,OAAO,EAAE,CAAC;MAE5F,OAAO,KAAK;IAChB;IAEA,MAAM;MAAEK,QAAQ;MAAEC,QAAQ;MAAEC,SAAS;MAAEC;IAAU,CAAC,GAAGJ,QAAQ;IAE7D,MAAMK,UAAU,GAAG,CACfJ,QAAQ,KAAKK,SAAS,GAAG,eAAeL,QAAQ,KAAK,GAAGK,SAAS,EACjEJ,QAAQ,KAAKI,SAAS,GAAG,eAAeJ,QAAQ,KAAK,GAAGI,SAAS,EACjEH,SAAS,KAAKG,SAAS,GAAG,gBAAgBH,SAAS,KAAK,GAAGG,SAAS,EACpEF,SAAS,KAAKE,SAAS,GAAG,gBAAgBF,SAAS,KAAK,GAAGE,SAAS,CACvE,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;IAE/B,MAAMC,KAAK,GAAGC,MAAM,CAACC,UAAU,CAACP,UAAU,CAAC;IAC3C,MAAMQ,OAAO,GAAIC,KAA0B,IAAKnB,YAAY,CAACmB,KAAK,CAACC,OAAO,CAAC;IAE3EL,KAAK,CAACM,gBAAgB,CAAC,QAAQ,EAAEH,OAAO,CAAC;IACzCpB,UAAU,CAACwB,OAAO,GAAG,MAAMP,KAAK,CAACQ,mBAAmB,CAAC,QAAQ,EAAEL,OAAO,CAAC;IAEvE,OAAOH,KAAK,CAACK,OAAO;EACxB,CAAC,CAAC;;EAEF;EACA9B,SAAS,CAAC,MAAM,MAAMQ,UAAU,CAACwB,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;EAE/C,OAAO;IACHvB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { useEffect, useLayoutEffect, useState } from 'react';
|
4
|
+
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
5
|
+
import { isValidMq, parseMq, isUnistylesMq } from '../mq';
|
6
|
+
export const useMedia = config => {
|
7
|
+
const computeIsVisible = () => {
|
8
|
+
const maybeMq = config.mq;
|
9
|
+
if (!isUnistylesMq(maybeMq)) {
|
10
|
+
console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`);
|
11
|
+
return false;
|
12
|
+
}
|
13
|
+
const parsedMq = parseMq(maybeMq);
|
14
|
+
if (!isValidMq(parsedMq)) {
|
15
|
+
console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`);
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
const {
|
19
|
+
width,
|
20
|
+
height
|
21
|
+
} = UnistylesRuntime.screen;
|
22
|
+
if (parsedMq.minWidth !== undefined && width < parsedMq.minWidth) {
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
if (parsedMq.maxWidth !== undefined && width > parsedMq.maxWidth) {
|
26
|
+
return false;
|
27
|
+
}
|
28
|
+
if (parsedMq.minHeight !== undefined && height < parsedMq.minHeight) {
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
if (parsedMq.maxHeight !== undefined && height > parsedMq.maxHeight) {
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
return true;
|
35
|
+
};
|
36
|
+
const [isVisible, setIsVisible] = useState(computeIsVisible());
|
37
|
+
useEffect(() => {
|
38
|
+
setIsVisible(computeIsVisible());
|
39
|
+
}, [config.mq]);
|
40
|
+
useLayoutEffect(() => {
|
41
|
+
// @ts-expect-error - this is hidden from TS
|
42
|
+
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
43
|
+
if (dependencies.includes(UnistyleDependency.Breakpoints)) {
|
44
|
+
setIsVisible(computeIsVisible());
|
45
|
+
}
|
46
|
+
});
|
47
|
+
return () => {
|
48
|
+
removeChangeListener();
|
49
|
+
};
|
50
|
+
}, [config.mq]);
|
51
|
+
return {
|
52
|
+
isVisible
|
53
|
+
};
|
54
|
+
};
|
55
|
+
//# sourceMappingURL=useMedia.native.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","isValidMq","parseMq","isUnistylesMq","useMedia","config","computeIsVisible","maybeMq","mq","console","error","parsedMq","width","height","screen","minWidth","undefined","maxWidth","minHeight","maxHeight","isVisible","setIsVisible","removeChangeListener","addChangeListener","dependencies","includes","Breakpoints"],"sourceRoot":"../../../src","sources":["hooks/useMedia.native.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAA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BAAgB,CAAC,CAAC,CAAC;EAE9EX,SAAS,CAAC,MAAM;IACZ0B,YAAY,CAACf,gBAAgB,CAAC,CAAC,CAAC;EACpC,CAAC,EAAE,CAACD,MAAM,CAACG,EAAE,CAAC,CAAC;EAEfZ,eAAe,CAAC,MAAM;IAClB;IACA,MAAM0B,oBAAoB,GAAGxB,UAAU,CAACyB,iBAAiB,CAAEC,YAAuC,IAAK;MACnG,IAAIA,YAAY,CAACC,QAAQ,CAAC1B,kBAAkB,CAAC2B,WAAW,CAAC,EAAE;QACvDL,YAAY,CAACf,gBAAgB,CAAC,CAAC,CAAC;MACpC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTgB,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,CAACjB,MAAM,CAACG,EAAE,CAAC,CAAC;EAEf,OAAO;IACHY;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
export * from './specs';
|
4
4
|
export { mq } from './mq';
|
5
|
-
export { createUnistylesComponent,
|
6
|
-
export
|
5
|
+
export { createUnistylesComponent, withUnistyles } from './core';
|
6
|
+
export { Display, Hide, Variants, ScopedTheme } from './components';
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["mq","createUnistylesComponent","
|
1
|
+
{"version":3,"names":["mq","createUnistylesComponent","withUnistyles","Display","Hide","Variants","ScopedTheme"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,SAAS;AACvB,SAASA,EAAE,QAAQ,MAAM;AAEzB,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,QAAQ;AAEhE,SAASC,OAAO,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,cAAc","ignoreList":[]}
|
@@ -3,13 +3,13 @@
|
|
3
3
|
import { NitroModules } from 'react-native-nitro-modules';
|
4
4
|
const HybridShadowRegistry = NitroModules.createHybridObject('UnistylesShadowRegistry');
|
5
5
|
const findShadowNodeForHandle = handle => {
|
6
|
-
const node = handle?.__internalInstanceHandle?.stateNode?.node ?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node;
|
6
|
+
const node = handle?.__internalInstanceHandle?.stateNode?.node ?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ?? handle?._viewRef?.__internalInstanceHandle?.stateNode?.node ?? handle?.viewRef?.current?.__internalInstanceHandle?.stateNode?.node ?? handle?._nativeRef?.__internalInstanceHandle?.stateNode?.node;
|
7
7
|
if (!node) {
|
8
8
|
throw new Error(`Unistyles: Could not find shadow node for one of your components of type ${handle?.__internalInstanceHandle?.elementType ?? 'unknown'}`);
|
9
9
|
}
|
10
10
|
return node;
|
11
11
|
};
|
12
|
-
HybridShadowRegistry.add = (handle, styles
|
12
|
+
HybridShadowRegistry.add = (handle, styles) => {
|
13
13
|
// virtualized nodes can be null
|
14
14
|
if (!handle || !styles || !Array.isArray(styles)) {
|
15
15
|
return;
|
@@ -17,7 +17,7 @@ HybridShadowRegistry.add = (handle, styles, variants, args, id) => {
|
|
17
17
|
|
18
18
|
// filter Reanimated styles and styles that are undefined
|
19
19
|
const filteredStyles = styles.filter(style => !style?.initial?.updater).filter(Boolean);
|
20
|
-
HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles
|
20
|
+
HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles);
|
21
21
|
};
|
22
22
|
HybridShadowRegistry.remove = handle => {
|
23
23
|
if (!handle) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","
|
1
|
+
{"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","_viewRef","viewRef","current","_nativeRef","Error","elementType","add","styles","Array","isArray","filteredStyles","filter","style","initial","updater","Boolean","link","remove","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAmBzD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACzED,MAAM,EAAEM,QAAQ,EAAEJ,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IAC3DD,MAAM,EAAEO,OAAO,EAAEC,OAAO,EAAEN,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACnED,MAAM,EAAES,UAAU,EAAEP,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEpE,IAAI,CAACA,IAAI,EAAE;IACP,MAAM,IAAIS,KAAK,CAAC,4EAA4EV,MAAM,EAAEE,wBAAwB,EAAES,WAAW,IAAI,SAAS,EAAE,CAAC;EAC7J;EAEA,OAAOV,IAAI;AACf,CAAC;AAEDJ,oBAAoB,CAACe,GAAG,GAAG,CAACZ,MAAM,EAAEa,MAAM,KAAK;EAC3C;EACA,IAAI,CAACb,MAAM,IAAI,CAACa,MAAM,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IAC9C;EACJ;;EAEA;EACA,MAAMG,cAAc,GAAGH,MAAM,CACxBI,MAAM,CAACC,KAAK,IAAI,CAACA,KAAK,EAAEC,OAAO,EAAEC,OAAO,CAAC,CACzCH,MAAM,CAACI,OAAO,CAAC;EAEpBxB,oBAAoB,CAACyB,IAAI,CAACvB,uBAAuB,CAACC,MAAM,CAAC,EAAEgB,cAAc,CAAC;AAC9E,CAAC;AAEDnB,oBAAoB,CAAC0B,MAAM,GAAGvB,MAAM,IAAI;EACpC,IAAI,CAACA,MAAM,EAAE;IACT;EACJ;EAEAH,oBAAoB,CAAC2B,MAAM,CAACzB,uBAAuB,CAACC,MAAM,CAAC,CAAC;AAChE,CAAC;AAQD,OAAO,MAAMyB,uBAAuB,GAAG5B,oBAA4D","ignoreList":[]}
|
@@ -1,11 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
import { StyleSheet } from './StyleSheet';
|
6
|
-
import { UnistylesShadowRegistry } from './ShadowRegistry';
|
7
|
-
import { StatusBarStyle, ColorScheme, Orientation } from './types';
|
8
|
-
import { UnistyleDependency } from './NativePlatform';
|
9
|
-
export { StatusBarStyle, ColorScheme, Orientation, UnistyleDependency };
|
10
|
-
export { UnistylesShadowRegistry, Runtime as UnistylesRuntime, StyleSheet };
|
3
|
+
export * from '../web';
|
4
|
+
export { UnistyleDependency } from './NativePlatform';
|
11
5
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["UnistyleDependency"],"sourceRoot":"../../../src","sources":["specs/index.ts"],"mappings":";;AAAA,cAAc,QAAQ;AAEtB,SAASA,kBAAkB,QAAQ,kBAAkB","ignoreList":[]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import './TurboUnistyles';
|
4
|
+
import { Runtime } from './UnistylesRuntime';
|
5
|
+
import { StyleSheet } from './StyleSheet';
|
6
|
+
import { UnistylesShadowRegistry } from './ShadowRegistry';
|
7
|
+
import { StatusBarStyle, ColorScheme, Orientation } from './types';
|
8
|
+
import { UnistyleDependency } from './NativePlatform';
|
9
|
+
export { StatusBarStyle, ColorScheme, Orientation, UnistyleDependency };
|
10
|
+
export { UnistylesShadowRegistry, Runtime as UnistylesRuntime, StyleSheet };
|
11
|
+
//# sourceMappingURL=index.native.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["Runtime","StyleSheet","UnistylesShadowRegistry","StatusBarStyle","ColorScheme","Orientation","UnistyleDependency","UnistylesRuntime"],"sourceRoot":"../../../src","sources":["specs/index.native.ts"],"mappings":";;AAAA,OAAO,kBAAkB;AAEzB,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,UAAU,QAAQ,cAAc;AAEzC,SAASC,uBAAuB,QAAQ,kBAAkB;AAE1D,SAASC,cAAc,EAAEC,WAAW,EAAEC,WAAW,QAAQ,SAAS;AAClE,SAASC,kBAAkB,QAAQ,kBAAkB;AAErD,SACIH,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,kBAAkB;AAGtB,SACIJ,uBAAuB,EACvBF,OAAO,IAAIO,gBAAgB,EAC3BN,UAAU","ignoreList":[]}
|
package/lib/module/web/create.js
CHANGED
@@ -1,52 +1,31 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
import { assignSecrets,
|
4
|
-
import { deepMergeObjects } from '../utils';
|
3
|
+
import { assignSecrets, error, removeInlineStyles } from './utils';
|
5
4
|
import { UnistylesRuntime } from './runtime';
|
6
|
-
import {
|
5
|
+
import { UnistylesShadowRegistry } from '../specs';
|
6
|
+
const useVariants = ['useVariants', variants => {
|
7
|
+
UnistylesShadowRegistry.selectVariants(variants);
|
8
|
+
}];
|
7
9
|
export const create = (stylesheet, id) => {
|
8
10
|
if (!id) {
|
9
11
|
throw error('Unistyles is not initialized correctly. Please add babel plugin to your babel config.');
|
10
12
|
}
|
11
13
|
const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : stylesheet;
|
12
|
-
const selectedVariants = new Map();
|
13
|
-
const copyVariants = () => Object.fromEntries(selectedVariants.entries());
|
14
14
|
const addSecrets = (value, key, args) => assignSecrets(value, {
|
15
15
|
__uni__key: key,
|
16
|
-
__uni__refs: new Set(),
|
17
16
|
__uni__stylesheet: stylesheet,
|
18
17
|
__uni__args: args,
|
19
|
-
|
18
|
+
__uni__refs: new Set()
|
20
19
|
});
|
21
|
-
const
|
22
|
-
const key = String(_key);
|
20
|
+
const styleSheetStyles = Object.entries(computedStylesheet).map(([key, value]) => {
|
23
21
|
if (typeof value === 'function') {
|
24
|
-
|
25
|
-
const result = value(...args);
|
26
|
-
|
27
|
-
|
28
|
-
}, copyVariants()));
|
29
|
-
const resultWithVariants = deepMergeObjects(result, variants[key] ?? {});
|
30
|
-
|
31
|
-
// Add secrets to result of dynamic styles function
|
32
|
-
return addSecrets(getStyles(resultWithVariants), key, args);
|
33
|
-
};
|
34
|
-
|
35
|
-
// Add secrets to dynamic styles function
|
36
|
-
return addSecrets(dynamicStyle, key);
|
22
|
+
return [key, (...args) => {
|
23
|
+
const result = removeInlineStyles(value(...args));
|
24
|
+
return addSecrets(result, key, args);
|
25
|
+
}];
|
37
26
|
}
|
38
|
-
|
39
|
-
// Add secrets to static styles
|
40
|
-
return addSecrets(getStyles(value), key);
|
41
|
-
});
|
42
|
-
|
43
|
-
// Inject useVariants hook to styles
|
44
|
-
Object.defineProperty(styles, 'useVariants', {
|
45
|
-
value: variants => {
|
46
|
-
Object.entries(variants).forEach(([key, value]) => selectedVariants.set(key, value));
|
47
|
-
},
|
48
|
-
configurable: false
|
27
|
+
return [key, addSecrets(removeInlineStyles(value), key)];
|
49
28
|
});
|
50
|
-
return
|
29
|
+
return Object.fromEntries(styleSheetStyles.concat([useVariants]));
|
51
30
|
};
|
52
31
|
//# sourceMappingURL=create.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["assignSecrets","
|
1
|
+
{"version":3,"names":["assignSecrets","error","removeInlineStyles","UnistylesRuntime","UnistylesShadowRegistry","useVariants","variants","selectVariants","create","stylesheet","id","computedStylesheet","theme","miniRuntime","addSecrets","value","key","args","__uni__key","__uni__stylesheet","__uni__args","__uni__refs","Set","styleSheetStyles","Object","entries","map","result","fromEntries","concat"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;AACA,SAASA,aAAa,EAAEC,KAAK,EAAEC,kBAAkB,QAAQ,SAAS;AAClE,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,UAAU;AAElD,MAAMC,WAAW,GAAG,CAAC,aAAa,EAAGC,QAA0C,IAAK;EAChFF,uBAAuB,CAACG,cAAc,CAACD,QAAQ,CAAC;AACpD,CAAC,CAAC;AAEF,OAAO,MAAME,MAAM,GAAGA,CAACC,UAAiD,EAAEC,EAAW,KAAK;EACtF,IAAI,CAACA,EAAE,EAAE;IACL,MAAMT,KAAK,CAAC,uFAAuF,CAAC;EACxG;EAEA,MAAMU,kBAAkB,GAAG,OAAOF,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACN,gBAAgB,CAACS,KAAK,EAAET,gBAAgB,CAACU,WAAW,CAAC,GAChEJ,UAAU;EAEhB,MAAMK,UAAU,GAAGA,CAACC,KAAU,EAAEC,GAAW,EAAEC,IAAiB,KAAKjB,aAAa,CAACe,KAAK,EAAE;IACpFG,UAAU,EAAEF,GAAG;IACfG,iBAAiB,EAAEV,UAAU;IAC7BW,WAAW,EAAEH,IAAI;IACjBI,WAAW,EAAE,IAAIC,GAAG,CAAC;EACzB,CAAC,CAAC;EAEF,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,OAAO,CAACd,kBAAkB,CAAC,CAACe,GAAG,CAAC,CAAC,CAACV,GAAG,EAAED,KAAK,CAAC,KAAK;IAC9E,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO,CAACC,GAAG,EAAE,CAAC,GAAGC,IAAgB,KAAK;QAClC,MAAMU,MAAM,GAAGzB,kBAAkB,CAACa,KAAK,CAAC,GAAGE,IAAI,CAAC,CAAC;QAEjD,OAAOH,UAAU,CAACa,MAAM,EAAEX,GAAG,EAAEC,IAAI,CAAC;MACxC,CAAC,CAAC;IACN;IAEA,OAAO,CAACD,GAAG,EAAEF,UAAU,CAACZ,kBAAkB,CAACa,KAAK,CAAC,EAAEC,GAAG,CAAC,CAAC;EAC5D,CAAC,CAAC;EAEF,OAAOQ,MAAM,CAACI,WAAW,CAACL,gBAAgB,CAACM,MAAM,CAAC,CAACxB,WAAW,CAAC,CAAC,CAAC;AACrE,CAAC","ignoreList":[]}
|
package/lib/module/web/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["create","UnistylesState","deepMergeObjects","StyleSheet","configure","init","absoluteFill","position","left","top","right","bottom","absoluteFillObject","compose","a","b","flatten","styles","hairlineWidth","UnistylesRuntime","UnistylesShadowRegistry"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,gBAAgB,QAAQ,UAAU;
|
1
|
+
{"version":3,"names":["create","UnistylesState","deepMergeObjects","StyleSheet","configure","init","absoluteFill","position","left","top","right","bottom","absoluteFillObject","compose","a","b","flatten","styles","hairlineWidth","UnistylesRuntime","UnistylesShadowRegistry"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,gBAAgB,QAAQ,UAAU;AAG3C,OAAO,MAAMC,UAAU,GAAG;EACtBC,SAAS,EAAEH,cAAc,CAACI,IAAI;EAC9BL,MAAM,EAAEA,MAAmC;EAC3CM,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,kBAAkB,EAAE;IAChBL,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDE,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAKb,gBAAgB,CAACY,CAAC,EAAEC,CAAC,CAAC;EACzDC,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAKf,gBAAgB,CAAC,GAAGe,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAED,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,cAAc,QAAQ","ignoreList":[]}
|