react-native-unistyles 1.3.0 → 1.4.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 +38 -30
- package/lib/commonjs/UnistylesTheme.js +21 -0
- package/lib/commonjs/UnistylesTheme.js.map +1 -0
- package/lib/commonjs/createUnistyles.js +57 -0
- package/lib/commonjs/createUnistyles.js.map +1 -0
- package/lib/commonjs/hooks/index.js +3 -24
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useDimensions.js +10 -0
- package/lib/commonjs/hooks/useDimensions.js.map +1 -0
- package/lib/commonjs/hooks/useDimensions.web.js +34 -0
- package/lib/commonjs/hooks/useDimensions.web.js.map +1 -0
- package/lib/commonjs/index.js +6 -63
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/index.js +0 -11
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/mediaQueries.js +2 -0
- package/lib/commonjs/types/{unistyles.js.map → mediaQueries.js.map} +1 -1
- package/lib/commonjs/utils/breakpoints.js +122 -20
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/common.js +20 -0
- package/lib/commonjs/utils/common.js.map +1 -0
- package/lib/commonjs/utils/index.js +54 -22
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mediaQueries.js +189 -0
- package/lib/commonjs/utils/mediaQueries.js.map +1 -0
- package/lib/{module/types/common.js.map → commonjs/utils/module.d.js.map} +1 -1
- package/lib/commonjs/utils/normalizeStyles.js +10 -0
- package/lib/commonjs/utils/normalizeStyles.js.map +1 -0
- package/lib/commonjs/{normalizer/normalizeStyle.js → utils/normalizeStyles.web.js} +5 -5
- package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -0
- package/lib/commonjs/{normalizer → utils}/normalizer.js +3 -2
- package/lib/commonjs/utils/normalizer.js.map +1 -0
- package/lib/commonjs/utils/styles.js +72 -45
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/UnistylesTheme.js +12 -0
- package/lib/module/UnistylesTheme.js.map +1 -0
- package/lib/module/createUnistyles.js +50 -0
- package/lib/module/createUnistyles.js.map +1 -0
- package/lib/module/hooks/index.js +1 -4
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useDimensions.js +3 -0
- package/lib/module/hooks/useDimensions.js.map +1 -0
- package/lib/module/hooks/useDimensions.web.js +27 -0
- package/lib/module/hooks/useDimensions.web.js.map +1 -0
- package/lib/module/index.js +2 -30
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/index.js +0 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/mediaQueries.js +2 -0
- package/lib/{commonjs/types/stylesheet.js.map → module/types/mediaQueries.js.map} +1 -1
- package/lib/module/utils/breakpoints.js +120 -19
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/common.js +12 -0
- package/lib/module/utils/common.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/mediaQueries.js +176 -0
- package/lib/module/utils/mediaQueries.js.map +1 -0
- package/lib/{commonjs/types/variants.js.map → module/utils/module.d.js.map} +1 -1
- package/lib/module/utils/normalizeStyles.js +3 -0
- package/lib/module/utils/normalizeStyles.js.map +1 -0
- package/lib/module/{normalizer/normalizeStyle.js → utils/normalizeStyles.web.js} +3 -3
- package/lib/module/utils/normalizeStyles.web.js.map +1 -0
- package/lib/module/{normalizer → utils}/normalizer.js +3 -2
- package/lib/module/utils/normalizer.js.map +1 -0
- package/lib/module/utils/styles.js +72 -44
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/examples/expo/src/App.d.ts +3 -0
- package/lib/typescript/examples/expo/src/App.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +7 -0
- package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts +9 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/index.d.ts +2 -0
- package/lib/typescript/examples/expo/src/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +8 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts +46 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +24 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesTheme.d.ts +9 -0
- package/lib/typescript/src/UnistylesTheme.d.ts.map +1 -0
- package/lib/typescript/src/createUnistyles.d.ts +10 -0
- package/lib/typescript/src/createUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +1 -4
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts +3 -0
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDimensions.web.d.ts +3 -0
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -76
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +17 -25
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +25 -11
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -7
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +8 -0
- package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -0
- package/lib/typescript/src/utils/breakpoints.d.ts +62 -2
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/common.d.ts +7 -0
- package/lib/typescript/src/utils/common.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +6 -7
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +130 -0
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeStyles.d.ts +2 -0
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +5 -0
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -0
- package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts +49 -3
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +25 -46
- package/src/UnistylesTheme.tsx +17 -0
- package/src/__tests__/createUnistyles.spec.tsx +192 -0
- package/src/createUnistyles.ts +70 -0
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useDimensions.ts +4 -0
- package/src/hooks/useDimensions.web.ts +34 -0
- package/src/index.ts +2 -50
- package/src/types/breakpoints.ts +33 -58
- package/src/types/core.ts +36 -11
- package/src/types/index.ts +7 -12
- package/src/types/mediaQueries.ts +10 -0
- package/src/utils/breakpoints.ts +124 -28
- package/src/utils/common.ts +14 -0
- package/src/utils/index.ts +13 -7
- package/src/utils/mediaQueries.ts +201 -0
- package/src/utils/normalizeStyles.ts +2 -0
- package/src/{normalizer/normalizeStyle.ts → utils/normalizeStyles.web.ts} +3 -3
- package/src/{normalizer → utils}/normalizer.ts +4 -5
- package/src/utils/styles.ts +102 -54
- package/android/CMakeLists.txt +0 -27
- package/android/build.gradle +0 -75
- package/android/src/main/cxx/cpp-adapter.cpp +0 -132
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +0 -189
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +0 -18
- package/cxx/UnistylesRuntime.cpp +0 -318
- package/cxx/UnistylesRuntime.h +0 -74
- package/ios/UnistylesHelpers.h +0 -3
- package/ios/UnistylesHelpers.mm +0 -5
- package/ios/UnistylesModule.h +0 -16
- package/ios/UnistylesModule.mm +0 -138
- package/ios/platform/Platform_iOS.h +0 -21
- package/ios/platform/Platform_iOS.mm +0 -132
- package/ios/platform/Platform_macOS.h +0 -20
- package/ios/platform/Platform_macOS.mm +0 -83
- package/lib/commonjs/common.js +0 -60
- package/lib/commonjs/common.js.map +0 -1
- package/lib/commonjs/core/UnistyleRegistry.js +0 -94
- package/lib/commonjs/core/UnistyleRegistry.js.map +0 -1
- package/lib/commonjs/core/Unistyles.js +0 -32
- package/lib/commonjs/core/Unistyles.js.map +0 -1
- package/lib/commonjs/core/UnistylesModule.js +0 -197
- package/lib/commonjs/core/UnistylesModule.js.map +0 -1
- package/lib/commonjs/core/UnistylesModule.native.js +0 -9
- package/lib/commonjs/core/UnistylesModule.native.js.map +0 -1
- package/lib/commonjs/core/UnistylesRuntime.js +0 -140
- package/lib/commonjs/core/UnistylesRuntime.js.map +0 -1
- package/lib/commonjs/core/index.js +0 -13
- package/lib/commonjs/core/index.js.map +0 -1
- package/lib/commonjs/createStyleSheet.js +0 -14
- package/lib/commonjs/createStyleSheet.js.map +0 -1
- package/lib/commonjs/global.js +0 -2
- package/lib/commonjs/global.js.map +0 -1
- package/lib/commonjs/hooks/useCSS.js +0 -44
- package/lib/commonjs/hooks/useCSS.js.map +0 -1
- package/lib/commonjs/hooks/useCSS.native.js +0 -9
- package/lib/commonjs/hooks/useCSS.native.js.map +0 -1
- package/lib/commonjs/hooks/useInitialTheme.js +0 -17
- package/lib/commonjs/hooks/useInitialTheme.js.map +0 -1
- package/lib/commonjs/hooks/useUnistyles.js +0 -64
- package/lib/commonjs/hooks/useUnistyles.js.map +0 -1
- package/lib/commonjs/hooks/useVariants.js +0 -14
- package/lib/commonjs/hooks/useVariants.js.map +0 -1
- package/lib/commonjs/normalizer/index.js +0 -32
- package/lib/commonjs/normalizer/index.js.map +0 -1
- package/lib/commonjs/normalizer/module.d.js.map +0 -1
- package/lib/commonjs/normalizer/normalizeStyle.js.map +0 -1
- package/lib/commonjs/normalizer/normalizer.js.map +0 -1
- package/lib/commonjs/normalizer/normalizer.macos.js +0 -3
- package/lib/commonjs/normalizer/normalizer.macos.js.map +0 -1
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js +0 -14
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +0 -1
- package/lib/commonjs/plugins/index.js +0 -20
- package/lib/commonjs/plugins/index.js.map +0 -1
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +0 -12
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +0 -1
- package/lib/commonjs/types/common.js +0 -2
- package/lib/commonjs/types/common.js.map +0 -1
- package/lib/commonjs/types/plugin.js +0 -6
- package/lib/commonjs/types/plugin.js.map +0 -1
- package/lib/commonjs/types/stylesheet.js +0 -6
- package/lib/commonjs/types/unistyles.js +0 -6
- package/lib/commonjs/types/variants.js +0 -2
- package/lib/commonjs/useStyles.js +0 -47
- package/lib/commonjs/useStyles.js.map +0 -1
- package/lib/commonjs/utils/cssMediaQuery.js +0 -244
- package/lib/commonjs/utils/cssMediaQuery.js.map +0 -1
- package/lib/commonjs/utils/generateId.js +0 -15
- package/lib/commonjs/utils/generateId.js.map +0 -1
- package/lib/commonjs/utils/hash32.js +0 -43
- package/lib/commonjs/utils/hash32.js.map +0 -1
- package/lib/commonjs/utils/mq.js +0 -38
- package/lib/commonjs/utils/mq.js.map +0 -1
- package/lib/commonjs/utils/mqParser.js +0 -89
- package/lib/commonjs/utils/mqParser.js.map +0 -1
- package/lib/commonjs/utils/withPlugins.js +0 -15
- package/lib/commonjs/utils/withPlugins.js.map +0 -1
- package/lib/module/common.js +0 -53
- package/lib/module/common.js.map +0 -1
- package/lib/module/core/UnistyleRegistry.js +0 -87
- package/lib/module/core/UnistyleRegistry.js.map +0 -1
- package/lib/module/core/Unistyles.js +0 -26
- package/lib/module/core/Unistyles.js.map +0 -1
- package/lib/module/core/UnistylesModule.js +0 -190
- package/lib/module/core/UnistylesModule.js.map +0 -1
- package/lib/module/core/UnistylesModule.native.js +0 -3
- package/lib/module/core/UnistylesModule.native.js.map +0 -1
- package/lib/module/core/UnistylesRuntime.js +0 -133
- package/lib/module/core/UnistylesRuntime.js.map +0 -1
- package/lib/module/core/index.js +0 -2
- package/lib/module/core/index.js.map +0 -1
- package/lib/module/createStyleSheet.js +0 -7
- package/lib/module/createStyleSheet.js.map +0 -1
- package/lib/module/global.js +0 -2
- package/lib/module/global.js.map +0 -1
- package/lib/module/hooks/useCSS.js +0 -37
- package/lib/module/hooks/useCSS.js.map +0 -1
- package/lib/module/hooks/useCSS.native.js +0 -2
- package/lib/module/hooks/useCSS.native.js.map +0 -1
- package/lib/module/hooks/useInitialTheme.js +0 -10
- package/lib/module/hooks/useInitialTheme.js.map +0 -1
- package/lib/module/hooks/useUnistyles.js +0 -57
- package/lib/module/hooks/useUnistyles.js.map +0 -1
- package/lib/module/hooks/useVariants.js +0 -7
- package/lib/module/hooks/useVariants.js.map +0 -1
- package/lib/module/normalizer/index.js +0 -3
- package/lib/module/normalizer/index.js.map +0 -1
- package/lib/module/normalizer/module.d.js.map +0 -1
- package/lib/module/normalizer/normalizeStyle.js.map +0 -1
- package/lib/module/normalizer/normalizer.js.map +0 -1
- package/lib/module/normalizer/normalizer.macos.js +0 -2
- package/lib/module/normalizer/normalizer.macos.js.map +0 -1
- package/lib/module/plugins/cssMediaQueriesPlugin.js +0 -7
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +0 -1
- package/lib/module/plugins/index.js +0 -3
- package/lib/module/plugins/index.js.map +0 -1
- package/lib/module/plugins/normalizeWebStylesPlugin.js +0 -6
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +0 -1
- package/lib/module/types/common.js +0 -2
- package/lib/module/types/plugin.js +0 -2
- package/lib/module/types/plugin.js.map +0 -1
- package/lib/module/types/stylesheet.js +0 -2
- package/lib/module/types/stylesheet.js.map +0 -1
- package/lib/module/types/unistyles.js +0 -2
- package/lib/module/types/unistyles.js.map +0 -1
- package/lib/module/types/variants.js +0 -2
- package/lib/module/types/variants.js.map +0 -1
- package/lib/module/useStyles.js +0 -40
- package/lib/module/useStyles.js.map +0 -1
- package/lib/module/utils/cssMediaQuery.js +0 -237
- package/lib/module/utils/cssMediaQuery.js.map +0 -1
- package/lib/module/utils/generateId.js +0 -7
- package/lib/module/utils/generateId.js.map +0 -1
- package/lib/module/utils/hash32.js +0 -36
- package/lib/module/utils/hash32.js.map +0 -1
- package/lib/module/utils/mq.js +0 -32
- package/lib/module/utils/mq.js.map +0 -1
- package/lib/module/utils/mqParser.js +0 -78
- package/lib/module/utils/mqParser.js.map +0 -1
- package/lib/module/utils/withPlugins.js +0 -8
- package/lib/module/utils/withPlugins.js.map +0 -1
- package/lib/typescript/src/common.d.ts +0 -46
- package/lib/typescript/src/common.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +0 -56
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +0 -1
- package/lib/typescript/src/core/Unistyles.d.ts +0 -13
- package/lib/typescript/src/core/Unistyles.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts +0 -19
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistylesModule.native.d.ts +0 -6
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +0 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +0 -81
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +0 -1
- package/lib/typescript/src/core/index.d.ts +0 -3
- package/lib/typescript/src/core/index.d.ts.map +0 -1
- package/lib/typescript/src/createStyleSheet.d.ts +0 -8
- package/lib/typescript/src/createStyleSheet.d.ts.map +0 -1
- package/lib/typescript/src/global.d.ts +0 -7
- package/lib/typescript/src/global.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCSS.d.ts +0 -3
- package/lib/typescript/src/hooks/useCSS.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCSS.native.d.ts +0 -3
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useInitialTheme.d.ts +0 -3
- package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +0 -14
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useVariants.d.ts +0 -3
- package/lib/typescript/src/hooks/useVariants.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/index.d.ts +0 -3
- package/lib/typescript/src/normalizer/index.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts +0 -3
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/normalizer.d.ts.map +0 -1
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts +0 -1
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +0 -1
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts +0 -3
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts.map +0 -1
- package/lib/typescript/src/plugins/index.d.ts +0 -3
- package/lib/typescript/src/plugins/index.d.ts.map +0 -1
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +0 -3
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +0 -1
- package/lib/typescript/src/types/common.d.ts +0 -3
- package/lib/typescript/src/types/common.d.ts.map +0 -1
- package/lib/typescript/src/types/plugin.d.ts +0 -7
- package/lib/typescript/src/types/plugin.d.ts.map +0 -1
- package/lib/typescript/src/types/stylesheet.d.ts +0 -40
- package/lib/typescript/src/types/stylesheet.d.ts.map +0 -1
- package/lib/typescript/src/types/unistyles.d.ts +0 -53
- package/lib/typescript/src/types/unistyles.d.ts.map +0 -1
- package/lib/typescript/src/types/variants.d.ts +0 -14
- package/lib/typescript/src/types/variants.d.ts.map +0 -1
- package/lib/typescript/src/useStyles.d.ts +0 -16
- package/lib/typescript/src/useStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/cssMediaQuery.d.ts +0 -4
- package/lib/typescript/src/utils/cssMediaQuery.d.ts.map +0 -1
- package/lib/typescript/src/utils/generateId.d.ts +0 -2
- package/lib/typescript/src/utils/generateId.d.ts.map +0 -1
- package/lib/typescript/src/utils/hash32.d.ts +0 -2
- package/lib/typescript/src/utils/hash32.d.ts.map +0 -1
- package/lib/typescript/src/utils/mq.d.ts +0 -26
- package/lib/typescript/src/utils/mq.d.ts.map +0 -1
- package/lib/typescript/src/utils/mqParser.d.ts +0 -16
- package/lib/typescript/src/utils/mqParser.d.ts.map +0 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +0 -3
- package/lib/typescript/src/utils/withPlugins.d.ts.map +0 -1
- package/react-native-unistyles.podspec +0 -22
- package/src/__tests__/mocks.ts +0 -24
- package/src/common.ts +0 -55
- package/src/core/UnistyleRegistry.ts +0 -108
- package/src/core/Unistyles.ts +0 -35
- package/src/core/UnistylesModule.native.ts +0 -7
- package/src/core/UnistylesModule.ts +0 -230
- package/src/core/UnistylesRuntime.ts +0 -135
- package/src/core/index.ts +0 -2
- package/src/createStyleSheet.ts +0 -8
- package/src/global.ts +0 -6
- package/src/hooks/useCSS.native.ts +0 -3
- package/src/hooks/useCSS.ts +0 -51
- package/src/hooks/useInitialTheme.ts +0 -11
- package/src/hooks/useUnistyles.ts +0 -64
- package/src/hooks/useVariants.ts +0 -10
- package/src/normalizer/index.ts +0 -2
- package/src/normalizer/normalizer.macos.ts +0 -1
- package/src/plugins/cssMediaQueriesPlugin.ts +0 -8
- package/src/plugins/index.ts +0 -2
- package/src/plugins/normalizeWebStylesPlugin.ts +0 -7
- package/src/types/common.ts +0 -2
- package/src/types/plugin.ts +0 -7
- package/src/types/stylesheet.ts +0 -49
- package/src/types/unistyles.ts +0 -63
- package/src/types/variants.ts +0 -19
- package/src/useStyles.ts +0 -60
- package/src/utils/cssMediaQuery.ts +0 -268
- package/src/utils/generateId.ts +0 -10
- package/src/utils/hash32.ts +0 -53
- package/src/utils/mq.ts +0 -57
- package/src/utils/mqParser.ts +0 -99
- package/src/utils/withPlugins.ts +0 -13
- /package/lib/commonjs/{normalizer → utils}/module.d.js +0 -0
- /package/lib/module/{normalizer → utils}/module.d.js +0 -0
- /package/lib/typescript/src/{normalizer → utils}/normalizer.d.ts +0 -0
- /package/src/{normalizer → utils}/module.d.ts +0 -0
@@ -1,5 +1,2 @@
|
|
1
|
-
export {
|
2
|
-
export { useUnistyles } from './useUnistyles';
|
3
|
-
export { useVariants } from './useVariants';
|
4
|
-
export { useCSS } from './useCSS';
|
1
|
+
export { useDimensions } from './useDimensions';
|
5
2
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["useDimensions"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useWindowDimensions","useDimensions"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.ts"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAGlD,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkBD,mBAAmB,CAAC,CAAC"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
2
|
+
export const useDimensions = () => {
|
3
|
+
const timerRef = useRef();
|
4
|
+
const [screenSize, setScreenSize] = useState({});
|
5
|
+
useLayoutEffect(() => {
|
6
|
+
setScreenSize({
|
7
|
+
width: window.innerWidth,
|
8
|
+
height: window.innerHeight
|
9
|
+
});
|
10
|
+
}, []);
|
11
|
+
useEffect(() => {
|
12
|
+
const handleResize = () => {
|
13
|
+
clearTimeout(timerRef.current);
|
14
|
+
timerRef.current = setTimeout(() => setScreenSize({
|
15
|
+
width: window.innerWidth,
|
16
|
+
height: window.innerHeight
|
17
|
+
}), 100);
|
18
|
+
};
|
19
|
+
window.addEventListener('resize', handleResize);
|
20
|
+
return () => {
|
21
|
+
window.removeEventListener('resize', handleResize);
|
22
|
+
clearTimeout(timerRef.current);
|
23
|
+
};
|
24
|
+
}, []);
|
25
|
+
return screenSize;
|
26
|
+
};
|
27
|
+
//# sourceMappingURL=useDimensions.web.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useRef","useState","useDimensions","timerRef","screenSize","setScreenSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAGpE,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAGH,MAAM,CAAgC,CAAC;EACxD,MAAM,CAACI,UAAU,EAAEC,aAAa,CAAC,GAAGJ,QAAQ,CAAa,CAAC,CAAe,CAAC;EAE1EF,eAAe,CAAC,MAAM;IAClBM,aAAa,CAAC;MACVC,KAAK,EAAEC,MAAM,CAACC,UAAU;MACxBC,MAAM,EAAEF,MAAM,CAACG;IACnB,CAAC,CAAC;EACN,CAAC,EAAE,EAAE,CAAC;EAENZ,SAAS,CAAC,MAAM;IACZ,MAAMa,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;MAE9BV,QAAQ,CAACU,OAAO,GAAGC,UAAU,CAAC,MAAMT,aAAa,CAAC;QAC9CC,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTJ,MAAM,CAACS,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOT,UAAU;AACrB,CAAC"}
|
package/lib/module/index.js
CHANGED
@@ -1,31 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import { useInitialTheme } from './hooks';
|
4
|
-
import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common';
|
5
|
-
import { useStyles } from './useStyles';
|
6
|
-
import { createStyleSheet } from './createStyleSheet';
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Utility to interact with the Unistyles
|
10
|
-
* (should be called only once)
|
11
|
-
*/
|
12
|
-
const UnistylesRegistry = {
|
13
|
-
/**
|
14
|
-
* Register themes to be used in the app
|
15
|
-
* @param themes - Key value pair of themes
|
16
|
-
*/
|
17
|
-
addThemes: unistyles.registry.addThemes,
|
18
|
-
/**
|
19
|
-
* Register breakpoints to be used in the app
|
20
|
-
* @param breakpoints - Key value pair of breakpoints
|
21
|
-
*/
|
22
|
-
addBreakpoints: unistyles.registry.addBreakpoints,
|
23
|
-
/**
|
24
|
-
* Register additional config to customize the Unistyles
|
25
|
-
* @param config - Key value pair of config
|
26
|
-
*/
|
27
|
-
addConfig: unistyles.registry.addConfig
|
28
|
-
};
|
29
|
-
const UnistylesRuntime = unistyles.runtime;
|
30
|
-
export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesRegistry, UnistylesRuntime };
|
1
|
+
export { UnistylesTheme } from './UnistylesTheme';
|
2
|
+
export { createUnistyles } from './createUnistyles';
|
31
3
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["UnistylesTheme","createUnistyles"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,eAAe,QAAQ,mBAAmB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"AAAA,cAAc,cAAc
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"AAAA,cAAc,cAAc"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/mediaQueries.ts"],"mappings":""}
|
@@ -1,26 +1,127 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
import { throwError } from './common';
|
2
|
+
import { getKeyForCustomMediaQuery, isMediaQuery } from './mediaQueries';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Sorts the breakpoints object based on its numeric values in ascending order and validates them.
|
6
|
+
*
|
7
|
+
* This function takes an object where keys represent breakpoint names and values are numeric.
|
8
|
+
* It returns a new object with the same keys but sorted based on their corresponding numeric values.
|
9
|
+
* Additionally, it validates that:
|
10
|
+
* 1. The first breakpoint starts with a value of 0.
|
11
|
+
* 2. No duplicate breakpoint values exist.
|
12
|
+
*
|
13
|
+
* If the validation fails, appropriate error messages are logged to the console.
|
14
|
+
*
|
15
|
+
* @template B - An object type where keys are strings and values are numbers.
|
16
|
+
* @param {B} breakpoints - The breakpoints object to be sorted and validated.
|
17
|
+
* @returns {B} A new object with sorted and validated breakpoints.
|
18
|
+
*
|
19
|
+
* @example
|
20
|
+
* const input = { md: 768, lg: 1024, sm: 0 }
|
21
|
+
* sortAndValidateBreakpoints(input) // returns { sm: 0, md: 768, lg: 1024 }
|
22
|
+
*/
|
23
|
+
export const sortAndValidateBreakpoints = breakpoints => {
|
24
|
+
const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
25
|
+
const [, value1] = breakpoint1;
|
26
|
+
const [, value2] = breakpoint2;
|
27
|
+
return value1 - value2;
|
28
|
+
});
|
29
|
+
const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
|
30
|
+
const breakpointValues = Object.values(sortedBreakpoints);
|
31
|
+
const [firstBreakpoint] = breakpointValues;
|
32
|
+
if (firstBreakpoint !== 0) {
|
33
|
+
throwError('first breakpoint must start with 0');
|
8
34
|
}
|
9
|
-
|
10
|
-
|
11
|
-
return value[unistyles.runtime.orientation];
|
35
|
+
if (breakpointValues.length !== new Set(breakpointValues).size) {
|
36
|
+
throwError('breakpoint values are duplicated');
|
12
37
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
38
|
+
return sortedBreakpoints;
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Determines the appropriate breakpoint key for a given screen width based on provided breakpoints.
|
43
|
+
*
|
44
|
+
* This function takes a screen width and an object of breakpoints. It returns the key of the breakpoint
|
45
|
+
* that the screen width falls into. The breakpoints are assumed to be sorted in ascending order.
|
46
|
+
*
|
47
|
+
* @template B - An object type where keys are strings and values are numbers representing screen widths.
|
48
|
+
* @param {number} width - The screen width to determine the breakpoint for.
|
49
|
+
* @param breakpointEntries - sorted pairs of breakpoints
|
50
|
+
* @returns {keyof B & string} The key of the breakpoint that the screen width falls into.
|
51
|
+
*
|
52
|
+
* @example
|
53
|
+
* const breakpoints = { sm: 0, md: 768, lg: 1024 }
|
54
|
+
* getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
|
55
|
+
*/
|
56
|
+
export const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
57
|
+
const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
|
58
|
+
let [, value] = _ref;
|
59
|
+
const minVal = value;
|
60
|
+
const maxVal = otherBreakpoints[index + 1]?.[1];
|
61
|
+
if (!maxVal) {
|
62
|
+
return true;
|
63
|
+
}
|
64
|
+
return width >= minVal && width < maxVal;
|
65
|
+
});
|
66
|
+
return key;
|
67
|
+
};
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Retrieves the value associated with a given breakpoint or custom media query based on the provided screen size.
|
71
|
+
*
|
72
|
+
* The function first checks for custom media queries. If a matching custom media query is found, its associated value is returned.
|
73
|
+
* If no custom media query matches, the function then checks for a direct breakpoint match.
|
74
|
+
* If there's no direct breakpoint match, the function simulates CSS cascading to find the closest matching breakpoint.
|
75
|
+
*
|
76
|
+
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
77
|
+
*
|
78
|
+
* @param {Record<keyof B & string, string | number>} value - An object containing values associated with breakpoints or custom media queries.
|
79
|
+
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
80
|
+
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
81
|
+
* @param breakpointPairs - sorted pairs of breakpoints
|
82
|
+
*
|
83
|
+
* @returns {string | number | undefined} Returns the value associated with the matching breakpoint or custom media query, or `undefined` if no match is found.
|
84
|
+
*
|
85
|
+
* @example
|
86
|
+
*
|
87
|
+
* const values = { ':w[200]': 'value1', sm: 'value2', md: 'value3' }
|
88
|
+
* const screenSize = { width: 250, height: 400 }
|
89
|
+
* const breakpoints = { sm: 300, md: 600, lg: 900 }
|
90
|
+
*
|
91
|
+
* getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
|
92
|
+
*/
|
93
|
+
export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointPairs) => {
|
94
|
+
// the highest priority is for custom media queries
|
95
|
+
const customMediaQueries = Object.entries(value).filter(_ref2 => {
|
96
|
+
let [key] = _ref2;
|
97
|
+
return isMediaQuery(key);
|
98
|
+
});
|
99
|
+
const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize);
|
100
|
+
if (customMediaQueryKey && customMediaQueryKey in value) {
|
101
|
+
return value[customMediaQueryKey];
|
16
102
|
}
|
17
|
-
|
18
|
-
if
|
103
|
+
|
104
|
+
// if no custom media query, or didn't match, proceed with defined breakpoints
|
105
|
+
const unifiedKey = breakpoint;
|
106
|
+
const directBreakpoint = value[unifiedKey];
|
107
|
+
|
108
|
+
// if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
|
109
|
+
if (directBreakpoint || unifiedKey in value) {
|
19
110
|
return directBreakpoint;
|
20
111
|
}
|
21
|
-
|
22
|
-
|
23
|
-
const
|
24
|
-
|
112
|
+
|
113
|
+
// there is no direct hit for breakpoint nor media-query, so let's simulate CSS cascading
|
114
|
+
const currentBreakpoint = breakpointPairs.findIndex(_ref3 => {
|
115
|
+
let [key] = _ref3;
|
116
|
+
return key === unifiedKey;
|
117
|
+
});
|
118
|
+
const availableBreakpoints = breakpointPairs.filter((_ref4, index) => {
|
119
|
+
let [key] = _ref4;
|
120
|
+
return index < currentBreakpoint && key && key in value;
|
121
|
+
}).map(_ref5 => {
|
122
|
+
let [key] = _ref5;
|
123
|
+
return key;
|
124
|
+
});
|
125
|
+
return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
|
25
126
|
};
|
26
127
|
//# sourceMappingURL=breakpoints.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["throwError","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","breakpointPairs","customMediaQueries","filter","_ref2","customMediaQueryKey","unifiedKey","directBreakpoint","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,UAAU;AAErC,SAASC,yBAAyB,EAAEC,YAAY,QAAQ,gBAAgB;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAA2BC,WAAc,IAAQ;EACpF,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAOC,MAAM,GAAGC,MAAM;EAC1B,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS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= message => {
|
3
|
+
throw new Error(`🦄 [react-native-unistyles]: ${message}`);
|
4
|
+
};
|
5
|
+
export const warn = message => {
|
6
|
+
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
7
|
+
};
|
8
|
+
export const isWeb = Platform.OS === 'web';
|
9
|
+
export const isIOS = Platform.OS === 'ios';
|
10
|
+
export const isAndroid = Platform.OS === 'android';
|
11
|
+
export const isServer = typeof window === 'undefined';
|
12
|
+
//# sourceMappingURL=common.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["Platform","throwError","message","Error","warn","console","isWeb","OS","isIOS","isAndroid","isServer","window"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,KAAK,GAAGN,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,KAAK,GAAGR,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,SAAS,GAAGT,QAAQ,CAACO,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMG,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW"}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
export {
|
2
|
-
export
|
3
|
-
export { getValueForBreakpoint } from './breakpoints';
|
4
|
-
export { proxifyFunction, parseStyle
|
5
|
-
export {
|
6
|
-
export {
|
1
|
+
export { normalizeStyles } from './normalizeStyles';
|
2
|
+
export * from './normalizer';
|
3
|
+
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
|
4
|
+
export { proxifyFunction, parseStyle } from './styles';
|
5
|
+
export { isServer } from './common';
|
6
|
+
export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
|
7
7
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,QAAQ,UAAU;AACnC,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
|
@@ -0,0 +1,176 @@
|
|
1
|
+
/**
|
2
|
+
* Extracts numeric values from a coded string.
|
3
|
+
*
|
4
|
+
* The function is designed to process strings that have a format like "w[100,200]" or "h[300]".
|
5
|
+
* It removes characters 'w', 'h', '[', and ']' from the input string and then extracts the numbers.
|
6
|
+
*
|
7
|
+
* @param {string} codedValue - The input string to extract values from.
|
8
|
+
* @returns {Array<number>} An array of extracted numbers. Can contain one or two numbers based on the input format.
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* extractValues("w[100,200]") // returns [100, 200]
|
12
|
+
* extractValues("h[300]") // returns [300]
|
13
|
+
* extractValues("h[,300]") // returns [0,300]
|
14
|
+
* extractValues("h[100,]") // returns [100]
|
15
|
+
*/
|
16
|
+
export const extractValues = codedValue => {
|
17
|
+
const [lh, rh] = codedValue.replace(/[wh[\]]/g, '').split(',');
|
18
|
+
return rh ? [Number(lh), Number(rh)] : [Number(lh)];
|
19
|
+
};
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Determines if the given screen size matches the specified breakpoint query.
|
23
|
+
*
|
24
|
+
* The function checks if the screen size (width and/or height) falls within the range
|
25
|
+
* specified by the breakpoint query. The query can specify width (using 'w'), height (using 'h'),
|
26
|
+
* or both.
|
27
|
+
*
|
28
|
+
* @param {string} query - The breakpoint query string. Examples: 'w[100,200]', 'h[300]', 'w[100,200]h[300,400]'.
|
29
|
+
* @param {ScreenSize} screenSize - The screen size to check against the breakpoint query.
|
30
|
+
* @returns {boolean} True if the screen size matches the breakpoint query, false otherwise.
|
31
|
+
*
|
32
|
+
* @example
|
33
|
+
* const screenSize = { width: 150, height: 350 }
|
34
|
+
* isWithinBreakpoint('w[100,200]', screenSize) // returns true
|
35
|
+
* isWithinBreakpoint('h[400]', screenSize) // returns false
|
36
|
+
*/
|
37
|
+
export const isWithinBreakpoint = (query, screenSize) => {
|
38
|
+
if (query.includes('w') && query.includes('h')) {
|
39
|
+
return isWithinTheWidthAndHeight(query, screenSize);
|
40
|
+
}
|
41
|
+
if (query.charAt(0) === 'w') {
|
42
|
+
return isWithinTheWidth(query, screenSize.width);
|
43
|
+
}
|
44
|
+
if (query.charAt(0) === 'h') {
|
45
|
+
return isWithinTheHeight(query, screenSize.height);
|
46
|
+
}
|
47
|
+
return false;
|
48
|
+
};
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Determines if the given width matches the specified width range in the query.
|
52
|
+
*
|
53
|
+
* The function checks if the provided width falls within the range specified by the query.
|
54
|
+
* The query specifies a width range using a format like 'w[100,200]'. If only one value is provided,
|
55
|
+
* it's treated as a minimum width.
|
56
|
+
*
|
57
|
+
* @param {string} query - The width query string. Examples: 'w[100,200]' or 'w[100]'.
|
58
|
+
* @param {number} width - The width to check against the query.
|
59
|
+
* @returns {boolean} True if the width matches the query range, false otherwise.
|
60
|
+
*
|
61
|
+
* @example
|
62
|
+
* isWithinTheWidth('w[100,200]', 150) // returns true
|
63
|
+
* isWithinTheWidth('w[100]', 50) // returns false
|
64
|
+
* isWithinTheWidth('w[100]', 150) // returns true
|
65
|
+
*/
|
66
|
+
export const isWithinTheWidth = (query, width) => {
|
67
|
+
const [minWidth, maxWidth] = extractValues(query);
|
68
|
+
if (maxWidth && width >= minWidth && width <= maxWidth) {
|
69
|
+
return true;
|
70
|
+
}
|
71
|
+
return !maxWidth && width >= minWidth;
|
72
|
+
};
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Determines if the given height matches the specified height range in the query.
|
76
|
+
*
|
77
|
+
* The function checks if the provided height falls within the range specified by the query.
|
78
|
+
* The query specifies a height range using a format like 'h[100,200]'. If only one value is provided,
|
79
|
+
* it's treated as a minimum height.
|
80
|
+
*
|
81
|
+
* @param {string} query - The height query string. Examples: 'h[100,200]' or 'h[100]'.
|
82
|
+
* @param {number} height - The height to check against the query.
|
83
|
+
* @returns {boolean} True if the height matches the query range, false otherwise.
|
84
|
+
*
|
85
|
+
* @example
|
86
|
+
* isWithinTheHeight('h[100,200]', 150) // returns true
|
87
|
+
* isWithinTheHeight('h[100]', 50) // returns false
|
88
|
+
* isWithinTheHeight('h[100]', 150) // returns true
|
89
|
+
*/
|
90
|
+
export const isWithinTheHeight = (query, height) => {
|
91
|
+
const [minHeight, maxHeight] = extractValues(query);
|
92
|
+
if (maxHeight && height >= minHeight && height <= maxHeight) {
|
93
|
+
return true;
|
94
|
+
}
|
95
|
+
return !maxHeight && height >= minHeight;
|
96
|
+
};
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Determines if the given screen size matches both the specified width and height ranges in the query.
|
100
|
+
*
|
101
|
+
* The function checks if the provided screen size (both width and height) falls within the ranges
|
102
|
+
* specified by the query. The query can specify both width and height using a format like 'w[100,200]:h[300,400]'.
|
103
|
+
*
|
104
|
+
* @param {string} query - The combined width and height query string. Example: 'w[100,200]:h[300,400]'.
|
105
|
+
* @param {ScreenSize} screenSize - The screen size to check against the query.
|
106
|
+
* @returns {boolean} True if the screen size matches both the width and height ranges in the query, false otherwise.
|
107
|
+
*
|
108
|
+
* @example
|
109
|
+
* const screenSize = { width: 150, height: 350 }
|
110
|
+
* isWithinTheWidthAndHeight('w[100,200]:h[300,400]', screenSize) // returns true
|
111
|
+
* isWithinTheWidthAndHeight('w[100,200]:h[400,500]', screenSize) // returns false
|
112
|
+
*/
|
113
|
+
export const isWithinTheWidthAndHeight = (query, screenSize) => {
|
114
|
+
const result = query.split(':').filter(Boolean).map(q => isWithinBreakpoint(q, screenSize)).filter(Boolean);
|
115
|
+
return result.length === 2;
|
116
|
+
};
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Checks if the given query string is a valid custom media query.
|
120
|
+
*
|
121
|
+
* The valid custom media query formats include:
|
122
|
+
* - :w[200]
|
123
|
+
* - :w[0, 200]
|
124
|
+
* - :w[, 300]
|
125
|
+
* - :h[200]
|
126
|
+
* - :h[0, 500]
|
127
|
+
* - :h[,200]
|
128
|
+
* - :w[100, 300]:h[200,500]
|
129
|
+
* - :h[200,500]:w[100, 300]
|
130
|
+
*
|
131
|
+
* @param {string} query - The query string to be checked.
|
132
|
+
* @returns {boolean} Returns `true` if the query is a valid custom media query, otherwise `false`.
|
133
|
+
* @example
|
134
|
+
*
|
135
|
+
* isMediaQuery(':w[200]') // true
|
136
|
+
* isMediaQuery(':w100]') // false
|
137
|
+
*/
|
138
|
+
export const isMediaQuery = query => {
|
139
|
+
const regex = /^(?:(:w\[\d*(?:,\s?\d+)?])?(:h\[\d*(?:,\s?\d+)?])?|(:h\[\d*(?:,\s?\d+)?])?(:w\[\d*(?:,\s?\d+)?])?)$/;
|
140
|
+
return query.length > 0 && regex.test(query);
|
141
|
+
};
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Retrieves the first matching custom media query key based on the provided screen size.
|
145
|
+
*
|
146
|
+
* The function processes an array of media queries and returns the first query that matches
|
147
|
+
* the given screen size. The media queries can be in formats like:
|
148
|
+
* - w[200]
|
149
|
+
* - w[0, 200]
|
150
|
+
* - w[, 300]
|
151
|
+
* - h[200]
|
152
|
+
* - h[0, 500]
|
153
|
+
* - h[,200]
|
154
|
+
* - w[100, 300]:h[200,500]
|
155
|
+
* - h[200,500]:w[100, 300]
|
156
|
+
*
|
157
|
+
* @param {Array<[string, string | number]>} mediaQueries - An array of tuples containing media query keys and associated values.
|
158
|
+
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
159
|
+
* @returns {string | undefined} Returns the first matching media query key or `undefined` if no match is found.
|
160
|
+
* @example
|
161
|
+
*
|
162
|
+
* const queries = [[':w[200]', 'value1'], [':h[300,500]', 'value2']]
|
163
|
+
* const size = { width: 250, height: 400 }
|
164
|
+
* getKeyForCustomMediaQuery(queries, size) // ':w[200]
|
165
|
+
*/
|
166
|
+
export const getKeyForCustomMediaQuery = (mediaQueries, screenSize) => {
|
167
|
+
const [matchedQuery] = mediaQueries.flatMap(_ref => {
|
168
|
+
let [key] = _ref;
|
169
|
+
if (key.includes('w') && key.includes('h')) {
|
170
|
+
return isWithinBreakpoint(key, screenSize) ? key : undefined;
|
171
|
+
}
|
172
|
+
return key.split(':').filter(Boolean).map(query => isWithinBreakpoint(query, screenSize) ? key : undefined);
|
173
|
+
}).filter(Boolean);
|
174
|
+
return matchedQuery;
|
175
|
+
};
|
176
|
+
//# sourceMappingURL=mediaQueries.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["extractValues","codedValue","lh","rh","replace","split","Number","isWithinBreakpoint","query","screenSize","includes","isWithinTheWidthAndHeight","charAt","isWithinTheWidth","width","isWithinTheHeight","height","minWidth","maxWidth","minHeight","maxHeight","result","filter","Boolean","map","q","length","isMediaQuery","regex","test","getKeyForCustomMediaQuery","mediaQueries","matchedQuery","flatMap","_ref","key","undefined"],"sourceRoot":"../../../src","sources":["utils/mediaQueries.ts"],"mappings":"AAEA;AACA;AACA;AACA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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMsB,yBAAyB,GAAGA,CAACC,YAA0D,EAAEtB,UAAsB,KAAyB;EACjJ,MAAM,CAACuB,YAAY,CAAC,GAAGD,YAAY,CAC9BE,OAAO,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IACX,IAAIC,GAAG,CAACzB,QAAQ,CAAC,GAAG,CAAC,IAAIyB,GAAG,CAACzB,QAAQ,CAAC,GAAG,CAAC,EAAE;MACxC,OAAOH,kBAAkB,CAAC4B,GAAG,EAAE1B,UAAU,CAAC,GAAG0B,GAAG,GAAGC,SAAS;IAChE;IAEA,OAAOD,GAAG,CACL9B,KAAK,CAAC,GAAG,CAAC,CACViB,MAAM,CAACC,OAAO,CAAC,CACfC,GAAG,CAAChB,KAAK,IAAID,kBAAkB,CAACC,KAAK,EAAEC,UAAU,CAAC,GAAG0B,GAAG,GAAGC,SAAS,CAAC;EAC9E,CAAC,CAAC,CACDd,MAAM,CAACC,OAAO,CAAC;EAEpB,OAAOS,YAAY;AACvB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["normalizeStyles","styles"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.ts"],"mappings":"AAAA;AACA,OAAO,MAAMA,eAAe,GAAOC,MAAS,IAAKA,MAAW"}
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import { warn } from './common';
|
1
2
|
import { preprocessor } from './normalizer';
|
2
|
-
import { warn } from '../common';
|
3
3
|
const normalizeBoxShadow = style => {
|
4
4
|
const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
|
5
5
|
if (!requiredBoxShadowProperties.every(prop => prop in style)) {
|
@@ -36,7 +36,7 @@ const normalizeTextShadow = style => {
|
|
36
36
|
textShadowRadius: undefined
|
37
37
|
};
|
38
38
|
};
|
39
|
-
export const
|
39
|
+
export const normalizeStyles = style => {
|
40
40
|
const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
|
41
41
|
transform: preprocessor.createTransformValue(style.transform)
|
42
42
|
} : {};
|
@@ -49,4 +49,4 @@ export const normalizeStyle = style => {
|
|
49
49
|
...normalizedTextShadow
|
50
50
|
};
|
51
51
|
};
|
52
|
-
//# sourceMappingURL=
|
52
|
+
//# sourceMappingURL=normalizeStyles.web.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["warn","preprocessor","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,SAASC,YAAY,QAAQ,cAAc;AAG3C,MAAMC,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC3DH,IAAI,CAAE,wEAAuEI,2BAA2B,CAACG,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,S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G,CAAC,CAAC;EAE/C,MAAM0B,oBAAoB,GACtB,iBAAiB,IAAI1B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3BY,mBAAmB,CAACZ,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGoB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC"}
|
@@ -1,14 +1,15 @@
|
|
1
1
|
// based on react-native-web normalizer
|
2
2
|
// https://github.com/necolas/react-native-web
|
3
3
|
import normalizeColors from '@react-native/normalize-colors';
|
4
|
-
export const normalizeColor = (color
|
4
|
+
export const normalizeColor = function (color) {
|
5
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
5
6
|
// If the opacity is 1 there's no need to normalize the color
|
6
7
|
if (opacity === 1) {
|
7
8
|
return color;
|
8
9
|
}
|
9
10
|
const integer = normalizeColors(color);
|
10
11
|
|
11
|
-
// If the
|
12
|
+
// If the colour is an unknown format, the return value is null
|
12
13
|
if (integer === null) {
|
13
14
|
return color;
|
14
15
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["normalizeColors","normalizeColor","color","opacity","arguments","length","undefined","integer","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["utils/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QA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