@granite-js/blur-view 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # @granite-js/blur-view
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 260daab: feat: introduce support react native 0.84
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [260daab]
12
+ - @granite-js/native@1.0.0
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ import { View } from 'react-native';
4
+ import { ReactNativeBlurModule } from "./ReactNativeBlurModule.js";
5
+ import { isBlurNativeModuleSupported } from "./constants.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ /**
8
+ * @public
9
+ * @category UI
10
+ * @name BlurView
11
+ * @description
12
+ * `BlurView` adds a blurred background effect, primarily on iOS. It creates a visual blur on the background view.
13
+ *
14
+ * This component is supported only on iOS. On Android, it simply renders a regular [`View`](https://reactnative.dev/docs/0.72/view) without any blur effect.
15
+ *
16
+ * You can control the blur intensity and optionally enable the [vibrancy effect](https://developer.apple.com/documentation/uikit/uivibrancyeffect?language=objc), which enhances the visual impact of content displayed over a blurred background.
17
+ *
18
+ * If blur is not supported or doesn't render properly, you can use the `reducedTransparencyFallbackColor` prop to set a fallback background color.
19
+ *
20
+ * Use the `isSupported` property to check whether the current device supports blur. Blur is available on iOS from version 5.126.0 and not supported on Android.
21
+ *
22
+ * @param {BlurViewProps} [props] The props you can pass to `BlurView`. It extends `react-native`'s `ViewProps`, so you can use layout and style properties. The props align with those of [`@react-native-community/blur`](https://github.com/Kureev/react-native-blur/tree/v4.3.2?tab=readme-ov-file#blurview).
23
+ * @param {BlurType} [props.blurType] Type of blur to apply, such as `light`, `dark`, or `extraDark`.
24
+ * @param {number} [props.blurAmount=10] Intensity of the blur effect. Higher values make the blur stronger. Accepts values from `0` to `100`. Default is `10`.
25
+ * @param {boolean} [props.vibrancyEffect=false] Enables the vibrancy effect. This effect enhances content displayed on top of the blur. Only supported on iOS. Default is `false`.
26
+ * @param {string} [props.reducedTransparencyFallbackColor] Fallback background color used when blur cannot be applied due to system settings or device limitations.
27
+ *
28
+ * @returns {JSX.Element} On iOS, returns a blurred `BlurView` or `VibrancyView` component. On Android, returns a regular `View` without blur.
29
+ *
30
+ * ::: warning Note
31
+ * `BlurView` is only supported on iOS. On Android, it renders a regular `View` without any blur effect.
32
+ * :::
33
+ *
34
+ * @example
35
+ *
36
+ * ### Blurring background behind a text
37
+ *
38
+ * ```tsx
39
+ * import { BlurView } from '@granite-js/react-native';
40
+ * import { View, Text, StyleSheet } from 'react-native';
41
+ *
42
+ * export function BlurViewExample() {
43
+ * return (
44
+ * <View style={styles.container}>
45
+ * <Text style={styles.absolute}>Blurred Text</Text>
46
+ * <BlurView style={styles.absolute} blurType="light" blurAmount={1} />
47
+ * <Text>Non Blurred Text</Text>
48
+ * </View>
49
+ * );
50
+ * }
51
+ *
52
+ * const styles = StyleSheet.create({
53
+ * container: {
54
+ * justifyContent: 'center',
55
+ * alignItems: 'center',
56
+ * width: '100%',
57
+ * height: 300,
58
+ * },
59
+ * absolute: {
60
+ * position: 'absolute',
61
+ * top: 0,
62
+ * left: 0,
63
+ * bottom: 0,
64
+ * right: 0,
65
+ * },
66
+ * });
67
+ * ```
68
+ *
69
+ * @see [iOS Vibrancy Effect Documentation](https://developer.apple.com/documentation/uikit/uivibrancyeffect)
70
+ * @see [Zeddios Blog Explanation](https://zeddios.tistory.com/1140)
71
+ */
72
+ export function BlurView({
73
+ blurType,
74
+ blurAmount = 10,
75
+ reducedTransparencyFallbackColor,
76
+ vibrancyEffect = false,
77
+ ...viewProps
78
+ }) {
79
+ if (!isBlurNativeModuleSupported || ReactNativeBlurModule == null) {
80
+ return /*#__PURE__*/_jsx(View, {
81
+ ...viewProps
82
+ });
83
+ }
84
+ const Component = vibrancyEffect ? ReactNativeBlurModule.VibrancyView : ReactNativeBlurModule.BlurView;
85
+ return /*#__PURE__*/_jsx(Component, {
86
+ blurAmount: blurAmount,
87
+ blurType: blurType,
88
+ reducedTransparencyFallbackColor: reducedTransparencyFallbackColor,
89
+ ...viewProps
90
+ });
91
+ }
92
+ BlurView.isSupported = isBlurNativeModuleSupported;
93
+ //# sourceMappingURL=BlurView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["View","ReactNativeBlurModule","isBlurNativeModuleSupported","jsx","_jsx","BlurView","blurType","blurAmount","reducedTransparencyFallbackColor","vibrancyEffect","viewProps","Component","VibrancyView","isSupported"],"sourceRoot":"../../src","sources":["BlurView.tsx"],"mappings":";;AACA,SAASA,IAAI,QAAmB,cAAc;AAC9C,SAASC,qBAAqB,QAAQ,4BAAyB;AAC/D,SAASC,2BAA2B,QAAQ,gBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAW1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAC;EACvBC,QAAQ;EACRC,UAAU,GAAG,EAAE;EACfC,gCAAgC;EAChCC,cAAc,GAAG,KAAK;EACtB,GAAGC;AACU,CAAC,EAAE;EAChB,IAAI,CAACR,2BAA2B,IAAID,qBAAqB,IAAI,IAAI,EAAE;IACjE,oBAAOG,IAAA,CAACJ,IAAI;MAAA,GAAKU;IAAS,CAAG,CAAC;EAChC;EAEA,MAAMC,SAAS,GAAGF,cAAc,GAAGR,qBAAqB,CAACW,YAAY,GAAGX,qBAAqB,CAACI,QAAQ;EAEtG,oBACED,IAAA,CAACO,SAAS;IACRJ,UAAU,EAAEA,UAAW;IACvBD,QAAQ,EAAEA,QAAS;IACnBE,gCAAgC,EAAEA,gCAAiC;IAAA,GAC/DE;EAAS,CACd,CAAC;AAEN;AAEAL,QAAQ,CAACQ,WAAW,GAAGX,2BAA2B","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ import { isBlurNativeModuleSupported } from "./constants.js";
4
+ const ReactNativeBlurModule = (() => {
5
+ if (!isBlurNativeModuleSupported) {
6
+ return undefined;
7
+ }
8
+ try {
9
+ return require('@granite-js/native/@react-native-community/blur');
10
+ } catch {
11
+ return undefined;
12
+ }
13
+ })();
14
+ export { ReactNativeBlurModule };
15
+ //# sourceMappingURL=ReactNativeBlurModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isBlurNativeModuleSupported","ReactNativeBlurModule","undefined","require"],"sourceRoot":"../../src","sources":["ReactNativeBlurModule.ts"],"mappings":";;AACA,SAASA,2BAA2B,QAAQ,gBAAa;AAEzD,MAAMC,qBAAqB,GAAG,CAAC,MAAM;EACnC,IAAI,CAACD,2BAA2B,EAAE;IAChC,OAAOE,SAAS;EAClB;EAEA,IAAI;IACF,OAAOC,OAAO,CAAC,iDAAiD,CAAC;EAInE,CAAC,CAAC,MAAM;IACN,OAAOD,SAAS;EAClB;AACF,CAAC,EAAE,CAAC;AAEJ,SAASD,qBAAqB","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { Platform } from 'react-native';
4
+ export const isBlurNativeModuleSupported = Platform.OS === 'ios';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","isBlurNativeModuleSupported","OS"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,2BAA2B,GAAGD,QAAQ,CAACE,EAAE,KAAK,KAAK","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export * from "./BlurView.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,eAAY","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,78 @@
1
+ import type { BlurViewProps as InternalBlurViewProps } from '@granite-js/native/@react-native-community/blur';
2
+ import { ViewProps } from 'react-native';
3
+ export type BlurType = InternalBlurViewProps['blurType'];
4
+ export interface BlurViewProps extends ViewProps {
5
+ blurType?: BlurType;
6
+ blurAmount?: number;
7
+ vibrancyEffect?: boolean;
8
+ reducedTransparencyFallbackColor?: string;
9
+ }
10
+ /**
11
+ * @public
12
+ * @category UI
13
+ * @name BlurView
14
+ * @description
15
+ * `BlurView` adds a blurred background effect, primarily on iOS. It creates a visual blur on the background view.
16
+ *
17
+ * This component is supported only on iOS. On Android, it simply renders a regular [`View`](https://reactnative.dev/docs/0.72/view) without any blur effect.
18
+ *
19
+ * You can control the blur intensity and optionally enable the [vibrancy effect](https://developer.apple.com/documentation/uikit/uivibrancyeffect?language=objc), which enhances the visual impact of content displayed over a blurred background.
20
+ *
21
+ * If blur is not supported or doesn't render properly, you can use the `reducedTransparencyFallbackColor` prop to set a fallback background color.
22
+ *
23
+ * Use the `isSupported` property to check whether the current device supports blur. Blur is available on iOS from version 5.126.0 and not supported on Android.
24
+ *
25
+ * @param {BlurViewProps} [props] The props you can pass to `BlurView`. It extends `react-native`'s `ViewProps`, so you can use layout and style properties. The props align with those of [`@react-native-community/blur`](https://github.com/Kureev/react-native-blur/tree/v4.3.2?tab=readme-ov-file#blurview).
26
+ * @param {BlurType} [props.blurType] Type of blur to apply, such as `light`, `dark`, or `extraDark`.
27
+ * @param {number} [props.blurAmount=10] Intensity of the blur effect. Higher values make the blur stronger. Accepts values from `0` to `100`. Default is `10`.
28
+ * @param {boolean} [props.vibrancyEffect=false] Enables the vibrancy effect. This effect enhances content displayed on top of the blur. Only supported on iOS. Default is `false`.
29
+ * @param {string} [props.reducedTransparencyFallbackColor] Fallback background color used when blur cannot be applied due to system settings or device limitations.
30
+ *
31
+ * @returns {JSX.Element} On iOS, returns a blurred `BlurView` or `VibrancyView` component. On Android, returns a regular `View` without blur.
32
+ *
33
+ * ::: warning Note
34
+ * `BlurView` is only supported on iOS. On Android, it renders a regular `View` without any blur effect.
35
+ * :::
36
+ *
37
+ * @example
38
+ *
39
+ * ### Blurring background behind a text
40
+ *
41
+ * ```tsx
42
+ * import { BlurView } from '@granite-js/react-native';
43
+ * import { View, Text, StyleSheet } from 'react-native';
44
+ *
45
+ * export function BlurViewExample() {
46
+ * return (
47
+ * <View style={styles.container}>
48
+ * <Text style={styles.absolute}>Blurred Text</Text>
49
+ * <BlurView style={styles.absolute} blurType="light" blurAmount={1} />
50
+ * <Text>Non Blurred Text</Text>
51
+ * </View>
52
+ * );
53
+ * }
54
+ *
55
+ * const styles = StyleSheet.create({
56
+ * container: {
57
+ * justifyContent: 'center',
58
+ * alignItems: 'center',
59
+ * width: '100%',
60
+ * height: 300,
61
+ * },
62
+ * absolute: {
63
+ * position: 'absolute',
64
+ * top: 0,
65
+ * left: 0,
66
+ * bottom: 0,
67
+ * right: 0,
68
+ * },
69
+ * });
70
+ * ```
71
+ *
72
+ * @see [iOS Vibrancy Effect Documentation](https://developer.apple.com/documentation/uikit/uivibrancyeffect)
73
+ * @see [Zeddios Blog Explanation](https://zeddios.tistory.com/1140)
74
+ */
75
+ export declare function BlurView({ blurType, blurAmount, reducedTransparencyFallbackColor, vibrancyEffect, ...viewProps }: BlurViewProps): import("react/jsx-runtime").JSX.Element;
76
+ export declare namespace BlurView {
77
+ var isSupported: boolean;
78
+ }
@@ -0,0 +1,6 @@
1
+ import type { BlurView, VibrancyView } from '@granite-js/native/@react-native-community/blur';
2
+ declare const ReactNativeBlurModule: {
3
+ BlurView: typeof BlurView;
4
+ VibrancyView: typeof VibrancyView;
5
+ } | undefined;
6
+ export { ReactNativeBlurModule };
@@ -0,0 +1 @@
1
+ export declare const isBlurNativeModuleSupported: boolean;
@@ -0,0 +1 @@
1
+ export * from './BlurView';
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@granite-js/blur-view",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/module/index.js",
6
+ "types": "./dist/typescript/index.d.ts",
7
+ "react-native": "./src/index.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/typescript/index.d.ts",
11
+ "react-native": "./src/index.ts",
12
+ "default": "./dist/module/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "scripts": {
17
+ "prepack": "yarn build",
18
+ "typecheck": "tsc --noEmit",
19
+ "lint": "eslint .",
20
+ "build": "bob build && tsc --project tsconfig.build.json"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/toss/granite.git",
25
+ "directory": "packages/blur-view"
26
+ },
27
+ "files": [
28
+ "src",
29
+ "dist"
30
+ ],
31
+ "devDependencies": {
32
+ "@granite-js/native": "1.0.0",
33
+ "@types/react": "19.2.0",
34
+ "react": "19.2.3",
35
+ "react-native": "0.84.0-rc.5",
36
+ "react-native-builder-bob": "0.40.17",
37
+ "typescript": "5.9.3"
38
+ },
39
+ "peerDependencies": {
40
+ "@granite-js/native": "1.0.0",
41
+ "@types/react": "*",
42
+ "react": "*",
43
+ "react-native": "*"
44
+ },
45
+ "sideEffects": false,
46
+ "react-native-builder-bob": {
47
+ "source": "src",
48
+ "output": "dist",
49
+ "targets": [
50
+ [
51
+ "module",
52
+ {
53
+ "esm": true
54
+ }
55
+ ]
56
+ ]
57
+ }
58
+ }
@@ -0,0 +1,103 @@
1
+ import type { BlurViewProps as InternalBlurViewProps } from '@granite-js/native/@react-native-community/blur';
2
+ import { View, ViewProps } from 'react-native';
3
+ import { ReactNativeBlurModule } from './ReactNativeBlurModule';
4
+ import { isBlurNativeModuleSupported } from './constants';
5
+
6
+ export type BlurType = InternalBlurViewProps['blurType'];
7
+
8
+ export interface BlurViewProps extends ViewProps {
9
+ blurType?: BlurType;
10
+ blurAmount?: number;
11
+ vibrancyEffect?: boolean;
12
+ reducedTransparencyFallbackColor?: string;
13
+ }
14
+
15
+ /**
16
+ * @public
17
+ * @category UI
18
+ * @name BlurView
19
+ * @description
20
+ * `BlurView` adds a blurred background effect, primarily on iOS. It creates a visual blur on the background view.
21
+ *
22
+ * This component is supported only on iOS. On Android, it simply renders a regular [`View`](https://reactnative.dev/docs/0.72/view) without any blur effect.
23
+ *
24
+ * You can control the blur intensity and optionally enable the [vibrancy effect](https://developer.apple.com/documentation/uikit/uivibrancyeffect?language=objc), which enhances the visual impact of content displayed over a blurred background.
25
+ *
26
+ * If blur is not supported or doesn't render properly, you can use the `reducedTransparencyFallbackColor` prop to set a fallback background color.
27
+ *
28
+ * Use the `isSupported` property to check whether the current device supports blur. Blur is available on iOS from version 5.126.0 and not supported on Android.
29
+ *
30
+ * @param {BlurViewProps} [props] The props you can pass to `BlurView`. It extends `react-native`'s `ViewProps`, so you can use layout and style properties. The props align with those of [`@react-native-community/blur`](https://github.com/Kureev/react-native-blur/tree/v4.3.2?tab=readme-ov-file#blurview).
31
+ * @param {BlurType} [props.blurType] Type of blur to apply, such as `light`, `dark`, or `extraDark`.
32
+ * @param {number} [props.blurAmount=10] Intensity of the blur effect. Higher values make the blur stronger. Accepts values from `0` to `100`. Default is `10`.
33
+ * @param {boolean} [props.vibrancyEffect=false] Enables the vibrancy effect. This effect enhances content displayed on top of the blur. Only supported on iOS. Default is `false`.
34
+ * @param {string} [props.reducedTransparencyFallbackColor] Fallback background color used when blur cannot be applied due to system settings or device limitations.
35
+ *
36
+ * @returns {JSX.Element} On iOS, returns a blurred `BlurView` or `VibrancyView` component. On Android, returns a regular `View` without blur.
37
+ *
38
+ * ::: warning Note
39
+ * `BlurView` is only supported on iOS. On Android, it renders a regular `View` without any blur effect.
40
+ * :::
41
+ *
42
+ * @example
43
+ *
44
+ * ### Blurring background behind a text
45
+ *
46
+ * ```tsx
47
+ * import { BlurView } from '@granite-js/react-native';
48
+ * import { View, Text, StyleSheet } from 'react-native';
49
+ *
50
+ * export function BlurViewExample() {
51
+ * return (
52
+ * <View style={styles.container}>
53
+ * <Text style={styles.absolute}>Blurred Text</Text>
54
+ * <BlurView style={styles.absolute} blurType="light" blurAmount={1} />
55
+ * <Text>Non Blurred Text</Text>
56
+ * </View>
57
+ * );
58
+ * }
59
+ *
60
+ * const styles = StyleSheet.create({
61
+ * container: {
62
+ * justifyContent: 'center',
63
+ * alignItems: 'center',
64
+ * width: '100%',
65
+ * height: 300,
66
+ * },
67
+ * absolute: {
68
+ * position: 'absolute',
69
+ * top: 0,
70
+ * left: 0,
71
+ * bottom: 0,
72
+ * right: 0,
73
+ * },
74
+ * });
75
+ * ```
76
+ *
77
+ * @see [iOS Vibrancy Effect Documentation](https://developer.apple.com/documentation/uikit/uivibrancyeffect)
78
+ * @see [Zeddios Blog Explanation](https://zeddios.tistory.com/1140)
79
+ */
80
+ export function BlurView({
81
+ blurType,
82
+ blurAmount = 10,
83
+ reducedTransparencyFallbackColor,
84
+ vibrancyEffect = false,
85
+ ...viewProps
86
+ }: BlurViewProps) {
87
+ if (!isBlurNativeModuleSupported || ReactNativeBlurModule == null) {
88
+ return <View {...viewProps} />;
89
+ }
90
+
91
+ const Component = vibrancyEffect ? ReactNativeBlurModule.VibrancyView : ReactNativeBlurModule.BlurView;
92
+
93
+ return (
94
+ <Component
95
+ blurAmount={blurAmount}
96
+ blurType={blurType}
97
+ reducedTransparencyFallbackColor={reducedTransparencyFallbackColor}
98
+ {...viewProps}
99
+ />
100
+ );
101
+ }
102
+
103
+ BlurView.isSupported = isBlurNativeModuleSupported;
@@ -0,0 +1,19 @@
1
+ import type { BlurView, VibrancyView } from '@granite-js/native/@react-native-community/blur';
2
+ import { isBlurNativeModuleSupported } from './constants';
3
+
4
+ const ReactNativeBlurModule = (() => {
5
+ if (!isBlurNativeModuleSupported) {
6
+ return undefined;
7
+ }
8
+
9
+ try {
10
+ return require('@granite-js/native/@react-native-community/blur') as {
11
+ BlurView: typeof BlurView;
12
+ VibrancyView: typeof VibrancyView;
13
+ };
14
+ } catch {
15
+ return undefined;
16
+ }
17
+ })();
18
+
19
+ export { ReactNativeBlurModule };
@@ -0,0 +1,3 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ export const isBlurNativeModuleSupported = Platform.OS === 'ios';
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './BlurView';