@vxrn/safe-area 1.1.308 → 1.1.310

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.
@@ -0,0 +1,28 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var InitialWindow_exports = {};
22
+ __export(InitialWindow_exports, {
23
+ initialWindowMetrics: () => initialWindowMetrics,
24
+ initialWindowSafeAreaInsets: () => initialWindowSafeAreaInsets
25
+ });
26
+ module.exports = __toCommonJS(InitialWindow_exports);
27
+ const initialWindowMetrics = null,
28
+ initialWindowSafeAreaInsets = null;
@@ -2,30 +2,41 @@ 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, __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
6
7
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
15
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
21
  // If the importer is in node compatibility mode or this is not an ESM
17
22
  // file that has been converted to a CommonJS file using a Babel-
18
23
  // compatible transform (i.e. "__esModule" has not been set), then set
19
24
  // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
23
32
  var NativeSafeAreaProvider_exports = {};
24
33
  __export(NativeSafeAreaProvider_exports, {
25
34
  NativeSafeAreaProvider: () => NativeSafeAreaProvider
26
35
  });
27
36
  module.exports = __toCommonJS(NativeSafeAreaProvider_exports);
28
- var React = __toESM(require("react"), 1), import_react_native = require("react-native-web"), import_jsx_runtime = require("react/jsx-runtime");
37
+ var React = __toESM(require("react"), 1),
38
+ import_react_native = require("react-native-web"),
39
+ import_jsx_runtime = require("react/jsx-runtime");
29
40
  const CSSTransitions = {
30
41
  WebkitTransition: "webkitTransitionEnd",
31
42
  Transition: "transitionEnd",
@@ -39,60 +50,75 @@ function NativeSafeAreaProvider({
39
50
  onInsetsChange
40
51
  }) {
41
52
  return React.useEffect(() => {
42
- if (typeof document > "u")
43
- return;
53
+ if (typeof document > "u") return;
44
54
  const element = createContextElement();
45
55
  document.body.appendChild(element);
46
56
  const onEnd = () => {
47
- const { paddingTop, paddingBottom, paddingLeft, paddingRight } = window.getComputedStyle(element), insets = {
48
- top: paddingTop ? Number.parseInt(paddingTop, 10) : 0,
49
- bottom: paddingBottom ? Number.parseInt(paddingBottom, 10) : 0,
50
- left: paddingLeft ? Number.parseInt(paddingLeft, 10) : 0,
51
- right: paddingRight ? Number.parseInt(paddingRight, 10) : 0
52
- }, frame = {
53
- x: 0,
54
- y: 0,
55
- width: document.documentElement.offsetWidth,
56
- height: document.documentElement.offsetHeight
57
- };
58
- onInsetsChange({ nativeEvent: { insets, frame } });
57
+ const {
58
+ paddingTop,
59
+ paddingBottom,
60
+ paddingLeft,
61
+ paddingRight
62
+ } = window.getComputedStyle(element),
63
+ insets = {
64
+ top: paddingTop ? Number.parseInt(paddingTop, 10) : 0,
65
+ bottom: paddingBottom ? Number.parseInt(paddingBottom, 10) : 0,
66
+ left: paddingLeft ? Number.parseInt(paddingLeft, 10) : 0,
67
+ right: paddingRight ? Number.parseInt(paddingRight, 10) : 0
68
+ },
69
+ frame = {
70
+ x: 0,
71
+ y: 0,
72
+ width: document.documentElement.offsetWidth,
73
+ height: document.documentElement.offsetHeight
74
+ };
75
+ onInsetsChange({
76
+ nativeEvent: {
77
+ insets,
78
+ frame
79
+ }
80
+ });
59
81
  };
60
82
  return element.addEventListener(getSupportedTransitionEvent(), onEnd), onEnd(), () => {
61
83
  document.body.removeChild(element), element.removeEventListener(getSupportedTransitionEvent(), onEnd);
62
84
  };
63
- }, [onInsetsChange]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: style || {
64
- flex: 1,
65
- width: "100%",
66
- height: "100%",
67
- maxHeight: "100%",
68
- maxWidth: "100%"
69
- }, children });
85
+ }, [onInsetsChange]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
86
+ style: style || {
87
+ flex: 1,
88
+ width: "100%",
89
+ height: "100%",
90
+ maxHeight: "100%",
91
+ maxWidth: "100%"
92
+ },
93
+ children
94
+ });
70
95
  }
