@vxrn/safe-area 1.14.4 → 1.15.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/.turbo/turbo-build.log +1 -1
- package/dist/cjs/InitialWindow.cjs +14 -12
- package/dist/cjs/InitialWindow.native.js +14 -12
- package/dist/cjs/InitialWindow.native.js.map +1 -1
- package/dist/cjs/NativeSafeAreaProvider.cjs +98 -61
- package/dist/cjs/NativeSafeAreaProvider.native.js +115 -79
- package/dist/cjs/NativeSafeAreaProvider.native.js.map +1 -1
- package/dist/cjs/SafeArea-types.cjs +7 -5
- package/dist/cjs/SafeArea-types.native.js +7 -5
- package/dist/cjs/SafeArea-types.native.js.map +1 -1
- package/dist/cjs/SafeAreaContext.cjs +82 -55
- package/dist/cjs/SafeAreaContext.native.js +88 -70
- package/dist/cjs/SafeAreaContext.native.js.map +1 -1
- package/dist/cjs/SafeAreaView.cjs +94 -92
- package/dist/cjs/SafeAreaView.native.js +97 -95
- package/dist/cjs/SafeAreaView.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/InitialWindow.mjs +2 -2
- package/dist/esm/InitialWindow.mjs.map +1 -1
- package/dist/esm/InitialWindow.native.js +2 -2
- package/dist/esm/InitialWindow.native.js.map +1 -1
- package/dist/esm/NativeSafeAreaProvider.mjs +71 -36
- package/dist/esm/NativeSafeAreaProvider.mjs.map +1 -1
- package/dist/esm/NativeSafeAreaProvider.native.js +81 -47
- package/dist/esm/NativeSafeAreaProvider.native.js.map +1 -1
- package/dist/esm/SafeAreaContext.mjs +54 -29
- package/dist/esm/SafeAreaContext.mjs.map +1 -1
- package/dist/esm/SafeAreaContext.native.js +60 -44
- package/dist/esm/SafeAreaContext.native.js.map +1 -1
- package/dist/esm/SafeAreaView.mjs +65 -65
- package/dist/esm/SafeAreaView.mjs.map +1 -1
- package/dist/esm/SafeAreaView.native.js +69 -69
- package/dist/esm/SafeAreaView.native.js.map +1 -1
- package/package.json +2 -2
- package/src/SafeAreaContext.tsx +8 -2
- package/types/SafeAreaContext.d.ts.map +1 -1
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var SafeAreaContext_exports = {};
|
|
33
35
|
__export(SafeAreaContext_exports, {
|
|
34
36
|
SafeAreaConsumer: () => SafeAreaConsumer,
|
|
@@ -42,44 +44,65 @@ __export(SafeAreaContext_exports, {
|
|
|
42
44
|
withSafeAreaInsets: () => withSafeAreaInsets
|
|
43
45
|
});
|
|
44
46
|
module.exports = __toCommonJS(SafeAreaContext_exports);
|
|
45
|
-
var React = __toESM(require("react"), 1)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const isDev = process.env.NODE_ENV !== "production"
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
var React = __toESM(require("react"), 1);
|
|
48
|
+
var import_react_native = require("react-native-web");
|
|
49
|
+
var import_NativeSafeAreaProvider = require("./NativeSafeAreaProvider.cjs");
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
52
|
+
const SafeAreaInsetsContext = React.createContext(null);
|
|
53
|
+
if (isDev) {
|
|
54
|
+
SafeAreaInsetsContext.displayName = "SafeAreaInsetsContext";
|
|
55
|
+
}
|
|
52
56
|
const SafeAreaFrameContext = React.createContext(null);
|
|
53
|
-
|
|
57
|
+
if (isDev) {
|
|
58
|
+
SafeAreaFrameContext.displayName = "SafeAreaFrameContext";
|
|
59
|
+
}
|
|
60
|
+
const ZERO_INSETS = {
|
|
61
|
+
top: 0,
|
|
62
|
+
bottom: 0,
|
|
63
|
+
left: 0,
|
|
64
|
+
right: 0
|
|
65
|
+
};
|
|
54
66
|
function SafeAreaProvider({
|
|
55
67
|
children,
|
|
56
68
|
initialMetrics,
|
|
57
69
|
initialSafeAreaInsets,
|
|
58
70
|
...others
|
|
59
71
|
}) {
|
|
60
|
-
const parentInsets = useParentSafeAreaInsets()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
const parentInsets = useParentSafeAreaInsets();
|
|
73
|
+
const parentFrame = useParentSafeAreaFrame();
|
|
74
|
+
const [insets, setInsets] = React.useState(initialMetrics?.insets ?? initialSafeAreaInsets ?? parentInsets ?? ZERO_INSETS);
|
|
75
|
+
const [frame, setFrame] = React.useState(initialMetrics?.frame ?? parentFrame ?? {
|
|
76
|
+
// Backwards compat so we render anyway if we don't have frame.
|
|
77
|
+
x: 0,
|
|
78
|
+
y: 0,
|
|
79
|
+
width: import_react_native.Dimensions.get("window").width,
|
|
80
|
+
height: import_react_native.Dimensions.get("window").height
|
|
81
|
+
});
|
|
82
|
+
const onInsetsChange = React.useCallback(event => {
|
|
83
|
+
const {
|
|
84
|
+
nativeEvent: {
|
|
85
|
+
frame: nextFrame,
|
|
86
|
+
insets: nextInsets
|
|
87
|
+
}
|
|
88
|
+
} = event;
|
|
89
|
+
React.startTransition(() => {
|
|
90
|
+
setFrame(curFrame => {
|
|
91
|
+
if (
|
|
79
92
|
// Backwards compat with old native code that won't send frame.
|
|
80
|
-
nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y)
|
|
93
|
+
nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y)) {
|
|
94
|
+
return nextFrame;
|
|
95
|
+
}
|
|
96
|
+
return curFrame;
|
|
81
97
|
});
|
|
82
|
-
|
|
98
|
+
setInsets(curInsets => {
|
|
99
|
+
if (!curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top) {
|
|
100
|
+
return nextInsets;
|
|
101
|
+
}
|
|
102
|
+
return curInsets;
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}, []);
|
|
83
106
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NativeSafeAreaProvider.NativeSafeAreaProvider, {
|
|
84
107
|
onInsetsChange,
|
|
85
108
|
...others,
|
|
@@ -101,12 +124,16 @@ function useParentSafeAreaFrame() {
|
|
|
101
124
|
const NO_INSETS_ERROR = "No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.";
|
|
102
125
|
function useSafeAreaInsets() {
|
|
103
126
|
const insets = React.useContext(SafeAreaInsetsContext);
|
|
104
|
-
if (insets == null)
|
|
127
|
+
if (insets == null) {
|
|
128
|
+
throw new Error(NO_INSETS_ERROR);
|
|
129
|
+
}
|
|
105
130
|
return insets;
|
|
106
131
|
}
|
|
107
132
|
function useSafeAreaFrame() {
|
|
108
133
|
const frame = React.useContext(SafeAreaFrameContext);
|
|
109
|
-
if (frame == null)
|
|
134
|
+
if (frame == null) {
|
|
135
|
+
throw new Error(NO_INSETS_ERROR);
|
|
136
|
+
}
|
|
110
137
|
return frame;
|
|
111
138
|
}
|
|
112
139
|
function withSafeAreaInsets(WrappedComponent) {
|
|
@@ -122,5 +149,5 @@ function withSafeAreaInsets(WrappedComponent) {
|
|
|
122
149
|
function useSafeArea() {
|
|
123
150
|
return useSafeAreaInsets();
|
|
124
151
|
}
|
|
125
|
-
const SafeAreaConsumer = SafeAreaInsetsContext.Consumer
|
|
126
|
-
|
|
152
|
+
const SafeAreaConsumer = SafeAreaInsetsContext.Consumer;
|
|
153
|
+
const SafeAreaContext = SafeAreaInsetsContext;
|
|
@@ -4,33 +4,35 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var SafeAreaContext_exports = {};
|
|
35
37
|
__export(SafeAreaContext_exports, {
|
|
36
38
|
SafeAreaConsumer: () => SafeAreaConsumer,
|
|
@@ -44,55 +46,67 @@ __export(SafeAreaContext_exports, {
|
|
|
44
46
|
withSafeAreaInsets: () => withSafeAreaInsets
|
|
45
47
|
});
|
|
46
48
|
module.exports = __toCommonJS(SafeAreaContext_exports);
|
|
47
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
+
var React = __toESM(require("react"), 1);
|
|
51
|
+
var import_react_native = require("react-native");
|
|
52
|
+
var import_NativeSafeAreaProvider = require("./NativeSafeAreaProvider.native.js");
|
|
53
|
+
var isDev = process.env.NODE_ENV !== "production";
|
|
54
|
+
var SafeAreaInsetsContext = /* @__PURE__ */React.createContext(null);
|
|
55
|
+
if (isDev) {
|
|
56
|
+
SafeAreaInsetsContext.displayName = "SafeAreaInsetsContext";
|
|
57
|
+
}
|
|
54
58
|
var SafeAreaFrameContext = /* @__PURE__ */React.createContext(null);
|
|
55
|
-
|
|
59
|
+
if (isDev) {
|
|
60
|
+
SafeAreaFrameContext.displayName = "SafeAreaFrameContext";
|
|
61
|
+
}
|
|
62
|
+
var ZERO_INSETS = {
|
|
63
|
+
top: 0,
|
|
64
|
+
bottom: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
right: 0
|
|
67
|
+
};
|
|
56
68
|
function SafeAreaProvider(param) {
|
|
57
69
|
var {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
children,
|
|
71
|
+
initialMetrics,
|
|
72
|
+
initialSafeAreaInsets,
|
|
73
|
+
...others
|
|
74
|
+
} = param;
|
|
75
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
76
|
+
var parentInsets = useParentSafeAreaInsets();
|
|
77
|
+
var parentFrame = useParentSafeAreaFrame();
|
|
78
|
+
var [insets, setInsets] = React.useState((_ref = (_ref1 = (_ref2 = initialMetrics === null || initialMetrics === void 0 ? void 0 : initialMetrics.insets) !== null && _ref2 !== void 0 ? _ref2 : initialSafeAreaInsets) !== null && _ref1 !== void 0 ? _ref1 : parentInsets) !== null && _ref !== void 0 ? _ref : ZERO_INSETS);
|
|
79
|
+
var [frame, setFrame] = React.useState((_ref3 = (_ref4 = initialMetrics === null || initialMetrics === void 0 ? void 0 : initialMetrics.frame) !== null && _ref4 !== void 0 ? _ref4 : parentFrame) !== null && _ref3 !== void 0 ? _ref3 : {
|
|
80
|
+
// Backwards compat so we render anyway if we don't have frame.
|
|
81
|
+
x: 0,
|
|
82
|
+
y: 0,
|
|
83
|
+
width: import_react_native.Dimensions.get("window").width,
|
|
84
|
+
height: import_react_native.Dimensions.get("window").height
|
|
85
|
+
});
|
|
86
|
+
var onInsetsChange = React.useCallback(function (event) {
|
|
87
|
+
var {
|
|
88
|
+
nativeEvent: {
|
|
89
|
+
frame: nextFrame,
|
|
90
|
+
insets: nextInsets
|
|
91
|
+
}
|
|
92
|
+
} = event;
|
|
93
|
+
React.startTransition(function () {
|
|
94
|
+
setFrame(function (curFrame) {
|
|
95
|
+
if (
|
|
96
|
+
// Backwards compat with old native code that won't send frame.
|
|
97
|
+
nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y)) {
|
|
98
|
+
return nextFrame;
|
|
99
|
+
}
|
|
100
|
+
return curFrame;
|
|
101
|
+
});
|
|
102
|
+
setInsets(function (curInsets) {
|
|
103
|
+
if (!curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top) {
|
|
104
|
+
return nextInsets;
|
|
83
105
|
}
|
|
84
|
-
|
|
85
|
-
React.startTransition(function () {
|
|
86
|
-
setFrame(function (curFrame) {
|
|
87
|
-
return (
|
|
88
|
-
// Backwards compat with old native code that won't send frame.
|
|
89
|
-
nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y) ? nextFrame : curFrame
|
|
90
|
-
);
|
|
91
|
-
}), setInsets(function (curInsets) {
|
|
92
|
-
return !curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top ? nextInsets : curInsets;
|
|
93
|
-
});
|
|
106
|
+
return curInsets;
|
|
94
107
|
});
|
|
95
|
-
}
|
|
108
|
+
});
|
|
109
|
+
}, []);
|
|
96
110
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NativeSafeAreaProvider.NativeSafeAreaProvider, {
|
|
97
111
|
onInsetsChange,
|
|
98
112
|
...others,
|
|
@@ -114,12 +128,16 @@ function useParentSafeAreaFrame() {
|
|
|
114
128
|
var NO_INSETS_ERROR = "No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.";
|
|
115
129
|
function useSafeAreaInsets() {
|
|
116
130
|
var insets = React.useContext(SafeAreaInsetsContext);
|
|
117
|
-
if (insets == null)
|
|
131
|
+
if (insets == null) {
|
|
132
|
+
throw new Error(NO_INSETS_ERROR);
|
|
133
|
+
}
|
|
118
134
|
return insets;
|
|
119
135
|
}
|
|
120
136
|
function useSafeAreaFrame() {
|
|
121
137
|
var frame = React.useContext(SafeAreaFrameContext);
|
|
122
|
-
if (frame == null)
|
|
138
|
+
if (frame == null) {
|
|
139
|
+
throw new Error(NO_INSETS_ERROR);
|
|
140
|
+
}
|
|
123
141
|
return frame;
|
|
124
142
|
}
|
|
125
143
|
function withSafeAreaInsets(WrappedComponent) {
|
|
@@ -135,6 +153,6 @@ function withSafeAreaInsets(WrappedComponent) {
|
|
|
135
153
|
function useSafeArea() {
|
|
136
154
|
return useSafeAreaInsets();
|
|
137
155
|
}
|
|
138
|
-
var SafeAreaConsumer = SafeAreaInsetsContext.Consumer
|
|
139
|
-
|
|
156
|
+
var SafeAreaConsumer = SafeAreaInsetsContext.Consumer;
|
|
157
|
+
var SafeAreaContext = SafeAreaInsetsContext;
|
|
140
158
|
//# sourceMappingURL=SafeAreaContext.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","SafeAreaContext_exports","__export","SafeAreaConsumer","SafeAreaContext","SafeAreaFrameContext","SafeAreaInsetsContext","SafeAreaProvider","useSafeArea","useSafeAreaFrame","useSafeAreaInsets","withSafeAreaInsets","module","exports","import_jsx_runtime","require","React","__toESM","import_react_native","import_NativeSafeAreaProvider","isDev","process","env","NODE_ENV","createContext","displayName","param","children","initialMetrics","initialSafeAreaInsets","others","_ref","_ref1","_ref2","_ref3","_ref4","parentInsets","useParentSafeAreaInsets","parentFrame","useParentSafeAreaFrame","insets","setInsets","useState","frame","setFrame","x","y","width","Dimensions","get","height","onInsetsChange","useCallback","event","nativeEvent","nextFrame","nextInsets","startTransition","curFrame","curInsets","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","SafeAreaContext_exports","__export","SafeAreaConsumer","SafeAreaContext","SafeAreaFrameContext","SafeAreaInsetsContext","SafeAreaProvider","useSafeArea","useSafeAreaFrame","useSafeAreaInsets","withSafeAreaInsets","module","exports","import_jsx_runtime","require","React","__toESM","import_react_native","import_NativeSafeAreaProvider","isDev","process","env","NODE_ENV","createContext","displayName","ZERO_INSETS","top","bottom","left","right","param","children","initialMetrics","initialSafeAreaInsets","others","_ref","_ref1","_ref2","_ref3","_ref4","parentInsets","useParentSafeAreaInsets","parentFrame","useParentSafeAreaFrame","insets","setInsets","useState","frame","setFrame","x","y","width","Dimensions","get","height","onInsetsChange","useCallback","event","nativeEvent","nextFrame","nextInsets","startTransition","curFrame","curInsets","jsx","NativeSafeAreaProvider","Provider","useContext","NO_INSETS_ERROR","Error","WrappedComponent","forwardRef","props","ref"],"sources":["../../src/SafeAreaContext.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,oBAAA,EAAAA,CAAA,KAAAA,oBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA,qBAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAuB,GAAAjB,YAAA,CAAAK,uBAAA;AACvB,IAAAa,kBAAA,GAAAC,OAA2B;AAC3B,IAAAC,KAAA,GAAAC,OAAA,CAAAF,OAAA,SAAuC;AAyF/B,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3D,qBAAA,CAAA6D,QAAA;QACpDnE,KAAO,EAAM6C,MAAA;QACfb;MAEA;IACE;EACF;AAEA;AAGO,SAASU,uBAAgCA,CAAA;EAC9C,OAAM1B,KAAA,CAAAoD,UAAe,CAAA9D,qBAAW;AAChC;AACE,SAAAsC,sBAAgBA,CAAA;EAClB,OAAA5B,KAAA,CAAAoD,UAAA,CAAA/D,oBAAA;AACA;AACF,IAAAgE,eAAA;AAEO,SAAS3D,kBAAA,EAAyB;EACvC,IAAAmC,MAAM,GAAA7B,KAAQ,CAAAoD,UAAM,CAAA9D,qBAA+B;EACnD,IAAIuC,MAAA,IAAS,MAAM;IACjB,MAAM,IAAIyB,KAAA,CAAMD,eAAe;EACjC;EACA,OAAOxB,MAAA;AACT;AAMO,SAASpC,iBAAA,EACd;EAIA,IAAAuC,KAAO,GAAAhC,KAAM,CAAAoD,UAAY,CAAA/D,oBAAe;EACtC,IAAA2C,KAAM,QAAS;IAEf,UAAOsB,KAAA,CAAAD,eAAA;EACT;EACF,OAAArB,KAAA;AAKO;AACL,SAAOrC,kBAAkBA,CAAA4D,gBAAA;EAC3B,sBAAAvD,KAAA,CAAAwD,UAAA,WAAAC,KAAA,EAAAC,GAAA;IAKO,IAAM7B,MAAA,GAAAnC,iBAAmB;IAKzB,OAAM,eAAkB,IAAAI,kBAAA,CAAAmD,GAAA,EAAAM,gBAAA","ignoreList":[]}
|
|
@@ -2,105 +2,107 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var SafeAreaView_exports = {};
|
|
33
35
|
__export(SafeAreaView_exports, {
|
|
34
36
|
SafeAreaView: () => SafeAreaView
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(SafeAreaView_exports);
|
|
37
|
-
var React = __toESM(require("react"), 1)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const TOP = 8
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
39
|
+
var React = __toESM(require("react"), 1);
|
|
40
|
+
var import_react_native = require("react-native-web");
|
|
41
|
+
var import_SafeAreaContext = require("./SafeAreaContext.cjs");
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
const TOP = 8;
|
|
44
|
+
const RIGHT = 4;
|
|
45
|
+
const BOTTOM = 2;
|
|
46
|
+
const LEFT = 1;
|
|
47
|
+
const ALL = 15;
|
|
48
|
+
const edgeBitmaskMap = {
|
|
49
|
+
top: TOP,
|
|
50
|
+
right: RIGHT,
|
|
51
|
+
bottom: BOTTOM,
|
|
52
|
+
left: LEFT
|
|
53
|
+
};
|
|
54
|
+
const SafeAreaView = React.forwardRef(({
|
|
55
|
+
style = {},
|
|
56
|
+
mode,
|
|
57
|
+
edges,
|
|
58
|
+
...rest
|
|
59
|
+
}, ref) => {
|
|
60
|
+
const insets = (0, import_SafeAreaContext.useSafeAreaInsets)();
|
|
61
|
+
const edgeBitmask = edges != null ? Array.isArray(edges) ? edges.reduce((acc, edge) => acc | edgeBitmaskMap[edge], 0) : Object.keys(edges).reduce((acc, edge) => acc | edgeBitmaskMap[edge], 0) : ALL;
|
|
62
|
+
const appliedStyle = React.useMemo(() => {
|
|
63
|
+
const insetTop = edgeBitmask & TOP ? insets.top : 0;
|
|
64
|
+
const insetRight = edgeBitmask & RIGHT ? insets.right : 0;
|
|
65
|
+
const insetBottom = edgeBitmask & BOTTOM ? insets.bottom : 0;
|
|
66
|
+
const insetLeft = edgeBitmask & LEFT ? insets.left : 0;
|
|
67
|
+
const flatStyle = import_react_native.StyleSheet.flatten(style);
|
|
68
|
+
if (mode === "margin") {
|
|
69
|
+
const {
|
|
70
|
+
margin = 0,
|
|
71
|
+
marginVertical = margin,
|
|
72
|
+
marginHorizontal = margin,
|
|
73
|
+
marginTop = marginVertical,
|
|
74
|
+
marginRight = marginHorizontal,
|
|
75
|
+
marginBottom = marginVertical,
|
|
76
|
+
marginLeft = marginHorizontal
|
|
77
|
+
} = flatStyle;
|
|
78
|
+
const marginStyle = {
|
|
79
|
+
marginTop: marginTop + insetTop,
|
|
80
|
+
marginRight: marginRight + insetRight,
|
|
81
|
+
marginBottom: marginBottom + insetBottom,
|
|
82
|
+
marginLeft: marginLeft + insetLeft
|
|
83
|
+
};
|
|
84
|
+
return [style, marginStyle];
|
|
85
|
+
}
|
|
86
|
+
const {
|
|
87
|
+
padding = 0,
|
|
88
|
+
paddingVertical = padding,
|
|
89
|
+
paddingHorizontal = padding,
|
|
90
|
+
paddingTop = paddingVertical,
|
|
91
|
+
paddingRight = paddingHorizontal,
|
|
92
|
+
paddingBottom = paddingVertical,
|
|
93
|
+
paddingLeft = paddingHorizontal
|
|
94
|
+
} = flatStyle;
|
|
95
|
+
const paddingStyle = {
|
|
96
|
+
paddingTop: paddingTop + insetTop,
|
|
97
|
+
paddingRight: paddingRight + insetRight,
|
|
98
|
+
paddingBottom: paddingBottom + insetBottom,
|
|
99
|
+
paddingLeft: paddingLeft + insetLeft
|
|
100
|
+
};
|
|
101
|
+
return [style, paddingStyle];
|
|
102
|
+
}, [style, insets, mode, edgeBitmask]);
|
|
103
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
104
|
+
style: appliedStyle,
|
|
105
|
+
...rest,
|
|
106
|
+
ref
|
|
107
|
+
});
|
|
108
|
+
});
|