@liberation-data/desk 0.20.0 → 0.20.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/README.md +1 -1
- package/dist/css/overlays.css +6 -18
- package/dist/desk.css +6 -18
- package/dist/react/overlays.d.ts.map +1 -1
- package/dist/react/overlays.js +56 -2
- package/dist/react/overlays.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/src/css/overlays.css +6 -18
- package/src/react/overlays.tsx +59 -3
package/README.md
CHANGED
|
@@ -536,7 +536,7 @@ const toast = useToast()
|
|
|
536
536
|
toast.show({ message: 'Ride deleted', action: { label: 'Undo', onSelect: restore } })
|
|
537
537
|
```
|
|
538
538
|
|
|
539
|
-
A **popover** belongs to one control and closes when you press outside. A **sheet** belongs to one window
|
|
539
|
+
A **popover** belongs to one control and closes when you press outside. It floats over its window rather than inside it, so opening one never resizes or scrolls the window; it stays within the window's edges and flips side when there is no room. A **sheet** belongs to one window
|
|
540
540
|
and blocks only that window — it renders inside it, so the rest of the desk stays usable. An **alert** stops
|
|
541
541
|
the app and is for what cannot be undone; Cancel comes before the action, and a destructive action is never
|
|
542
542
|
the default button. A **toast** interrupts nothing, carries Undo, and waits while the pointer or focus is on
|
package/dist/css/overlays.css
CHANGED
|
@@ -7,10 +7,14 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.desk-popover {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/* Fixed, and placed by script beside its trigger: a popover overlaps its window, never grows it. */
|
|
11
|
+
position: fixed;
|
|
12
|
+
/* Above a sheet or an alert (1300): it is drawn in the body now, not inside the layer that opened it. */
|
|
13
|
+
z-index: 1350;
|
|
14
|
+
box-sizing: border-box;
|
|
12
15
|
min-width: 220px;
|
|
13
16
|
max-width: min(360px, calc(100vw - 24px));
|
|
17
|
+
overflow: auto;
|
|
14
18
|
padding: var(--desk-space-3);
|
|
15
19
|
border: 1px solid var(--desk-rule);
|
|
16
20
|
border-radius: 12px;
|
|
@@ -19,22 +23,6 @@
|
|
|
19
23
|
animation: desk-menu-in .14s var(--desk-ease);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
.desk-popover[data-placement="below"] {
|
|
23
|
-
top: calc(100% + 6px);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.desk-popover[data-placement="above"] {
|
|
27
|
-
bottom: calc(100% + 6px);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.desk-popover[data-align="start"] {
|
|
31
|
-
left: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.desk-popover[data-align="end"] {
|
|
35
|
-
right: 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
26
|
/* A sheet belongs to its window: the scrim covers that window and nothing else. */
|
|
39
27
|
.desk-sheet-scrim,
|
|
40
28
|
.desk-alert-scrim {
|
package/dist/desk.css
CHANGED
|
@@ -2319,10 +2319,14 @@
|
|
|
2319
2319
|
}
|
|
2320
2320
|
|
|
2321
2321
|
.desk-popover {
|
|
2322
|
-
|
|
2323
|
-
|
|
2322
|
+
/* Fixed, and placed by script beside its trigger: a popover overlaps its window, never grows it. */
|
|
2323
|
+
position: fixed;
|
|
2324
|
+
/* Above a sheet or an alert (1300): it is drawn in the body now, not inside the layer that opened it. */
|
|
2325
|
+
z-index: 1350;
|
|
2326
|
+
box-sizing: border-box;
|
|
2324
2327
|
min-width: 220px;
|
|
2325
2328
|
max-width: min(360px, calc(100vw - 24px));
|
|
2329
|
+
overflow: auto;
|
|
2326
2330
|
padding: var(--desk-space-3);
|
|
2327
2331
|
border: 1px solid var(--desk-rule);
|
|
2328
2332
|
border-radius: 12px;
|
|
@@ -2331,22 +2335,6 @@
|
|
|
2331
2335
|
animation: desk-menu-in .14s var(--desk-ease);
|
|
2332
2336
|
}
|
|
2333
2337
|
|
|
2334
|
-
.desk-popover[data-placement="below"] {
|
|
2335
|
-
top: calc(100% + 6px);
|
|
2336
|
-
}
|
|
2337
|
-
|
|
2338
|
-
.desk-popover[data-placement="above"] {
|
|
2339
|
-
bottom: calc(100% + 6px);
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
.desk-popover[data-align="start"] {
|
|
2343
|
-
left: 0;
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
|
-
.desk-popover[data-align="end"] {
|
|
2347
|
-
right: 0;
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
2338
|
/* A sheet belongs to its window: the scrim covers that window and nothing else. */
|
|
2351
2339
|
.desk-sheet-scrim,
|
|
2352
2340
|
.desk-alert-scrim {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlays.d.ts","sourceRoot":"","sources":["../../src/react/overlays.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAkB/D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IACjD,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAA;IAClC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IAC9C,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,YAAY,CAAA;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;IAChC,QAAQ,CAAC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AC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;KAAE,CAAA;IAC3E,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAErE,UAAU,QAAQ;IAChB,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAA;IACnC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B;AAID,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAkB3E;AAED,wBAAgB,QAAQ,IAAI,QAAQ,CAInC"}
|
package/dist/react/overlays.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import { windowElement } from '../core/commands.js';
|
|
4
|
+
import { WINDOW_ATTRIBUTE, windowElement } from '../core/commands.js';
|
|
5
5
|
import { Button } from './controls.js';
|
|
6
6
|
import { useWindowId } from './context.js';
|
|
7
7
|
import { useFocusTrap, useLayer } from './layers.js';
|
|
@@ -23,7 +23,61 @@ export function Popover({ open, onOpenChange, label, trigger, placement = 'below
|
|
|
23
23
|
document.addEventListener('pointerdown', onPointerDown, true);
|
|
24
24
|
return () => document.removeEventListener('pointerdown', onPointerDown, true);
|
|
25
25
|
}, [open, onOpenChange]);
|
|
26
|
-
|
|
26
|
+
const place = useCallback(() => {
|
|
27
|
+
const anchor = button.current;
|
|
28
|
+
const element = panel.current;
|
|
29
|
+
if (anchor && element)
|
|
30
|
+
placePopover(anchor, element, placement, align);
|
|
31
|
+
}, [placement, align]);
|
|
32
|
+
// Measured once it exists, then kept beside its control while anything under it scrolls.
|
|
33
|
+
useLayoutEffect(() => {
|
|
34
|
+
if (!open)
|
|
35
|
+
return;
|
|
36
|
+
place();
|
|
37
|
+
addEventListener('resize', place);
|
|
38
|
+
document.addEventListener('scroll', place, true);
|
|
39
|
+
return () => {
|
|
40
|
+
removeEventListener('resize', place);
|
|
41
|
+
document.removeEventListener('scroll', place, true);
|
|
42
|
+
};
|
|
43
|
+
}, [open, place]);
|
|
44
|
+
return (_jsxs("span", { className: "desk-popover-anchor", children: [trigger({ ref: button, 'aria-haspopup': 'dialog', 'aria-expanded': open, onClick: () => onOpenChange(!open) }), open && typeof document !== 'undefined' && createPortal(_jsx("div", { ref: panel, role: "dialog", "aria-label": label, className: "desk-popover", "data-placement": placement, "data-align": align, children: children }), document.body)] }));
|
|
45
|
+
}
|
|
46
|
+
const POPOVER_GAP = 6;
|
|
47
|
+
const POPOVER_MARGIN = 8;
|
|
48
|
+
/*
|
|
49
|
+
* A popover floats OVER its window rather than inside it. Drawn in the window's content it made that
|
|
50
|
+
* content taller or wider, so opening an (i) grew a scrollbar or pushed the layout — the window
|
|
51
|
+
* changed size to make room for a note about it. Here it is fixed to the viewport, kept inside the
|
|
52
|
+
* window it belongs to, flipped to the other side when its side has no room, and scrolls within
|
|
53
|
+
* itself when neither side has.
|
|
54
|
+
*/
|
|
55
|
+
function placePopover(anchor, element, placement, align) {
|
|
56
|
+
const box = anchor.getBoundingClientRect();
|
|
57
|
+
const frame = anchor.closest(`[${WINDOW_ATTRIBUTE}]`)?.getBoundingClientRect();
|
|
58
|
+
const bounds = {
|
|
59
|
+
left: (frame?.left ?? 0) + POPOVER_MARGIN,
|
|
60
|
+
top: (frame?.top ?? 0) + POPOVER_MARGIN,
|
|
61
|
+
right: (frame?.right ?? innerWidth) - POPOVER_MARGIN,
|
|
62
|
+
bottom: (frame?.bottom ?? innerHeight) - POPOVER_MARGIN,
|
|
63
|
+
};
|
|
64
|
+
element.style.maxHeight = '';
|
|
65
|
+
const { width, height } = element.getBoundingClientRect();
|
|
66
|
+
const roomBelow = bounds.bottom - box.bottom - POPOVER_GAP;
|
|
67
|
+
const roomAbove = box.top - bounds.top - POPOVER_GAP;
|
|
68
|
+
const fits = (side) => height <= (side === 'below' ? roomBelow : roomAbove);
|
|
69
|
+
const other = placement === 'below' ? 'above' : 'below';
|
|
70
|
+
const side = fits(placement) ? placement : fits(other) ? other : roomBelow >= roomAbove ? 'below' : 'above';
|
|
71
|
+
const below = side === 'below';
|
|
72
|
+
const room = Math.max(below ? roomBelow : roomAbove, 0);
|
|
73
|
+
const shown = Math.min(height, room);
|
|
74
|
+
const preferred = align === 'start' ? box.left : box.right - width;
|
|
75
|
+
const left = Math.max(bounds.left, Math.min(preferred, bounds.right - width));
|
|
76
|
+
element.style.left = `${left}px`;
|
|
77
|
+
element.style.top = `${below ? box.bottom + POPOVER_GAP : box.top - POPOVER_GAP - shown}px`;
|
|
78
|
+
if (height > room)
|
|
79
|
+
element.style.maxHeight = `${room}px`;
|
|
80
|
+
element.dataset.side = side;
|
|
27
81
|
}
|
|
28
82
|
export function Sheet({ open, onDismiss, title, description, actions, children }) {
|
|
29
83
|
const id = useId();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlays.js","sourceRoot":"","sources":["../../src/react/overlays.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE5H,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":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;QAC/B,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;QAC7C,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;IAEjC,OAAO,CACL,eACE,SAAS,EAAC,YAAY,eACX,KAAK,CAAC,IAAI,IAAI,SAAS,EAClC,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;QAC/C,4EAA4E;QAC5E,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EACrC,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EACtC,cAAc,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EACrC,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,aAErC,eAAM,SAAS,EAAC,oBAAoB,YAAE,KAAK,CAAC,OAAO,GAAQ,EAC1D,KAAK,CAAC,MAAM,IAAI,CACf,KAAC,MAAM,IACL,IAAI,EAAC,OAAO,EACZ,MAAM,EAAC,OAAO,EACd,OAAO,EAAE,GAAG,EAAE;oBACZ,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;oBACxB,SAAS,EAAE,CAAA;gBACb,CAAC,YAEA,KAAK,CAAC,MAAM,CAAC,KAAK,GACZ,CACV,EACD,KAAC,MAAM,IAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,OAAO,gBAAY,SAAS,EAAC,OAAO,EAAE,SAAS,uBAElE,IACL,CACP,CAAA;AACH,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -420,7 +420,7 @@ sortable headings. It renders what it is given — no paging, no fetching.
|
|
|
420
420
|
### Overlays
|
|
421
421
|
|
|
422
422
|
```tsx
|
|
423
|
-
<Popover open onOpenChange label trigger={(props) => <Button {...props} />} placement? align? />
|
|
423
|
+
<Popover open onOpenChange label trigger={(props) => <Button {...props} />} placement? align? /> // floats over its window, clamped to it; never resizes it
|
|
424
424
|
<Sheet open onDismiss title description? actions? /> // renders inside its own window
|
|
425
425
|
<Alert open title message? confirmLabel onConfirm onCancel cancelLabel? destructive? />
|
|
426
426
|
<ToastProvider>; useToast(): { show(toast): string; dismiss(id): void }
|
package/package.json
CHANGED
package/src/css/overlays.css
CHANGED
|
@@ -6,10 +6,14 @@
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.desk-popover {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/* Fixed, and placed by script beside its trigger: a popover overlaps its window, never grows it. */
|
|
10
|
+
position: fixed;
|
|
11
|
+
/* Above a sheet or an alert (1300): it is drawn in the body now, not inside the layer that opened it. */
|
|
12
|
+
z-index: 1350;
|
|
13
|
+
box-sizing: border-box;
|
|
11
14
|
min-width: 220px;
|
|
12
15
|
max-width: min(360px, calc(100vw - 24px));
|
|
16
|
+
overflow: auto;
|
|
13
17
|
padding: var(--desk-space-3);
|
|
14
18
|
border: 1px solid var(--desk-rule);
|
|
15
19
|
border-radius: 12px;
|
|
@@ -18,22 +22,6 @@
|
|
|
18
22
|
animation: desk-menu-in .14s var(--desk-ease);
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
.desk-popover[data-placement="below"] {
|
|
22
|
-
top: calc(100% + 6px);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.desk-popover[data-placement="above"] {
|
|
26
|
-
bottom: calc(100% + 6px);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.desk-popover[data-align="start"] {
|
|
30
|
-
left: 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.desk-popover[data-align="end"] {
|
|
34
|
-
right: 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
25
|
/* A sheet belongs to its window: the scrim covers that window and nothing else. */
|
|
38
26
|
.desk-sheet-scrim,
|
|
39
27
|
.desk-alert-scrim {
|
package/src/react/overlays.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
2
2
|
import type { ReactElement, ReactNode, RefObject } from 'react'
|
|
3
3
|
import { createPortal } from 'react-dom'
|
|
4
|
-
import { windowElement } from '../core/commands.js'
|
|
4
|
+
import { WINDOW_ATTRIBUTE, windowElement } from '../core/commands.js'
|
|
5
5
|
import { Button } from './controls.js'
|
|
6
6
|
import { useWindowId } from './context.js'
|
|
7
7
|
import { useFocusTrap, useLayer } from './layers.js'
|
|
@@ -53,18 +53,74 @@ export function Popover({ open, onOpenChange, label, trigger, placement = 'below
|
|
|
53
53
|
return () => document.removeEventListener('pointerdown', onPointerDown, true)
|
|
54
54
|
}, [open, onOpenChange])
|
|
55
55
|
|
|
56
|
+
const place = useCallback(() => {
|
|
57
|
+
const anchor = button.current
|
|
58
|
+
const element = panel.current
|
|
59
|
+
if (anchor && element) placePopover(anchor, element, placement, align)
|
|
60
|
+
}, [placement, align])
|
|
61
|
+
|
|
62
|
+
// Measured once it exists, then kept beside its control while anything under it scrolls.
|
|
63
|
+
useLayoutEffect(() => {
|
|
64
|
+
if (!open) return
|
|
65
|
+
place()
|
|
66
|
+
addEventListener('resize', place)
|
|
67
|
+
document.addEventListener('scroll', place, true)
|
|
68
|
+
return () => {
|
|
69
|
+
removeEventListener('resize', place)
|
|
70
|
+
document.removeEventListener('scroll', place, true)
|
|
71
|
+
}
|
|
72
|
+
}, [open, place])
|
|
73
|
+
|
|
56
74
|
return (
|
|
57
75
|
<span className="desk-popover-anchor">
|
|
58
76
|
{trigger({ ref: button, 'aria-haspopup': 'dialog', 'aria-expanded': open, onClick: () => onOpenChange(!open) })}
|
|
59
|
-
{open && (
|
|
77
|
+
{open && typeof document !== 'undefined' && createPortal(
|
|
60
78
|
<div ref={panel} role="dialog" aria-label={label} className="desk-popover" data-placement={placement} data-align={align}>
|
|
61
79
|
{children}
|
|
62
|
-
</div
|
|
80
|
+
</div>,
|
|
81
|
+
document.body,
|
|
63
82
|
)}
|
|
64
83
|
</span>
|
|
65
84
|
)
|
|
66
85
|
}
|
|
67
86
|
|
|
87
|
+
const POPOVER_GAP = 6
|
|
88
|
+
const POPOVER_MARGIN = 8
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* A popover floats OVER its window rather than inside it. Drawn in the window's content it made that
|
|
92
|
+
* content taller or wider, so opening an (i) grew a scrollbar or pushed the layout — the window
|
|
93
|
+
* changed size to make room for a note about it. Here it is fixed to the viewport, kept inside the
|
|
94
|
+
* window it belongs to, flipped to the other side when its side has no room, and scrolls within
|
|
95
|
+
* itself when neither side has.
|
|
96
|
+
*/
|
|
97
|
+
function placePopover(anchor: HTMLElement, element: HTMLElement, placement: 'below' | 'above', align: 'start' | 'end') {
|
|
98
|
+
const box = anchor.getBoundingClientRect()
|
|
99
|
+
const frame = anchor.closest(`[${WINDOW_ATTRIBUTE}]`)?.getBoundingClientRect()
|
|
100
|
+
const bounds = {
|
|
101
|
+
left: (frame?.left ?? 0) + POPOVER_MARGIN,
|
|
102
|
+
top: (frame?.top ?? 0) + POPOVER_MARGIN,
|
|
103
|
+
right: (frame?.right ?? innerWidth) - POPOVER_MARGIN,
|
|
104
|
+
bottom: (frame?.bottom ?? innerHeight) - POPOVER_MARGIN,
|
|
105
|
+
}
|
|
106
|
+
element.style.maxHeight = ''
|
|
107
|
+
const { width, height } = element.getBoundingClientRect()
|
|
108
|
+
const roomBelow = bounds.bottom - box.bottom - POPOVER_GAP
|
|
109
|
+
const roomAbove = box.top - bounds.top - POPOVER_GAP
|
|
110
|
+
const fits = (side: 'below' | 'above') => height <= (side === 'below' ? roomBelow : roomAbove)
|
|
111
|
+
const other = placement === 'below' ? 'above' : 'below'
|
|
112
|
+
const side = fits(placement) ? placement : fits(other) ? other : roomBelow >= roomAbove ? 'below' : 'above'
|
|
113
|
+
const below = side === 'below'
|
|
114
|
+
const room = Math.max(below ? roomBelow : roomAbove, 0)
|
|
115
|
+
const shown = Math.min(height, room)
|
|
116
|
+
const preferred = align === 'start' ? box.left : box.right - width
|
|
117
|
+
const left = Math.max(bounds.left, Math.min(preferred, bounds.right - width))
|
|
118
|
+
element.style.left = `${left}px`
|
|
119
|
+
element.style.top = `${below ? box.bottom + POPOVER_GAP : box.top - POPOVER_GAP - shown}px`
|
|
120
|
+
if (height > room) element.style.maxHeight = `${room}px`
|
|
121
|
+
element.dataset.side = side
|
|
122
|
+
}
|
|
123
|
+
|
|
68
124
|
/* ── Sheet: a task that belongs to one window, and blocks only that window ── */
|
|
69
125
|
|
|
70
126
|
export interface SheetProps {
|