@ai-matrx/design-system 0.35.0 → 0.36.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.
@@ -8366,6 +8366,19 @@ function targetsAnEditor(target) {
8366
8366
  if (!element) return false;
8367
8367
  return element.closest("input, textarea, select, [contenteditable='true']") !== null;
8368
8368
  }
8369
+ function camePastAPortal(target, host) {
8370
+ if (typeof Element === "undefined") return false;
8371
+ const element = target instanceof Element ? target : null;
8372
+ const owner = host instanceof Element ? host : null;
8373
+ if (!element || !owner) return false;
8374
+ return !owner.contains(element);
8375
+ }
8376
+ function camePastAPortalIntoTheContainer(target) {
8377
+ if (typeof Element === "undefined") return false;
8378
+ const element = target instanceof Element ? target : null;
8379
+ if (!element) return false;
8380
+ return element.closest('[data-matrx-table-spreadsheet="true"]') === null;
8381
+ }
8369
8382
  function useSpreadsheetGrid(options) {
8370
8383
  const [range, setRange] = useState16(null);
8371
8384
  const [fillTarget, setFillTarget] = useState16(null);
@@ -8537,6 +8550,7 @@ function useSpreadsheetGrid(options) {
8537
8550
  const current = optionsRef.current;
8538
8551
  if (!current) return;
8539
8552
  if (targetsAnEditor(event.target)) return;
8553
+ if (camePastAPortalIntoTheContainer(event.target)) return;
8540
8554
  const accel = event.metaKey || event.ctrlKey;
8541
8555
  if (accel && (event.key === "z" || event.key === "Z")) {
8542
8556
  event.preventDefault();
@@ -8623,6 +8637,7 @@ function useSpreadsheetGrid(options) {
8623
8637
  const onCopy = useCallback7(
8624
8638
  (event) => {
8625
8639
  if (!optionsRef.current || !range || targetsAnEditor(event.target)) return;
8640
+ if (camePastAPortalIntoTheContainer(event.target)) return;
8626
8641
  const text = selectionAsTsv();
8627
8642
  if (!text) return;
8628
8643
  event.preventDefault();
@@ -8633,6 +8648,7 @@ function useSpreadsheetGrid(options) {
8633
8648
  const onCut = useCallback7(
8634
8649
  (event) => {
8635
8650
  if (!optionsRef.current || !range || targetsAnEditor(event.target)) return;
8651
+ if (camePastAPortalIntoTheContainer(event.target)) return;
8636
8652
  const text = selectionAsTsv();
8637
8653
  if (!text) return;
8638
8654
  event.preventDefault();
@@ -8645,6 +8661,7 @@ function useSpreadsheetGrid(options) {
8645
8661
  (event) => {
8646
8662
  const current = optionsRef.current;
8647
8663
  if (!current || current.paste === false || !range || targetsAnEditor(event.target)) return;
8664
+ if (camePastAPortalIntoTheContainer(event.target)) return;
8648
8665
  const text = event.clipboardData?.getData("text/plain") ?? "";
8649
8666
  if (!text) return;
8650
8667
  event.preventDefault();
@@ -8728,6 +8745,7 @@ function useSpreadsheetGrid(options) {
8728
8745
  ...inFillPreview ? { "data-matrx-cell-fill-preview": "true" } : {},
8729
8746
  onMouseDown: (event) => {
8730
8747
  if (event.button !== 0) return;
8748
+ if (camePastAPortal(event.target ?? null, event.currentTarget)) return;
8731
8749
  event.preventDefault();
8732
8750
  const origin = event.currentTarget;
8733
8751
  if (typeof HTMLElement !== "undefined" && origin instanceof HTMLElement) {