@flytedan/flytebot-design-system 0.11.1 → 0.11.2

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
@@ -288,7 +288,7 @@ var parsePlacement = (p) => {
288
288
  };
289
289
  var samePosition = (a, b) => {
290
290
  if (!a || !b) return a === b;
291
- return a.left === b.left && a.top === b.top && a.bottom === b.bottom && a.width === b.width && a.minWidth === b.minWidth && a.maxH === b.maxH && a.side === b.side && a.anchorWidth === b.anchorWidth;
291
+ return a.left === b.left && a.top === b.top && a.bottom === b.bottom && a.width === b.width && a.minWidth === b.minWidth && a.maxH === b.maxH && a.maxW === b.maxW && a.side === b.side && a.anchorWidth === b.anchorWidth;
292
292
  };
293
293
  var SCROLL_REGIONS = ".fd-pop-body, .fd-pop-list";
294
294
  var PINNED_REGIONS = ":scope > .fd-pop-header, :scope > .fd-pop-footer";
@@ -345,9 +345,10 @@ function usePopoverPosition(open, anchorRef, opts) {
345
345
  const top = side === "bottom" ? beside ? r.bottom + offset : edge : null;
346
346
  const bottom = side === "top" ? beside ? vh - r.top + offset : edge : null;
347
347
  const maxH = beside ? room : vh - MARGIN - edge;
348
+ const maxW = Math.max(0, window.innerWidth - 2 * MARGIN);
348
349
  const exact = o.matchWidth === true;
349
350
  const width = exact ? r.width : Math.max(o.width || 0, o.minWidth || 0, o.matchWidth === "min" ? r.width : 0);
350
- const w = exact || o.width ? width : Math.max(layer.width, width) || o.estWidth || 260;
351
+ const w = Math.min(maxW, exact || o.width ? width : Math.max(layer.width, width) || o.estWidth || 260);
351
352
  let left = align === "end" ? r.right - w : align === "center" ? r.left + r.width / 2 - w / 2 : r.left;
352
353
  left = Math.max(MARGIN, Math.min(left, window.innerWidth - w - MARGIN));
353
354
  const next = {
@@ -357,6 +358,7 @@ function usePopoverPosition(open, anchorRef, opts) {
357
358
  top,
358
359
  bottom,
359
360
  maxH,
361
+ maxW,
360
362
  side,
361
363
  anchorWidth: r.width
362
364
  };
@@ -381,6 +383,7 @@ function usePopoverPosition(open, anchorRef, opts) {
381
383
  }, [open, o.placement, o.offset, o.matchWidth, o.width, o.minWidth, o.maxHeight, o.estHeight]);
382
384
  return pos;
383
385
  }
386
+ var capWidth = (value, max) => value == null ? void 0 : Math.min(value, max);
384
387
  var portal = (node) => {
385
388
  if (typeof document !== "undefined") return (0, import_react_dom.createPortal)(node, document.body);
386
389
  return node;
@@ -472,7 +475,14 @@ function Popover({
472
475
  top: pos.top == null ? "auto" : pos.top,
473
476
  bottom: pos.bottom == null ? "auto" : pos.bottom,
474
477
  width: matchWidth === true ? pos.width : width,
475
- minWidth: matchWidth === "min" ? Math.max(pos.anchorWidth, minWidth || 0) : minWidth || (matchWidth ? void 0 : 200),
478
+ // CSS lets min-width win over max-width, so every minimum is capped to the viewport too.
479
+ minWidth: capWidth(
480
+ matchWidth === "min" ? Math.max(pos.anchorWidth, minWidth || 0) : minWidth || (matchWidth ? void 0 : 200),
481
+ pos.maxW
482
+ ),
483
+ // The surface never runs past the viewport edge, whatever fixed `width` a caller asked
484
+ // for: pos.maxW is the viewport less its margins, and `left` is clamped against it.
485
+ maxWidth: pos.maxW,
476
486
  // Size to content by default — cap only at real available room between the
477
487
  // anchor and the viewport edge (pos.maxH, computed by usePopoverPosition).
478
488
  // A caller-supplied `maxHeight` narrows that further (e.g. a long menu that