react-native-unistyles 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +30 -38
- package/android/CMakeLists.txt +27 -0
- package/android/build.gradle +75 -0
- package/android/src/main/cxx/cpp-adapter.cpp +132 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +189 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
- package/cxx/UnistylesRuntime.cpp +318 -0
- package/cxx/UnistylesRuntime.h +74 -0
- package/ios/UnistylesHelpers.h +3 -0
- package/ios/UnistylesHelpers.mm +5 -0
- package/ios/UnistylesModule.h +16 -0
- package/ios/UnistylesModule.mm +138 -0
- package/ios/platform/Platform_iOS.h +21 -0
- package/ios/platform/Platform_iOS.mm +132 -0
- package/ios/platform/Platform_macOS.h +20 -0
- package/ios/platform/Platform_macOS.mm +83 -0
- package/lib/commonjs/common.js +60 -0
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/core/UnistyleRegistry.js +94 -0
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/core/Unistyles.js +32 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.js +197 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.native.js +9 -0
- package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
- package/lib/commonjs/core/UnistylesRuntime.js +140 -0
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
- package/lib/commonjs/core/index.js +13 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/createStyleSheet.js +14 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -0
- package/lib/commonjs/global.js +2 -0
- package/lib/commonjs/global.js.map +1 -0
- package/lib/commonjs/hooks/index.js +24 -3
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.js +44 -0
- package/lib/commonjs/hooks/useCSS.js.map +1 -0
- package/lib/commonjs/hooks/useCSS.native.js +9 -0
- package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
- package/lib/commonjs/hooks/useInitialTheme.js +17 -0
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +64 -0
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
- package/lib/commonjs/hooks/useVariants.js +14 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/index.js +63 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/normalizer/index.js +32 -0
- package/lib/commonjs/normalizer/index.js.map +1 -0
- package/lib/commonjs/normalizer/module.d.js.map +1 -0
- package/lib/commonjs/{utils/normalizeStyles.web.js → normalizer/normalizeStyle.js} +5 -5
- package/lib/commonjs/normalizer/normalizeStyle.js.map +1 -0
- package/lib/commonjs/{utils → normalizer}/normalizer.js +2 -3
- package/lib/commonjs/normalizer/normalizer.js.map +1 -0
- package/lib/commonjs/normalizer/normalizer.macos.js +3 -0
- package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -0
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js +14 -0
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +1 -0
- package/lib/commonjs/plugins/index.js +20 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/commonjs/types/common.js +2 -0
- package/lib/{module/utils/module.d.js.map → commonjs/types/common.js.map} +1 -1
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/plugin.js +6 -0
- package/lib/commonjs/{utils/module.d.js.map → types/plugin.js.map} +1 -1
- package/lib/commonjs/types/stylesheet.js +6 -0
- package/lib/commonjs/types/{mediaQueries.js.map → stylesheet.js.map} +1 -1
- package/lib/commonjs/types/unistyles.js +6 -0
- package/lib/{module/types/mediaQueries.js.map → commonjs/types/unistyles.js.map} +1 -1
- package/lib/commonjs/types/variants.js +2 -0
- package/lib/commonjs/types/variants.js.map +1 -0
- package/lib/commonjs/useStyles.js +47 -0
- package/lib/commonjs/useStyles.js.map +1 -0
- package/lib/commonjs/utils/breakpoints.js +20 -122
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/cssMediaQuery.js +244 -0
- package/lib/commonjs/utils/cssMediaQuery.js.map +1 -0
- package/lib/commonjs/utils/generateId.js +15 -0
- package/lib/commonjs/utils/generateId.js.map +1 -0
- package/lib/commonjs/utils/hash32.js +43 -0
- package/lib/commonjs/utils/hash32.js.map +1 -0
- package/lib/commonjs/utils/index.js +22 -54
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +38 -0
- package/lib/commonjs/utils/mq.js.map +1 -0
- package/lib/commonjs/utils/mqParser.js +89 -0
- package/lib/commonjs/utils/mqParser.js.map +1 -0
- package/lib/commonjs/utils/styles.js +45 -72
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js +15 -0
- package/lib/commonjs/utils/withPlugins.js.map +1 -0
- package/lib/module/common.js +53 -0
- package/lib/module/common.js.map +1 -0
- package/lib/module/core/UnistyleRegistry.js +87 -0
- package/lib/module/core/UnistyleRegistry.js.map +1 -0
- package/lib/module/core/Unistyles.js +26 -0
- package/lib/module/core/Unistyles.js.map +1 -0
- package/lib/module/core/UnistylesModule.js +190 -0
- package/lib/module/core/UnistylesModule.js.map +1 -0
- package/lib/module/core/UnistylesModule.native.js +3 -0
- package/lib/module/core/UnistylesModule.native.js.map +1 -0
- package/lib/module/core/UnistylesRuntime.js +133 -0
- package/lib/module/core/UnistylesRuntime.js.map +1 -0
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/createStyleSheet.js +7 -0
- package/lib/module/createStyleSheet.js.map +1 -0
- package/lib/module/global.js +2 -0
- package/lib/module/global.js.map +1 -0
- package/lib/module/hooks/index.js +4 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useCSS.js +37 -0
- package/lib/module/hooks/useCSS.js.map +1 -0
- package/lib/module/hooks/useCSS.native.js +2 -0
- package/lib/module/hooks/useCSS.native.js.map +1 -0
- package/lib/module/hooks/useInitialTheme.js +10 -0
- package/lib/module/hooks/useInitialTheme.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +57 -0
- package/lib/module/hooks/useUnistyles.js.map +1 -0
- package/lib/module/hooks/useVariants.js +7 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/index.js +30 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizer/index.js +3 -0
- package/lib/module/normalizer/index.js.map +1 -0
- package/lib/module/normalizer/module.d.js.map +1 -0
- package/lib/module/{utils/normalizeStyles.web.js → normalizer/normalizeStyle.js} +3 -3
- package/lib/module/normalizer/normalizeStyle.js.map +1 -0
- package/lib/module/{utils → normalizer}/normalizer.js +2 -3
- package/lib/module/normalizer/normalizer.js.map +1 -0
- package/lib/module/normalizer/normalizer.macos.js +2 -0
- package/lib/module/normalizer/normalizer.macos.js.map +1 -0
- package/lib/module/plugins/cssMediaQueriesPlugin.js +7 -0
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +1 -0
- package/lib/module/plugins/index.js +3 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/plugin.js.map +1 -0
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/stylesheet.js.map +1 -0
- package/lib/module/types/unistyles.js +2 -0
- package/lib/module/types/unistyles.js.map +1 -0
- package/lib/module/types/variants.js +2 -0
- package/lib/module/types/variants.js.map +1 -0
- package/lib/module/useStyles.js +40 -0
- package/lib/module/useStyles.js.map +1 -0
- package/lib/module/utils/breakpoints.js +19 -120
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/cssMediaQuery.js +237 -0
- package/lib/module/utils/cssMediaQuery.js.map +1 -0
- package/lib/module/utils/generateId.js +7 -0
- package/lib/module/utils/generateId.js.map +1 -0
- package/lib/module/utils/hash32.js +36 -0
- package/lib/module/utils/hash32.js.map +1 -0
- package/lib/module/utils/index.js +6 -6
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +32 -0
- package/lib/module/utils/mq.js.map +1 -0
- package/lib/module/utils/mqParser.js +78 -0
- package/lib/module/utils/mqParser.js.map +1 -0
- package/lib/module/utils/styles.js +44 -72
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js +8 -0
- package/lib/module/utils/withPlugins.js.map +1 -0
- package/lib/typescript/src/common.d.ts +46 -0
- package/lib/typescript/src/common.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +56 -0
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/Unistyles.d.ts +13 -0
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts +19 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +81 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +3 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/createStyleSheet.d.ts +8 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
- package/lib/typescript/src/global.d.ts +7 -0
- package/lib/typescript/src/global.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +4 -1
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.d.ts +3 -0
- package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
- package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +14 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +76 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizer/index.d.ts +3 -0
- package/lib/typescript/src/normalizer/index.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts +3 -0
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts +1 -0
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +1 -0
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/plugins/index.d.ts +3 -0
- package/lib/typescript/src/plugins/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/types/breakpoints.d.ts +25 -17
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +3 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +11 -25
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/plugin.d.ts +7 -0
- package/lib/typescript/src/types/plugin.d.ts.map +1 -0
- package/lib/typescript/src/types/stylesheet.d.ts +40 -0
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +53 -0
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
- package/lib/typescript/src/types/variants.d.ts +14 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +16 -0
- package/lib/typescript/src/useStyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -62
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/cssMediaQuery.d.ts +4 -0
- package/lib/typescript/src/utils/cssMediaQuery.d.ts.map +1 -0
- package/lib/typescript/src/utils/generateId.d.ts +2 -0
- package/lib/typescript/src/utils/generateId.d.ts.map +1 -0
- package/lib/typescript/src/utils/hash32.d.ts +2 -0
- package/lib/typescript/src/utils/hash32.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +7 -6
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +26 -0
- package/lib/typescript/src/utils/mq.d.ts.map +1 -0
- package/lib/typescript/src/utils/mqParser.d.ts +16 -0
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts +3 -49
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
- package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
- package/package.json +46 -25
- package/react-native-unistyles.podspec +22 -0
- package/src/__tests__/mocks.ts +24 -0
- package/src/common.ts +55 -0
- package/src/core/UnistyleRegistry.ts +108 -0
- package/src/core/Unistyles.ts +35 -0
- package/src/core/UnistylesModule.native.ts +7 -0
- package/src/core/UnistylesModule.ts +230 -0
- package/src/core/UnistylesRuntime.ts +135 -0
- package/src/core/index.ts +2 -0
- package/src/createStyleSheet.ts +8 -0
- package/src/global.ts +6 -0
- package/src/hooks/index.ts +4 -1
- package/src/hooks/useCSS.native.ts +3 -0
- package/src/hooks/useCSS.ts +51 -0
- package/src/hooks/useInitialTheme.ts +11 -0
- package/src/hooks/useUnistyles.ts +64 -0
- package/src/hooks/useVariants.ts +10 -0
- package/src/index.ts +50 -2
- package/src/normalizer/index.ts +2 -0
- package/src/{utils/normalizeStyles.web.ts → normalizer/normalizeStyle.ts} +3 -3
- package/src/normalizer/normalizer.macos.ts +1 -0
- package/src/{utils → normalizer}/normalizer.ts +5 -4
- package/src/plugins/cssMediaQueriesPlugin.ts +8 -0
- package/src/plugins/index.ts +2 -0
- package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
- package/src/types/breakpoints.ts +58 -33
- package/src/types/common.ts +2 -0
- package/src/types/core.ts +11 -36
- package/src/types/index.ts +12 -7
- package/src/types/plugin.ts +7 -0
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +63 -0
- package/src/types/variants.ts +19 -0
- package/src/useStyles.ts +60 -0
- package/src/utils/breakpoints.ts +28 -124
- package/src/utils/cssMediaQuery.ts +268 -0
- package/src/utils/generateId.ts +10 -0
- package/src/utils/hash32.ts +53 -0
- package/src/utils/index.ts +7 -13
- package/src/utils/mq.ts +57 -0
- package/src/utils/mqParser.ts +99 -0
- package/src/utils/styles.ts +54 -102
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/UnistylesTheme.js +0 -21
- package/lib/commonjs/UnistylesTheme.js.map +0 -1
- package/lib/commonjs/createUnistyles.js +0 -57
- package/lib/commonjs/createUnistyles.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.js +0 -10
- package/lib/commonjs/hooks/useDimensions.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.web.js +0 -34
- package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
- package/lib/commonjs/types/mediaQueries.js +0 -2
- package/lib/commonjs/utils/common.js +0 -20
- package/lib/commonjs/utils/common.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.js +0 -189
- package/lib/commonjs/utils/mediaQueries.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.js +0 -10
- package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
- package/lib/commonjs/utils/normalizer.js.map +0 -1
- package/lib/module/UnistylesTheme.js +0 -12
- package/lib/module/UnistylesTheme.js.map +0 -1
- package/lib/module/createUnistyles.js +0 -50
- package/lib/module/createUnistyles.js.map +0 -1
- package/lib/module/hooks/useDimensions.js +0 -3
- package/lib/module/hooks/useDimensions.js.map +0 -1
- package/lib/module/hooks/useDimensions.web.js +0 -27
- package/lib/module/hooks/useDimensions.web.js.map +0 -1
- package/lib/module/types/mediaQueries.js +0 -2
- package/lib/module/utils/common.js +0 -12
- package/lib/module/utils/common.js.map +0 -1
- package/lib/module/utils/mediaQueries.js +0 -176
- package/lib/module/utils/mediaQueries.js.map +0 -1
- package/lib/module/utils/normalizeStyles.js +0 -3
- package/lib/module/utils/normalizeStyles.js.map +0 -1
- package/lib/module/utils/normalizeStyles.web.js.map +0 -1
- package/lib/module/utils/normalizer.js.map +0 -1
- package/lib/typescript/examples/expo/src/App.d.ts +0 -3
- package/lib/typescript/examples/expo/src/App.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +0 -7
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts +0 -3
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/examples/index.d.ts +0 -9
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/index.d.ts +0 -2
- package/lib/typescript/examples/expo/src/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +0 -8
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/index.d.ts +0 -46
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +0 -1
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +0 -24
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
- package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
- package/lib/typescript/src/createUnistyles.d.ts +0 -10
- package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
- package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/utils/common.d.ts +0 -7
- package/lib/typescript/src/utils/common.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
- package/src/UnistylesTheme.tsx +0 -17
- package/src/__tests__/createUnistyles.spec.tsx +0 -192
- package/src/createUnistyles.ts +0 -70
- package/src/hooks/useDimensions.ts +0 -4
- package/src/hooks/useDimensions.web.ts +0 -34
- package/src/types/mediaQueries.ts +0 -10
- package/src/utils/common.ts +0 -14
- package/src/utils/mediaQueries.ts +0 -201
- package/src/utils/normalizeStyles.ts +0 -2
- /package/lib/commonjs/{utils → normalizer}/module.d.js +0 -0
- /package/lib/module/{utils → normalizer}/module.d.js +0 -0
- /package/lib/typescript/src/{utils → normalizer}/normalizer.d.ts +0 -0
- /package/src/{utils → normalizer}/module.d.ts +0 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "cssMediaQueriesPlugin", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _cssMediaQueriesPlugin.cssMediaQueriesPlugin;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
Object.defineProperty(exports, "normalizeWebStylesPlugin", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () {
|
15
|
+
return _normalizeWebStylesPlugin.normalizeWebStylesPlugin;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
var _normalizeWebStylesPlugin = require("./normalizeWebStylesPlugin");
|
19
|
+
var _cssMediaQueriesPlugin = require("./cssMediaQueriesPlugin");
|
20
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizeWebStylesPlugin","require","_cssMediaQueriesPlugin"],"sourceRoot":"../../../src","sources":["plugins/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.normalizeWebStylesPlugin = void 0;
|
7
|
+
var _normalizer = require("../normalizer");
|
8
|
+
const normalizeWebStylesPlugin = exports.normalizeWebStylesPlugin = {
|
9
|
+
name: '__unistylesNormalizeWebStyles',
|
10
|
+
onParsedStyle: (_key, styles) => (0, _normalizer.normalizeStyle)(styles)
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=normalizeWebStylesPlugin.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizer","require","normalizeWebStylesPlugin","exports","name","onParsedStyle","_key","styles","normalizeStyle"],"sourceRoot":"../../../src","sources":["plugins/normalizeWebStylesPlugin.ts"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEO,MAAMC,wBAAyC,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACrDE,IAAI,EAAE,+BAA+B;EACrCC,aAAa,EAAEA,CAACC,IAAI,EAAEC,MAAM,KAAK,IAAAC,0BAAc,EAACD,MAAM;AAC1D,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/common.ts"],"mappings":""}
|
@@ -14,4 +14,15 @@ Object.keys(_normalizer).forEach(function (key) {
|
|
14
14
|
}
|
15
15
|
});
|
16
16
|
});
|
17
|
+
var _unistyles = require("./unistyles");
|
18
|
+
Object.keys(_unistyles).forEach(function (key) {
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
20
|
+
if (key in exports && exports[key] === _unistyles[key]) return;
|
21
|
+
Object.defineProperty(exports, key, {
|
22
|
+
enumerable: true,
|
23
|
+
get: function () {
|
24
|
+
return _unistyles[key];
|
25
|
+
}
|
26
|
+
});
|
27
|
+
});
|
17
28
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
1
|
+
{"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_unistyles"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/plugin.ts"],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/stylesheet.ts"],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/unistyles.ts"],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/variants.ts"],"mappings":""}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useStyles = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
var _reactNative = require("react-native");
|
9
|
+
var _utils = require("./utils");
|
10
|
+
var _hooks = require("./hooks");
|
11
|
+
var _core = require("./core");
|
12
|
+
var _common = require("./common");
|
13
|
+
/**
|
14
|
+
* Hook that enables all the features of Unistyles
|
15
|
+
* @param stylesheet - The stylesheet with superpowers to be used
|
16
|
+
* @param variantsMap - The map of variants to be used
|
17
|
+
* @returns - The theme, current breakpoint and RN compatible styles
|
18
|
+
*/
|
19
|
+
const useStyles = (stylesheet, variantsMap) => {
|
20
|
+
const {
|
21
|
+
theme,
|
22
|
+
layout,
|
23
|
+
plugins
|
24
|
+
} = (0, _hooks.useUnistyles)();
|
25
|
+
const variants = (0, _hooks.useVariants)(variantsMap);
|
26
|
+
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
|
27
|
+
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, [key, value]) => {
|
28
|
+
if (typeof value === 'function') {
|
29
|
+
return {
|
30
|
+
...acc,
|
31
|
+
[key]: (0, _utils.proxifyFunction)(key, value, variants)
|
32
|
+
};
|
33
|
+
}
|
34
|
+
return _reactNative.StyleSheet.create({
|
35
|
+
...acc,
|
36
|
+
[key]: (0, _utils.withPlugins)(key, (0, _utils.parseStyle)(value, variants, !_common.isWeb || !_core.unistyles.registry.config.experimentalCSSMediaQueries))
|
37
|
+
});
|
38
|
+
}, {}), [parsedStyles, variants, plugins]);
|
39
|
+
(0, _hooks.useCSS)(dynamicStyleSheet);
|
40
|
+
return {
|
41
|
+
theme,
|
42
|
+
breakpoint: layout.breakpoint,
|
43
|
+
styles: dynamicStyleSheet
|
44
|
+
};
|
45
|
+
};
|
46
|
+
exports.useStyles = useStyles;
|
47
|
+
//# sourceMappingURL=useStyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","_common","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","key","value","proxifyFunction","StyleSheet","create","withPlugins","parseStyle","isWeb","unistyles","registry","config","experimentalCSSMediaQueries","useCSS","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAGA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACjD,MAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAACN,WAAW,CAAC;EACzC,MAAMO,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOT,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMO,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAME,MAAM,CACzCC,OAAO,CAACJ,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BK,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IAC3B,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGF,GAAG;QACN,CAACC,GAAG,GAAG,IAAAE,sBAAe,EAACF,GAAG,EAAEC,KAAK,EAAEV,QAAQ;MAC/C,CAAC;IACL;IAEA,OAAOY,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGL,GAAG;MACN,CAACC,GAAG,GAAG,IAAAK,kBAAW,EAACL,GAAG,EAAE,IAAAM,iBAAU,EAC9BL,KAAK,EACLV,QAAQ,EACR,CAACgB,aAAK,IAAI,CAACC,eAAS,CAACC,QAAQ,CAACC,MAAM,CAACC,2BAA2B,CACpE;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAClB,YAAY,EAAEF,QAAQ,EAAEF,OAAO,CAC5C,CAAC;EAED,IAAAuB,aAAM,EAACjB,iBAA8C,CAAC;EAEtD,OAAO;IACHR,KAAK;IACL0B,UAAU,EAAEzB,MAAM,CAACyB,UAAU;IAC7BC,MAAM,EAAEnB;EACZ,CAAC;AACL,CAAC;AAAAoB,OAAA,CAAA/B,SAAA,GAAAA,SAAA"}
|
@@ -3,133 +3,31 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
7
|
-
var
|
8
|
-
var
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
* Additionally, it validates that:
|
15
|
-
* 1. The first breakpoint starts with a value of 0.
|
16
|
-
* 2. No duplicate breakpoint values exist.
|
17
|
-
*
|
18
|
-
* If the validation fails, appropriate error messages are logged to the console.
|
19
|
-
*
|
20
|
-
* @template B - An object type where keys are strings and values are numbers.
|
21
|
-
* @param {B} breakpoints - The breakpoints object to be sorted and validated.
|
22
|
-
* @returns {B} A new object with sorted and validated breakpoints.
|
23
|
-
*
|
24
|
-
* @example
|
25
|
-
* const input = { md: 768, lg: 1024, sm: 0 }
|
26
|
-
* sortAndValidateBreakpoints(input) // returns { sm: 0, md: 768, lg: 1024 }
|
27
|
-
*/
|
28
|
-
const sortAndValidateBreakpoints = breakpoints => {
|
29
|
-
const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
30
|
-
const [, value1] = breakpoint1;
|
31
|
-
const [, value2] = breakpoint2;
|
32
|
-
return value1 - value2;
|
33
|
-
});
|
34
|
-
const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
|
35
|
-
const breakpointValues = Object.values(sortedBreakpoints);
|
36
|
-
const [firstBreakpoint] = breakpointValues;
|
37
|
-
if (firstBreakpoint !== 0) {
|
38
|
-
(0, _common.throwError)('first breakpoint must start with 0');
|
6
|
+
exports.getValueForBreakpoint = void 0;
|
7
|
+
var _core = require("../core");
|
8
|
+
var _common = require("../common");
|
9
|
+
var _mqParser = require("./mqParser");
|
10
|
+
const getValueForBreakpoint = value => {
|
11
|
+
const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
|
12
|
+
if (customMediaQueryKey) {
|
13
|
+
return value[customMediaQueryKey];
|
39
14
|
}
|
40
|
-
|
41
|
-
|
15
|
+
const hasBreakpoints = _core.unistyles.registry.sortedBreakpointPairs.length > 0;
|
16
|
+
if (!hasBreakpoints && _common.isMobile && (_common.ScreenOrientation.Landscape in value || _common.ScreenOrientation.Portrait in value)) {
|
17
|
+
return value[_core.unistyles.runtime.orientation];
|
42
18
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Determines the appropriate breakpoint key for a given screen width based on provided breakpoints.
|
48
|
-
*
|
49
|
-
* This function takes a screen width and an object of breakpoints. It returns the key of the breakpoint
|
50
|
-
* that the screen width falls into. The breakpoints are assumed to be sorted in ascending order.
|
51
|
-
*
|
52
|
-
* @template B - An object type where keys are strings and values are numbers representing screen widths.
|
53
|
-
* @param {number} width - The screen width to determine the breakpoint for.
|
54
|
-
* @param breakpointEntries - sorted pairs of breakpoints
|
55
|
-
* @returns {keyof B & string} The key of the breakpoint that the screen width falls into.
|
56
|
-
*
|
57
|
-
* @example
|
58
|
-
* const breakpoints = { sm: 0, md: 768, lg: 1024 }
|
59
|
-
* getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
|
60
|
-
*/
|
61
|
-
exports.sortAndValidateBreakpoints = sortAndValidateBreakpoints;
|
62
|
-
const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
63
|
-
const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
|
64
|
-
let [, value] = _ref;
|
65
|
-
const minVal = value;
|
66
|
-
const maxVal = otherBreakpoints[index + 1]?.[1];
|
67
|
-
if (!maxVal) {
|
68
|
-
return true;
|
69
|
-
}
|
70
|
-
return width >= minVal && width < maxVal;
|
71
|
-
});
|
72
|
-
return key;
|
73
|
-
};
|
74
|
-
|
75
|
-
/**
|
76
|
-
* Retrieves the value associated with a given breakpoint or custom media query based on the provided screen size.
|
77
|
-
*
|
78
|
-
* The function first checks for custom media queries. If a matching custom media query is found, its associated value is returned.
|
79
|
-
* If no custom media query matches, the function then checks for a direct breakpoint match.
|
80
|
-
* If there's no direct breakpoint match, the function simulates CSS cascading to find the closest matching breakpoint.
|
81
|
-
*
|
82
|
-
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
83
|
-
*
|
84
|
-
* @param {Record<keyof B & string, string | number>} value - An object containing values associated with breakpoints or custom media queries.
|
85
|
-
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
86
|
-
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
87
|
-
* @param breakpointPairs - sorted pairs of breakpoints
|
88
|
-
*
|
89
|
-
* @returns {string | number | undefined} Returns the value associated with the matching breakpoint or custom media query, or `undefined` if no match is found.
|
90
|
-
*
|
91
|
-
* @example
|
92
|
-
*
|
93
|
-
* const values = { ':w[200]': 'value1', sm: 'value2', md: 'value3' }
|
94
|
-
* const screenSize = { width: 250, height: 400 }
|
95
|
-
* const breakpoints = { sm: 300, md: 600, lg: 900 }
|
96
|
-
*
|
97
|
-
* getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
|
98
|
-
*/
|
99
|
-
exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
|
100
|
-
const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointPairs) => {
|
101
|
-
// the highest priority is for custom media queries
|
102
|
-
const customMediaQueries = Object.entries(value).filter(_ref2 => {
|
103
|
-
let [key] = _ref2;
|
104
|
-
return (0, _mediaQueries.isMediaQuery)(key);
|
105
|
-
});
|
106
|
-
const customMediaQueryKey = (0, _mediaQueries.getKeyForCustomMediaQuery)(customMediaQueries, screenSize);
|
107
|
-
if (customMediaQueryKey && customMediaQueryKey in value) {
|
108
|
-
return value[customMediaQueryKey];
|
19
|
+
const breakpoint = _core.unistyles.runtime.breakpoint;
|
20
|
+
if (!breakpoint) {
|
21
|
+
return undefined;
|
109
22
|
}
|
110
|
-
|
111
|
-
|
112
|
-
const unifiedKey = breakpoint;
|
113
|
-
const directBreakpoint = value[unifiedKey];
|
114
|
-
|
115
|
-
// if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
|
116
|
-
if (directBreakpoint || unifiedKey in value) {
|
23
|
+
const directBreakpoint = value[breakpoint];
|
24
|
+
if (directBreakpoint || breakpoint in value) {
|
117
25
|
return directBreakpoint;
|
118
26
|
}
|
119
|
-
|
120
|
-
|
121
|
-
const
|
122
|
-
|
123
|
-
return key === unifiedKey;
|
124
|
-
});
|
125
|
-
const availableBreakpoints = breakpointPairs.filter((_ref4, index) => {
|
126
|
-
let [key] = _ref4;
|
127
|
-
return index < currentBreakpoint && key && key in value;
|
128
|
-
}).map(_ref5 => {
|
129
|
-
let [key] = _ref5;
|
130
|
-
return key;
|
131
|
-
});
|
132
|
-
return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
|
27
|
+
const breakpointPairs = _core.unistyles.registry.sortedBreakpointPairs;
|
28
|
+
const currentBreakpointIndex = breakpointPairs.findIndex(([key]) => key === breakpoint);
|
29
|
+
const availableBreakpoints = breakpointPairs.filter(([key], index) => index < currentBreakpointIndex && key in value).map(([key]) => key);
|
30
|
+
return value[availableBreakpoints[availableBreakpoints.length - 1]];
|
133
31
|
};
|
134
32
|
exports.getValueForBreakpoint = getValueForBreakpoint;
|
135
33
|
//# sourceMappingURL=breakpoints.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_core","require","_common","_mqParser","getValueForBreakpoint","value","customMediaQueryKey","getKeyForUnistylesMediaQuery","Object","entries","unistyles","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","isMobile","ScreenOrientation","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","key","availableBreakpoints","filter","index","map","exports"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAG,IAAAC,sCAA4B,EACpDC,MAAM,CAACC,OAAO,CAACJ,KAAK,CAAC,EACrBK,eAAS,CAACC,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIN,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMO,cAAc,GAAGH,eAAS,CAACI,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAII,gBAAQ,KAAKC,yBAAiB,CAACC,SAAS,IAAId,KAAK,IAAIa,yBAAiB,CAACE,QAAQ,IAAIf,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACK,eAAS,CAACC,OAAO,CAACU,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGZ,eAAS,CAACC,OAAO,CAACW,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGnB,KAAK,CAACiB,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIjB,KAAM,EAAE;IAC3C,OAAOmB,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGf,eAAS,CAACI,QAAQ,CAACC,qBAAqB;EAChE,MAAMW,sBAAsB,GAAGD,eAAe,CACzCE,SAAS,CAAC,CAAC,CAACC,GAAG,CAAC,KAAKA,GAAG,KAAKN,UAAU,CAAC;EAE7C,MAAMO,oBAAoB,GAAGJ,eAAe,CACvCK,MAAM,CAAC,CAAC,CAACF,GAAG,CAAC,EAAEG,KAAK,KAAKA,KAAK,GAAGL,sBAAsB,IAAIE,GAAG,IAAIvB,KAAK,CAAC,CACxE2B,GAAG,CAAC,CAAC,CAACJ,GAAG,CAAC,KAAKA,GAAG,CAAC;EAExB,OAAOvB,KAAK,CAACwB,oBAAoB,CAACA,oBAAoB,CAACb,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC;AAAAiB,OAAA,CAAA7B,qBAAA,GAAAA,qBAAA"}
|
@@ -0,0 +1,244 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createMediaQueryForStyles = void 0;
|
7
|
+
var _normalizer = require("../normalizer");
|
8
|
+
var _mqParser = require("./mqParser");
|
9
|
+
var _generateId = require("./generateId");
|
10
|
+
const createMediaQueryForStyles = (styles, runtime) => {
|
11
|
+
const withMediaQueries = Object.entries(styles).filter(([, value]) => typeof value === 'object').reduce((acc, [prop, value]) => {
|
12
|
+
const objectKeys = Object.keys(value);
|
13
|
+
const mediaQueries = objectKeys.filter(key => (0, _mqParser.isUnistylesMq)(key));
|
14
|
+
const breakpoints = objectKeys.filter(key => runtime.breakpoints[key]);
|
15
|
+
if (mediaQueries.length === 0 && breakpoints.length === 0) {
|
16
|
+
return acc;
|
17
|
+
}
|
18
|
+
const className = (0, _generateId.generateReactNativeWebId)(prop, '""');
|
19
|
+
const breakpointsStyles = getBreakpointsStyles(prop, value, runtime, className);
|
20
|
+
const mediaQueriesStyles = getMediaQueriesFromMQ(prop, value, className);
|
21
|
+
return {
|
22
|
+
...acc,
|
23
|
+
[prop]: `
|
24
|
+
${breakpointsStyles}
|
25
|
+
${mediaQueriesStyles}
|
26
|
+
`.trim()
|
27
|
+
};
|
28
|
+
}, {});
|
29
|
+
return {
|
30
|
+
...styles,
|
31
|
+
...withMediaQueries
|
32
|
+
};
|
33
|
+
};
|
34
|
+
exports.createMediaQueryForStyles = createMediaQueryForStyles;
|
35
|
+
const getMaxWidthMediaQuery = width => {
|
36
|
+
if (!width) {
|
37
|
+
return '';
|
38
|
+
}
|
39
|
+
if (width.to === Infinity) {
|
40
|
+
return '';
|
41
|
+
}
|
42
|
+
return `and (max-width: ${width.to}px)`;
|
43
|
+
};
|
44
|
+
const getMaxHeightMediaQuery = height => {
|
45
|
+
if (!height) {
|
46
|
+
return '';
|
47
|
+
}
|
48
|
+
if (height.to === Infinity) {
|
49
|
+
return '';
|
50
|
+
}
|
51
|
+
return `and (max-height: ${height.to}px)`;
|
52
|
+
};
|
53
|
+
const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, [key, value]) => {
|
54
|
+
const result = (0, _mqParser.parseMq)(key);
|
55
|
+
if (!(0, _mqParser.isValidMq)(result)) {
|
56
|
+
return acc;
|
57
|
+
}
|
58
|
+
if (result.width && result.height) {
|
59
|
+
return `${acc}
|
60
|
+
|
61
|
+
@media screen and (min-width: ${result.width.from}px) and (min-height: ${result.height.from}px) ${getMaxWidthMediaQuery(result.width)} ${getMaxHeightMediaQuery(result.height)} {
|
62
|
+
.${className} {
|
63
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
64
|
+
}
|
65
|
+
}
|
66
|
+
`;
|
67
|
+
}
|
68
|
+
if (result.width) {
|
69
|
+
return `${acc}
|
70
|
+
|
71
|
+
@media screen and (min-width: ${result.width.from}px) ${getMaxWidthMediaQuery(result.width)} {
|
72
|
+
.${className} {
|
73
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
74
|
+
}
|
75
|
+
}
|
76
|
+
`;
|
77
|
+
}
|
78
|
+
if (result.height) {
|
79
|
+
return `${acc}
|
80
|
+
|
81
|
+
@media screen and (min-height: ${result.height.from}px) ${getMaxHeightMediaQuery(result.height)} {
|
82
|
+
.${className} {
|
83
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
84
|
+
}
|
85
|
+
}
|
86
|
+
`;
|
87
|
+
}
|
88
|
+
return acc;
|
89
|
+
}, '');
|
90
|
+
const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, [key, value]) => {
|
91
|
+
const breakpoint = runtime.breakpoints[key];
|
92
|
+
if (breakpoint === undefined) {
|
93
|
+
return acc;
|
94
|
+
}
|
95
|
+
return `${acc}
|
96
|
+
|
97
|
+
@media screen and (min-width: ${breakpoint}px) {
|
98
|
+
.${className} {
|
99
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
100
|
+
}
|
101
|
+
}
|
102
|
+
`;
|
103
|
+
}, '');
|
104
|
+
const normalizePropName = prop => prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
105
|
+
const normalizeWebValue = (prop, value) => {
|
106
|
+
if (value === undefined) {
|
107
|
+
return 'unset';
|
108
|
+
}
|
109
|
+
switch (prop) {
|
110
|
+
// colors
|
111
|
+
case 'color':
|
112
|
+
case 'backgroundColor':
|
113
|
+
case 'borderColor':
|
114
|
+
case 'borderBottomColor':
|
115
|
+
case 'borderLeftColor':
|
116
|
+
case 'borderRightColor':
|
117
|
+
case 'borderTopColor':
|
118
|
+
case 'borderBlockColor':
|
119
|
+
case 'borderBlockEndColor':
|
120
|
+
case 'borderBlockStartColor':
|
121
|
+
case 'textDecorationColor':
|
122
|
+
return (0, _normalizer.normalizeColor)(value);
|
123
|
+
|
124
|
+
// dimensions
|
125
|
+
case 'width':
|
126
|
+
case 'height':
|
127
|
+
case 'minWidth':
|
128
|
+
case 'minHeight':
|
129
|
+
case 'maxWidth':
|
130
|
+
case 'maxHeight':
|
131
|
+
case 'borderRadius':
|
132
|
+
case 'borderWidth':
|
133
|
+
case 'borderBottomLeftRadius':
|
134
|
+
case 'borderBottomRightRadius':
|
135
|
+
case 'borderEndEndRadius':
|
136
|
+
case 'borderEndStartRadius':
|
137
|
+
case 'borderStartEndRadius':
|
138
|
+
case 'borderStartStartRadius':
|
139
|
+
case 'borderTopLeftRadius':
|
140
|
+
case 'borderTopRightRadius':
|
141
|
+
case 'borderBottomWidth':
|
142
|
+
case 'borderLeftWidth':
|
143
|
+
case 'borderRightWidth':
|
144
|
+
case 'borderTopWidth':
|
145
|
+
case 'bottom':
|
146
|
+
case 'left':
|
147
|
+
case 'right':
|
148
|
+
case 'top':
|
149
|
+
case 'marginTop':
|
150
|
+
case 'marginBottom':
|
151
|
+
case 'marginLeft':
|
152
|
+
case 'marginRight':
|
153
|
+
case 'paddingTop':
|
154
|
+
case 'paddingBottom':
|
155
|
+
case 'paddingLeft':
|
156
|
+
case 'paddingRight':
|
157
|
+
case 'flexBasis':
|
158
|
+
case 'rowGap':
|
159
|
+
case 'columnGap':
|
160
|
+
case 'gap':
|
161
|
+
case 'margin':
|
162
|
+
case 'padding':
|
163
|
+
case 'fontSize':
|
164
|
+
case 'letterSpacing':
|
165
|
+
return `${value}px`;
|
166
|
+
|
167
|
+
// without unit
|
168
|
+
case 'borderStyle':
|
169
|
+
case 'pointerEvents':
|
170
|
+
case 'backfaceVisibility':
|
171
|
+
case 'alignContent':
|
172
|
+
case 'alignItems':
|
173
|
+
case 'alignSelf':
|
174
|
+
case 'flexDirection':
|
175
|
+
case 'flexWrap':
|
176
|
+
case 'flex':
|
177
|
+
case 'aspectRatio':
|
178
|
+
case 'opacity':
|
179
|
+
case 'direction':
|
180
|
+
case 'zIndex':
|
181
|
+
case 'justifyContent':
|
182
|
+
case 'overflow':
|
183
|
+
case 'display':
|
184
|
+
case 'position':
|
185
|
+
case 'flexGrow':
|
186
|
+
case 'flexShrink':
|
187
|
+
case 'fontFamily':
|
188
|
+
case 'fontStyle':
|
189
|
+
case 'textDecorationLine':
|
190
|
+
case 'textAlign':
|
191
|
+
case 'textDecorationStyle':
|
192
|
+
case 'lineHeight':
|
193
|
+
case 'textTransform':
|
194
|
+
case 'fontVariant':
|
195
|
+
case 'verticalAlign':
|
196
|
+
case 'objectFit':
|
197
|
+
return value;
|
198
|
+
|
199
|
+
// to be transformed for now
|
200
|
+
// not supported
|
201
|
+
case 'marginHorizontal':
|
202
|
+
case 'paddingHorizontal':
|
203
|
+
case 'marginVertical':
|
204
|
+
case 'paddingVertical':
|
205
|
+
case 'shadowColor':
|
206
|
+
case 'shadowOffset':
|
207
|
+
case 'shadowOpacity':
|
208
|
+
case 'shadowRadius':
|
209
|
+
case 'transform':
|
210
|
+
case 'transformMatrix':
|
211
|
+
case 'fontWeight':
|
212
|
+
case 'textShadowOffset':
|
213
|
+
case 'textShadowRadius':
|
214
|
+
case 'textShadowColor':
|
215
|
+
return '';
|
216
|
+
|
217
|
+
// unsupported
|
218
|
+
case 'borderStartColor':
|
219
|
+
case 'borderEndColor':
|
220
|
+
case 'borderEndWidth':
|
221
|
+
case 'borderBottomEndRadius':
|
222
|
+
case 'borderBottomStartRadius':
|
223
|
+
case 'borderCurve':
|
224
|
+
case 'elevation':
|
225
|
+
case 'borderTopEndRadius':
|
226
|
+
case 'borderTopStartRadius':
|
227
|
+
case 'borderStartWidth':
|
228
|
+
case 'start':
|
229
|
+
case 'end':
|
230
|
+
case 'margin-end':
|
231
|
+
case 'margin-start':
|
232
|
+
case 'padding-end':
|
233
|
+
case 'padding-start':
|
234
|
+
case 'writingDirection':
|
235
|
+
case 'textAlignVertical':
|
236
|
+
case 'includeFontPadding':
|
237
|
+
case 'resizeMode':
|
238
|
+
case 'overlayColor':
|
239
|
+
case 'tintColor':
|
240
|
+
default:
|
241
|
+
return '';
|
242
|
+
}
|
243
|
+
};
|
244
|
+
//# sourceMappingURL=cssMediaQuery.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizer","require","_mqParser","_generateId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","value","reduce","acc","prop","objectKeys","keys","mediaQueries","key","isUnistylesMq","breakpoints","length","className","generateReactNativeWebId","breakpointsStyles","getBreakpointsStyles","mediaQueriesStyles","getMediaQueriesFromMQ","trim","exports","getMaxWidthMediaQuery","width","to","Infinity","getMaxHeightMediaQuery","height","result","parseMq","isValidMq","from","normalizePropName","normalizeWebValue","breakpoint","undefined","replace","toLowerCase","normalizeColor"],"sourceRoot":"../../../src","sources":["utils/cssMediaQuery.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAGO,MAAMG,yBAAyB,GAAGA,CAACC,MAAe,EAAEC,OAAyB,KAAc;EAC9F,MAAMC,gBAAgB,GAAGC,MAAM,CAC1BC,OAAO,CAACJ,MAAM,CAAC,CACfK,MAAM,CAAC,CAAC,GAAGC,KAAK,CAAC,KAAK,OAAOA,KAAK,KAAK,QAAQ,CAAC,CAChDC,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,IAAI,EAAEH,KAAK,CAAC,KAAK;IAC5B,MAAMI,UAAU,GAAGP,MAAM,CAACQ,IAAI,CAACL,KAAK,CAAC;IACrC,MAAMM,YAAY,GAAGF,UAAU,CAACL,MAAM,CAACQ,GAAG,IAAI,IAAAC,uBAAa,EAACD,GAAG,CAAC,CAAC;IACjE,MAAME,WAAW,GAAGL,UAAU,CAACL,MAAM,CAACQ,GAAG,IAAIZ,OAAO,CAACc,WAAW,CAACF,GAAG,CAAqC,CAAC;IAE1G,IAAID,YAAY,CAACI,MAAM,KAAK,CAAC,IAAID,WAAW,CAAC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A;IACA,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,gBAAgB;IACrB,KAAK,iBAAiB;IACtB,KAAK,aAAa;IAClB,KAAK,cAAc;IACnB,KAAK,eAAe;IACpB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB,KAAK,iBAAiB;IACtB,KAAK,YAAY;IACjB,KAAK,kBAAkB;IACvB,KAAK,kBAAkB;IACvB,KAAK,iBAAiB;MAClB,OAAO,EAAE;;IAEb;IACA,KAAK,kBAAkB;IACvB,KAAK,gBAAgB;IACrB,KAAK,gBAAgB;IACrB,KAAK,uBAAuB;IAC5B,KAAK,yBAAyB;IAC9B,KAAK,aAAa;IAClB,KAAK,WAAW;IAChB,KAAK,oBAAoB;IACzB,KAAK,sBAAsB;IAC3B,KAAK,kBAAkB;IACvB,KAAK,OAAO;IACZ,KAAK,KAAK;IACV,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,aAAa;IAClB,KAAK,eAAe;IACpB,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,oBAAoB;IACzB,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB;MACI,OAAO,EAAE;EACjB;AACJ,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.generateReactNativeWebId = void 0;
|
7
|
+
var _hash = require("./hash32");
|
8
|
+
// eslint-disable-next-line camelcase
|
9
|
+
|
10
|
+
const generateReactNativeWebId = (key, value) => {
|
11
|
+
const hashedString = (0, _hash.murmurhash2_32_gc)(key + value, 1).toString(36);
|
12
|
+
return process.env.NODE_ENV !== 'production' ? `r-${key}-${hashedString}` : `r-${hashedString}`;
|
13
|
+
};
|
14
|
+
exports.generateReactNativeWebId = generateReactNativeWebId;
|
15
|
+
//# sourceMappingURL=generateId.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_hash","require","generateReactNativeWebId","key","value","hashedString","murmurhash2_32_gc","toString","process","env","NODE_ENV","exports"],"sourceRoot":"../../../src","sources":["utils/generateId.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA;;AAGO,MAAMC,wBAAwB,GAAGA,CAACC,GAAW,EAAEC,KAAa,KAAa;EAC5E,MAAMC,YAAY,GAAG,IAAAC,uBAAiB,EAACH,GAAG,GAAGC,KAAK,EAAE,CAAC,CAAC,CAACG,QAAQ,CAAC,EAAE,CAAC;EAEnE,OAAOC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACrC,KAAIP,GAAI,IAAGE,YAAa,EAAC,GACzB,KAAIA,YAAa,EAAC;AAC7B,CAAC;AAAAM,OAAA,CAAAT,wBAAA,GAAAA,wBAAA"}
|