@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 +13 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -88,6 +88,10 @@ interface PopoverPosition {
|
|
|
88
88
|
top: number | null;
|
|
89
89
|
bottom: number | null;
|
|
90
90
|
maxH: number;
|
|
91
|
+
/** The widest the layer may be: the viewport less its margins. A fixed `width`, a
|
|
92
|
+
* `minWidth` or an anchor-matched width wider than the screen is capped to this, so the
|
|
93
|
+
* surface — and the action in its footer — never runs past the viewport edge. */
|
|
94
|
+
maxW: number;
|
|
91
95
|
side: "top" | "bottom";
|
|
92
96
|
anchorWidth: number;
|
|
93
97
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,10 @@ interface PopoverPosition {
|
|
|
88
88
|
top: number | null;
|
|
89
89
|
bottom: number | null;
|
|
90
90
|
maxH: number;
|
|
91
|
+
/** The widest the layer may be: the viewport less its margins. A fixed `width`, a
|
|
92
|
+
* `minWidth` or an anchor-matched width wider than the screen is capped to this, so the
|
|
93
|
+
* surface — and the action in its footer — never runs past the viewport edge. */
|
|
94
|
+
maxW: number;
|
|
91
95
|
side: "top" | "bottom";
|
|
92
96
|
anchorWidth: number;
|
|
93
97
|
}
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ var parsePlacement = (p) => {
|
|
|
85
85
|
};
|
|
86
86
|
var samePosition = (a, b) => {
|
|
87
87
|
if (!a || !b) return a === b;
|
|
88
|
-
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;
|
|
88
|
+
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;
|
|
89
89
|
};
|
|
90
90
|
var SCROLL_REGIONS = ".fd-pop-body, .fd-pop-list";
|
|
91
91
|
var PINNED_REGIONS = ":scope > .fd-pop-header, :scope > .fd-pop-footer";
|
|
@@ -142,9 +142,10 @@ function usePopoverPosition(open, anchorRef, opts) {
|
|
|
142
142
|
const top = side === "bottom" ? beside ? r.bottom + offset : edge : null;
|
|
143
143
|
const bottom = side === "top" ? beside ? vh - r.top + offset : edge : null;
|
|
144
144
|
const maxH = beside ? room : vh - MARGIN - edge;
|
|
145
|
+
const maxW = Math.max(0, window.innerWidth - 2 * MARGIN);
|
|
145
146
|
const exact = o.matchWidth === true;
|
|
146
147
|
const width = exact ? r.width : Math.max(o.width || 0, o.minWidth || 0, o.matchWidth === "min" ? r.width : 0);
|
|
147
|
-
const w = exact || o.width ? width : Math.max(layer.width, width) || o.estWidth || 260;
|
|
148
|
+
const w = Math.min(maxW, exact || o.width ? width : Math.max(layer.width, width) || o.estWidth || 260);
|
|
148
149
|
let left = align === "end" ? r.right - w : align === "center" ? r.left + r.width / 2 - w / 2 : r.left;
|
|
149
150
|
left = Math.max(MARGIN, Math.min(left, window.innerWidth - w - MARGIN));
|
|
150
151
|
const next = {
|
|
@@ -154,6 +155,7 @@ function usePopoverPosition(open, anchorRef, opts) {
|
|
|
154
155
|
top,
|
|
155
156
|
bottom,
|
|
156
157
|
maxH,
|
|
158
|
+
maxW,
|
|
157
159
|
side,
|
|
158
160
|
anchorWidth: r.width
|
|
159
161
|
};
|
|
@@ -178,6 +180,7 @@ function usePopoverPosition(open, anchorRef, opts) {
|
|
|
178
180
|
}, [open, o.placement, o.offset, o.matchWidth, o.width, o.minWidth, o.maxHeight, o.estHeight]);
|
|
179
181
|
return pos;
|
|
180
182
|
}
|
|
183
|
+
var capWidth = (value, max) => value == null ? void 0 : Math.min(value, max);
|
|
181
184
|
var portal = (node) => {
|
|
182
185
|
if (typeof document !== "undefined") return createPortal(node, document.body);
|
|
183
186
|
return node;
|
|
@@ -269,7 +272,14 @@ function Popover({
|
|
|
269
272
|
top: pos.top == null ? "auto" : pos.top,
|
|
270
273
|
bottom: pos.bottom == null ? "auto" : pos.bottom,
|
|
271
274
|
width: matchWidth === true ? pos.width : width,
|
|
272
|
-
|
|
275
|
+
// CSS lets min-width win over max-width, so every minimum is capped to the viewport too.
|
|
276
|
+
minWidth: capWidth(
|
|
277
|
+
matchWidth === "min" ? Math.max(pos.anchorWidth, minWidth || 0) : minWidth || (matchWidth ? void 0 : 200),
|
|
278
|
+
pos.maxW
|
|
279
|
+
),
|
|
280
|
+
// The surface never runs past the viewport edge, whatever fixed `width` a caller asked
|
|
281
|
+
// for: pos.maxW is the viewport less its margins, and `left` is clamped against it.
|
|
282
|
+
maxWidth: pos.maxW,
|
|
273
283
|
// Size to content by default — cap only at real available room between the
|
|
274
284
|
// anchor and the viewport edge (pos.maxH, computed by usePopoverPosition).
|
|
275
285
|
// A caller-supplied `maxHeight` narrows that further (e.g. a long menu that
|