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,18 +1,32 @@
|
|
1
1
|
import type { MatrixTransform, PerpectiveTransform, RotateTransform, RotateXTransform, RotateYTransform, RotateZTransform, ScaleTransform, ScaleXTransform, ScaleYTransform, SkewXTransform, SkewYTransform, TranslateXTransform, TranslateYTransform } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
|
2
2
|
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
3
|
-
import type {
|
4
|
-
|
3
|
+
import type { Breakpoints } from './breakpoints';
|
4
|
+
import type { MediaQueries } from './mediaQueries';
|
5
|
+
type ShadowOffset = {
|
5
6
|
width: number;
|
6
7
|
height: number;
|
7
8
|
};
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
type TransformStyles = PerpectiveTransform & RotateTransform & RotateXTransform & RotateYTransform & RotateZTransform & ScaleTransform & ScaleXTransform & ScaleYTransform & TranslateXTransform & TranslateYTransform & SkewXTransform & SkewYTransform & MatrixTransform;
|
10
|
+
type UnistyleNested<B> = {
|
11
|
+
shadowOffset?: DeepUniStyle<ShadowOffset, B>;
|
12
|
+
textShadowOffset?: DeepUniStyle<ShadowOffset, B>;
|
13
|
+
transform?: Array<DeepUniStyle<TransformStyles, B>>;
|
14
|
+
};
|
15
|
+
type UniStyle<V, B> = {
|
16
|
+
[innerKey in keyof B]?: V;
|
17
|
+
} | {
|
18
|
+
[innerKey in MediaQueries]?: V;
|
19
|
+
} | V;
|
20
|
+
type DeepUniStyle<T, B> = {
|
21
|
+
[K in keyof T]?: UniStyle<T[K], B>;
|
22
|
+
};
|
23
|
+
type NestedTypes = 'shadowOffset' | 'transform' | 'textShadowOffset';
|
24
|
+
type UnistyleView<B> = DeepUniStyle<Omit<ViewStyle, NestedTypes>, B>;
|
25
|
+
type UnistyleText<B> = DeepUniStyle<Omit<TextStyle, NestedTypes>, B>;
|
26
|
+
type UnistyleImage<B> = DeepUniStyle<Omit<ImageStyle, NestedTypes>, B>;
|
27
|
+
export type StaticStyles<B extends Breakpoints> = UnistyleView<B> | UnistyleText<B> | UnistyleImage<B> & UnistyleNested<B>;
|
28
|
+
export type CustomNamedStyles<T, B extends Breakpoints> = {
|
29
|
+
[K in keyof T]: T[K] extends (...args: infer A) => StaticStyles<B> ? (...args: A) => StaticStyles<B> : StaticStyles<B>;
|
12
30
|
};
|
13
|
-
export
|
14
|
-
export type RNValue = ViewStyle[keyof ViewStyle] | TextStyle[keyof TextStyle] | ImageStyle[keyof ImageStyle];
|
15
|
-
export type NestedStyle = Record<keyof UnistylesBreakpoints | symbol, RNValue>;
|
16
|
-
export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | symbol, RNValue]>;
|
17
|
-
export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes];
|
31
|
+
export {};
|
18
32
|
//# sourceMappingURL=core.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,KAAK,YAAY,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,eAAe,GACd,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,eAAe,CAAA;AAErB,KAAK,cAAc,CAAC,CAAC,IAAI;IACrB,YAAY,CAAC,EAAE,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAA;CACtD,CAAA;AAED,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI;KACjB,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5B,GAAG;KACC,QAAQ,IAAI,YAAY,CAAC,CAAC,EAAE,CAAC;CACjC,GAAG,CAAC,CAAA;AAEL,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI;KACrB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CACrC,CAAA;AAGD,KAAK,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,kBAAkB,CAAA;AAEpE,KAAK,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;AACpE,KAAK,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;AACpE,KAAK,aAAa,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;AAEtE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,WAAW,IACxC,YAAY,CAAC,CAAC,CAAC,GACf,YAAY,CAAC,CAAC,CAAC,GACf,aAAa,CAAC,CAAC,CAAC,GAChB,cAAc,CAAC,CAAC,CAAC,CAAA;AAEvB,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI;KACrD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,GAC5D,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,GAC/B,YAAY,CAAC,CAAC,CAAC;CACxB,CAAA"}
|
@@ -1,9 +1,4 @@
|
|
1
1
|
export * from './normalizer';
|
2
|
-
export
|
3
|
-
export type {
|
4
|
-
export type { NestedStylePairs, UnistylesTheme, ScreenSize, NestedStyle, RNValue, RNStyle } from './core';
|
5
|
-
export type { StyleSheetWithSuperPowers, StyleSheet, AllAvailableKeys } from './stylesheet';
|
6
|
-
export type { ReactNativeStyleSheet } from './breakpoints';
|
7
|
-
export type { ExtractVariantNames } from './variants';
|
8
|
-
export type { UnistylesPlugin } from './plugin';
|
2
|
+
export type { CustomNamedStyles } from './core';
|
3
|
+
export type { ScreenSize, Breakpoints, CreateStylesFactory, ExtractBreakpoints, RemoveKeysWithPrefix, SortedBreakpointEntries } from './breakpoints';
|
9
4
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/C,YAAY,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EAC1B,MAAM,eAAe,CAAA"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
type Optional<TOptional extends string> = TOptional | '';
|
2
|
+
type Separator = ',' | ', ';
|
3
|
+
type MediaQuery = `[${Separator}${bigint}]` | `[${bigint}${Optional<`${Separator}${bigint}`>}]`;
|
4
|
+
type WidthMediaQuery = `:w${MediaQuery}`;
|
5
|
+
type HeightMediaQuery = `:h${MediaQuery}`;
|
6
|
+
export type MediaQueries = `${WidthMediaQuery}${Optional<HeightMediaQuery>}` | `${HeightMediaQuery}${Optional<WidthMediaQuery>}`;
|
7
|
+
export {};
|
8
|
+
//# sourceMappingURL=mediaQueries.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../../src/types/mediaQueries.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,SAAS,SAAS,MAAM,IAAI,SAAS,GAAG,EAAE,CAAA;AACxD,KAAK,SAAS,GAAG,GAAG,GAAG,IAAI,CAAA;AAE3B,KAAK,UAAU,GAAG,IAAI,SAAS,GAAG,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,QAAQ,CAAC,GAAG,SAAS,GAAG,MAAM,EAAE,CAAC,GAAG,CAAA;AAC/F,KAAK,eAAe,GAAG,KAAK,UAAU,EAAE,CAAA;AACxC,KAAK,gBAAgB,GAAG,KAAK,UAAU,EAAE,CAAA;AAEzC,MAAM,MAAM,YAAY,GAClB,GAAG,eAAe,GAAG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,GACjD,GAAG,gBAAgB,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAA"}
|
@@ -1,3 +1,63 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { Breakpoints, ScreenSize, SortedBreakpointEntries } from '../types';
|
2
|
+
/**
|
3
|
+
* Sorts the breakpoints object based on its numeric values in ascending order and validates them.
|
4
|
+
*
|
5
|
+
* This function takes an object where keys represent breakpoint names and values are numeric.
|
6
|
+
* It returns a new object with the same keys but sorted based on their corresponding numeric values.
|
7
|
+
* Additionally, it validates that:
|
8
|
+
* 1. The first breakpoint starts with a value of 0.
|
9
|
+
* 2. No duplicate breakpoint values exist.
|
10
|
+
*
|
11
|
+
* If the validation fails, appropriate error messages are logged to the console.
|
12
|
+
*
|
13
|
+
* @template B - An object type where keys are strings and values are numbers.
|
14
|
+
* @param {B} breakpoints - The breakpoints object to be sorted and validated.
|
15
|
+
* @returns {B} A new object with sorted and validated breakpoints.
|
16
|
+
*
|
17
|
+
* @example
|
18
|
+
* const input = { md: 768, lg: 1024, sm: 0 }
|
19
|
+
* sortAndValidateBreakpoints(input) // returns { sm: 0, md: 768, lg: 1024 }
|
20
|
+
*/
|
21
|
+
export declare const sortAndValidateBreakpoints: <B extends Breakpoints>(breakpoints: B) => B;
|
22
|
+
/**
|
23
|
+
* Determines the appropriate breakpoint key for a given screen width based on provided breakpoints.
|
24
|
+
*
|
25
|
+
* This function takes a screen width and an object of breakpoints. It returns the key of the breakpoint
|
26
|
+
* that the screen width falls into. The breakpoints are assumed to be sorted in ascending order.
|
27
|
+
*
|
28
|
+
* @template B - An object type where keys are strings and values are numbers representing screen widths.
|
29
|
+
* @param {number} width - The screen width to determine the breakpoint for.
|
30
|
+
* @param breakpointEntries - sorted pairs of breakpoints
|
31
|
+
* @returns {keyof B & string} The key of the breakpoint that the screen width falls into.
|
32
|
+
*
|
33
|
+
* @example
|
34
|
+
* const breakpoints = { sm: 0, md: 768, lg: 1024 }
|
35
|
+
* getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
|
36
|
+
*/
|
37
|
+
export declare const getBreakpointFromScreenWidth: <B extends Breakpoints>(width: number, breakpointEntries: SortedBreakpointEntries<B>) => keyof B & string;
|
38
|
+
/**
|
39
|
+
* Retrieves the value associated with a given breakpoint or custom media query based on the provided screen size.
|
40
|
+
*
|
41
|
+
* The function first checks for custom media queries. If a matching custom media query is found, its associated value is returned.
|
42
|
+
* If no custom media query matches, the function then checks for a direct breakpoint match.
|
43
|
+
* If there's no direct breakpoint match, the function simulates CSS cascading to find the closest matching breakpoint.
|
44
|
+
*
|
45
|
+
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
46
|
+
*
|
47
|
+
* @param {Record<keyof B & string, string | number>} value - An object containing values associated with breakpoints or custom media queries.
|
48
|
+
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
49
|
+
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
50
|
+
* @param breakpointPairs - sorted pairs of breakpoints
|
51
|
+
*
|
52
|
+
* @returns {string | number | undefined} Returns the value associated with the matching breakpoint or custom media query, or `undefined` if no match is found.
|
53
|
+
*
|
54
|
+
* @example
|
55
|
+
*
|
56
|
+
* const values = { ':w[200]': 'value1', sm: 'value2', md: 'value3' }
|
57
|
+
* const screenSize = { width: 250, height: 400 }
|
58
|
+
* const breakpoints = { sm: 300, md: 600, lg: 900 }
|
59
|
+
*
|
60
|
+
* getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
|
61
|
+
*/
|
62
|
+
export declare const getValueForBreakpoint: <B extends Breakpoints>(value: Record<keyof B & string, string | number | undefined>, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => string | number | undefined;
|
3
63
|
//# sourceMappingURL=breakpoints.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAGhF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,8CAuBtC,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,4BAA4B,iCAAkC,MAAM,oEAchF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,qBAAqB,kIAGlB,UAAU,kDAEvB,MAAM,GAAG,MAAM,GAAG,SA+BpB,CAAA"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export declare const throwError: (message: string) => never;
|
2
|
+
export declare const warn: (message: string) => void;
|
3
|
+
export declare const isWeb: boolean;
|
4
|
+
export declare const isIOS: boolean;
|
5
|
+
export declare const isAndroid: boolean;
|
6
|
+
export declare const isServer: boolean;
|
7
|
+
//# sourceMappingURL=common.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,YAAa,MAAM,UAEzC,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAgC,CAAA"}
|
@@ -1,8 +1,7 @@
|
|
1
|
-
export {
|
2
|
-
export
|
3
|
-
export {
|
4
|
-
export {
|
5
|
-
export {
|
6
|
-
export {
|
7
|
-
export { generateReactNativeWebId } from './generateId';
|
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';
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import type { ScreenSize } from '../types';
|
2
|
+
/**
|
3
|
+
* Extracts numeric values from a coded string.
|
4
|
+
*
|
5
|
+
* The function is designed to process strings that have a format like "w[100,200]" or "h[300]".
|
6
|
+
* It removes characters 'w', 'h', '[', and ']' from the input string and then extracts the numbers.
|
7
|
+
*
|
8
|
+
* @param {string} codedValue - The input string to extract values from.
|
9
|
+
* @returns {Array<number>} An array of extracted numbers. Can contain one or two numbers based on the input format.
|
10
|
+
*
|
11
|
+
* @example
|
12
|
+
* extractValues("w[100,200]") // returns [100, 200]
|
13
|
+
* extractValues("h[300]") // returns [300]
|
14
|
+
* extractValues("h[,300]") // returns [0,300]
|
15
|
+
* extractValues("h[100,]") // returns [100]
|
16
|
+
*/
|
17
|
+
export declare const extractValues: (codedValue: string) => Array<number>;
|
18
|
+
/**
|
19
|
+
* Determines if the given screen size matches the specified breakpoint query.
|
20
|
+
*
|
21
|
+
* The function checks if the screen size (width and/or height) falls within the range
|
22
|
+
* specified by the breakpoint query. The query can specify width (using 'w'), height (using 'h'),
|
23
|
+
* or both.
|
24
|
+
*
|
25
|
+
* @param {string} query - The breakpoint query string. Examples: 'w[100,200]', 'h[300]', 'w[100,200]h[300,400]'.
|
26
|
+
* @param {ScreenSize} screenSize - The screen size to check against the breakpoint query.
|
27
|
+
* @returns {boolean} True if the screen size matches the breakpoint query, false otherwise.
|
28
|
+
*
|
29
|
+
* @example
|
30
|
+
* const screenSize = { width: 150, height: 350 }
|
31
|
+
* isWithinBreakpoint('w[100,200]', screenSize) // returns true
|
32
|
+
* isWithinBreakpoint('h[400]', screenSize) // returns false
|
33
|
+
*/
|
34
|
+
export declare const isWithinBreakpoint: (query: string, screenSize: ScreenSize) => boolean;
|
35
|
+
/**
|
36
|
+
* Determines if the given width matches the specified width range in the query.
|
37
|
+
*
|
38
|
+
* The function checks if the provided width falls within the range specified by the query.
|
39
|
+
* The query specifies a width range using a format like 'w[100,200]'. If only one value is provided,
|
40
|
+
* it's treated as a minimum width.
|
41
|
+
*
|
42
|
+
* @param {string} query - The width query string. Examples: 'w[100,200]' or 'w[100]'.
|
43
|
+
* @param {number} width - The width to check against the query.
|
44
|
+
* @returns {boolean} True if the width matches the query range, false otherwise.
|
45
|
+
*
|
46
|
+
* @example
|
47
|
+
* isWithinTheWidth('w[100,200]', 150) // returns true
|
48
|
+
* isWithinTheWidth('w[100]', 50) // returns false
|
49
|
+
* isWithinTheWidth('w[100]', 150) // returns true
|
50
|
+
*/
|
51
|
+
export declare const isWithinTheWidth: (query: string, width: number) => boolean;
|
52
|
+
/**
|
53
|
+
* Determines if the given height matches the specified height range in the query.
|
54
|
+
*
|
55
|
+
* The function checks if the provided height falls within the range specified by the query.
|
56
|
+
* The query specifies a height range using a format like 'h[100,200]'. If only one value is provided,
|
57
|
+
* it's treated as a minimum height.
|
58
|
+
*
|
59
|
+
* @param {string} query - The height query string. Examples: 'h[100,200]' or 'h[100]'.
|
60
|
+
* @param {number} height - The height to check against the query.
|
61
|
+
* @returns {boolean} True if the height matches the query range, false otherwise.
|
62
|
+
*
|
63
|
+
* @example
|
64
|
+
* isWithinTheHeight('h[100,200]', 150) // returns true
|
65
|
+
* isWithinTheHeight('h[100]', 50) // returns false
|
66
|
+
* isWithinTheHeight('h[100]', 150) // returns true
|
67
|
+
*/
|
68
|
+
export declare const isWithinTheHeight: (query: string, height: number) => boolean;
|
69
|
+
/**
|
70
|
+
* Determines if the given screen size matches both the specified width and height ranges in the query.
|
71
|
+
*
|
72
|
+
* The function checks if the provided screen size (both width and height) falls within the ranges
|
73
|
+
* specified by the query. The query can specify both width and height using a format like 'w[100,200]:h[300,400]'.
|
74
|
+
*
|
75
|
+
* @param {string} query - The combined width and height query string. Example: 'w[100,200]:h[300,400]'.
|
76
|
+
* @param {ScreenSize} screenSize - The screen size to check against the query.
|
77
|
+
* @returns {boolean} True if the screen size matches both the width and height ranges in the query, false otherwise.
|
78
|
+
*
|
79
|
+
* @example
|
80
|
+
* const screenSize = { width: 150, height: 350 }
|
81
|
+
* isWithinTheWidthAndHeight('w[100,200]:h[300,400]', screenSize) // returns true
|
82
|
+
* isWithinTheWidthAndHeight('w[100,200]:h[400,500]', screenSize) // returns false
|
83
|
+
*/
|
84
|
+
export declare const isWithinTheWidthAndHeight: (query: string, screenSize: ScreenSize) => boolean;
|
85
|
+
/**
|
86
|
+
* Checks if the given query string is a valid custom media query.
|
87
|
+
*
|
88
|
+
* The valid custom media query formats include:
|
89
|
+
* - :w[200]
|
90
|
+
* - :w[0, 200]
|
91
|
+
* - :w[, 300]
|
92
|
+
* - :h[200]
|
93
|
+
* - :h[0, 500]
|
94
|
+
* - :h[,200]
|
95
|
+
* - :w[100, 300]:h[200,500]
|
96
|
+
* - :h[200,500]:w[100, 300]
|
97
|
+
*
|
98
|
+
* @param {string} query - The query string to be checked.
|
99
|
+
* @returns {boolean} Returns `true` if the query is a valid custom media query, otherwise `false`.
|
100
|
+
* @example
|
101
|
+
*
|
102
|
+
* isMediaQuery(':w[200]') // true
|
103
|
+
* isMediaQuery(':w100]') // false
|
104
|
+
*/
|
105
|
+
export declare const isMediaQuery: (query: string) => boolean;
|
106
|
+
/**
|
107
|
+
* Retrieves the first matching custom media query key based on the provided screen size.
|
108
|
+
*
|
109
|
+
* The function processes an array of media queries and returns the first query that matches
|
110
|
+
* the given screen size. The media queries can be in formats like:
|
111
|
+
* - w[200]
|
112
|
+
* - w[0, 200]
|
113
|
+
* - w[, 300]
|
114
|
+
* - h[200]
|
115
|
+
* - h[0, 500]
|
116
|
+
* - h[,200]
|
117
|
+
* - w[100, 300]:h[200,500]
|
118
|
+
* - h[200,500]:w[100, 300]
|
119
|
+
*
|
120
|
+
* @param {Array<[string, string | number]>} mediaQueries - An array of tuples containing media query keys and associated values.
|
121
|
+
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
122
|
+
* @returns {string | undefined} Returns the first matching media query key or `undefined` if no match is found.
|
123
|
+
* @example
|
124
|
+
*
|
125
|
+
* const queries = [[':w[200]', 'value1'], [':h[300,500]', 'value2']]
|
126
|
+
* const size = { width: 250, height: 400 }
|
127
|
+
* getKeyForCustomMediaQuery(queries, size) // ':w[200]
|
128
|
+
*/
|
129
|
+
export declare const getKeyForCustomMediaQuery: (mediaQueries: Array<[string, string | number | undefined]>, screenSize: ScreenSize) => string | undefined;
|
130
|
+
//# sourceMappingURL=mediaQueries.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../../src/utils/mediaQueries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,eAAgB,MAAM,KAAG,MAAM,MAAM,CAQ9D,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,UAAW,MAAM,cAAc,UAAU,KAAG,OAc1E,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,SAAS,MAAM,KAAG,OAQ/D,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,UAAU,MAAM,KAAG,OAQjE,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,UAAW,MAAM,cAAc,UAAU,KAAG,OAQjF,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,OAI5C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,iBAAkB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,cAAc,UAAU,KAAG,MAAM,GAAG,SAevI,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizeStyles.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizeStyles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,qBAAgC,CAAA"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { Transforms } from '../types';
|
2
|
+
export declare const normalizeStyles: <T extends Required<import("react-native").ShadowStyleIOS> | Required<Pick<import("react-native").TextStyle, "textShadowColor" | "textShadowOffset" | "textShadowRadius">> | {
|
3
|
+
transform: Transforms;
|
4
|
+
}>(style: T) => T;
|
5
|
+
//# sourceMappingURL=normalizeStyles.web.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizeStyles.web.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizeStyles.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoE,UAAU,EAAE,MAAM,UAAU,CAAA;AAuD5G,eAAO,MAAM,eAAe;;iBAwB3B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEjE,KAAK,YAAY,GAAG;IAChB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC;IACjD,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IACzD,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;CAClE,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,MAAM,YAAW,MAAM,WAyB5D,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,MAAM,oBAAiC,CAAA;AAwDpF,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAA"}
|
@@ -1,5 +1,51 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { Breakpoints, CustomNamedStyles, ScreenSize, SortedBreakpointEntries } from '../types';
|
2
|
+
/**
|
3
|
+
* Proxies a function to parse its return value for custom media queries or breakpoints.
|
4
|
+
*
|
5
|
+
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
6
|
+
*
|
7
|
+
* @param {Function} fn - The function to be proxified.
|
8
|
+
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
9
|
+
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
10
|
+
* @param breakpointPairs - sorted pairs of breakpoints
|
11
|
+
*
|
12
|
+
* @returns {Function} Returns the proxified function
|
13
|
+
*
|
14
|
+
* @example
|
15
|
+
*
|
16
|
+
* const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
|
17
|
+
* const screenSize = { width: 250, height: 400 }
|
18
|
+
* const breakpoints = { sm: 300, md: 600 }
|
19
|
+
*
|
20
|
+
* const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
|
21
|
+
* proxifiedFunction() // parsed style based on screenSize and breakpoints
|
22
|
+
*/
|
23
|
+
export declare const proxifyFunction: <B extends Breakpoints>(fn: Function, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => Function;
|
3
24
|
export declare const isPlatformColor: <T extends {}>(value: T) => boolean;
|
4
|
-
|
25
|
+
/**
|
26
|
+
* Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
|
27
|
+
*
|
28
|
+
* The function processes each key-value pair in the style object. If the value is a function or a valid style (not an object or a 'transform' key),
|
29
|
+
* it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
|
30
|
+
*
|
31
|
+
* @template T - The type of the style object.
|
32
|
+
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
33
|
+
*
|
34
|
+
* @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
|
35
|
+
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
36
|
+
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
37
|
+
* @param breakpointPairs - sorted pairs of breakpoints
|
38
|
+
*
|
39
|
+
* @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
|
40
|
+
*
|
41
|
+
* @example
|
42
|
+
*
|
43
|
+
* const style = { fontSize: { sm: '12px', md: '16px' } }
|
44
|
+
* const screenSize = { width: 300, height: 400 }
|
45
|
+
* const breakpoints = { xs: 0, sm: 300, md: 600 }
|
46
|
+
*
|
47
|
+
* const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
|
48
|
+
* // { fontSize: '12px' }
|
49
|
+
*/
|
50
|
+
export declare const parseStyle: <T, B extends Breakpoints>(style: CustomNamedStyles<T, B>, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => T;
|
5
51
|
//# sourceMappingURL=styles.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAKnG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,8BACpB,QAAQ,4CACA,UAAU,kDAEvB,QAGD,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,uGAGP,UAAU,mDAmDzB,CAAA"}
|
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.4.0",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
7
7
|
"test:coverage": "jest --coverage",
|
8
8
|
"tsc": "node_modules/typescript/bin/tsc --noEmit",
|
9
9
|
"lint": "eslint . --ext .ts,.tsx",
|
10
|
+
"clean": "del-cli lib",
|
10
11
|
"prepare": "husky install && bob build",
|
11
12
|
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
|
12
13
|
"release": "release-it"
|
@@ -19,28 +20,13 @@
|
|
19
20
|
"files": [
|
20
21
|
"src",
|
21
22
|
"lib",
|
22
|
-
"ios",
|
23
|
-
"android",
|
24
|
-
"cxx",
|
25
|
-
"react-native-unistyles.podspec",
|
26
|
-
"!lib/typescript/examples",
|
27
|
-
"!ios/build",
|
28
|
-
"!android/build",
|
29
|
-
"!android/gradle",
|
30
|
-
"!android/gradlew",
|
31
|
-
"!android/gradlew.bat",
|
32
|
-
"!android/local.properties",
|
33
23
|
"!**/*.spec.ts",
|
34
|
-
"!**/*.spec.tsx",
|
35
24
|
"!**/.*"
|
36
25
|
],
|
37
26
|
"keywords": [
|
38
27
|
"react-native",
|
39
28
|
"ios",
|
40
|
-
"android"
|
41
|
-
"react-native-macos",
|
42
|
-
"react-native-web",
|
43
|
-
"expo"
|
29
|
+
"android"
|
44
30
|
],
|
45
31
|
"repository": "https://github.com/jpudysz/react-native-unistyles",
|
46
32
|
"author": "Jacek Pudysz <jacekpudysz@gmail.com> (https://github.com/jpudysz)",
|
@@ -53,24 +39,26 @@
|
|
53
39
|
"registry": "https://registry.npmjs.org/"
|
54
40
|
},
|
55
41
|
"devDependencies": {
|
56
|
-
"@commitlint/config-conventional": "
|
42
|
+
"@commitlint/config-conventional": "17.8.0",
|
57
43
|
"@react-native/eslint-config": "0.74.0",
|
58
44
|
"@react-native/normalize-colors": "0.74.1",
|
59
|
-
"@release-it/conventional-changelog": "
|
45
|
+
"@release-it/conventional-changelog": "5.1.1",
|
60
46
|
"@testing-library/react-hooks": "8.0.1",
|
61
|
-
"@types/jest": "29.5.
|
62
|
-
"@types/react": "18.2.
|
63
|
-
"@
|
64
|
-
"@typescript-eslint/eslint-plugin
|
65
|
-
"@typescript-eslint/
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
47
|
+
"@types/jest": "29.5.5",
|
48
|
+
"@types/react": "18.2.28",
|
49
|
+
"@types/react-native": "0.72.3",
|
50
|
+
"@typescript-eslint/eslint-plugin": "6.8.0",
|
51
|
+
"@typescript-eslint/eslint-plugin-tslint": "6.8.0",
|
52
|
+
"@typescript-eslint/parser": "6.8.0",
|
53
|
+
"commitlint": "17.8.0",
|
54
|
+
"concurrently": "8.2.1",
|
55
|
+
"del-cli": "5.1.0",
|
56
|
+
"eslint": "8.51.0",
|
69
57
|
"eslint-config-codemask": "1.1.7",
|
70
58
|
"eslint-plugin-functional": "6.0.0",
|
71
|
-
"eslint-plugin-import": "2.
|
72
|
-
"eslint-plugin-jsdoc": "46.
|
73
|
-
"eslint-plugin-jsx-a11y": "6.
|
59
|
+
"eslint-plugin-import": "2.28.1",
|
60
|
+
"eslint-plugin-jsdoc": "46.8.2",
|
61
|
+
"eslint-plugin-jsx-a11y": "6.7.1",
|
74
62
|
"eslint-plugin-nested-if": "1.0.0",
|
75
63
|
"eslint-plugin-no-else": "0.2.2",
|
76
64
|
"eslint-plugin-no-loops": "0.3.0",
|
@@ -80,31 +68,26 @@
|
|
80
68
|
"husky": "8.0.3",
|
81
69
|
"jest": "29.7.0",
|
82
70
|
"react": "18.2.0",
|
83
|
-
"react-native": "0.72.
|
84
|
-
"react-native-builder-bob": "0.23.
|
71
|
+
"react-native": "0.72.6",
|
72
|
+
"react-native-builder-bob": "0.23.1",
|
85
73
|
"react-native-web": "0.19.9",
|
86
74
|
"react-test-renderer": "18.2.0",
|
87
|
-
"release-it": "
|
88
|
-
"typescript": "5.
|
75
|
+
"release-it": "16.2.1",
|
76
|
+
"typescript": "5.2.2"
|
89
77
|
},
|
90
78
|
"peerDependencies": {
|
91
79
|
"@react-native/normalize-colors": "*",
|
92
80
|
"react": "*",
|
93
81
|
"react-native": "*",
|
94
|
-
"react-native-macos": "*",
|
95
82
|
"react-native-web": "*"
|
96
83
|
},
|
97
84
|
"peerDependenciesMeta": {
|
98
|
-
"react-native-macos": {
|
99
|
-
"optional": true
|
100
|
-
},
|
101
85
|
"react-native-web": {
|
102
86
|
"optional": true
|
103
87
|
}
|
104
88
|
},
|
105
89
|
"workspaces": [
|
106
90
|
"examples/expo",
|
107
|
-
"examples/macos",
|
108
91
|
"docs"
|
109
92
|
],
|
110
93
|
"packageManager": "yarn@3.6.1",
|
@@ -115,13 +98,10 @@
|
|
115
98
|
"preset": "react-native",
|
116
99
|
"modulePathIgnorePatterns": [
|
117
100
|
"<rootDir>/examples/expo/node_modules",
|
118
|
-
"<rootDir>/examples/
|
101
|
+
"<rootDir>/examples/ssr/node_modules",
|
119
102
|
"<rootDir>/docs/node_modules",
|
120
103
|
"<rootDir>/lib/"
|
121
104
|
],
|
122
|
-
"testMatch": [
|
123
|
-
"**/*.spec.(ts|tsx)"
|
124
|
-
],
|
125
105
|
"coverageReporters": [
|
126
106
|
"html"
|
127
107
|
]
|
@@ -144,14 +124,13 @@
|
|
144
124
|
},
|
145
125
|
"plugins": {
|
146
126
|
"@release-it/conventional-changelog": {
|
147
|
-
"preset": "
|
127
|
+
"preset": "conventionalcommits"
|
148
128
|
}
|
149
129
|
}
|
150
130
|
},
|
151
131
|
"eslintIgnore": [
|
152
132
|
"node_modules/",
|
153
|
-
"lib/"
|
154
|
-
"src/utils/hash32.ts"
|
133
|
+
"lib/"
|
155
134
|
],
|
156
135
|
"react-native-builder-bob": {
|
157
136
|
"source": "src",
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React, { createContext } from 'react'
|
2
|
+
import type { PropsWithChildren } from 'react'
|
3
|
+
|
4
|
+
interface UnistylesThemeProps extends PropsWithChildren {
|
5
|
+
theme: any
|
6
|
+
}
|
7
|
+
|
8
|
+
export const UnistylesContext = createContext({})
|
9
|
+
|
10
|
+
export const UnistylesTheme: React.FunctionComponent<UnistylesThemeProps> = ({
|
11
|
+
theme,
|
12
|
+
children
|
13
|
+
}) => (
|
14
|
+
<UnistylesContext.Provider value={theme}>
|
15
|
+
{children}
|
16
|
+
</UnistylesContext.Provider>
|
17
|
+
)
|