@flytedan/flytebot-design-system 0.11.0 → 0.11.1
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 +29 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -106,6 +106,7 @@ __export(index_exports, {
|
|
|
106
106
|
ModeSwitch: () => ModeSwitch,
|
|
107
107
|
ModelControls: () => ModelControls,
|
|
108
108
|
NumberInput: () => NumberInput,
|
|
109
|
+
POPOVER_BODY_MIN: () => POPOVER_BODY_MIN,
|
|
109
110
|
PacketCard: () => PacketCard,
|
|
110
111
|
Pagination: () => Pagination,
|
|
111
112
|
PermissionDenied: () => PermissionDenied,
|
|
@@ -290,13 +291,21 @@ var samePosition = (a, b) => {
|
|
|
290
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
292
|
};
|
|
292
293
|
var SCROLL_REGIONS = ".fd-pop-body, .fd-pop-list";
|
|
294
|
+
var PINNED_REGIONS = ":scope > .fd-pop-header, :scope > .fd-pop-footer";
|
|
295
|
+
var POPOVER_BODY_MIN = 96;
|
|
293
296
|
function measureLayer(el) {
|
|
294
|
-
if (!el) return { width: 0, height: 0 };
|
|
297
|
+
if (!el || !el.offsetHeight) return { width: el ? el.offsetWidth : 0, height: 0, pinned: 0 };
|
|
295
298
|
let hidden = 0;
|
|
296
299
|
el.querySelectorAll(SCROLL_REGIONS).forEach((r) => {
|
|
297
300
|
hidden += Math.max(0, r.scrollHeight - r.clientHeight);
|
|
298
301
|
});
|
|
299
|
-
|
|
302
|
+
let pinned = 0;
|
|
303
|
+
el.querySelectorAll(PINNED_REGIONS).forEach((r) => {
|
|
304
|
+
pinned += r.offsetHeight;
|
|
305
|
+
});
|
|
306
|
+
const border = Math.max(0, el.offsetHeight - el.clientHeight);
|
|
307
|
+
const content = Math.max(el.scrollHeight, el.clientHeight);
|
|
308
|
+
return { width: el.offsetWidth, height: content + border + hidden, pinned: pinned + border };
|
|
300
309
|
}
|
|
301
310
|
function usePopoverPosition(open, anchorRef, opts) {
|
|
302
311
|
const o = opts || {};
|
|
@@ -318,24 +327,35 @@ function usePopoverPosition(open, anchorRef, opts) {
|
|
|
318
327
|
const r = el.getBoundingClientRect();
|
|
319
328
|
const offset = o.offset == null ? 8 : o.offset;
|
|
320
329
|
const layer = measureLayer(layerRef ? layerRef.current : null);
|
|
330
|
+
const vh = window.innerHeight;
|
|
321
331
|
const need = layer.height || Math.min(o.estHeight || 300, 180);
|
|
322
|
-
const below =
|
|
332
|
+
const below = vh - r.bottom - offset - MARGIN;
|
|
323
333
|
const above = r.top - offset - MARGIN;
|
|
324
334
|
let side = wantSide;
|
|
325
335
|
if (side === "bottom" && below < need && above > below) side = "top";
|
|
326
336
|
else if (side === "top" && above < need && below > above) side = "bottom";
|
|
337
|
+
const ceiling = Math.min(vh - 2 * MARGIN, o.maxHeight != null ? o.maxHeight : Infinity);
|
|
338
|
+
const floor = Math.min(
|
|
339
|
+
ceiling,
|
|
340
|
+
layer.height ? layer.pinned + Math.min(POPOVER_BODY_MIN, layer.height - layer.pinned) : Math.min(need, 140)
|
|
341
|
+
);
|
|
342
|
+
const room = side === "top" ? above : below;
|
|
343
|
+
const beside = room >= floor;
|
|
344
|
+
const edge = beside ? 0 : Math.max(MARGIN, vh - MARGIN - Math.min(need, ceiling));
|
|
345
|
+
const top = side === "bottom" ? beside ? r.bottom + offset : edge : null;
|
|
346
|
+
const bottom = side === "top" ? beside ? vh - r.top + offset : edge : null;
|
|
347
|
+
const maxH = beside ? room : vh - MARGIN - edge;
|
|
327
348
|
const exact = o.matchWidth === true;
|
|
328
349
|
const width = exact ? r.width : Math.max(o.width || 0, o.minWidth || 0, o.matchWidth === "min" ? r.width : 0);
|
|
329
350
|
const w = exact || o.width ? width : Math.max(layer.width, width) || o.estWidth || 260;
|
|
330
351
|
let left = align === "end" ? r.right - w : align === "center" ? r.left + r.width / 2 - w / 2 : r.left;
|
|
331
352
|
left = Math.max(MARGIN, Math.min(left, window.innerWidth - w - MARGIN));
|
|
332
|
-
const maxH = Math.max(140, side === "top" ? above : below);
|
|
333
353
|
const next = {
|
|
334
354
|
left,
|
|
335
355
|
width: exact ? r.width : void 0,
|
|
336
356
|
minWidth: o.minWidth,
|
|
337
|
-
top
|
|
338
|
-
bottom
|
|
357
|
+
top,
|
|
358
|
+
bottom,
|
|
339
359
|
maxH,
|
|
340
360
|
side,
|
|
341
361
|
anchorWidth: r.width
|
|
@@ -358,7 +378,7 @@ function usePopoverPosition(open, anchorRef, opts) {
|
|
|
358
378
|
};
|
|
359
379
|
raf = requestAnimationFrame(tick);
|
|
360
380
|
return () => cancelAnimationFrame(raf);
|
|
361
|
-
}, [open, o.placement, o.offset, o.matchWidth, o.width, o.minWidth, o.estHeight]);
|
|
381
|
+
}, [open, o.placement, o.offset, o.matchWidth, o.width, o.minWidth, o.maxHeight, o.estHeight]);
|
|
362
382
|
return pos;
|
|
363
383
|
}
|
|
364
384
|
var portal = (node) => {
|
|
@@ -395,6 +415,7 @@ function Popover({
|
|
|
395
415
|
matchWidth,
|
|
396
416
|
width,
|
|
397
417
|
minWidth,
|
|
418
|
+
maxHeight,
|
|
398
419
|
estHeight: maxHeight || 320,
|
|
399
420
|
onDetach: onClose,
|
|
400
421
|
layerRef: ref
|
|
@@ -10623,6 +10644,7 @@ function createVersionStore(initialState, options) {
|
|
|
10623
10644
|
ModeSwitch,
|
|
10624
10645
|
ModelControls,
|
|
10625
10646
|
NumberInput,
|
|
10647
|
+
POPOVER_BODY_MIN,
|
|
10626
10648
|
PacketCard,
|
|
10627
10649
|
Pagination,
|
|
10628
10650
|
PermissionDenied,
|