@vxrn/safe-area 1.14.4 → 1.14.5
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 +76 -55
- package/dist/cjs/SafeAreaContext.native.js +82 -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 +48 -29
- package/dist/esm/SafeAreaContext.mjs.map +1 -1
- package/dist/esm/SafeAreaContext.native.js +54 -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
|
@@ -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,59 @@ __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
|
+
}
|
|
54
60
|
function SafeAreaProvider({
|
|
55
61
|
children,
|
|
56
62
|
initialMetrics,
|
|
57
63
|
initialSafeAreaInsets,
|
|
58
64
|
...others
|
|
59
65
|
}) {
|
|
60
|
-
const parentInsets = useParentSafeAreaInsets()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
const parentInsets = useParentSafeAreaInsets();
|
|
67
|
+
const parentFrame = useParentSafeAreaFrame();
|
|
68
|
+
const [insets, setInsets] = React.useState(initialMetrics?.insets ?? initialSafeAreaInsets ?? parentInsets ?? null);
|
|
69
|
+
const [frame, setFrame] = React.useState(initialMetrics?.frame ?? parentFrame ?? {
|
|
70
|
+
// Backwards compat so we render anyway if we don't have frame.
|
|
71
|
+
x: 0,
|
|
72
|
+
y: 0,
|
|
73
|
+
width: import_react_native.Dimensions.get("window").width,
|
|
74
|
+
height: import_react_native.Dimensions.get("window").height
|
|
75
|
+
});
|
|
76
|
+
const onInsetsChange = React.useCallback(event => {
|
|
77
|
+
const {
|
|
78
|
+
nativeEvent: {
|
|
79
|
+
frame: nextFrame,
|
|
80
|
+
insets: nextInsets
|
|
81
|
+
}
|
|
82
|
+
} = event;
|
|
83
|
+
React.startTransition(() => {
|
|
84
|
+
setFrame(curFrame => {
|
|
85
|
+
if (
|
|
79
86
|
// 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)
|
|
87
|
+
nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y)) {
|
|
88
|
+
return nextFrame;
|
|
89
|
+
}
|
|
90
|
+
return curFrame;
|
|
81
91
|
});
|
|
82
|
-
|
|
92
|
+
setInsets(curInsets => {
|
|
93
|
+
if (!curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top) {
|
|
94
|
+
return nextInsets;
|
|
95
|
+
}
|
|
96
|
+
return curInsets;
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}, []);
|
|
83
100
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NativeSafeAreaProvider.NativeSafeAreaProvider, {
|
|
84
101
|
onInsetsChange,
|
|
85
102
|
...others,
|
|
@@ -101,12 +118,16 @@ function useParentSafeAreaFrame() {
|
|
|
101
118
|
const NO_INSETS_ERROR = "No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.";
|
|
102
119
|
function useSafeAreaInsets() {
|
|
103
120
|
const insets = React.useContext(SafeAreaInsetsContext);
|
|
104
|
-
if (insets == null)
|
|
121
|
+
if (insets == null) {
|
|
122
|
+
throw new Error(NO_INSETS_ERROR);
|
|
123
|
+
}
|
|
105
124
|
return insets;
|
|
106
125
|
}
|
|
107
126
|
function useSafeAreaFrame() {
|
|
108
127
|
const frame = React.useContext(SafeAreaFrameContext);
|
|
109
|
-
if (frame == null)
|
|
128
|
+
if (frame == null) {
|
|
129
|
+
throw new Error(NO_INSETS_ERROR);
|
|
130
|
+
}
|
|
110
131
|
return frame;
|
|
111
132
|
}
|
|
112
133
|
function withSafeAreaInsets(WrappedComponent) {
|
|
@@ -122,5 +143,5 @@ function withSafeAreaInsets(WrappedComponent) {
|
|
|
122
143
|
function useSafeArea() {
|
|
123
144
|
return useSafeAreaInsets();
|
|
124
145
|
}
|
|
125
|
-
const SafeAreaConsumer = SafeAreaInsetsContext.Consumer
|
|
126
|
-
|
|
146
|
+
const SafeAreaConsumer = SafeAreaInsetsContext.Consumer;
|
|
147
|
+
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,61 @@ __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
|
+
}
|
|
56
62
|
function SafeAreaProvider(param) {
|
|
57
63
|
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
|
-
|
|
64
|
+
children,
|
|
65
|
+
initialMetrics,
|
|
66
|
+
initialSafeAreaInsets,
|
|
67
|
+
...others
|
|
68
|
+
} = param;
|
|
69
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
70
|
+
var parentInsets = useParentSafeAreaInsets();
|
|
71
|
+
var parentFrame = useParentSafeAreaFrame();
|
|
72
|
+
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 : null);
|
|
73
|
+
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 : {
|
|
74
|
+
// Backwards compat so we render anyway if we don't have frame.
|
|
75
|
+
x: 0,
|
|
76
|
+
y: 0,
|
|
77
|
+
width: import_react_native.Dimensions.get("window").width,
|
|
78
|
+
height: import_react_native.Dimensions.get("window").height
|
|
79
|
+
});
|
|
80
|
+
var onInsetsChange = React.useCallback(function (event) {
|
|
81
|
+
var {
|
|
82
|
+
nativeEvent: {
|
|
83
|
+
frame: nextFrame,
|
|
84
|
+
insets: nextInsets
|
|
85
|
+
}
|
|
86
|
+
} = event;
|
|
87
|
+
React.startTransition(function () {
|
|
88
|
+
setFrame(function (curFrame) {
|
|
89
|
+
if (
|
|
90
|
+
// Backwards compat with old native code that won't send frame.
|
|
91
|
+
nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y)) {
|
|
92
|
+
return nextFrame;
|
|
93
|
+
}
|
|
94
|
+
return curFrame;
|
|
95
|
+
});
|
|
96
|
+
setInsets(function (curInsets) {
|
|
97
|
+
if (!curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top) {
|
|
98
|
+
return nextInsets;
|
|
83
99
|
}
|
|
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
|
-
});
|
|
100
|
+
return curInsets;
|
|
94
101
|
});
|
|
95
|
-
}
|
|
102
|
+
});
|
|
103
|
+
}, []);
|
|
96
104
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NativeSafeAreaProvider.NativeSafeAreaProvider, {
|
|
97
105
|
onInsetsChange,
|
|
98
106
|
...others,
|
|
@@ -114,12 +122,16 @@ function useParentSafeAreaFrame() {
|
|
|
114
122
|
var NO_INSETS_ERROR = "No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.";
|
|
115
123
|
function useSafeAreaInsets() {
|
|
116
124
|
var insets = React.useContext(SafeAreaInsetsContext);
|
|
117
|
-
if (insets == null)
|
|
125
|
+
if (insets == null) {
|
|
126
|
+
throw new Error(NO_INSETS_ERROR);
|
|
127
|
+
}
|
|
118
128
|
return insets;
|
|
119
129
|
}
|
|
120
130
|
function useSafeAreaFrame() {
|
|
121
131
|
var frame = React.useContext(SafeAreaFrameContext);
|
|
122
|
-
if (frame == null)
|
|
132
|
+
if (frame == null) {
|
|
133
|
+
throw new Error(NO_INSETS_ERROR);
|
|
134
|
+
}
|
|
123
135
|
return frame;
|
|
124
136
|
}
|
|
125
137
|
function withSafeAreaInsets(WrappedComponent) {
|
|
@@ -135,6 +147,6 @@ function withSafeAreaInsets(WrappedComponent) {
|
|
|
135
147
|
function useSafeArea() {
|
|
136
148
|
return useSafeAreaInsets();
|
|
137
149
|
}
|
|
138
|
-
var SafeAreaConsumer = SafeAreaInsetsContext.Consumer
|
|
139
|
-
|
|
150
|
+
var SafeAreaConsumer = SafeAreaInsetsContext.Consumer;
|
|
151
|
+
var SafeAreaContext = SafeAreaInsetsContext;
|
|
140
152
|
//# 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","bottom","left","right","top","jsx","NativeSafeAreaProvider","Provider","useContext","NO_INSETS_ERROR","Error","WrappedComponent","forwardRef","props","ref"],"sources":["../../src/SafeAreaContext.tsx"],"sourcesContent":[null],"mappings":"
|
|
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","bottom","left","right","top","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;AAmF/B,IAAAG,mBAAA,GAAAH,OAAA;AAhFR,IAAAI,6BAA0B,GAAAJ,OAAa;AAEhC,IAAAK,KAAM,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAwB,KAAM;AAC3C,IAAIjB,qBAAO,kBAAAU,KAAA,CAAAQ,aAAA;AACT,IAAAJ,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AmD,UAAA,CAAA7D,qBAAe;EACjC,IAAAkC,MAAA;IACA,MAAO,IAAA6B,KAAA,CAAAD,eAAA;EACT;EAEO,OAAS5B,MAAA;AACd;AACA,SAAI/B,gBAAeA,CAAA;EACjB,IAAAkC,KAAM,GAAI3B,KAAA,CAAMmD,UAAA,CAAA9D,oBAAe;EACjC,IAAAsC,KAAA;IACA,MAAO,IAAA0B,KAAA,CAAAD,eAAA;EACT;EAMO,OAASzB,KAAA;AAKd;AACE,SAAAhC,kBAAeA,CAAA2D,gBAAkB;EAEjC,sBAAOtD,KAAA,CAAAuD,UAAA,WAAAC,KAAC,EAAAC,GAAA;IACT,IAAAjC,MAAA,GAAA9B,iBAAA;IACH,0BAAAI,kBAAA,CAAAkD,GAAA,EAAAM,gBAAA;MAKO,GAASE,KAAA;MACdhC,MAAO;MACTiC;IAKO,EAAM;EAKN","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
|
+
});
|