@worldcoin/mini-apps-ui-kit-react 1.3.2 → 1.3.4

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.
@@ -5,6 +5,7 @@ import * as React from "react";
5
5
  import { Drawer } from "../../node_modules/.pnpm/vaul@1.1.2_@types_react-dom@18.3.7_@types_react@18.3.23__@types_react@18.3.23_react-dom@18.3._hck6bgtscpcdlplcvchrs7yfhu/node_modules/vaul/dist/index.js";
6
6
  import { XMark } from "../Icons/XMark.js";
7
7
  import { AlertDialogContext, useAlertDialog } from "./use-alert-dialog.js";
8
+ import { useSafeAreaInsets } from "../SafeAreaView/useSafeAreaInsets.js";
8
9
  import { BottomBar } from "../BottomBar/BottomBar.js";
9
10
  import { Typography } from "../Typography/Typography.js";
10
11
  import { Button } from "../Button/Button.js";
@@ -29,25 +30,37 @@ AlertDialogTrigger.displayName = "AlertDialogTrigger";
29
30
  const AlertDialogPortal = Drawer.Portal;
30
31
  const AlertDialogClose = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(Drawer.Close, { ref, ...props }));
31
32
  AlertDialogClose.displayName = "AlertDialogClose";
32
- const AlertDialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [
33
- /* @__PURE__ */ jsx(
34
- Drawer.Overlay,
35
- {
36
- ref,
37
- className: cn("fixed inset-0 z-50 bg-gray-900/40", className),
38
- ...props
39
- }
40
- ),
41
- /* @__PURE__ */ jsx(
42
- Drawer.Content,
43
- {
44
- ref,
45
- className: cn("fixed inset-x-0 bottom-0 z-50 mt-24 h-auto", className),
46
- ...props,
47
- children: /* @__PURE__ */ jsx("div", { className: "flex flex-col rounded-[1.75rem] bg-gray-0 m-3 p-8", children })
48
- }
49
- )
50
- ] }));
33
+ const AlertDialogContent = React.forwardRef(({ className, children, ...props }, ref) => {
34
+ const safe = useSafeAreaInsets();
35
+ return /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [
36
+ /* @__PURE__ */ jsx(
37
+ Drawer.Overlay,
38
+ {
39
+ ref,
40
+ className: cn("fixed inset-0 z-50 bg-gray-900/40", className),
41
+ ...props
42
+ }
43
+ ),
44
+ /* @__PURE__ */ jsx(
45
+ Drawer.Content,
46
+ {
47
+ ref,
48
+ className: cn("fixed inset-x-0 bottom-0 z-50 mt-24 h-auto", className),
49
+ ...props,
50
+ children: /* @__PURE__ */ jsx(
51
+ "div",
52
+ {
53
+ className: "flex flex-col rounded-[1.75rem] bg-gray-0 m-3 p-8",
54
+ style: {
55
+ marginBottom: Math.max(safe.bottom, 12)
56
+ },
57
+ children
58
+ }
59
+ )
60
+ }
61
+ )
62
+ ] });
63
+ });
51
64
  AlertDialogContent.displayName = "AlertDialogContent";
52
65
  const AlertDialogHeader = ({ icon, children, ...props }) => {
53
66
  const { dismissible } = useAlertDialog();
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import React__default from "react";
3
4
  import { cn } from "../../lib/utils.js";
@@ -1,7 +1,29 @@
1
+ "use client";
2
+ import { useState, useEffect } from "react";
3
+ const defaultSafeAreaInsets = {
4
+ top: 0,
5
+ right: 0,
6
+ bottom: 0,
7
+ left: 0
8
+ };
1
9
  function useSafeAreaInsets() {
2
- var _a, _b;
3
- const safeAreaInsets = (_b = (_a = window == null ? void 0 : window.MiniKit) == null ? void 0 : _a.deviceProperties) == null ? void 0 : _b.safeAreaInsets;
4
- return safeAreaInsets ?? { top: 0, right: 0, bottom: 0, left: 0 };
10
+ const [safeAreaInsets, setSafeAreaInsets] = useState(() => {
11
+ var _a, _b;
12
+ if (typeof window !== "undefined") {
13
+ return ((_b = (_a = window == null ? void 0 : window.MiniKit) == null ? void 0 : _a.deviceProperties) == null ? void 0 : _b.safeAreaInsets) ?? defaultSafeAreaInsets;
14
+ }
15
+ return defaultSafeAreaInsets;
16
+ });
17
+ useEffect(() => {
18
+ var _a, _b;
19
+ if (typeof window !== "undefined") {
20
+ const insets = (_b = (_a = window == null ? void 0 : window.MiniKit) == null ? void 0 : _a.deviceProperties) == null ? void 0 : _b.safeAreaInsets;
21
+ if (insets && JSON.stringify(insets) !== JSON.stringify(safeAreaInsets)) {
22
+ setSafeAreaInsets(insets);
23
+ }
24
+ }
25
+ }, [safeAreaInsets]);
26
+ return safeAreaInsets;
5
27
  }
6
28
  export {
7
29
  useSafeAreaInsets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/mini-apps-ui-kit-react",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",