@ai-matrx/design-system 0.61.14 → 0.61.16

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/index.js CHANGED
@@ -413,9 +413,50 @@ function overflowPast(el, rect, view) {
413
413
  if (by > 0.5) return { what: "its container", by };
414
414
  }
415
415
  }
416
- const vw = el.ownerDocument.documentElement.clientWidth || view.innerWidth;
416
+ let clip = null;
417
+ let transformed = false;
418
+ let pannedInsideClip = false;
419
+ const root = el.ownerDocument.documentElement;
420
+ for (let p = el.parentElement; p && p !== root; p = p.parentElement) {
421
+ const pcs = view.getComputedStyle(p);
422
+ if (!clip && pcs.overflowX !== "visible" && pcs.overflowX !== "") clip = p;
423
+ if (pcs.transform && pcs.transform !== "none" || pcs.translate && pcs.translate !== "none" || pcs.scale && pcs.scale !== "none" || pcs.rotate && pcs.rotate !== "none") {
424
+ transformed = true;
425
+ if (!clip) pannedInsideClip = true;
426
+ }
427
+ }
428
+ if (clip && !pinned && clip !== parent) {
429
+ const cr = clip.getBoundingClientRect();
430
+ if (cr.width > 0) {
431
+ const by = pannedInsideClip ? rect.width - cr.width : Math.max(rect.right - cr.right, cr.left - rect.left);
432
+ if (by > 0.5) return { what: "its clipping container", by };
433
+ }
434
+ }
435
+ let left = rect.left;
436
+ let right = rect.right;
437
+ let top = rect.top;
438
+ let bottom = rect.bottom;
439
+ for (let p = el.parentElement; p && p !== root; p = p.parentElement) {
440
+ const pcs = view.getComputedStyle(p);
441
+ if (pcs.overflowX === "visible" && pcs.overflowY === "visible") continue;
442
+ const cr = p.getBoundingClientRect();
443
+ if (cr.width === 0 && cr.height === 0) continue;
444
+ if (pcs.overflowX !== "visible") {
445
+ left = Math.max(left, cr.left);
446
+ right = Math.min(right, cr.right);
447
+ }
448
+ if (pcs.overflowY !== "visible") {
449
+ top = Math.max(top, cr.top);
450
+ bottom = Math.min(bottom, cr.bottom);
451
+ }
452
+ }
453
+ const vw = root.clientWidth || view.innerWidth;
454
+ const vh = root.clientHeight || view.innerHeight;
455
+ if (transformed) return null;
456
+ if (vw > 0 && (right <= left || right <= 0 || left >= vw)) return null;
457
+ if (vh > 0 && (bottom <= top || bottom <= 0 || top >= vh)) return null;
417
458
  if (vw > 0) {
418
- const by = Math.max(rect.right - vw, -rect.left);
459
+ const by = Math.max(right - vw, -left);
419
460
  if (by > 0.5) return { what: "the viewport", by };
420
461
  }
421
462
  return null;