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