@t3q-ui/design-system 1.63.2 → 1.65.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.
@@ -1393,9 +1393,62 @@ function Badge({ className, variant, rounded, appearance, size, children, ...pro
1393
1393
  }
1394
1394
  );
1395
1395
  }
1396
+ var restoring = false;
1397
+ function isRestoringFocus() {
1398
+ return restoring;
1399
+ }
1400
+ function useRestoreFocusToOpener({
1401
+ onOpenAutoFocus,
1402
+ onCloseAutoFocus
1403
+ }) {
1404
+ const openerRef = React10.useRef(null);
1405
+ const handleOpenAutoFocus = React10.useCallback(
1406
+ (event) => {
1407
+ openerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
1408
+ onOpenAutoFocus?.(event);
1409
+ },
1410
+ [onOpenAutoFocus]
1411
+ );
1412
+ const handleCloseAutoFocus = React10.useCallback(
1413
+ (event) => {
1414
+ onCloseAutoFocus?.(event);
1415
+ if (event.defaultPrevented) return;
1416
+ const opener = openerRef.current;
1417
+ if (!opener || opener === document.body || !opener.isConnected) return;
1418
+ event.preventDefault();
1419
+ restoring = true;
1420
+ try {
1421
+ opener.focus({ preventScroll: true });
1422
+ } finally {
1423
+ restoring = false;
1424
+ }
1425
+ },
1426
+ [onCloseAutoFocus]
1427
+ );
1428
+ return { onOpenAutoFocus: handleOpenAutoFocus, onCloseAutoFocus: handleCloseAutoFocus };
1429
+ }
1396
1430
  var TooltipProvider = TooltipPrimitive__namespace.Provider;
1431
+ function isKeyboardFocus(el) {
1432
+ try {
1433
+ return el.matches(":focus-visible");
1434
+ } catch {
1435
+ return true;
1436
+ }
1437
+ }
1397
1438
  var Tooltip = TooltipPrimitive__namespace.Root;
1398
- var TooltipTrigger = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { type: "button", ref, className: chunkOQOBPYZT_cjs.cn(className), ...props }));
1439
+ var TooltipTrigger = React10__namespace.forwardRef(({ className, onFocus, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1440
+ TooltipPrimitive__namespace.Trigger,
1441
+ {
1442
+ type: "button",
1443
+ ref,
1444
+ className: chunkOQOBPYZT_cjs.cn(className),
1445
+ ...props,
1446
+ onFocus: (e) => {
1447
+ onFocus?.(e);
1448
+ if (isRestoringFocus() && !isKeyboardFocus(e.target)) e.preventDefault();
1449
+ }
1450
+ }
1451
+ ));
1399
1452
  TooltipTrigger.displayName = TooltipPrimitive__namespace.Trigger.displayName;
1400
1453
  var TooltipContent = React10__namespace.forwardRef(({ className, sideOffset = 4, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1401
1454
  TooltipPrimitive__namespace.Content,
@@ -3609,31 +3662,6 @@ function ChatMessage({
3609
3662
  }
3610
3663
  );
3611
3664
  }
3612
- function useRestoreFocusToOpener({
3613
- onOpenAutoFocus,
3614
- onCloseAutoFocus
3615
- }) {
3616
- const openerRef = React10.useRef(null);
3617
- const handleOpenAutoFocus = React10.useCallback(
3618
- (event) => {
3619
- openerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
3620
- onOpenAutoFocus?.(event);
3621
- },
3622
- [onOpenAutoFocus]
3623
- );
3624
- const handleCloseAutoFocus = React10.useCallback(
3625
- (event) => {
3626
- onCloseAutoFocus?.(event);
3627
- if (event.defaultPrevented) return;
3628
- const opener = openerRef.current;
3629
- if (!opener || opener === document.body || !opener.isConnected) return;
3630
- event.preventDefault();
3631
- opener.focus({ preventScroll: true });
3632
- },
3633
- [onCloseAutoFocus]
3634
- );
3635
- return { onOpenAutoFocus: handleOpenAutoFocus, onCloseAutoFocus: handleCloseAutoFocus };
3636
- }
3637
3665
  var Dialog = DialogPrimitive__namespace.Root;
3638
3666
  var DialogTrigger = DialogPrimitive__namespace.Trigger;
3639
3667
  var DialogPortal = DialogPrimitive__namespace.Portal;
@@ -3870,14 +3898,16 @@ var DrawerContent = React10__namespace.forwardRef(
3870
3898
  props.className
3871
3899
  ),
3872
3900
  children: [
3873
- /* @__PURE__ */ jsxRuntime.jsxs(
3874
- DialogPrimitive__namespace.Close,
3901
+ /* @__PURE__ */ jsxRuntime.jsx(
3902
+ chunkOQOBPYZT_cjs.IconButton,
3875
3903
  {
3876
- className: chunkOQOBPYZT_cjs.cn("absolute right-[24px] top-[24px] disabled:pointer-events-none"),
3877
- children: [
3904
+ asChild: true,
3905
+ variant: "secondaryLink",
3906
+ className: "absolute right-[24px] top-[24px] -m-[6px]",
3907
+ children: /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { children: [
3878
3908
  /* @__PURE__ */ jsxRuntime.jsx(lucide.X, { size: 24 }),
3879
3909
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only a11y", children: "Close" })
3880
- ]
3910
+ ] })
3881
3911
  }
3882
3912
  ),
3883
3913
  children
@@ -5797,5 +5827,5 @@ exports.withNumberColumnWidth = withNumberColumnWidth;
5797
5827
  exports.withSortIconOffset = withSortIconOffset;
5798
5828
  exports.withTypeClasses = withTypeClasses;
5799
5829
  exports.withWidthFloor = withWidthFloor;
5800
- //# sourceMappingURL=chunk-LIXLOSPF.cjs.map
5801
- //# sourceMappingURL=chunk-LIXLOSPF.cjs.map
5830
+ //# sourceMappingURL=chunk-RVIZMXPB.cjs.map
5831
+ //# sourceMappingURL=chunk-RVIZMXPB.cjs.map