@ai-matrx/design-system 0.61.10 → 0.61.12

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.cjs CHANGED
@@ -716,6 +716,10 @@ function findPillViolation(el, maxWidth = PILL_MAX_WIDTH_PX) {
716
716
  if (rect.width > maxWidth + 0.5) {
717
717
  return `pill is ${Math.round(rect.width)}px wide (budget ${maxWidth}px) holding "${describe(el)}" \u2014 a pill holds a short label: clamp it (Badge, or truncate + max-w + title) or render a list row.`;
718
718
  }
719
+ const past = overflowPast(el, rect, view);
720
+ if (past) {
721
+ return `pill overflows ${past.what} by ${Math.round(past.by)}px holding "${describe(el)}" \u2014 a pill never runs past its row or the page gutter: let the row wrap and give the pill max-w-full with a truncating label.`;
722
+ }
719
723
  const lines = lineCount(el, own, cs, rect.height);
720
724
  if (lines > 1) {
721
725
  return `pill wraps to ${lines} lines holding "${describe(el)}" \u2014 a pill is one line: clamp it (Badge, or truncate + max-w + title) or render a list row.`;
@@ -726,6 +730,26 @@ function findPillViolation(el, maxWidth = PILL_MAX_WIDTH_PX) {
726
730
  }
727
731
  return null;
728
732
  }
733
+ function overflowPast(el, rect, view) {
734
+ for (let p = el.parentElement; p; p = p.parentElement) {
735
+ const ox = view.getComputedStyle(p).overflowX;
736
+ if (ox === "auto" || ox === "scroll") return null;
737
+ }
738
+ const parent = el.parentElement;
739
+ if (parent) {
740
+ const pr = parent.getBoundingClientRect();
741
+ if (pr.width > 0) {
742
+ const by = Math.max(rect.right - pr.right, pr.left - rect.left);
743
+ if (by > 0.5) return { what: "its container", by };
744
+ }
745
+ }
746
+ const vw = el.ownerDocument.documentElement.clientWidth || view.innerWidth;
747
+ if (vw > 0) {
748
+ const by = Math.max(rect.right - vw, -rect.left);
749
+ if (by > 0.5) return { what: "the viewport", by };
750
+ }
751
+ return null;
752
+ }
729
753
  function stretchSlack(el, own, cs, width, view) {
730
754
  const range = el.ownerDocument.createRange?.();
731
755
  if (!range || typeof range.getClientRects !== "function") return null;