@amazon-devices/react-native-safe-area-context 8.0.9000000000 → 8.0.9000000002
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/SystemModules/amzn__react-native-safe-area-context-8.private.modules.txt +35 -29
- package/kepler-compatibility.json +4 -2
- package/lib/commonjs/index.js +0 -50
- package/oss-attribution/attribution.txt +0 -0
- package/oss-attribution/licenseInfos.json +1 -0
- package/package.json +1 -1
- package/src/index.tsx +0 -5
- package/SystemBundles/3e1c492419a85957481898df760cf9cf3bd38d3e26ef2e78822fb256fdee0153.bundle +0 -7373
- package/SystemBundles/3e1c492419a85957481898df760cf9cf3bd38d3e26ef2e78822fb256fdee0153.map +0 -2780
- package/jest/mock.tsx +0 -59
- package/lib/commonjs/CompatNativeSafeAreaProvider.js +0 -43
- package/lib/commonjs/InitialWindow.js +0 -13
- package/lib/commonjs/InitialWindow.kepler.js +0 -15
- package/lib/commonjs/InitialWindow.native.js +0 -15
- package/lib/commonjs/NativeSafeAreaProvider.js +0 -14
- package/lib/commonjs/NativeSafeAreaProvider.kepler.js +0 -13
- package/lib/commonjs/NativeSafeAreaProvider.web.js +0 -135
- package/lib/commonjs/NativeSafeAreaProvider.windows.js +0 -13
- package/lib/commonjs/SafeArea.types.js +0 -6
- package/lib/commonjs/SafeAreaContext.js +0 -133
- package/lib/commonjs/SafeAreaView.js +0 -49
- package/lib/commonjs/SafeAreaView.kepler.js +0 -9
- package/lib/commonjs/SafeAreaView.web.js +0 -91
- package/lib/commonjs/SafeAreaView.windows.js +0 -9
- package/lib/commonjs/specs/NativeSafeAreaContext.js +0 -9
- package/lib/commonjs/specs/NativeSafeAreaProvider.js +0 -10
- package/lib/commonjs/specs/NativeSafeAreaView.js +0 -12
- package/lib/module/CompatNativeSafeAreaProvider.js +0 -38
- package/lib/module/InitialWindow.js +0 -9
- package/lib/module/InitialWindow.kepler.js +0 -11
- package/lib/module/InitialWindow.native.js +0 -10
- package/lib/module/NativeSafeAreaProvider.js +0 -5
- package/lib/module/NativeSafeAreaProvider.kepler.js +0 -4
- package/lib/module/NativeSafeAreaProvider.web.js +0 -130
- package/lib/module/NativeSafeAreaProvider.windows.js +0 -4
- package/lib/module/SafeArea.types.js +0 -4
- package/lib/module/SafeAreaContext.js +0 -123
- package/lib/module/SafeAreaView.js +0 -43
- package/lib/module/SafeAreaView.kepler.js +0 -5
- package/lib/module/SafeAreaView.web.js +0 -86
- package/lib/module/SafeAreaView.windows.js +0 -5
- package/lib/module/index.js +0 -8
- package/lib/module/specs/NativeSafeAreaContext.js +0 -5
- package/lib/module/specs/NativeSafeAreaProvider.js +0 -5
- package/lib/module/specs/NativeSafeAreaView.js +0 -7
- package/src/CompatNativeSafeAreaProvider.tsx +0 -28
- package/src/InitialWindow.kepler.ts +0 -10
- package/src/InitialWindow.native.ts +0 -10
- package/src/InitialWindow.ts +0 -8
- package/src/NativeSafeAreaProvider.kepler.tsx +0 -1
- package/src/NativeSafeAreaProvider.tsx +0 -3
- package/src/NativeSafeAreaProvider.web.tsx +0 -127
- package/src/NativeSafeAreaProvider.windows.tsx +0 -1
- package/src/SafeArea.types.ts +0 -47
- package/src/SafeAreaContext.tsx +0 -171
- package/src/SafeAreaView.kepler.tsx +0 -3
- package/src/SafeAreaView.tsx +0 -50
- package/src/SafeAreaView.web.tsx +0 -123
- package/src/SafeAreaView.windows.tsx +0 -4
- package/src/specs/NativeSafeAreaContext.ts +0 -23
- package/src/specs/NativeSafeAreaProvider.ts +0 -29
- package/src/specs/NativeSafeAreaView.ts +0 -17
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { useWindowDimensions, View } from 'react-native';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
export function CompatNativeSafeAreaProvider({
|
|
7
|
-
children,
|
|
8
|
-
style,
|
|
9
|
-
onInsetsChange
|
|
10
|
-
}) {
|
|
11
|
-
const window = useWindowDimensions();
|
|
12
|
-
React.useEffect(() => {
|
|
13
|
-
const insets = {
|
|
14
|
-
top: 0,
|
|
15
|
-
bottom: 0,
|
|
16
|
-
left: 0,
|
|
17
|
-
right: 0
|
|
18
|
-
};
|
|
19
|
-
const frame = {
|
|
20
|
-
x: 0,
|
|
21
|
-
y: 0,
|
|
22
|
-
width: window.width,
|
|
23
|
-
height: window.height
|
|
24
|
-
};
|
|
25
|
-
// @ts-ignore: missing properties
|
|
26
|
-
onInsetsChange({
|
|
27
|
-
nativeEvent: {
|
|
28
|
-
insets,
|
|
29
|
-
frame
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}, [onInsetsChange, window.height, window.width]);
|
|
33
|
-
return /*#__PURE__*/_jsx(View, {
|
|
34
|
-
style: style,
|
|
35
|
-
children: children
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=CompatNativeSafeAreaProvider.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// amznmod_react for kepler, `initialWindowMetrics` is always null
|
|
4
|
-
// so assigning null directly,
|
|
5
|
-
// and only calling getViewManagerConfig() for non-kepler platforms
|
|
6
|
-
export const initialWindowMetrics = null;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
|
|
11
|
-
//# sourceMappingURL=InitialWindow.kepler.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import NativeSafeAreaContext from './specs/NativeSafeAreaContext';
|
|
4
|
-
export const initialWindowMetrics = NativeSafeAreaContext?.getConstants?.()?.initialWindowMetrics ?? null;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated
|
|
8
|
-
*/
|
|
9
|
-
export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
|
|
10
|
-
//# sourceMappingURL=InitialWindow.native.js.map
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/* eslint-env browser */
|
|
4
|
-
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import { View } from 'react-native';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
/**
|
|
9
|
-
* TODO:
|
|
10
|
-
* Currently insets and frame are based on the window and are not
|
|
11
|
-
* relative to the provider view. This is inconsistent with iOS and Android.
|
|
12
|
-
* However in most cases if the provider view covers the screen this is not
|
|
13
|
-
* an issue.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const CSSTransitions = {
|
|
17
|
-
WebkitTransition: 'webkitTransitionEnd',
|
|
18
|
-
Transition: 'transitionEnd',
|
|
19
|
-
MozTransition: 'transitionend',
|
|
20
|
-
MSTransition: 'msTransitionEnd',
|
|
21
|
-
OTransition: 'oTransitionEnd'
|
|
22
|
-
};
|
|
23
|
-
export function NativeSafeAreaProvider({
|
|
24
|
-
children,
|
|
25
|
-
style,
|
|
26
|
-
onInsetsChange
|
|
27
|
-
}) {
|
|
28
|
-
React.useEffect(() => {
|
|
29
|
-
// Skip for SSR.
|
|
30
|
-
if (typeof document === 'undefined') {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const element = createContextElement();
|
|
34
|
-
document.body.appendChild(element);
|
|
35
|
-
const onEnd = () => {
|
|
36
|
-
const {
|
|
37
|
-
paddingTop,
|
|
38
|
-
paddingBottom,
|
|
39
|
-
paddingLeft,
|
|
40
|
-
paddingRight
|
|
41
|
-
} = window.getComputedStyle(element);
|
|
42
|
-
const insets = {
|
|
43
|
-
top: paddingTop ? parseInt(paddingTop, 10) : 0,
|
|
44
|
-
bottom: paddingBottom ? parseInt(paddingBottom, 10) : 0,
|
|
45
|
-
left: paddingLeft ? parseInt(paddingLeft, 10) : 0,
|
|
46
|
-
right: paddingRight ? parseInt(paddingRight, 10) : 0
|
|
47
|
-
};
|
|
48
|
-
const frame = {
|
|
49
|
-
x: 0,
|
|
50
|
-
y: 0,
|
|
51
|
-
width: document.documentElement.offsetWidth,
|
|
52
|
-
height: document.documentElement.offsetHeight
|
|
53
|
-
};
|
|
54
|
-
// @ts-ignore: missing properties
|
|
55
|
-
onInsetsChange({
|
|
56
|
-
nativeEvent: {
|
|
57
|
-
insets,
|
|
58
|
-
frame
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
element.addEventListener(getSupportedTransitionEvent(), onEnd);
|
|
63
|
-
onEnd();
|
|
64
|
-
return () => {
|
|
65
|
-
document.body.removeChild(element);
|
|
66
|
-
element.removeEventListener(getSupportedTransitionEvent(), onEnd);
|
|
67
|
-
};
|
|
68
|
-
}, [onInsetsChange]);
|
|
69
|
-
return /*#__PURE__*/_jsx(View, {
|
|
70
|
-
style: style,
|
|
71
|
-
children: children
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
let _supportedTransitionEvent = null;
|
|
75
|
-
function getSupportedTransitionEvent() {
|
|
76
|
-
if (_supportedTransitionEvent != null) {
|
|
77
|
-
return _supportedTransitionEvent;
|
|
78
|
-
}
|
|
79
|
-
const element = document.createElement('invalidtype');
|
|
80
|
-
_supportedTransitionEvent = CSSTransitions.Transition;
|
|
81
|
-
for (const key in CSSTransitions) {
|
|
82
|
-
if (element.style[key] !== undefined) {
|
|
83
|
-
_supportedTransitionEvent = CSSTransitions[key];
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return _supportedTransitionEvent;
|
|
88
|
-
}
|
|
89
|
-
let _supportedEnv = null;
|
|
90
|
-
function getSupportedEnv() {
|
|
91
|
-
if (_supportedEnv !== null) {
|
|
92
|
-
return _supportedEnv;
|
|
93
|
-
}
|
|
94
|
-
const {
|
|
95
|
-
CSS
|
|
96
|
-
} = window;
|
|
97
|
-
if (CSS && CSS.supports && CSS.supports('top: constant(safe-area-inset-top)')) {
|
|
98
|
-
_supportedEnv = 'constant';
|
|
99
|
-
} else {
|
|
100
|
-
_supportedEnv = 'env';
|
|
101
|
-
}
|
|
102
|
-
return _supportedEnv;
|
|
103
|
-
}
|
|
104
|
-
function getInset(side) {
|
|
105
|
-
return `${getSupportedEnv()}(safe-area-inset-${side})`;
|
|
106
|
-
}
|
|
107
|
-
function createContextElement() {
|
|
108
|
-
const element = document.createElement('div');
|
|
109
|
-
const {
|
|
110
|
-
style
|
|
111
|
-
} = element;
|
|
112
|
-
style.position = 'fixed';
|
|
113
|
-
style.left = '0';
|
|
114
|
-
style.top = '0';
|
|
115
|
-
style.width = '0';
|
|
116
|
-
style.height = '0';
|
|
117
|
-
style.zIndex = '-1';
|
|
118
|
-
style.overflow = 'hidden';
|
|
119
|
-
style.visibility = 'hidden';
|
|
120
|
-
// Bacon: Anything faster than this and the callback will be invoked too early with the wrong insets
|
|
121
|
-
style.transitionDuration = '0.05s';
|
|
122
|
-
style.transitionProperty = 'padding';
|
|
123
|
-
style.transitionDelay = '0s';
|
|
124
|
-
style.paddingTop = getInset('top');
|
|
125
|
-
style.paddingBottom = getInset('bottom');
|
|
126
|
-
style.paddingLeft = getInset('left');
|
|
127
|
-
style.paddingRight = getInset('right');
|
|
128
|
-
return element;
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=NativeSafeAreaProvider.web.js.map
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Dimensions, StyleSheet } from 'react-native';
|
|
5
|
-
import { NativeSafeAreaProvider } from './NativeSafeAreaProvider';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const isDev = process.env.NODE_ENV !== 'production';
|
|
8
|
-
export const SafeAreaInsetsContext = /*#__PURE__*/React.createContext(null);
|
|
9
|
-
if (isDev) {
|
|
10
|
-
SafeAreaInsetsContext.displayName = 'SafeAreaInsetsContext';
|
|
11
|
-
}
|
|
12
|
-
export const SafeAreaFrameContext = /*#__PURE__*/React.createContext(null);
|
|
13
|
-
if (isDev) {
|
|
14
|
-
SafeAreaFrameContext.displayName = 'SafeAreaFrameContext';
|
|
15
|
-
}
|
|
16
|
-
export function SafeAreaProvider({
|
|
17
|
-
children,
|
|
18
|
-
initialMetrics,
|
|
19
|
-
initialSafeAreaInsets,
|
|
20
|
-
style,
|
|
21
|
-
...others
|
|
22
|
-
}) {
|
|
23
|
-
const parentInsets = useParentSafeAreaInsets();
|
|
24
|
-
const parentFrame = useParentSafeAreaFrame();
|
|
25
|
-
const [insets, setInsets] = React.useState(initialMetrics?.insets ?? initialSafeAreaInsets ?? parentInsets ?? null);
|
|
26
|
-
const [frame, setFrame] = React.useState(initialMetrics?.frame ?? parentFrame ?? {
|
|
27
|
-
// Backwards compat so we render anyway if we don't have frame.
|
|
28
|
-
x: 0,
|
|
29
|
-
y: 0,
|
|
30
|
-
width: Dimensions.get('window').width,
|
|
31
|
-
height: Dimensions.get('window').height
|
|
32
|
-
});
|
|
33
|
-
const onInsetsChange = React.useCallback(event => {
|
|
34
|
-
const {
|
|
35
|
-
nativeEvent: {
|
|
36
|
-
frame: nextFrame,
|
|
37
|
-
insets: nextInsets
|
|
38
|
-
}
|
|
39
|
-
} = event;
|
|
40
|
-
setFrame(curFrame => {
|
|
41
|
-
if (
|
|
42
|
-
// Backwards compat with old native code that won't send frame.
|
|
43
|
-
nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y)) {
|
|
44
|
-
return nextFrame;
|
|
45
|
-
} else {
|
|
46
|
-
return curFrame;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
setInsets(curInsets => {
|
|
50
|
-
if (!curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top) {
|
|
51
|
-
return nextInsets;
|
|
52
|
-
} else {
|
|
53
|
-
return curInsets;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}, []);
|
|
57
|
-
return /*#__PURE__*/_jsx(NativeSafeAreaProvider, {
|
|
58
|
-
style: [styles.fill, style],
|
|
59
|
-
onInsetsChange: onInsetsChange,
|
|
60
|
-
...others,
|
|
61
|
-
children: insets != null ? /*#__PURE__*/_jsx(SafeAreaFrameContext.Provider, {
|
|
62
|
-
value: frame,
|
|
63
|
-
children: /*#__PURE__*/_jsx(SafeAreaInsetsContext.Provider, {
|
|
64
|
-
value: insets,
|
|
65
|
-
children: children
|
|
66
|
-
})
|
|
67
|
-
}) : null
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const styles = StyleSheet.create({
|
|
71
|
-
fill: {
|
|
72
|
-
flex: 1
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
function useParentSafeAreaInsets() {
|
|
76
|
-
return React.useContext(SafeAreaInsetsContext);
|
|
77
|
-
}
|
|
78
|
-
function useParentSafeAreaFrame() {
|
|
79
|
-
return React.useContext(SafeAreaFrameContext);
|
|
80
|
-
}
|
|
81
|
-
const NO_INSETS_ERROR = 'No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.';
|
|
82
|
-
export function useSafeAreaInsets() {
|
|
83
|
-
const insets = React.useContext(SafeAreaInsetsContext);
|
|
84
|
-
if (insets == null) {
|
|
85
|
-
throw new Error(NO_INSETS_ERROR);
|
|
86
|
-
}
|
|
87
|
-
return insets;
|
|
88
|
-
}
|
|
89
|
-
export function useSafeAreaFrame() {
|
|
90
|
-
const frame = React.useContext(SafeAreaFrameContext);
|
|
91
|
-
if (frame == null) {
|
|
92
|
-
throw new Error(NO_INSETS_ERROR);
|
|
93
|
-
}
|
|
94
|
-
return frame;
|
|
95
|
-
}
|
|
96
|
-
export function withSafeAreaInsets(WrappedComponent) {
|
|
97
|
-
return /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
98
|
-
const insets = useSafeAreaInsets();
|
|
99
|
-
return /*#__PURE__*/_jsx(WrappedComponent, {
|
|
100
|
-
...props,
|
|
101
|
-
insets: insets,
|
|
102
|
-
ref: ref
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @deprecated
|
|
109
|
-
*/
|
|
110
|
-
export function useSafeArea() {
|
|
111
|
-
return useSafeAreaInsets();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @deprecated
|
|
116
|
-
*/
|
|
117
|
-
export const SafeAreaConsumer = SafeAreaInsetsContext.Consumer;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @deprecated
|
|
121
|
-
*/
|
|
122
|
-
export const SafeAreaContext = SafeAreaInsetsContext;
|
|
123
|
-
//# sourceMappingURL=SafeAreaContext.js.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import NativeSafeAreaView from './specs/NativeSafeAreaView';
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const defaultEdges = {
|
|
8
|
-
top: 'additive',
|
|
9
|
-
left: 'additive',
|
|
10
|
-
bottom: 'additive',
|
|
11
|
-
right: 'additive'
|
|
12
|
-
};
|
|
13
|
-
export const SafeAreaView = /*#__PURE__*/React.forwardRef(({
|
|
14
|
-
edges,
|
|
15
|
-
...props
|
|
16
|
-
}, ref) => {
|
|
17
|
-
const nativeEdges = useMemo(() => {
|
|
18
|
-
if (edges == null) {
|
|
19
|
-
return defaultEdges;
|
|
20
|
-
}
|
|
21
|
-
const edgesObj = Array.isArray(edges) ? edges.reduce((acc, edge) => {
|
|
22
|
-
acc[edge] = 'additive';
|
|
23
|
-
return acc;
|
|
24
|
-
}, {}) :
|
|
25
|
-
// ts has trouble with refining readonly arrays.
|
|
26
|
-
edges;
|
|
27
|
-
|
|
28
|
-
// make sure that we always pass all edges, required for fabric
|
|
29
|
-
const requiredEdges = {
|
|
30
|
-
top: edgesObj.top ?? 'off',
|
|
31
|
-
right: edgesObj.right ?? 'off',
|
|
32
|
-
bottom: edgesObj.bottom ?? 'off',
|
|
33
|
-
left: edgesObj.left ?? 'off'
|
|
34
|
-
};
|
|
35
|
-
return requiredEdges;
|
|
36
|
-
}, [edges]);
|
|
37
|
-
return /*#__PURE__*/_jsx(NativeSafeAreaView, {
|
|
38
|
-
...props,
|
|
39
|
-
edges: nativeEdges,
|
|
40
|
-
ref: ref
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=SafeAreaView.js.map
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { StyleSheet, View } from 'react-native';
|
|
5
|
-
import { useSafeAreaInsets } from './SafeAreaContext';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const defaultEdges = {
|
|
8
|
-
top: 'additive',
|
|
9
|
-
left: 'additive',
|
|
10
|
-
bottom: 'additive',
|
|
11
|
-
right: 'additive'
|
|
12
|
-
};
|
|
13
|
-
function getEdgeValue(inset, current, mode) {
|
|
14
|
-
switch (mode) {
|
|
15
|
-
case 'off':
|
|
16
|
-
return current;
|
|
17
|
-
case 'maximum':
|
|
18
|
-
return Math.max(current, inset);
|
|
19
|
-
case 'additive':
|
|
20
|
-
default:
|
|
21
|
-
return current + inset;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export const SafeAreaView = /*#__PURE__*/React.forwardRef(({
|
|
25
|
-
style = {},
|
|
26
|
-
mode,
|
|
27
|
-
edges,
|
|
28
|
-
...rest
|
|
29
|
-
}, ref) => {
|
|
30
|
-
const insets = useSafeAreaInsets();
|
|
31
|
-
const edgesRecord = React.useMemo(() => {
|
|
32
|
-
if (edges == null) {
|
|
33
|
-
return defaultEdges;
|
|
34
|
-
}
|
|
35
|
-
return Array.isArray(edges) ? edges.reduce((acc, edge) => {
|
|
36
|
-
acc[edge] = 'additive';
|
|
37
|
-
return acc;
|
|
38
|
-
}, {}) :
|
|
39
|
-
// ts has trouble with refining readonly arrays.
|
|
40
|
-
edges;
|
|
41
|
-
}, [edges]);
|
|
42
|
-
const appliedStyle = React.useMemo(() => {
|
|
43
|
-
const flatStyle = StyleSheet.flatten(style);
|
|
44
|
-
if (mode === 'margin') {
|
|
45
|
-
const {
|
|
46
|
-
margin = 0,
|
|
47
|
-
marginVertical = margin,
|
|
48
|
-
marginHorizontal = margin,
|
|
49
|
-
marginTop = marginVertical,
|
|
50
|
-
marginRight = marginHorizontal,
|
|
51
|
-
marginBottom = marginVertical,
|
|
52
|
-
marginLeft = marginHorizontal
|
|
53
|
-
} = flatStyle;
|
|
54
|
-
const marginStyle = {
|
|
55
|
-
marginTop: getEdgeValue(insets.top, marginTop, edgesRecord.top),
|
|
56
|
-
marginRight: getEdgeValue(insets.right, marginRight, edgesRecord.right),
|
|
57
|
-
marginBottom: getEdgeValue(insets.bottom, marginBottom, edgesRecord.bottom),
|
|
58
|
-
marginLeft: getEdgeValue(insets.left, marginLeft, edgesRecord.left)
|
|
59
|
-
};
|
|
60
|
-
return [style, marginStyle];
|
|
61
|
-
} else {
|
|
62
|
-
const {
|
|
63
|
-
padding = 0,
|
|
64
|
-
paddingVertical = padding,
|
|
65
|
-
paddingHorizontal = padding,
|
|
66
|
-
paddingTop = paddingVertical,
|
|
67
|
-
paddingRight = paddingHorizontal,
|
|
68
|
-
paddingBottom = paddingVertical,
|
|
69
|
-
paddingLeft = paddingHorizontal
|
|
70
|
-
} = flatStyle;
|
|
71
|
-
const paddingStyle = {
|
|
72
|
-
paddingTop: getEdgeValue(insets.top, paddingTop, edgesRecord.top),
|
|
73
|
-
paddingRight: getEdgeValue(insets.right, paddingRight, edgesRecord.right),
|
|
74
|
-
paddingBottom: getEdgeValue(insets.bottom, paddingBottom, edgesRecord.bottom),
|
|
75
|
-
paddingLeft: getEdgeValue(insets.left, paddingLeft, edgesRecord.left)
|
|
76
|
-
};
|
|
77
|
-
return [style, paddingStyle];
|
|
78
|
-
}
|
|
79
|
-
}, [edgesRecord.bottom, edgesRecord.left, edgesRecord.right, edgesRecord.top, insets.bottom, insets.left, insets.right, insets.top, mode, style]);
|
|
80
|
-
return /*#__PURE__*/_jsx(View, {
|
|
81
|
-
style: appliedStyle,
|
|
82
|
-
...rest,
|
|
83
|
-
ref: ref
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=SafeAreaView.web.js.map
|
package/lib/module/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useWindowDimensions, View } from 'react-native';
|
|
3
|
-
import type { NativeSafeAreaProviderProps } from './SafeArea.types';
|
|
4
|
-
|
|
5
|
-
export function CompatNativeSafeAreaProvider({
|
|
6
|
-
children,
|
|
7
|
-
style,
|
|
8
|
-
onInsetsChange,
|
|
9
|
-
}: NativeSafeAreaProviderProps) {
|
|
10
|
-
const window = useWindowDimensions();
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
const insets = {
|
|
13
|
-
top: 0,
|
|
14
|
-
bottom: 0,
|
|
15
|
-
left: 0,
|
|
16
|
-
right: 0,
|
|
17
|
-
};
|
|
18
|
-
const frame = {
|
|
19
|
-
x: 0,
|
|
20
|
-
y: 0,
|
|
21
|
-
width: window.width,
|
|
22
|
-
height: window.height,
|
|
23
|
-
};
|
|
24
|
-
// @ts-ignore: missing properties
|
|
25
|
-
onInsetsChange({ nativeEvent: { insets, frame } });
|
|
26
|
-
}, [onInsetsChange, window.height, window.width]);
|
|
27
|
-
return <View style={style}>{children}</View>;
|
|
28
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Metrics } from './SafeArea.types';
|
|
2
|
-
|
|
3
|
-
// amznmod_react for kepler, `initialWindowMetrics` is always null
|
|
4
|
-
// so assigning null directly,
|
|
5
|
-
// and only calling getViewManagerConfig() for non-kepler platforms
|
|
6
|
-
export const initialWindowMetrics = null as Metrics | null;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Metrics } from './SafeArea.types';
|
|
2
|
-
import NativeSafeAreaContext from './specs/NativeSafeAreaContext';
|
|
3
|
-
|
|
4
|
-
export const initialWindowMetrics = (NativeSafeAreaContext?.getConstants?.()
|
|
5
|
-
?.initialWindowMetrics ?? null) as Metrics | null;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
|
package/src/InitialWindow.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CompatNativeSafeAreaProvider as NativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';
|