71
96
  let _supportedTransitionEvent = null;
72
97
  function getSupportedTransitionEvent() {
73
- if (_supportedTransitionEvent != null)
74
- return _supportedTransitionEvent;
98
+ if (_supportedTransitionEvent != null) return _supportedTransitionEvent;
75
99
  const element = document.createElement("invalidtype");
76
100
  _supportedTransitionEvent = CSSTransitions.Transition;
77
- for (const key in CSSTransitions)
78
- if (element.style[key] !== void 0) {
79
- _supportedTransitionEvent = CSSTransitions[key];
80
- break;
81
- }
101
+ for (const key in CSSTransitions) if (element.style[key] !== void 0) {
102
+ _supportedTransitionEvent = CSSTransitions[key];
103
+ break;
104
+ }
82
105
  return _supportedTransitionEvent;
83
106
  }
84
107
  let _supportedEnv = null;
85
108
  function getSupportedEnv() {
86
- if (_supportedEnv !== null)
87
- return _supportedEnv;
88
- const { CSS } = window;
109
+ if (_supportedEnv !== null) return _supportedEnv;
110
+ const {
111
+ CSS
112
+ } = window;
89
113
  return CSS && CSS.supports && CSS.supports("top: constant(safe-area-inset-top)") ? _supportedEnv = "constant" : _supportedEnv = "env", _supportedEnv;
90
114
  }
91
115
  function getInset(side) {
92
116
  return `${getSupportedEnv()}(safe-area-inset-${side})`;
93
117
  }
94
118
  function createContextElement() {
95
- const element = document.createElement("div"), { style } = element;
119
+ const element = document.createElement("div"),
120
+ {
121
+ style
122
+ } = element;
96
123
  return style.position = "fixed", style.left = "0", style.top = "0", style.width = "0", style.height = "0", style.zIndex = "-1", style.overflow = "hidden", style.visibility = "hidden", style.transitionDuration = "0.05s", style.transitionProperty = "padding", style.transitionDelay = "0s", style.paddingTop = getInset("top"), style.paddingBottom = getInset("bottom"), style.paddingLeft = getInset("left"), style.paddingRight = getInset("right"), element;
97
- }
98
- //# sourceMappingURL=NativeSafeAreaProvider.js.map
124
+ }
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ };
12
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
+ value: !0
14
+ }), mod);
15
+ var SafeArea_types_exports = {};
16
+ module.exports = __toCommonJS(SafeArea_types_exports);
@@ -2,24 +2,33 @@ 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, __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
6
7
  var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
15
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
21
  // If the importer is in node compatibility mode or this is not an ESM
17
22
  // file that has been converted to a CommonJS file using a Babel-
18
23
  // compatible transform (i.e. "__esModule" has not been set), then set
19
24
  // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
23
32
  var SafeAreaContext_exports = {};
