@ai-matrx/design-system 0.61.11 → 0.61.13

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
@@ -385,6 +385,10 @@ function findPillViolation(el, maxWidth = PILL_MAX_WIDTH_PX) {
385
385
  if (rect.width > maxWidth + 0.5) {
386
386
  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.`;
387
387
  }
388
+ const past = overflowPast(el, rect, view);
389
+ if (past) {
390
+ 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.`;
391
+ }
388
392
  const lines = lineCount(el, own, cs, rect.height);
389
393
  if (lines > 1) {
390
394
  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.`;
@@ -395,6 +399,27 @@ function findPillViolation(el, maxWidth = PILL_MAX_WIDTH_PX) {
395
399
  }
396
400
  return null;
397
401
  }
402
+ function overflowPast(el, rect, view) {
403
+ for (let p = el.parentElement; p; p = p.parentElement) {
404
+ const ox = view.getComputedStyle(p).overflowX;
405
+ if (ox === "auto" || ox === "scroll") return null;
406
+ }
407
+ const pinned = ["absolute", "fixed"].includes(view.getComputedStyle(el).position);
408
+ const parent = el.parentElement;
409
+ if (parent && !pinned) {
410
+ const pr = parent.getBoundingClientRect();
411
+ if (pr.width > 0) {
412
+ const by = Math.max(rect.right - pr.right, pr.left - rect.left);
413
+ if (by > 0.5) return { what: "its container", by };
414
+ }
415
+ }
416
+ const vw = el.ownerDocument.documentElement.clientWidth || view.innerWidth;
417
+ if (vw > 0) {
418
+ const by = Math.max(rect.right - vw, -rect.left);
419
+ if (by > 0.5) return { what: "the viewport", by };
420
+ }
421
+ return null;
422
+ }
398
423
  function stretchSlack(el, own, cs, width, view) {
399
424
  const range = el.ownerDocument.createRange?.();
400
425
  if (!range || typeof range.getClientRects !== "function") return null;