@ai-matrx/design-system 0.61.9 → 0.61.10
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/CHANGELOG.md +10 -0
- package/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -333,6 +333,7 @@ function Badge({ className, variant, children, title, ...props }) {
|
|
|
333
333
|
|
|
334
334
|
// src/pill-guard.ts
|
|
335
335
|
var PILL_MAX_WIDTH_PX = 320;
|
|
336
|
+
var PILL_STRETCH_TOLERANCE_PX = 8;
|
|
336
337
|
var SELECTOR = [
|
|
337
338
|
'[data-slot="badge"]',
|
|
338
339
|
"[data-matrx-pill]",
|
|
@@ -388,8 +389,39 @@ function findPillViolation(el, maxWidth = PILL_MAX_WIDTH_PX) {
|
|
|
388
389
|
if (lines > 1) {
|
|
389
390
|
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.`;
|
|
390
391
|
}
|
|
392
|
+
const slack = stretchSlack(el, own, cs, rect.width, view);
|
|
393
|
+
if (slack !== null && slack > PILL_STRETCH_TOLERANCE_PX) {
|
|
394
|
+
return `pill is stretched: ${Math.round(slack)}px of empty capsule beside "${describe(el)}" \u2014 a pill hugs its label; stop the parent stretching it (a grid cell: justify-self-start; drop w-full / flex-1), or render a full-width tappable item as a row, never a pill.`;
|
|
395
|
+
}
|
|
391
396
|
return null;
|
|
392
397
|
}
|
|
398
|
+
function stretchSlack(el, own, cs, width, view) {
|
|
399
|
+
const range = el.ownerDocument.createRange?.();
|
|
400
|
+
if (!range || typeof range.getClientRects !== "function") return null;
|
|
401
|
+
let left = Infinity;
|
|
402
|
+
let right = -Infinity;
|
|
403
|
+
const take = (r) => {
|
|
404
|
+
if (r.width <= 0 || r.height <= 0) return;
|
|
405
|
+
left = Math.min(left, r.left);
|
|
406
|
+
right = Math.max(right, r.right);
|
|
407
|
+
};
|
|
408
|
+
for (const node of own) {
|
|
409
|
+
if (!(node.textContent ?? "").trim()) continue;
|
|
410
|
+
range.selectNodeContents(node);
|
|
411
|
+
Array.from(range.getClientRects()).forEach(take);
|
|
412
|
+
}
|
|
413
|
+
range.detach?.();
|
|
414
|
+
if (!Number.isFinite(left)) return null;
|
|
415
|
+
el.querySelectorAll("svg, img").forEach((g) => {
|
|
416
|
+
for (let p = g; p && p !== el; p = p.parentElement) {
|
|
417
|
+
const pcs = view.getComputedStyle(p);
|
|
418
|
+
if (pcs.position === "absolute" || pcs.position === "fixed" || pcs.display === "none") return;
|
|
419
|
+
}
|
|
420
|
+
take(g.getBoundingClientRect());
|
|
421
|
+
});
|
|
422
|
+
const inner = width - px(cs.paddingLeft) - px(cs.paddingRight) - px(cs.borderLeftWidth) - px(cs.borderRightWidth);
|
|
423
|
+
return inner - (right - left);
|
|
424
|
+
}
|
|
393
425
|
function lineCount(el, own, cs, height) {
|
|
394
426
|
const range = el.ownerDocument.createRange?.();
|
|
395
427
|
if (range && typeof range.getClientRects === "function") {
|