@hyperbridge/ui 0.0.29 → 0.0.30

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/dist/index.mjs CHANGED
@@ -1210,7 +1210,7 @@ function EmptyState(props) {
1210
1210
 
1211
1211
  // src/components/molecules/modal.tsx
1212
1212
  import { AnimatePresence, motion } from "motion/react";
1213
- import { useEffect as useEffect3 } from "react";
1213
+ import { useEffect as useEffect4 } from "react";
1214
1214
 
1215
1215
  // src/hooks/is-mobile.ts
1216
1216
  import { useEffect as useEffect2, useState as useState3 } from "react";
@@ -1227,6 +1227,31 @@ var useIsMobile = () => {
1227
1227
  return isMobile;
1228
1228
  };
1229
1229
 
1230
+ // src/hooks/use-viewport-height.ts
1231
+ import { useEffect as useEffect3, useState as useState4 } from "react";
1232
+ function useViewportHeight(enabled = true) {
1233
+ const [viewportHeight, setViewportHeight] = useState4(null);
1234
+ useEffect3(() => {
1235
+ if (!enabled) return;
1236
+ const handleResize = () => {
1237
+ if (window.visualViewport) {
1238
+ setViewportHeight(window.visualViewport.height);
1239
+ }
1240
+ };
1241
+ if (window.visualViewport) {
1242
+ window.visualViewport.addEventListener("resize", handleResize);
1243
+ handleResize();
1244
+ }
1245
+ return () => {
1246
+ if (window.visualViewport) {
1247
+ window.visualViewport.removeEventListener("resize", handleResize);
1248
+ }
1249
+ setViewportHeight(null);
1250
+ };
1251
+ }, [enabled]);
1252
+ return viewportHeight;
1253
+ }
1254
+
1230
1255
  // src/lib/animations.ts
1231
1256
  var modalVariants = {
1232
1257
  initial: {
@@ -1398,8 +1423,22 @@ import { jsx as jsx17 } from "react/jsx-runtime";
1398
1423
  var Modal = (props) => {
1399
1424
  const { isOpen, children, onClose } = props;
1400
1425
  const isMobile = useIsMobile();
1426
+ const viewportHeight = useViewportHeight(isMobile && isOpen);
1401
1427
  if (isMobile) {
1402
- return /* @__PURE__ */ jsx17(Drawer, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsx17(DrawerContent, { className: "bg-brand-black-550 border-brand-black-300 min-h-[90dvh]", children }) });
1428
+ return /* @__PURE__ */ jsx17(Drawer, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsx17(
1429
+ DrawerContent,
1430
+ {
1431
+ className: "bg-brand-black-550 border-brand-black-300",
1432
+ style: viewportHeight ? {
1433
+ height: `${viewportHeight}px`,
1434
+ maxHeight: `${viewportHeight}px`,
1435
+ minHeight: "auto"
1436
+ } : {
1437
+ minHeight: "90dvh"
1438
+ },
1439
+ children
1440
+ }
1441
+ ) });
1403
1442
  }
1404
1443
  return /* @__PURE__ */ jsx17(DestkopModal, __spreadValues({}, props));
1405
1444
  };
@@ -1412,7 +1451,7 @@ function DestkopModal(props) {
1412
1451
  className
1413
1452
  } = props;
1414
1453
  const { variants, transition } = animationPresets[animationPreset];
1415
- useEffect3(() => {
1454
+ useEffect4(() => {
1416
1455
  const handleEscapeKey = (event) => {
1417
1456
  if (event.key === "Escape" && isOpen && onClose) {
1418
1457
  onClose();
@@ -4839,8 +4878,22 @@ function CWDrawerContent(_a) {
4839
4878
  "children"
4840
4879
  ]);
4841
4880
  const isMobile = useIsMobile();
4881
+ const viewportHeight = useViewportHeight(isMobile);
4842
4882
  if (isMobile) {
4843
- return /* @__PURE__ */ jsx48(HBDrawerContent, { className: "bg-brand-black-550 rounded-t-[1rem] w-full px-[1rem] border-t border-brand-black-300 min-h-[90dvh]", children: /* @__PURE__ */ jsx48("div", { className: "flex flex-col flex-1", children }) });
4883
+ return /* @__PURE__ */ jsx48(
4884
+ HBDrawerContent,
4885
+ {
4886
+ className: "bg-brand-black-550 rounded-t-[1rem] w-full px-[1rem] border-t border-brand-black-300",
4887
+ style: viewportHeight ? {
4888
+ height: `${viewportHeight}px`,
4889
+ maxHeight: `${viewportHeight}px`,
4890
+ minHeight: "auto"
4891
+ } : {
4892
+ minHeight: "90dvh"
4893
+ },
4894
+ children: /* @__PURE__ */ jsx48("div", { className: "flex flex-col flex-1", children })
4895
+ }
4896
+ );
4844
4897
  }
4845
4898
  return /* @__PURE__ */ jsx48(
4846
4899
  SheetContent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbridge/ui",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "sideEffects": false,
5
5
  "license": "MIT",
6
6
  "private": false,
package/styles/base.css CHANGED
@@ -294,3 +294,11 @@ input[type="number"]::-webkit-inner-spin-button {
294
294
  }
295
295
 
296
296
  /* End Dialog */
297
+
298
+ @media (max-width: 768px) {
299
+ body:has([data-drawer="true"]) {
300
+ position: fixed;
301
+ width: 100%;
302
+ height: 100vh;
303
+ }
304
+ }