24
33
  __export(SafeAreaContext_exports, {
25
34
  SafeAreaConsumer: () => SafeAreaConsumer,
@@ -33,8 +42,12 @@ __export(SafeAreaContext_exports, {
33
42
  withSafeAreaInsets: () => withSafeAreaInsets
34
43
  });
35
44
  module.exports = __toCommonJS(SafeAreaContext_exports);
36
- var React = __toESM(require("react"), 1), import_react_native = require("react-native-web"), import_NativeSafeAreaProvider = require("./NativeSafeAreaProvider"), import_jsx_runtime = require("react/jsx-runtime");
37
- const isDev = process.env.NODE_ENV !== "production", SafeAreaInsetsContext = React.createContext(null);
45
+ var React = __toESM(require("react"), 1),
46
+ import_react_native = require("react-native-web"),
47
+ import_NativeSafeAreaProvider = require("./NativeSafeAreaProvider.cjs"),
48
+ import_jsx_runtime = require("react/jsx-runtime");
49
+ const isDev = process.env.NODE_ENV !== "production",
50
+ SafeAreaInsetsContext = React.createContext(null);
38
51
  isDev && (SafeAreaInsetsContext.displayName = "SafeAreaInsetsContext");
39
52
  const SafeAreaFrameContext = React.createContext(null);
40
53
  isDev && (SafeAreaFrameContext.displayName = "SafeAreaFrameContext");
@@ -44,28 +57,40 @@ function SafeAreaProvider({
44
57
  initialSafeAreaInsets,
45
58
  ...others
46
59
  }) {
47
- const parentInsets = useParentSafeAreaInsets(), parentFrame = useParentSafeAreaFrame(), [insets, setInsets] = React.useState(
48
- initialMetrics?.insets ?? initialSafeAreaInsets ?? parentInsets ?? null
49
- ), [frame, setFrame] = React.useState(
50
- initialMetrics?.frame ?? parentFrame ?? {
60
+ const parentInsets = useParentSafeAreaInsets(),
61
+ parentFrame = useParentSafeAreaFrame(),
62
+ [insets, setInsets] = React.useState(initialMetrics?.insets ?? initialSafeAreaInsets ?? parentInsets ?? null),
63
+ [frame, setFrame] = React.useState(initialMetrics?.frame ?? parentFrame ?? {
51
64
  // Backwards compat so we render anyway if we don't have frame.
52
65
  x: 0,
53
66
  y: 0,
54
67
  width: import_react_native.Dimensions.get("window").width,
55
68
  height: import_react_native.Dimensions.get("window").height
56
- }
57
- ), onInsetsChange = React.useCallback((event) => {
58
- const {
59
- nativeEvent: { frame: nextFrame, insets: nextInsets }
60
- } = event;
61
- React.startTransition(() => {
62
- setFrame((curFrame) => (
69
+ }),
70
+ onInsetsChange = React.useCallback(event => {
71
+ const {
72
+ nativeEvent: {
73
+ frame: nextFrame,
74
+ insets: nextInsets
75
+ }
76
+ } = event;
77
+ React.startTransition(() => {
78
+ setFrame(curFrame =>
63
79
  // Backwards compat with old native code that won't send frame.
64
- nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y) ? nextFrame : curFrame
65
- )), setInsets((curInsets) => !curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top ? nextInsets : curInsets);
66
- });
67
- }, []);
68
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NativeSafeAreaProvider.NativeSafeAreaProvider, { onInsetsChange, ...others, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SafeAreaFrameContext.Provider, { value: frame, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SafeAreaInsetsContext.Provider, { value: insets, children }) }) });
80
+ nextFrame && (nextFrame.height !== curFrame.height || nextFrame.width !== curFrame.width || nextFrame.x !== curFrame.x || nextFrame.y !== curFrame.y) ? nextFrame : curFrame), setInsets(curInsets => !curInsets || nextInsets.bottom !== curInsets.bottom || nextInsets.left !== curInsets.left || nextInsets.right !== curInsets.right || nextInsets.top !== curInsets.top ? nextInsets : curInsets);
81
+ });
82
+ }, []);
83
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_NativeSafeAreaProvider.NativeSafeAreaProvider, {
84
+ onInsetsChange,
85
+ ...others,
86
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SafeAreaFrameContext.Provider, {
87
+ value: frame,
88
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(SafeAreaInsetsContext.Provider, {
89
+ value: insets,
90
+ children
91
+ })
92
+ })
93
+ });
69
94
  }
