@hyve-sdk/js 2.8.0-canary.0 → 2.10.0-canary.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/dist/react.js CHANGED
@@ -2363,25 +2363,33 @@ function MachineViewDialog({
2363
2363
  dialogWidth,
2364
2364
  viewHeight
2365
2365
  }) {
2366
+ const panelRef = (0, import_react.useRef)(null);
2366
2367
  (0, import_react.useEffect)(() => {
2367
2368
  if (!open) return;
2368
2369
  const onKeyDown = (e) => {
2369
2370
  if (e.key === "Escape") onClose();
2370
2371
  };
2372
+ const onMouseDown = (e) => {
2373
+ if (panelRef.current && !panelRef.current.contains(e.target)) {
2374
+ onClose();
2375
+ }
2376
+ };
2371
2377
  window.addEventListener("keydown", onKeyDown);
2372
- return () => window.removeEventListener("keydown", onKeyDown);
2378
+ document.addEventListener("mousedown", onMouseDown);
2379
+ return () => {
2380
+ window.removeEventListener("keydown", onKeyDown);
2381
+ document.removeEventListener("mousedown", onMouseDown);
2382
+ };
2373
2383
  }, [open, onClose]);
2374
2384
  if (!open) return null;
2375
2385
  const panelWidth = typeof dialogWidth === "number" ? `${dialogWidth}px` : dialogWidth;
2376
2386
  const iframeHeight = typeof viewHeight === "number" ? `${viewHeight}px` : viewHeight;
2377
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2387
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: OVERLAY_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
2378
2388
  "div",
2379
2389
  {
2380
- style: OVERLAY_STYLE,
2381
- onClick: (e) => {
2382
- if (e.target === e.currentTarget) onClose();
2383
- },
2384
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { ...PANEL_STYLE, maxWidth: panelWidth }, children: [
2390
+ ref: panelRef,
2391
+ style: { ...PANEL_STYLE, maxWidth: panelWidth },
2392
+ children: [
2385
2393
  title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: HEADER_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: TITLE_STYLE, children: title }) }),
2386
2394
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2387
2395
  MachineView,
@@ -2395,9 +2403,9 @@ function MachineViewDialog({
2395
2403
  }
2396
2404
  }
2397
2405
  )
2398
- ] })
2406
+ ]
2399
2407
  }
2400
- );
2408
+ ) });
2401
2409
  }
2402
2410
  function MachineViewButton({
2403
2411
  machineId,
package/dist/react.mjs CHANGED
@@ -2341,25 +2341,33 @@ function MachineViewDialog({
2341
2341
  dialogWidth,
2342
2342
  viewHeight
2343
2343
  }) {
2344
+ const panelRef = useRef(null);
2344
2345
  useEffect(() => {
2345
2346
  if (!open) return;
2346
2347
  const onKeyDown = (e) => {
2347
2348
  if (e.key === "Escape") onClose();
2348
2349
  };
2350
+ const onMouseDown = (e) => {
2351
+ if (panelRef.current && !panelRef.current.contains(e.target)) {
2352
+ onClose();
2353
+ }
2354
+ };
2349
2355
  window.addEventListener("keydown", onKeyDown);
2350
- return () => window.removeEventListener("keydown", onKeyDown);
2356
+ document.addEventListener("mousedown", onMouseDown);
2357
+ return () => {
2358
+ window.removeEventListener("keydown", onKeyDown);
2359
+ document.removeEventListener("mousedown", onMouseDown);
2360
+ };
2351
2361
  }, [open, onClose]);
2352
2362
  if (!open) return null;
2353
2363
  const panelWidth = typeof dialogWidth === "number" ? `${dialogWidth}px` : dialogWidth;
2354
2364
  const iframeHeight = typeof viewHeight === "number" ? `${viewHeight}px` : viewHeight;
2355
- return /* @__PURE__ */ jsx(
2365
+ return /* @__PURE__ */ jsx("div", { style: OVERLAY_STYLE, children: /* @__PURE__ */ jsxs(
2356
2366
  "div",
2357
2367
  {
2358
- style: OVERLAY_STYLE,
2359
- onClick: (e) => {
2360
- if (e.target === e.currentTarget) onClose();
2361
- },
2362
- children: /* @__PURE__ */ jsxs("div", { style: { ...PANEL_STYLE, maxWidth: panelWidth }, children: [
2368
+ ref: panelRef,
2369
+ style: { ...PANEL_STYLE, maxWidth: panelWidth },
2370
+ children: [
2363
2371
  title && /* @__PURE__ */ jsx("div", { style: HEADER_STYLE, children: /* @__PURE__ */ jsx("p", { style: TITLE_STYLE, children: title }) }),
2364
2372
  /* @__PURE__ */ jsx(
2365
2373
  MachineView,
@@ -2373,9 +2381,9 @@ function MachineViewDialog({
2373
2381
  }
2374
2382
  }
2375
2383
  )
2376
- ] })
2384
+ ]
2377
2385
  }
2378
- );
2386
+ ) });
2379
2387
  }
2380
2388
  function MachineViewButton({
2381
2389
  machineId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyve-sdk/js",
3
- "version": "2.8.0-canary.0",
3
+ "version": "2.10.0-canary.0",
4
4
  "description": "Hyve SDK - TypeScript wrapper for Hyve game server integration",
5
5
  "private": false,
6
6
  "publishConfig": {