@ai-matrx/design-system 0.48.6 → 0.48.7

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.
@@ -664,6 +664,7 @@ function camePastAPortalIntoTheContainer(target) {
664
664
  if (!element) return false;
665
665
  return element.closest('[data-matrx-table-spreadsheet="true"]') === null;
666
666
  }
667
+ var LAYERS_THE_GRID_OPENS = '[data-radix-popper-content-wrapper], [data-radix-portal], [role="menu"], [role="listbox"], [role="dialog"], [role="alertdialog"], [data-sonner-toaster]';
667
668
  var NOTHING = [];
668
669
  var READ_ONLY_REASON = "This table is view-only \u2014 you can select and copy, but not change cells.";
669
670
  function useSpreadsheetGrid(options) {
@@ -919,6 +920,23 @@ function useSpreadsheetGrid(options) {
919
920
  },
920
921
  [endEdit, focusIsLost]
921
922
  );
923
+ const holdsARange = range !== null;
924
+ (0, import_react.useEffect)(() => {
925
+ if (!holdsARange || typeof document === "undefined") return;
926
+ const onPointerDown = (event) => {
927
+ const target = event.target instanceof Element ? event.target : null;
928
+ const container = catcherRef.current?.closest('[data-matrx-table-spreadsheet="true"]');
929
+ if (!target || !container || !container.isConnected) return;
930
+ const table = container.closest("[data-matrx-table]") ?? container;
931
+ if (table.contains(target) || target.closest(LAYERS_THE_GRID_OPENS)) return;
932
+ setRange(null);
933
+ setFillTarget(null);
934
+ const active = document.activeElement;
935
+ if (active instanceof HTMLElement && container.contains(active)) active.blur();
936
+ };
937
+ document.addEventListener("pointerdown", onPointerDown, true);
938
+ return () => document.removeEventListener("pointerdown", onPointerDown, true);
939
+ }, [holdsARange]);
922
940
  const controller = (0, import_react.useMemo)(() => ({ endEdit, select, focusGrid }), [endEdit, select, focusGrid]);
923
941
  const onKeyDown = (0, import_react.useCallback)(
924
942
  (event) => {