70
95
  function useParentSafeAreaInsets() {
71
96
  return React.useContext(SafeAreaInsetsContext);
@@ -76,24 +101,26 @@ function useParentSafeAreaFrame() {
76
101
  const NO_INSETS_ERROR = "No safe area value available. Make sure you are rendering `<SafeAreaProvider>` at the top of your app.";
77
102
  function useSafeAreaInsets() {
78
103
  const insets = React.useContext(SafeAreaInsetsContext);
79
- if (insets == null)
80
- throw new Error(NO_INSETS_ERROR);
104
+ if (insets == null) throw new Error(NO_INSETS_ERROR);
81
105
  return insets;
82
106
  }
83
107
  function useSafeAreaFrame() {
84
108
  const frame = React.useContext(SafeAreaFrameContext);
85
- if (frame == null)
86
- throw new Error(NO_INSETS_ERROR);
109
+ if (frame == null) throw new Error(NO_INSETS_ERROR);
87
110
  return frame;
88
111
  }
89
112
  function withSafeAreaInsets(WrappedComponent) {
90
113
  return React.forwardRef((props, ref) => {
91
114
  const insets = useSafeAreaInsets();
92
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WrappedComponent, { ...props, insets, ref });
115
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(WrappedComponent, {
116
+ ...props,
117
+ insets,
118
+ ref
119
+ });
93
120
  });
94
121
  }
95
122
  function useSafeArea() {
96
123
  return useSafeAreaInsets();
97
124
  }
98
- const SafeAreaConsumer = SafeAreaInsetsContext.Consumer, SafeAreaContext = SafeAreaInsetsContext;
99
- //# sourceMappingURL=SafeAreaContext.js.map
125
+ const SafeAreaConsumer = SafeAreaInsetsContext.Consumer,
126
+ SafeAreaContext = SafeAreaInsetsContext;
@@ -0,0 +1,106 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var SafeAreaView_exports = {};
33
+ __export(SafeAreaView_exports, {
34
+ SafeAreaView: () => SafeAreaView
35
+ });
36
+ module.exports = __toCommonJS(SafeAreaView_exports);
37
+ var React = __toESM(require("react"), 1),
38
+ import_react_native = require("react-native-web"),
39
+ import_SafeAreaContext = require("./SafeAreaContext.cjs"),
40
+ import_jsx_runtime = require("react/jsx-runtime");
41
+ const TOP = 8,
42
+ RIGHT = 4,
43
+ BOTTOM = 2,
44
+ LEFT = 1,
45
+ ALL = 15,
46
+ edgeBitmaskMap = {
47
+ top: TOP,
48
+ right: RIGHT,
49
+ bottom: BOTTOM,
50
+ left: LEFT
51
+ },
52
+ SafeAreaView = React.forwardRef(({
53
+ style = {},
54
+ mode,
55
+ edges,
56
+ ...rest
57
+ }, ref) => {
58
+ const insets = (0, import_SafeAreaContext.useSafeAreaInsets)(),
59
+ 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,
60
+ appliedStyle = React.useMemo(() => {
61
+ const insetTop = edgeBitmask & TOP ? insets.top : 0,
62
+ insetRight = edgeBitmask & RIGHT ? insets.right : 0,
63
+ insetBottom = edgeBitmask & BOTTOM ? insets.bottom : 0,
64
+ insetLeft = edgeBitmask & LEFT ? insets.left : 0,
65
+ flatStyle = import_react_native.StyleSheet.flatten(style);
66
+ if (mode === "margin") {
67
+ const {
68
+ margin = 0,
69
+ marginVertical = margin,
70
+ marginHorizontal = margin,
71
+ marginTop = marginVertical,
72
+ marginRight = marginHorizontal,
73
+ marginBottom = marginVertical,
74
+ marginLeft = marginHorizontal
75
+ } = flatStyle,
76
+ marginStyle = {
77
+ marginTop: marginTop + insetTop,
78
+ marginRight: marginRight + insetRight,
79
+ marginBottom: marginBottom + insetBottom,
80
+ marginLeft: marginLeft + insetLeft
81
+ };
82
+ return [style, marginStyle];
83
+ }
84
+ const {
85
+ padding = 0,
86
+ paddingVertical = padding,
87
+ paddingHorizontal = padding,
88
+ paddingTop = paddingVertical,
89
+ paddingRight = paddingHorizontal,
90
+ paddingBottom = paddingVertical,
91
+ paddingLeft = paddingHorizontal
92
+ } = flatStyle,
93
+ paddingStyle = {
94
+ paddingTop: paddingTop + insetTop,
95
+ paddingRight: paddingRight + insetRight,
96
+ paddingBottom: paddingBottom + insetBottom,
97
+ paddingLeft: paddingLeft + insetLeft
98
+ };
99
+ return [style, paddingStyle];
100
+ }, [style, insets, mode, edgeBitmask]);
101
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
102
+ style: appliedStyle,
103
+ ...rest,
104
+ ref
105
+ });
106
+ });
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./SafeAreaContext.cjs"), module.exports);
19
+ __reExport(src_exports, require("./SafeAreaView.cjs"), module.exports);
20
+ __reExport(src_exports, require("./InitialWindow.cjs"), module.exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/safe-area",
3
- "version": "1.1.308",
3
+ "version": "1.1.310",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "type": "module",
@@ -19,13 +19,15 @@
19
19
  "exports": {
20
20
  "./package.json": "./package.json",
21
21
  ".": {
22
+ "react-native-import": "./dist/esm/index.native.js",
23
+ "react-native": "./dist/cjs/index.native.js",
22
24
  "types": "./types/index.d.ts",
23
25
  "import": "./dist/esm/index.mjs",
24
- "require": "./dist/cjs/index.js"
26
+ "require": "./dist/cjs/index.cjs"
25
27
  }
26
28
  },
27
29
  "devDependencies": {
28
30
  "@biomejs/biome": "^1.8.3",
29
- "@tamagui/build": "^1.114.4"
31
+ "@tamagui/build": "^1.115.0"
30
32
  }
31
33
  }
