@vokril/ui-solid 0.40.0 → 0.41.0
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 +11 -0
- package/README.md +19 -0
- package/dist/CommandPalette-B9qLLuxQ.cjs +2 -0
- package/dist/{CommandPalette-1XfwrR2D.js → CommandPalette-BSLMG8km.js} +774 -786
- package/dist/{DateRangePicker-DL1j6ww5.js → DateRangePicker-DsNwzYqP.js} +1 -1
- package/dist/{DateRangePicker-CZddrCVN.cjs → DateRangePicker-G2mk1fZM.cjs} +1 -1
- package/dist/{GuidedTour-BxmPJE-B.cjs → GuidedTour-CJ09go6v.cjs} +1 -1
- package/dist/{GuidedTour-DzmN3Cfq.js → GuidedTour-CSq40Cp9.js} +1 -1
- package/dist/{IconPicker-xydEBrKw.cjs → IconPicker-BBXd8Wet.cjs} +1 -1
- package/dist/{IconPicker-BuQkoRRB.js → IconPicker-CXL9cVtH.js} +1 -1
- package/dist/Modal-C5MGcO3D.js +956 -0
- package/dist/Modal-CkNS2oaD.cjs +1 -0
- package/dist/{StatusBarNotificationBell-DvKKK9jh.js → StatusBarNotificationBell-6SNCYifJ.js} +4 -4
- package/dist/{StatusBarNotificationBell-BIg-eu1Y.cjs → StatusBarNotificationBell-CVxvsv8h.cjs} +1 -1
- package/dist/{ToggleButton-CrVTb5ZP.js → ToggleButton-B-9WSFMZ.js} +2 -2
- package/dist/{ToggleButton-sXKMeceC.cjs → ToggleButton-DRmBFJwM.cjs} +1 -1
- package/dist/{createDialogShellFocus-GXYQh0Oh.js → createDialogShellFocus-D2u_bO7f.js} +1 -1
- package/dist/{createDialogShellFocus-CLuQ1s0l.cjs → createDialogShellFocus-pWBCBflu.cjs} +1 -1
- package/dist/{createResizableSidebar-Beu5DVYW.cjs → createResizableSidebar-CjPj5vwC.cjs} +1 -1
- package/dist/{createResizableSidebar-BGseZrMh.js → createResizableSidebar-D4K0ZCvk.js} +2 -2
- package/dist/forms/index.cjs +1 -1
- package/dist/forms/index.js +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +12 -12
- package/dist/layout/index.cjs +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/overlay/Modal.d.cts +27 -0
- package/dist/overlay/Modal.d.ts +27 -0
- package/dist/overlay/index.cjs +1 -1
- package/dist/overlay/index.js +4 -4
- package/dist/overlay/modalDefaults.d.cts +5 -0
- package/dist/overlay/modalDefaults.d.ts +5 -0
- package/dist/overlay/modalResize.d.cts +50 -0
- package/dist/overlay/modalResize.d.ts +50 -0
- package/dist/server/{CommandPalette-DorJXXoB.js → CommandPalette-B9ymY_SI.js} +2 -2
- package/dist/server/{CommandPalette-BMwxv_Yy.cjs → CommandPalette-BpH6CMuv.cjs} +1 -1
- package/dist/server/{GuidedTour-JPHl9qAv.cjs → GuidedTour-hk_hg5S7.cjs} +1 -1
- package/dist/server/{GuidedTour-DhVy485y.js → GuidedTour-taurKiCd.js} +1 -1
- package/dist/server/{IconPicker-Xb9VX3Lk.cjs → IconPicker-BN3EyrRA.cjs} +1 -1
- package/dist/server/{IconPicker-bUaMtcMV.js → IconPicker-f0VYyq4T.js} +2 -2
- package/dist/server/Modal-CTMmcjaQ.js +760 -0
- package/dist/server/Modal-J1-hJdFU.cjs +1 -0
- package/dist/server/{StatusBarNotificationBell-CyNRKMtb.cjs → StatusBarNotificationBell-5rh44U0F.cjs} +1 -1
- package/dist/server/{StatusBarNotificationBell-DzrBLG0C.js → StatusBarNotificationBell-C82RZkZm.js} +2 -2
- package/dist/server/{ToggleButton-BTKq5h-y.js → ToggleButton-D-ffVLWs.js} +2 -2
- package/dist/server/{ToggleButton-J-cKrSwa.cjs → ToggleButton-DobG6pBr.cjs} +1 -1
- package/dist/server/{createResizableSidebar-ClRpRZLh.js → createResizableSidebar-69_PRJGJ.js} +2 -2
- package/dist/server/{createResizableSidebar-Bukt4w81.cjs → createResizableSidebar-B7L5UMWS.cjs} +1 -1
- package/dist/server/forms/index.cjs +1 -1
- package/dist/server/forms/index.js +2 -2
- package/dist/server/{index-CxpRbGi3.cjs → index-BLcoVa-m.cjs} +1 -1
- package/dist/server/{index-BglF6V2r.js → index-H8cYvjqO.js} +2 -2
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +8 -8
- package/dist/server/layout/index.cjs +1 -1
- package/dist/server/layout/index.js +1 -1
- package/dist/server/notifications/index.cjs +1 -1
- package/dist/server/notifications/index.js +1 -1
- package/dist/server/overlay/index.cjs +1 -1
- package/dist/server/overlay/index.js +3 -3
- package/dist/solid/overlay/Modal.jsx +161 -4
- package/dist/solid/overlay/Modal.module.css.js +10 -0
- package/dist/solid/overlay/modalResize.js +49 -0
- package/dist/style.css +1 -1
- package/dist/ui.css +1 -1
- package/package.json +1 -1
- package/dist/CommandPalette-DgoP-6h9.cjs +0 -2
- package/dist/Modal-DospFxAr.js +0 -771
- package/dist/Modal-Dq7OTcoz.cjs +0 -1
- package/dist/server/Modal-CL3mMf3_.js +0 -666
- package/dist/server/Modal-J5LcYq9z.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Show, createMemo, createSignal, createUniqueId, onCleanup, onMount, } from 'solid-js';
|
|
1
|
+
import { For, Show, createMemo, createSignal, createUniqueId, onCleanup, onMount, untrack, } from 'solid-js';
|
|
2
2
|
import { prefersReducedMotion } from '../a11y/prefersReducedMotion';
|
|
3
3
|
import { modalTitlebarHeight } from './modalViewport';
|
|
4
4
|
import { useModalDefaults } from './modalDefaults';
|
|
@@ -14,6 +14,8 @@ import { getActiveWindow } from '../host/window';
|
|
|
14
14
|
import { hasOpenLayerIn, useOverlayRegistration } from './overlayStack';
|
|
15
15
|
import { requestOwnerAnimationFrame } from './ownerAnimationFrame';
|
|
16
16
|
import { t } from '../i18n/i18n';
|
|
17
|
+
import { nudgeDialog } from './dialogNudge';
|
|
18
|
+
import { MODAL_MIN_SIZE, MODAL_RESIZE_EDGES, fitModalSize, offsetForRect, resizeRect, } from './modalResize';
|
|
17
19
|
import styles from './Modal.module.css.js';
|
|
18
20
|
import { bestEffortFailed } from '../_internal/base/bestEffort';
|
|
19
21
|
import { isKey } from '../_internal/base/keys';
|
|
@@ -23,6 +25,9 @@ export function Modal(props) {
|
|
|
23
25
|
const modalDefaults = useModalDefaults();
|
|
24
26
|
const embedded = createMemo(() => Boolean(props.embedded));
|
|
25
27
|
const closeDisabled = createMemo(() => Boolean(props.closeDisabled));
|
|
28
|
+
const backdropDismiss = createMemo(() => props.backdropDismiss ?? 'close');
|
|
29
|
+
const closeGuard = createMemo(() => props.canClose);
|
|
30
|
+
const resizable = createMemo(() => !embedded() && (props.resizable ?? modalDefaults.resizable ?? true));
|
|
26
31
|
const openedIn = createMemo((previous) => embedded() || !props.open()
|
|
27
32
|
? null
|
|
28
33
|
: (previous ?? props.hostDocument ?? getActiveWindow().document), null);
|
|
@@ -43,7 +48,37 @@ export function Modal(props) {
|
|
|
43
48
|
return doc !== null && !hasOpenLayerIn(doc);
|
|
44
49
|
};
|
|
45
50
|
let closeShell;
|
|
46
|
-
|
|
51
|
+
let closeAsked = false;
|
|
52
|
+
const requestClose = () => {
|
|
53
|
+
const guard = closeGuard();
|
|
54
|
+
if (guard === undefined) {
|
|
55
|
+
closeShell?.();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (closeAsked || closeDisabled())
|
|
59
|
+
return;
|
|
60
|
+
closeAsked = true;
|
|
61
|
+
const settle = (ok) => {
|
|
62
|
+
closeAsked = false;
|
|
63
|
+
if (ok)
|
|
64
|
+
closeShell?.();
|
|
65
|
+
};
|
|
66
|
+
let answer;
|
|
67
|
+
try {
|
|
68
|
+
answer = guard();
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
closeAsked = false;
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
if (typeof answer === 'boolean')
|
|
75
|
+
settle(answer);
|
|
76
|
+
else
|
|
77
|
+
void answer.then(settle, (error) => {
|
|
78
|
+
closeAsked = false;
|
|
79
|
+
bestEffortFailed('modal close guard rejected', error);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
47
82
|
const handleOverlayMouseDown = (event) => {
|
|
48
83
|
mouseDownOnOverlay =
|
|
49
84
|
event.target === event.currentTarget && topmostAtPointerDown;
|
|
@@ -54,6 +89,11 @@ export function Modal(props) {
|
|
|
54
89
|
if (startedOnOverlay &&
|
|
55
90
|
event.target === event.currentTarget &&
|
|
56
91
|
!closeDisabled()) {
|
|
92
|
+
if (backdropDismiss() === 'nudge') {
|
|
93
|
+
if (dialogElement)
|
|
94
|
+
nudgeDialog(dialogElement);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
57
97
|
requestClose();
|
|
58
98
|
}
|
|
59
99
|
};
|
|
@@ -203,6 +243,8 @@ export function Modal(props) {
|
|
|
203
243
|
const [isMaximized, setIsMaximized] = createSignal(false);
|
|
204
244
|
const [dragOffset, setDragOffset] = createSignal({ x: 0, y: 0 });
|
|
205
245
|
const [isDragging, setIsDragging] = createSignal(false);
|
|
246
|
+
const [isResizing, setIsResizing] = createSignal(false);
|
|
247
|
+
const [size, setSize] = createSignal(untrack(() => props.initialSize) ?? null);
|
|
206
248
|
let headerElement = null;
|
|
207
249
|
let overlayElement = null;
|
|
208
250
|
const canMaximize = createMemo(() => !embedded() && (props.allowMaximize ?? true));
|
|
@@ -437,6 +479,102 @@ export function Modal(props) {
|
|
|
437
479
|
return;
|
|
438
480
|
endDrag();
|
|
439
481
|
};
|
|
482
|
+
const canResize = createMemo(() => resizable() && !isExiting() && !isMaximized());
|
|
483
|
+
const resizeBounds = (win) => {
|
|
484
|
+
const rootFont = Number.parseFloat(win.getComputedStyle(win.document.documentElement).fontSize);
|
|
485
|
+
return {
|
|
486
|
+
minWidth: MODAL_MIN_SIZE.width,
|
|
487
|
+
minHeight: MODAL_MIN_SIZE.height,
|
|
488
|
+
viewportWidth: win.innerWidth,
|
|
489
|
+
viewportHeight: win.innerHeight,
|
|
490
|
+
titlebar: titlebarHeight(win),
|
|
491
|
+
gap: 2 * (Number.isFinite(rootFont) ? rootFont : 16),
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
const fitSizeTo = (win) => {
|
|
495
|
+
const current = size();
|
|
496
|
+
if (current === null)
|
|
497
|
+
return;
|
|
498
|
+
const fitted = fitModalSize(current, resizeBounds(win));
|
|
499
|
+
if (fitted.width !== current.width || fitted.height !== current.height)
|
|
500
|
+
setSize(fitted);
|
|
501
|
+
};
|
|
502
|
+
let cleanupActiveResize = null;
|
|
503
|
+
const endResize = () => {
|
|
504
|
+
cleanupActiveResize?.();
|
|
505
|
+
cleanupActiveResize = null;
|
|
506
|
+
};
|
|
507
|
+
const startResize = (edge, e) => {
|
|
508
|
+
if (e.button !== undefined && e.button !== 0)
|
|
509
|
+
return;
|
|
510
|
+
if (!canResize() || !dialogElement)
|
|
511
|
+
return;
|
|
512
|
+
e.preventDefault();
|
|
513
|
+
e.stopPropagation();
|
|
514
|
+
dismissEntering();
|
|
515
|
+
endDrag();
|
|
516
|
+
endResize();
|
|
517
|
+
const handle = e.currentTarget;
|
|
518
|
+
const doc = handle.ownerDocument;
|
|
519
|
+
const win = doc.defaultView;
|
|
520
|
+
if (win === null)
|
|
521
|
+
return;
|
|
522
|
+
const pointerId = e.pointerId ?? 1;
|
|
523
|
+
try {
|
|
524
|
+
handle.setPointerCapture(pointerId);
|
|
525
|
+
}
|
|
526
|
+
catch (error) {
|
|
527
|
+
bestEffortFailed('resize works without pointer capture', error);
|
|
528
|
+
}
|
|
529
|
+
const r = dialogElement.getBoundingClientRect();
|
|
530
|
+
const start = {
|
|
531
|
+
left: r.left,
|
|
532
|
+
top: r.top,
|
|
533
|
+
width: r.width,
|
|
534
|
+
height: r.height,
|
|
535
|
+
};
|
|
536
|
+
const startOffset = { ...dragOffset() };
|
|
537
|
+
const startPointer = { x: e.clientX, y: e.clientY };
|
|
538
|
+
const bounds = resizeBounds(win);
|
|
539
|
+
setIsResizing(true);
|
|
540
|
+
const onMove = (moveEvt) => {
|
|
541
|
+
if ((moveEvt.pointerId ?? 1) !== pointerId)
|
|
542
|
+
return;
|
|
543
|
+
const raw = resizeRect(start, edge, moveEvt.clientX - startPointer.x, moveEvt.clientY - startPointer.y, bounds);
|
|
544
|
+
const rect = {
|
|
545
|
+
left: Math.round(raw.left),
|
|
546
|
+
top: Math.round(raw.top),
|
|
547
|
+
width: Math.round(raw.width),
|
|
548
|
+
height: Math.round(raw.height),
|
|
549
|
+
};
|
|
550
|
+
setSize({ width: rect.width, height: rect.height });
|
|
551
|
+
setDragOffset(offsetForRect(start, startOffset, rect));
|
|
552
|
+
};
|
|
553
|
+
const onEnd = (endEvt) => {
|
|
554
|
+
if ((endEvt.pointerId ?? 1) !== pointerId)
|
|
555
|
+
return;
|
|
556
|
+
const finished = size();
|
|
557
|
+
endResize();
|
|
558
|
+
if (finished !== null)
|
|
559
|
+
props.onResizeEnd?.(finished);
|
|
560
|
+
};
|
|
561
|
+
doc.addEventListener('pointermove', onMove);
|
|
562
|
+
doc.addEventListener('pointerup', onEnd);
|
|
563
|
+
doc.addEventListener('pointercancel', onEnd);
|
|
564
|
+
cleanupActiveResize = () => {
|
|
565
|
+
setIsResizing(false);
|
|
566
|
+
try {
|
|
567
|
+
if (handle.hasPointerCapture(pointerId))
|
|
568
|
+
handle.releasePointerCapture(pointerId);
|
|
569
|
+
}
|
|
570
|
+
catch (error) {
|
|
571
|
+
bestEffortFailed('pointer capture may already have been released', error);
|
|
572
|
+
}
|
|
573
|
+
doc.removeEventListener('pointermove', onMove);
|
|
574
|
+
doc.removeEventListener('pointerup', onEnd);
|
|
575
|
+
doc.removeEventListener('pointercancel', onEnd);
|
|
576
|
+
};
|
|
577
|
+
};
|
|
440
578
|
const handleHeaderDblClick = (e) => {
|
|
441
579
|
if (!canMaximize())
|
|
442
580
|
return;
|
|
@@ -450,10 +588,13 @@ export function Modal(props) {
|
|
|
450
588
|
const win = ownDocument()?.defaultView;
|
|
451
589
|
if (!win)
|
|
452
590
|
return;
|
|
591
|
+
if (!embedded())
|
|
592
|
+
fitSizeTo(win);
|
|
453
593
|
const handleResize = () => {
|
|
454
594
|
if (isMaximized() || isExiting() || embedded() || !dialogElement)
|
|
455
595
|
return;
|
|
456
596
|
dismissEntering();
|
|
597
|
+
fitSizeTo(win);
|
|
457
598
|
const current = dragOffset();
|
|
458
599
|
const rect = dialogElement.getBoundingClientRect();
|
|
459
600
|
const base = {
|
|
@@ -478,6 +619,7 @@ export function Modal(props) {
|
|
|
478
619
|
win.removeEventListener('resize', handleResize);
|
|
479
620
|
rootObserver.disconnect();
|
|
480
621
|
endDrag();
|
|
622
|
+
endResize();
|
|
481
623
|
});
|
|
482
624
|
});
|
|
483
625
|
return (<div ref={(el) => {
|
|
@@ -492,13 +634,21 @@ export function Modal(props) {
|
|
|
492
634
|
dismissOnEscape(e);
|
|
493
635
|
}}>
|
|
494
636
|
{props.decoration}
|
|
495
|
-
<div ref={captureAndFocus} class={`${styles.modal} ${embedded() ? styles.modalEmbedded : ''} ${isEntering() && !isExiting() ? styles.modalEntering : ''} ${isMaximized() ? styles.modalMaximized : ''} ${isDragging() ? styles.modalDragged : ''} ${isExiting() ? styles.modalExiting : ''}`} style={{
|
|
637
|
+
<div ref={captureAndFocus} class={`${styles.modal} ${embedded() ? styles.modalEmbedded : ''} ${isEntering() && !isExiting() ? styles.modalEntering : ''} ${isMaximized() ? styles.modalMaximized : ''} ${isDragging() || isResizing() ? styles.modalDragged : ''} ${isExiting() ? styles.modalExiting : ''}`} style={{
|
|
496
638
|
...(embedded()
|
|
497
639
|
? undefined
|
|
498
640
|
: {
|
|
499
641
|
'max-width': isMaximized()
|
|
500
642
|
? '100%'
|
|
501
|
-
: (
|
|
643
|
+
: size() !== null
|
|
644
|
+
? 'none'
|
|
645
|
+
: (props.maxWidth ?? '32rem'),
|
|
646
|
+
}),
|
|
647
|
+
...(embedded() || isMaximized() || size() === null
|
|
648
|
+
? undefined
|
|
649
|
+
: {
|
|
650
|
+
width: `${size()?.width ?? 0}px`,
|
|
651
|
+
height: `${size()?.height ?? 0}px`,
|
|
502
652
|
}),
|
|
503
653
|
...props.dialogStyle,
|
|
504
654
|
'--modal-drag-x': `${isMaximized() || embedded() ? 0 : dragOffset().x}px`,
|
|
@@ -526,6 +676,7 @@ export function Modal(props) {
|
|
|
526
676
|
</Show>
|
|
527
677
|
</div>
|
|
528
678
|
<div class={styles.modalHeaderActions}>
|
|
679
|
+
{props.headerActions}
|
|
529
680
|
<Show when={props.onDetach}>
|
|
530
681
|
<Button size="sm" variant="ghost" iconOnly onClick={() => props.onDetach?.()} disabled={closeDisabled()} title={t('Open in new window')} aria-label={t('Open in new window')}>
|
|
531
682
|
<VpExternalLink />
|
|
@@ -559,6 +710,12 @@ export function Modal(props) {
|
|
|
559
710
|
<Show when={props.footer}>
|
|
560
711
|
<div class={styles.modalFooter}>{props.footer}</div>
|
|
561
712
|
</Show>
|
|
713
|
+
|
|
714
|
+
<Show when={canResize()}>
|
|
715
|
+
<For each={MODAL_RESIZE_EDGES}>
|
|
716
|
+
{(edge) => (<div class={`${styles.resizeHandle} ${styles[`resize-${edge}`]}`} data-resize-edge={edge} aria-hidden="true" onPointerDown={(e) => startResize(edge, e)}/>)}
|
|
717
|
+
</For>
|
|
718
|
+
</Show>
|
|
562
719
|
</div>
|
|
563
720
|
</div>);
|
|
564
721
|
};
|
|
@@ -10,6 +10,16 @@ export default {
|
|
|
10
10
|
"modalExiting": "vk_modalExiting_qiJ02",
|
|
11
11
|
"modalExitScaleDown": "vk_modalExitScaleDown_-CC8F",
|
|
12
12
|
"modalDragged": "vk_modalDragged_tiDIq",
|
|
13
|
+
"resizeHandle": "vk_resizeHandle_b3UDa",
|
|
14
|
+
"resize-n": "vk_resize-n_mlVNh",
|
|
15
|
+
"resize-s": "vk_resize-s_02Egl",
|
|
16
|
+
"resize-e": "vk_resize-e_RGQAF",
|
|
17
|
+
"resize-w": "vk_resize-w_F3NAn",
|
|
18
|
+
"resize-ne": "vk_resize-ne_-goHY",
|
|
19
|
+
"resize-nw": "vk_resize-nw_20bHL",
|
|
20
|
+
"resize-se": "vk_resize-se_q2Qtb",
|
|
21
|
+
"resize-sw": "vk_resize-sw_n7kou",
|
|
22
|
+
"modalNudge": "vk_modalNudge_8ldIg",
|
|
13
23
|
"modalOverlayMaximized": "vk_modalOverlayMaximized_00k68",
|
|
14
24
|
"modalMaximized": "vk_modalMaximized_iL0gq",
|
|
15
25
|
"modalOverlayEmbedded": "vk_modalOverlayEmbedded_kz22G",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const MODAL_RESIZE_EDGES = [
|
|
2
|
+
'n',
|
|
3
|
+
's',
|
|
4
|
+
'e',
|
|
5
|
+
'w',
|
|
6
|
+
'ne',
|
|
7
|
+
'nw',
|
|
8
|
+
'se',
|
|
9
|
+
'sw',
|
|
10
|
+
];
|
|
11
|
+
export const MODAL_MIN_SIZE = { width: 360, height: 220 };
|
|
12
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), Math.max(min, max));
|
|
13
|
+
export function maxModalHeight(bounds) {
|
|
14
|
+
return Math.max(bounds.minHeight, bounds.viewportHeight - bounds.titlebar - bounds.gap);
|
|
15
|
+
}
|
|
16
|
+
export function resizeRect(start, edge, dx, dy, bounds) {
|
|
17
|
+
let { left, top, width, height } = start;
|
|
18
|
+
const right = start.left + start.width;
|
|
19
|
+
const bottom = start.top + start.height;
|
|
20
|
+
const maxHeight = maxModalHeight(bounds);
|
|
21
|
+
if (edge.includes('e')) {
|
|
22
|
+
width = clamp(start.width + dx, bounds.minWidth, bounds.viewportWidth - start.left);
|
|
23
|
+
}
|
|
24
|
+
if (edge.includes('w')) {
|
|
25
|
+
left = clamp(start.left + dx, 0, right - bounds.minWidth);
|
|
26
|
+
width = right - left;
|
|
27
|
+
}
|
|
28
|
+
if (edge.includes('s')) {
|
|
29
|
+
height = clamp(start.height + dy, bounds.minHeight, Math.min(maxHeight, bounds.viewportHeight - start.top));
|
|
30
|
+
}
|
|
31
|
+
if (edge.startsWith('n')) {
|
|
32
|
+
top = clamp(start.top + dy, Math.max(bounds.titlebar, bottom - maxHeight), bottom - bounds.minHeight);
|
|
33
|
+
height = bottom - top;
|
|
34
|
+
}
|
|
35
|
+
return { left, top, width, height };
|
|
36
|
+
}
|
|
37
|
+
export function offsetForRect(start, startOffset, rect) {
|
|
38
|
+
const startBaseLeft = start.left - startOffset.x;
|
|
39
|
+
const startBaseTop = start.top - startOffset.y;
|
|
40
|
+
const baseLeft = startBaseLeft - (rect.width - start.width) / 2;
|
|
41
|
+
const baseTop = startBaseTop - (rect.height - start.height) / 2;
|
|
42
|
+
return { x: rect.left - baseLeft, y: rect.top - baseTop };
|
|
43
|
+
}
|
|
44
|
+
export function fitModalSize(size, bounds) {
|
|
45
|
+
return {
|
|
46
|
+
width: clamp(size.width, bounds.minWidth, bounds.viewportWidth),
|
|
47
|
+
height: clamp(size.height, bounds.minHeight, maxModalHeight(bounds)),
|
|
48
|
+
};
|
|
49
|
+
}
|