@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.
@@ -42941,6 +42941,7 @@ function camePastAPortalIntoTheContainer(target) {
42941
42941
  if (!element) return false;
42942
42942
  return element.closest('[data-matrx-table-spreadsheet="true"]') === null;
42943
42943
  }
42944
+ var LAYERS_THE_GRID_OPENS = '[data-radix-popper-content-wrapper], [data-radix-portal], [role="menu"], [role="listbox"], [role="dialog"], [role="alertdialog"], [data-sonner-toaster]';
42944
42945
  var READ_ONLY_REASON = "This table is view-only \u2014 you can select and copy, but not change cells.";
42945
42946
  function useSpreadsheetGrid(options) {
42946
42947
  const [range, setRange] = useState17(null);
@@ -43195,6 +43196,23 @@ function useSpreadsheetGrid(options) {
43195
43196
  },
43196
43197
  [endEdit, focusIsLost]
43197
43198
  );
43199
+ const holdsARange = range !== null;
43200
+ useEffect13(() => {
43201
+ if (!holdsARange || typeof document === "undefined") return;
43202
+ const onPointerDown = (event) => {
43203
+ const target = event.target instanceof Element ? event.target : null;
43204
+ const container = catcherRef.current?.closest('[data-matrx-table-spreadsheet="true"]');
43205
+ if (!target || !container || !container.isConnected) return;
43206
+ const table = container.closest("[data-matrx-table]") ?? container;
43207
+ if (table.contains(target) || target.closest(LAYERS_THE_GRID_OPENS)) return;
43208
+ setRange(null);
43209
+ setFillTarget(null);
43210
+ const active = document.activeElement;
43211
+ if (active instanceof HTMLElement && container.contains(active)) active.blur();
43212
+ };
43213
+ document.addEventListener("pointerdown", onPointerDown, true);
43214
+ return () => document.removeEventListener("pointerdown", onPointerDown, true);
43215
+ }, [holdsARange]);
43198
43216
  const controller = useMemo8(() => ({ endEdit, select, focusGrid }), [endEdit, select, focusGrid]);
43199
43217
  const onKeyDown = useCallback7(
43200
43218
  (event) => {