@@ -1,22 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: !0 });
8
- }, __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from == "object" || typeof from == "function")
10
- for (let key of __getOwnPropNames(from))
11
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
- var InitialWindow_exports = {};
16
- __export(InitialWindow_exports, {
17
- initialWindowMetrics: () => initialWindowMetrics,
18
- initialWindowSafeAreaInsets: () => initialWindowSafeAreaInsets
19
- });
20
- module.exports = __toCommonJS(InitialWindow_exports);
21
- const initialWindowMetrics = null, initialWindowSafeAreaInsets = null;
22
- //# sourceMappingURL=InitialWindow.js.map
@@ -1,14 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- };
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var SafeArea_types_exports = {};
13
- module.exports = __toCommonJS(SafeArea_types_exports);
14
- //# sourceMappingURL=SafeArea-types.js.map
@@ -1,74 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var SafeAreaView_exports = {};
24
- __export(SafeAreaView_exports, {
25
- SafeAreaView: () => SafeAreaView
26
- });
27
- module.exports = __toCommonJS(SafeAreaView_exports);
28
- var React = __toESM(require("react"), 1), import_react_native = require("react-native-web"), import_SafeAreaContext = require("./SafeAreaContext"), import_jsx_runtime = require("react/jsx-runtime");
29
- const TOP = 8, RIGHT = 4, BOTTOM = 2, LEFT = 1, ALL = 15, edgeBitmaskMap = {
30
- top: TOP,
31
- right: RIGHT,
32
- bottom: BOTTOM,
33
- left: LEFT
34
- }, SafeAreaView = React.forwardRef(
35
- ({ style = {}, mode, edges, ...rest }, ref) => {
36
- const insets = (0, import_SafeAreaContext.useSafeAreaInsets)(), 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, appliedStyle = React.useMemo(() => {
37
- const insetTop = edgeBitmask & TOP ? insets.top : 0, insetRight = edgeBitmask & RIGHT ? insets.right : 0, insetBottom = edgeBitmask & BOTTOM ? insets.bottom : 0, insetLeft = edgeBitmask & LEFT ? insets.left : 0, flatStyle = import_react_native.StyleSheet.flatten(style);
38
- if (mode === "margin") {
39
- const {
40
- margin = 0,
41
- marginVertical = margin,
42
- marginHorizontal = margin,
43
- marginTop = marginVertical,
44
- marginRight = marginHorizontal,
45
- marginBottom = marginVertical,
46
- marginLeft = marginHorizontal
47
- } = flatStyle, marginStyle = {
48
- marginTop: marginTop + insetTop,
49
- marginRight: marginRight + insetRight,
50
- marginBottom: marginBottom + insetBottom,
51
- marginLeft: marginLeft + insetLeft
52
- };
53
- return [style, marginStyle];
54
- }
55
- const {
56
- padding = 0,
57
- paddingVertical = padding,
58
- paddingHorizontal = padding,
59
- paddingTop = paddingVertical,
60
- paddingRight = paddingHorizontal,
61
- paddingBottom = paddingVertical,
62
- paddingLeft = paddingHorizontal
63
- } = flatStyle, paddingStyle = {
64
- paddingTop: paddingTop + insetTop,
65
- paddingRight: paddingRight + insetRight,
66
- paddingBottom: paddingBottom + insetBottom,
67
- paddingLeft: paddingLeft + insetLeft
68
- };
69
- return [style, paddingStyle];
70
- }, [style, insets, mode, edgeBitmask]);
71
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: appliedStyle, ...rest, ref });
72
- }
73
- );
74
- //# sourceMappingURL=SafeAreaView.js.map
package/dist/cjs/index.js DELETED
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./SafeAreaContext"), module.exports);
15
- __reExport(src_exports, require("./SafeAreaView"), module.exports);
16
- __reExport(src_exports, require("./InitialWindow"), module.exports);
17
- //# sourceMappingURL=index.js.map
File without changes