@ai-matrx/sharing 0.1.8 → 0.1.10

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
@@ -334,7 +334,7 @@ var useAppDispatch = () => passThroughDispatchRef;
334
334
 
335
335
  // src/react/sheet/ShareModal.tsx
336
336
  import { appUrl, getActiveOrgId, sendShareNotice } from "@ai-matrx/sharing/core";
337
- import { useState as useState16 } from "react";
337
+ import { useState as useState17 } from "react";
338
338
 
339
339
  // src/react/sheet/ui/dialog.tsx
340
340
  import {
@@ -4424,6 +4424,35 @@ function SecureLinkForm({ resourceType, resourceId, resourceName }) {
4424
4424
  ] });
4425
4425
  }
4426
4426
 
4427
+ // src/react/sheet/useKeepFocusInDialog.ts
4428
+ import { useEffect as useEffect13, useState as useState16 } from "react";
4429
+ function useKeepFocusInDialog() {
4430
+ const [element, setElement] = useState16(null);
4431
+ useEffect13(() => {
4432
+ if (!element) return void 0;
4433
+ let frame = 0;
4434
+ const settle = () => {
4435
+ cancelAnimationFrame(frame);
4436
+ frame = requestAnimationFrame(() => {
4437
+ if (!element.isConnected) return;
4438
+ const now = document.activeElement;
4439
+ if (now && now !== document.body && now !== document.documentElement) return;
4440
+ const target = element.querySelector(
4441
+ "input:not([disabled]):not([type=hidden]), button:not([disabled]), [href], [tabindex]:not([tabindex='-1'])"
4442
+ );
4443
+ (target ?? element).focus({ preventScroll: true });
4444
+ });
4445
+ };
4446
+ const observer = new MutationObserver(settle);
4447
+ observer.observe(element, { subtree: true, childList: true, attributes: true, attributeFilter: ["disabled"] });
4448
+ return () => {
4449
+ cancelAnimationFrame(frame);
4450
+ observer.disconnect();
4451
+ };
4452
+ }, [element]);
4453
+ return setElement;
4454
+ }
4455
+
4427
4456
  // src/react/sheet/ShareModal.tsx
4428
4457
  import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
4429
4458
  function ShareModal({
@@ -4438,11 +4467,12 @@ function ShareModal({
4438
4467
  isOwner: isOwnerOverride,
4439
4468
  outsideShare
4440
4469
  }) {
4441
- const [activeTab, setActiveTab] = useState16("users");
4442
- const [outsidePending, setOutsidePending] = useState16(0);
4443
- const [emailingLink, setEmailingLink] = useState16(false);
4444
- const [emailSent, setEmailSent] = useState16(false);
4470
+ const [activeTab, setActiveTab] = useState17("users");
4471
+ const [outsidePending, setOutsidePending] = useState17(0);
4472
+ const [emailingLink, setEmailingLink] = useState17(false);
4473
+ const [emailSent, setEmailSent] = useState17(false);
4445
4474
  const { toast } = useToast();
4475
+ const keepFocusInside = useKeepFocusInDialog();
4446
4476
  const getShareUrl = () => {
4447
4477
  const path = getResourceSharePath(resourceType, resourceId);
4448
4478
  if (!path) return null;
@@ -4595,7 +4625,7 @@ function ShareModal({
4595
4625
  /* @__PURE__ */ jsx20(Lock3, { className: "h-4 w-4 text-muted-foreground flex-shrink-0 mt-0.5" }),
4596
4626
  /* @__PURE__ */ jsx20("p", { className: "text-sm", children: grantable.error ?? grantable.levels.viewer ?? "You need Edit or Full access on this to share it." })
4597
4627
  ] });
4598
- return /* @__PURE__ */ jsx20(Dialog, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs16(DialogContent, { className: "max-w-2xl max-h-[90dvh] flex flex-col", children: [
4628
+ return /* @__PURE__ */ jsx20(Dialog, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs16(DialogContent, { ref: keepFocusInside, className: "max-w-2xl max-h-[90dvh] flex flex-col", children: [
4599
4629
  /* @__PURE__ */ jsx20(DialogHeader, { className: "flex-shrink-0", children: /* @__PURE__ */ jsxs16("div", { className: "flex items-start justify-between gap-2 pr-10", children: [
4600
4630
  /* @__PURE__ */ jsxs16("div", { className: "flex-1 min-w-0", children: [
4601
4631
  /* @__PURE__ */ jsxs16(DialogTitle, { className: "flex items-center gap-1.5", children: [