@labpane/os 1.2.0 → 1.3.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/dist/index.js +681 -304
- package/dist/index.js.map +4 -4
- package/dist/os/drag-content.d.ts +4 -2
- package/dist/os/frame-task.d.ts +5 -0
- package/dist/os/frame.d.ts +2 -2
- package/dist/os/geometry-task.d.ts +10 -0
- package/dist/os/surface.d.ts +3 -1
- package/dist/os/tabs.d.ts +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// workspace.tsx
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
memo as memo3,
|
|
4
|
+
useCallback as useCallback2,
|
|
5
|
+
useDeferredValue,
|
|
6
|
+
useEffect as useEffect5,
|
|
4
7
|
useId as useId2,
|
|
5
8
|
useLayoutEffect as useLayoutEffect8,
|
|
6
|
-
useMemo as
|
|
9
|
+
useMemo as useMemo3,
|
|
7
10
|
useRef as useRef9,
|
|
8
11
|
useState as useState5
|
|
9
12
|
} from "react";
|
|
@@ -75,20 +78,25 @@ function useWorkspaceIds() {
|
|
|
75
78
|
var TabLinks = createContext(/* @__PURE__ */ new Map());
|
|
76
79
|
function useTabLinks() {
|
|
77
80
|
const links = useContext(TabLinks);
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
return useMemo(
|
|
82
|
+
() => ({
|
|
83
|
+
register: (key2) => (element) => {
|
|
84
|
+
if (element) links.set(key2, element);
|
|
85
|
+
else links.delete(key2);
|
|
86
|
+
},
|
|
87
|
+
get: (key2) => links.get(key2),
|
|
88
|
+
focus: (key2) => requestAnimationFrame(() => links.get(key2)?.focus())
|
|
89
|
+
}),
|
|
90
|
+
[links]
|
|
91
|
+
);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
// surface.tsx
|
|
89
95
|
import {
|
|
90
96
|
Fragment,
|
|
97
|
+
memo,
|
|
91
98
|
useLayoutEffect,
|
|
99
|
+
useMemo as useMemo2,
|
|
92
100
|
useRef,
|
|
93
101
|
useState
|
|
94
102
|
} from "react";
|
|
@@ -268,6 +276,31 @@ function hasOpenOverlay() {
|
|
|
268
276
|
return !!full && full !== document.documentElement || !!document.querySelector(overlays);
|
|
269
277
|
}
|
|
270
278
|
|
|
279
|
+
// frame-task.ts
|
|
280
|
+
function frameTask(run) {
|
|
281
|
+
let frame2;
|
|
282
|
+
let pending2;
|
|
283
|
+
const flush2 = () => {
|
|
284
|
+
if (frame2 !== void 0) cancelAnimationFrame(frame2);
|
|
285
|
+
frame2 = void 0;
|
|
286
|
+
const next = pending2;
|
|
287
|
+
pending2 = void 0;
|
|
288
|
+
if (next) run(next.value);
|
|
289
|
+
};
|
|
290
|
+
return {
|
|
291
|
+
schedule(value) {
|
|
292
|
+
pending2 = { value };
|
|
293
|
+
if (frame2 === void 0) frame2 = requestAnimationFrame(flush2);
|
|
294
|
+
},
|
|
295
|
+
flush: flush2,
|
|
296
|
+
cancel() {
|
|
297
|
+
if (frame2 !== void 0) cancelAnimationFrame(frame2);
|
|
298
|
+
frame2 = void 0;
|
|
299
|
+
pending2 = void 0;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
271
304
|
// surface.tsx
|
|
272
305
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
273
306
|
var position = (box) => ({
|
|
@@ -276,6 +309,26 @@ var position = (box) => ({
|
|
|
276
309
|
width: box.width,
|
|
277
310
|
height: box.height
|
|
278
311
|
});
|
|
312
|
+
var PaneHeader = memo(function PaneHeader2({
|
|
313
|
+
pane,
|
|
314
|
+
first,
|
|
315
|
+
last,
|
|
316
|
+
docking,
|
|
317
|
+
insertion,
|
|
318
|
+
board,
|
|
319
|
+
render
|
|
320
|
+
}) {
|
|
321
|
+
const ids = useWorkspaceIds();
|
|
322
|
+
return render(
|
|
323
|
+
pane,
|
|
324
|
+
first,
|
|
325
|
+
last,
|
|
326
|
+
{ ...docking, insertion },
|
|
327
|
+
(key2 = pane.active) => board.current?.querySelector(
|
|
328
|
+
key2 ? `#${CSS.escape(ids.panel(key2))}` : `[data-pane-sheet="${CSS.escape(pane.id)}"]:not([hidden]):not([data-drag-content])`
|
|
329
|
+
) ?? null
|
|
330
|
+
);
|
|
331
|
+
});
|
|
279
332
|
function WorkspaceSurface({
|
|
280
333
|
layout,
|
|
281
334
|
change,
|
|
@@ -296,6 +349,15 @@ function WorkspaceSurface({
|
|
|
296
349
|
const [preview, setPreview] = useState();
|
|
297
350
|
const previewRef = useRef(void 0);
|
|
298
351
|
const [resizing, setResizing] = useState(false);
|
|
352
|
+
const [resizeDraft, setResizeDraft] = useState();
|
|
353
|
+
const resizeDraftRef = useRef(void 0);
|
|
354
|
+
const displayedLayout = resizeDraft?.base === layout ? resizeDraft.layout : layout;
|
|
355
|
+
const cancelResize = () => {
|
|
356
|
+
resizePointer.cancel();
|
|
357
|
+
resizeDraftRef.current = void 0;
|
|
358
|
+
setResizeDraft(void 0);
|
|
359
|
+
setResizing(false);
|
|
360
|
+
};
|
|
299
361
|
const geometry = [
|
|
300
362
|
size.width,
|
|
301
363
|
size.height,
|
|
@@ -309,19 +371,29 @@ function WorkspaceSurface({
|
|
|
309
371
|
previousGeometry.current = geometry;
|
|
310
372
|
}, [geometry]);
|
|
311
373
|
useLayoutEffect(() => {
|
|
312
|
-
const
|
|
374
|
+
const observer2 = new ResizeObserver(([entry]) => {
|
|
313
375
|
const { width, height } = entry.contentRect;
|
|
314
376
|
setSize({ width, height });
|
|
315
377
|
});
|
|
316
|
-
|
|
317
|
-
return () =>
|
|
378
|
+
observer2.observe(board.current);
|
|
379
|
+
return () => observer2.disconnect();
|
|
318
380
|
}, []);
|
|
319
381
|
const { leaves, dividers } = layoutBoxes(
|
|
320
|
-
|
|
382
|
+
displayedLayout,
|
|
321
383
|
size.width,
|
|
322
384
|
size.height,
|
|
323
385
|
gutter2
|
|
324
|
-
), required = minimumSize(
|
|
386
|
+
), required = minimumSize(displayedLayout, gutter2);
|
|
387
|
+
const [resizePointer] = useState(
|
|
388
|
+
() => frameTask((resize) => resize())
|
|
389
|
+
);
|
|
390
|
+
useLayoutEffect(() => {
|
|
391
|
+
addEventListener("blur", cancelResize);
|
|
392
|
+
return () => {
|
|
393
|
+
resizePointer.cancel();
|
|
394
|
+
removeEventListener("blur", cancelResize);
|
|
395
|
+
};
|
|
396
|
+
}, [resizePointer]);
|
|
325
397
|
const show = (next) => {
|
|
326
398
|
if (previewRef.current?.pane === next?.pane && previewRef.current?.edge === next?.edge && previewRef.current?.index === next?.index && previewRef.current?.key === next?.key)
|
|
327
399
|
return;
|
|
@@ -412,14 +484,36 @@ function WorkspaceSurface({
|
|
|
412
484
|
}
|
|
413
485
|
};
|
|
414
486
|
const lifted = preview?.key;
|
|
487
|
+
const operations = useRef(docking);
|
|
488
|
+
useLayoutEffect(() => {
|
|
489
|
+
operations.current = docking;
|
|
490
|
+
});
|
|
491
|
+
const paneCount = leaves.length;
|
|
492
|
+
const stableDocking = useMemo2(
|
|
493
|
+
() => ({
|
|
494
|
+
paneCount,
|
|
495
|
+
move: (drag) => operations.current.move(drag),
|
|
496
|
+
drop: () => operations.current.drop(),
|
|
497
|
+
cancel: () => operations.current.cancel(),
|
|
498
|
+
split: (key2, edge) => operations.current.split(key2, edge),
|
|
499
|
+
next: (key2) => operations.current.next(key2)
|
|
500
|
+
}),
|
|
501
|
+
[paneCount]
|
|
502
|
+
);
|
|
503
|
+
const sourcePreview = useMemo2(() => {
|
|
504
|
+
if (!lifted) return;
|
|
505
|
+
const pane = panes(displayedLayout).find(
|
|
506
|
+
(pane2) => pane2.tabs.includes(lifted)
|
|
507
|
+
);
|
|
508
|
+
if (!pane) return;
|
|
509
|
+
const remaining = pane.tabs.filter((key2) => key2 !== lifted);
|
|
510
|
+
return {
|
|
511
|
+
...pane,
|
|
512
|
+
active: remaining[Math.min(pane.tabs.indexOf(lifted), remaining.length - 1)]
|
|
513
|
+
};
|
|
514
|
+
}, [displayedLayout, lifted]);
|
|
415
515
|
const regions = leaves.map(({ pane, ...box }) => {
|
|
416
|
-
if (
|
|
417
|
-
const remaining = pane.tabs.filter((key2) => key2 !== lifted);
|
|
418
|
-
pane = {
|
|
419
|
-
...pane,
|
|
420
|
-
active: remaining[Math.min(pane.tabs.indexOf(lifted), remaining.length - 1)]
|
|
421
|
-
};
|
|
422
|
-
}
|
|
516
|
+
if (sourcePreview?.id === pane.id) pane = sourcePreview;
|
|
423
517
|
if (preview?.pane !== pane.id || !preview.edge) return { pane, box };
|
|
424
518
|
const drop = dropRegion(box, preview.edge, gutter2);
|
|
425
519
|
if (preview.edge === "left")
|
|
@@ -457,17 +551,17 @@ function WorkspaceSurface({
|
|
|
457
551
|
...position({ ...box, height: tabHeight }),
|
|
458
552
|
transitionDuration: transition ? "var(--workspace-duration, 180ms)" : "0ms"
|
|
459
553
|
},
|
|
460
|
-
children:
|
|
461
|
-
|
|
462
|
-
index === 0,
|
|
463
|
-
pane.id === topRight,
|
|
554
|
+
children: /* @__PURE__ */ jsx(
|
|
555
|
+
PaneHeader,
|
|
464
556
|
{
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
557
|
+
pane,
|
|
558
|
+
first: index === 0,
|
|
559
|
+
last: pane.id === topRight,
|
|
560
|
+
docking: stableDocking,
|
|
561
|
+
insertion: preview?.pane === pane.id ? preview.index : void 0,
|
|
562
|
+
board,
|
|
563
|
+
render: header
|
|
564
|
+
}
|
|
471
565
|
)
|
|
472
566
|
},
|
|
473
567
|
pane.id
|
|
@@ -476,12 +570,19 @@ function WorkspaceSurface({
|
|
|
476
570
|
dividers.map(({ split, bounds, ratio, low, high, ...box }) => {
|
|
477
571
|
const axis = split.axis, horizontal = axis === "x", dimension = horizontal ? "width" : "height";
|
|
478
572
|
const primary = panes(split.first).filter((p) => p.active);
|
|
479
|
-
const resize = (value) =>
|
|
480
|
-
updateLayout(
|
|
573
|
+
const resize = (value, preview2 = false) => {
|
|
574
|
+
const next = updateLayout(displayedLayout, split.id, (node) => ({
|
|
481
575
|
...node,
|
|
482
576
|
ratio: Math.max(low, Math.min(high, value))
|
|
483
|
-
}))
|
|
484
|
-
|
|
577
|
+
}));
|
|
578
|
+
if (preview2) {
|
|
579
|
+
resizeDraftRef.current = { base: layout, layout: next };
|
|
580
|
+
setResizeDraft(resizeDraftRef.current);
|
|
581
|
+
} else {
|
|
582
|
+
cancelResize();
|
|
583
|
+
change(next);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
485
586
|
const target = /* @__PURE__ */ jsx(
|
|
486
587
|
"div",
|
|
487
588
|
{
|
|
@@ -512,13 +613,24 @@ function WorkspaceSurface({
|
|
|
512
613
|
onPointerMove: (event) => {
|
|
513
614
|
if (!event.currentTarget.hasPointerCapture(event.pointerId))
|
|
514
615
|
return;
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
616
|
+
const { clientX, clientY } = event;
|
|
617
|
+
resizePointer.schedule(() => {
|
|
618
|
+
const b = board.current.getBoundingClientRect();
|
|
619
|
+
const coordinate = horizontal ? clientX - b.left : clientY - b.top;
|
|
620
|
+
resize(
|
|
621
|
+
(coordinate - bounds[axis]) / (bounds[dimension] - gutter2[axis]),
|
|
622
|
+
true
|
|
623
|
+
);
|
|
624
|
+
});
|
|
625
|
+
},
|
|
626
|
+
onPointerUp: () => {
|
|
627
|
+
resizePointer.flush();
|
|
628
|
+
const draft = resizeDraftRef.current;
|
|
629
|
+
if (draft?.base === layout) change(draft.layout);
|
|
630
|
+
cancelResize();
|
|
520
631
|
},
|
|
521
|
-
|
|
632
|
+
onPointerCancel: cancelResize,
|
|
633
|
+
onLostPointerCapture: cancelResize,
|
|
522
634
|
onKeyDown: (event) => {
|
|
523
635
|
if (hasOpenOverlay()) return;
|
|
524
636
|
const step = event.shiftKey ? 0.1 : 0.02;
|
|
@@ -588,6 +700,7 @@ var ChevronRightIcon = icon(4 / 3, "m6 4 4 4-4 4");
|
|
|
588
700
|
var XIcon = icon(7 / 6, "m12 4-8 8", "m4 4 8 8");
|
|
589
701
|
|
|
590
702
|
// frame.tsx
|
|
703
|
+
import { memo as memo2 } from "react";
|
|
591
704
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
592
705
|
var reach = 16;
|
|
593
706
|
var shoulder = [
|
|
@@ -650,7 +763,7 @@ function paneShape(leftGap, rightGap, bottom, morph = true, size = densityPreset
|
|
|
650
763
|
const leftCorner = morph && leftGap < reach ? "" : ` A15.5 15.5 0 0 1 ${left + 15.5} ${baseline} H0`;
|
|
651
764
|
return `${tabShape(morph ? leftGap : reach, morph ? rightGap : reach, size)[1]}${rightCorner} V${bottom - 15.5} A15.5 15.5 0 0 1 ${right - 15.5} ${bottom} H${left + 15.5} A15.5 15.5 0 0 1 ${left} ${bottom - 15.5} V${cornerBottom}${leftCorner} Z`;
|
|
652
765
|
}
|
|
653
|
-
|
|
766
|
+
var TabSurface = memo2(function TabSurface2({
|
|
654
767
|
selected,
|
|
655
768
|
keyboardFocus = false,
|
|
656
769
|
width
|
|
@@ -686,94 +799,204 @@ function TabSurface({
|
|
|
686
799
|
]
|
|
687
800
|
}
|
|
688
801
|
);
|
|
689
|
-
}
|
|
802
|
+
});
|
|
690
803
|
|
|
691
804
|
// drag-content.ts
|
|
692
805
|
import { useEffect, useRef as useRef2 } from "react";
|
|
806
|
+
|
|
807
|
+
// geometry-task.ts
|
|
808
|
+
var pending = /* @__PURE__ */ new Set();
|
|
809
|
+
var observed = /* @__PURE__ */ new Map();
|
|
810
|
+
var animations = /* @__PURE__ */ new Map();
|
|
811
|
+
var observer;
|
|
812
|
+
var frame;
|
|
813
|
+
var microtask = false;
|
|
814
|
+
function flush() {
|
|
815
|
+
if (frame !== void 0) cancelAnimationFrame(frame);
|
|
816
|
+
frame = void 0;
|
|
817
|
+
for (const [element, animation] of animations) {
|
|
818
|
+
for (const task of observed.get(element) ?? []) pending.add(task);
|
|
819
|
+
if (!element.isConnected || animation.playState !== "running")
|
|
820
|
+
animations.delete(element);
|
|
821
|
+
}
|
|
822
|
+
const reads = [...pending];
|
|
823
|
+
pending.clear();
|
|
824
|
+
const writes = reads.map((task) => {
|
|
825
|
+
const resized = task.resized;
|
|
826
|
+
task.resized = false;
|
|
827
|
+
return task.read(resized);
|
|
828
|
+
});
|
|
829
|
+
for (const write of writes) write?.();
|
|
830
|
+
if (animations.size && frame === void 0)
|
|
831
|
+
frame = requestAnimationFrame(flush);
|
|
832
|
+
}
|
|
833
|
+
function followGeometry(element, animation) {
|
|
834
|
+
animations.set(element, animation);
|
|
835
|
+
if (frame === void 0) frame = requestAnimationFrame(flush);
|
|
836
|
+
}
|
|
837
|
+
function geometryTask(read2) {
|
|
838
|
+
const task = { read: read2, resized: false };
|
|
839
|
+
return {
|
|
840
|
+
schedule() {
|
|
841
|
+
pending.add(task);
|
|
842
|
+
if (frame === void 0) frame = requestAnimationFrame(flush);
|
|
843
|
+
},
|
|
844
|
+
// Wait for layout effects, but measure before paint.
|
|
845
|
+
commit(resized = false) {
|
|
846
|
+
task.resized ||= resized;
|
|
847
|
+
pending.add(task);
|
|
848
|
+
if (microtask) return;
|
|
849
|
+
microtask = true;
|
|
850
|
+
queueMicrotask(() => {
|
|
851
|
+
microtask = false;
|
|
852
|
+
flush();
|
|
853
|
+
});
|
|
854
|
+
},
|
|
855
|
+
flush() {
|
|
856
|
+
pending.add(task);
|
|
857
|
+
flush();
|
|
858
|
+
},
|
|
859
|
+
cancel() {
|
|
860
|
+
pending.delete(task);
|
|
861
|
+
task.resized = false;
|
|
862
|
+
if (!pending.size && !animations.size && frame !== void 0) {
|
|
863
|
+
cancelAnimationFrame(frame);
|
|
864
|
+
frame = void 0;
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
observe(elements) {
|
|
868
|
+
observer ??= new ResizeObserver((entries) => {
|
|
869
|
+
for (const { target } of entries)
|
|
870
|
+
for (const task2 of observed.get(target) ?? []) {
|
|
871
|
+
task2.resized = true;
|
|
872
|
+
pending.add(task2);
|
|
873
|
+
}
|
|
874
|
+
flush();
|
|
875
|
+
});
|
|
876
|
+
for (const element of elements) {
|
|
877
|
+
let callbacks = observed.get(element);
|
|
878
|
+
if (!callbacks) {
|
|
879
|
+
observed.set(element, callbacks = /* @__PURE__ */ new Set());
|
|
880
|
+
observer.observe(element);
|
|
881
|
+
}
|
|
882
|
+
callbacks.add(task);
|
|
883
|
+
}
|
|
884
|
+
return () => {
|
|
885
|
+
for (const element of elements) {
|
|
886
|
+
const callbacks = observed.get(element);
|
|
887
|
+
callbacks?.delete(task);
|
|
888
|
+
if (!callbacks?.size) {
|
|
889
|
+
observed.delete(element);
|
|
890
|
+
observer?.unobserve(element);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
if (!observed.size) {
|
|
894
|
+
observer?.disconnect();
|
|
895
|
+
observer = void 0;
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// drag-content.ts
|
|
693
903
|
function useDragContent() {
|
|
694
904
|
const generation = useRef2(0);
|
|
695
905
|
const current = useRef2(void 0);
|
|
696
|
-
const
|
|
906
|
+
const prepareRelease = (animate = true) => {
|
|
697
907
|
const preview = current.current;
|
|
698
908
|
if (!preview) return;
|
|
699
|
-
current.current = void 0;
|
|
700
|
-
const version = ++generation.current;
|
|
701
909
|
const { element, inert } = preview;
|
|
702
910
|
const from = element.getBoundingClientRect();
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
element.
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
return;
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
911
|
+
return () => {
|
|
912
|
+
current.current = void 0;
|
|
913
|
+
const version = ++generation.current;
|
|
914
|
+
element.removeAttribute("data-drag-content");
|
|
915
|
+
element.inert = inert;
|
|
916
|
+
element.style.transition = "none";
|
|
917
|
+
element.style.removeProperty("transform");
|
|
918
|
+
for (const name of ["width", "height"])
|
|
919
|
+
element.style.removeProperty(`--lab-drag-${name}`);
|
|
920
|
+
requestAnimationFrame(() => {
|
|
921
|
+
if (version !== generation.current) return;
|
|
922
|
+
const to = element.getBoundingClientRect();
|
|
923
|
+
element.style.removeProperty("transition");
|
|
924
|
+
if (!animate || !element.isConnected || !to.width || matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
925
|
+
return;
|
|
926
|
+
const resized = Math.abs(from.width - to.width) > 0.5 || Math.abs(from.height - to.height) > 0.5;
|
|
927
|
+
const animation = element.animate(
|
|
928
|
+
[
|
|
929
|
+
{
|
|
930
|
+
transform: `translate(${from.left - to.left}px, ${from.top - to.top}px)`,
|
|
931
|
+
width: `${from.width}px`,
|
|
932
|
+
height: `${from.height}px`,
|
|
933
|
+
filter: "blur(0)",
|
|
934
|
+
opacity: 1
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
filter: resized ? "blur(3px)" : "blur(0)",
|
|
938
|
+
opacity: resized ? 0.85 : 1,
|
|
939
|
+
offset: 0.35
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
transform: "none",
|
|
943
|
+
width: `${to.width}px`,
|
|
944
|
+
height: `${to.height}px`,
|
|
945
|
+
filter: "blur(0)",
|
|
946
|
+
opacity: 1
|
|
947
|
+
}
|
|
948
|
+
],
|
|
949
|
+
{ duration: 220, easing: "cubic-bezier(.2,.8,.2,1)" }
|
|
950
|
+
);
|
|
951
|
+
followGeometry(element, animation);
|
|
952
|
+
});
|
|
953
|
+
};
|
|
740
954
|
};
|
|
955
|
+
const release = (animate = true) => prepareRelease(animate)?.();
|
|
741
956
|
useEffect(() => () => release(false), []);
|
|
742
957
|
return {
|
|
743
958
|
release,
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
)
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
959
|
+
prepareRelease,
|
|
960
|
+
prepareLift(element, tab, fallback) {
|
|
961
|
+
if (current.current?.element === element)
|
|
962
|
+
return { ...current.current, apply: () => {
|
|
963
|
+
} };
|
|
964
|
+
const releasePrevious = prepareRelease(false);
|
|
965
|
+
const animations2 = element.getAnimations();
|
|
966
|
+
const bounds = element.hidden ? fallback : element.getBoundingClientRect();
|
|
967
|
+
const preview = {
|
|
968
|
+
element,
|
|
969
|
+
width: bounds.width,
|
|
970
|
+
height: bounds.height,
|
|
971
|
+
offset: Math.max(
|
|
972
|
+
8,
|
|
973
|
+
Math.min(
|
|
974
|
+
tab.getBoundingClientRect().left - bounds.left,
|
|
975
|
+
bounds.width - tab.offsetWidth - 8
|
|
976
|
+
)
|
|
977
|
+
),
|
|
978
|
+
inert: element.inert
|
|
979
|
+
};
|
|
980
|
+
return {
|
|
981
|
+
...preview,
|
|
982
|
+
apply: () => {
|
|
983
|
+
releasePrevious?.();
|
|
984
|
+
generation.current++;
|
|
985
|
+
animations2.forEach((animation) => animation.cancel());
|
|
986
|
+
current.current = preview;
|
|
987
|
+
for (const [name, value] of Object.entries({
|
|
988
|
+
width: `${bounds.width}px`,
|
|
989
|
+
height: `${bounds.height}px`
|
|
990
|
+
}))
|
|
991
|
+
element.style.setProperty(`--lab-drag-${name}`, String(value));
|
|
992
|
+
element.inert = true;
|
|
993
|
+
element.setAttribute("data-drag-content", "");
|
|
994
|
+
}
|
|
995
|
+
};
|
|
772
996
|
},
|
|
773
997
|
move(x, y) {
|
|
774
998
|
const element = current.current?.element;
|
|
775
|
-
element?.style.setProperty("
|
|
776
|
-
element?.style.setProperty("--lab-drag-y", `${y}px`);
|
|
999
|
+
element?.style.setProperty("transform", `translate3d(${x}px, ${y}px, 0)`);
|
|
777
1000
|
}
|
|
778
1001
|
};
|
|
779
1002
|
}
|
|
@@ -781,8 +1004,11 @@ function useDragContent() {
|
|
|
781
1004
|
// tabs.tsx
|
|
782
1005
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
783
1006
|
var motion = { duration: 160, easing: "cubic-bezier(.2,.8,.2,1)" };
|
|
1007
|
+
var pathData = (path, value) => {
|
|
1008
|
+
if (path.getAttribute("d") !== value) path.setAttribute("d", value);
|
|
1009
|
+
};
|
|
784
1010
|
function WorkspaceTabs({
|
|
785
|
-
items,
|
|
1011
|
+
items: sourceItems,
|
|
786
1012
|
active,
|
|
787
1013
|
onClose,
|
|
788
1014
|
onDuplicate,
|
|
@@ -793,25 +1019,25 @@ function WorkspaceTabs({
|
|
|
793
1019
|
docking,
|
|
794
1020
|
menu
|
|
795
1021
|
}) {
|
|
1022
|
+
const [draftOrder, setDraftOrder] = React.useState();
|
|
1023
|
+
const itemOrder = new Map(draftOrder?.map((key2, index) => [key2, index]));
|
|
1024
|
+
const items = draftOrder ? sourceItems.slice().sort(
|
|
1025
|
+
(a, b) => (itemOrder.get(a.key) ?? Infinity) - (itemOrder.get(b.key) ?? Infinity)
|
|
1026
|
+
) : sourceItems;
|
|
796
1027
|
const ids = useWorkspaceIds();
|
|
797
1028
|
const tabLinks = useTabLinks();
|
|
798
1029
|
const content = useDragContent();
|
|
799
1030
|
const density = useTabSize();
|
|
800
1031
|
const [metrics, setMetrics] = React.useState({
|
|
801
|
-
|
|
1032
|
+
width: density.width,
|
|
802
1033
|
overflow: false,
|
|
803
1034
|
left: false,
|
|
804
1035
|
right: false
|
|
805
1036
|
});
|
|
806
1037
|
const measured = React.useRef(metrics);
|
|
807
|
-
const { available } = metrics;
|
|
808
1038
|
const size = {
|
|
809
1039
|
...density,
|
|
810
|
-
width:
|
|
811
|
-
density.width,
|
|
812
|
-
available,
|
|
813
|
-
items.length + (docking.insertion === void 0 ? 0 : 1)
|
|
814
|
-
)
|
|
1040
|
+
width: metrics.width
|
|
815
1041
|
}, { width: tabWidth, height, contentHeight } = size, width = tabWidth + 16;
|
|
816
1042
|
const links = items.map(({ key: key2, label }) => [key2, label]);
|
|
817
1043
|
const tabOrder = JSON.stringify(items.map(({ key: key2 }) => key2));
|
|
@@ -839,97 +1065,125 @@ function WorkspaceTabs({
|
|
|
839
1065
|
maskedOutline.current = null;
|
|
840
1066
|
};
|
|
841
1067
|
const settling = React.useRef(void 0);
|
|
1068
|
+
const animations2 = React.useRef(/* @__PURE__ */ new Map());
|
|
1069
|
+
const transitions = React.useRef(/* @__PURE__ */ new Map());
|
|
842
1070
|
const positions = React.useRef({
|
|
843
1071
|
order: "",
|
|
844
1072
|
tabs: /* @__PURE__ */ new Map()
|
|
845
1073
|
});
|
|
846
|
-
const frame = React.useRef(0);
|
|
847
1074
|
const suppressClick = React.useRef(false);
|
|
848
|
-
const tabElement = (key2) =>
|
|
849
|
-
|
|
850
|
-
)?.parentElement;
|
|
851
|
-
const reveal = (key2 = active) => {
|
|
1075
|
+
const tabElement = (key2) => tabLinks.get(key2)?.parentElement;
|
|
1076
|
+
const readReveal = (key2 = active) => {
|
|
852
1077
|
const nav = navRef.current, tab = tabElement(key2);
|
|
853
1078
|
if (!nav || !tab || drag.current?.moved || docking.insertion !== void 0)
|
|
854
1079
|
return;
|
|
855
|
-
|
|
1080
|
+
const left = Math.max(
|
|
856
1081
|
tab.offsetLeft + tab.offsetWidth + 8 - nav.clientWidth,
|
|
857
1082
|
Math.min(nav.scrollLeft, tab.offsetLeft - 8)
|
|
858
1083
|
);
|
|
1084
|
+
if (left === nav.scrollLeft) return;
|
|
1085
|
+
return {
|
|
1086
|
+
delta: left - nav.scrollLeft,
|
|
1087
|
+
apply: () => {
|
|
1088
|
+
nav.scrollLeft = left;
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
859
1091
|
};
|
|
860
|
-
const
|
|
861
|
-
|
|
862
|
-
|
|
1092
|
+
const reveal = (key2 = active) => readReveal(key2)?.apply();
|
|
1093
|
+
const readDrawing = (scrollDelta = 0) => {
|
|
1094
|
+
const current = drag.current, ghost2 = ghostRef.current, nav = navRef.current, bounds = dragBoundary?.getBoundingClientRect(), floating = !!ghost2 && !!current?.detached, tab = (floating ? null : ghost2) ?? tabElement(active), frame2 = frameRef.current, sheet = surface(), sheetBox = sheet?.getBoundingClientRect(), navBox = nav?.getBoundingClientRect(), origin = frame2?.parentElement?.getBoundingClientRect();
|
|
1095
|
+
let box = tab && (tab !== ghost2 || !current?.moved) ? tab.getBoundingClientRect() : void 0;
|
|
1096
|
+
if (box && tab !== ghost2 && scrollDelta)
|
|
1097
|
+
box = new DOMRect(box.x - scrollDelta, box.y, box.width, box.height);
|
|
1098
|
+
const lift = ghost2 && current?.moved && floating ? (() => {
|
|
863
1099
|
const sheet2 = surface(current.key);
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
Math.
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
ghost2.style.top = `${y}px`;
|
|
876
|
-
if (preview) {
|
|
877
|
-
content.move(x2 - preview.offset, y + height - 1);
|
|
878
|
-
const left3 = preview.offset - 8, right3 = preview.width - preview.offset - tabWidth - 8;
|
|
879
|
-
ghost2.querySelector("svg > path").setAttribute("d", tabShape(left3, right3, size)[0]);
|
|
880
|
-
const outline = ghost2.querySelector("[data-tab-outline]");
|
|
881
|
-
outline.style.visibility = "visible";
|
|
882
|
-
outline.setAttribute(
|
|
883
|
-
"d",
|
|
884
|
-
paneShape(left3, right3, height + preview.height - 1.5, true, size)
|
|
1100
|
+
return sheet2 ? content.prepareLift(sheet2, ghost2, current.sheet) : void 0;
|
|
1101
|
+
})() : void 0;
|
|
1102
|
+
const release = ghost2 && current?.moved && !lift ? content.prepareRelease() : void 0;
|
|
1103
|
+
return () => {
|
|
1104
|
+
if (ghost2 && current?.moved && bounds) {
|
|
1105
|
+
const preview = lift;
|
|
1106
|
+
preview?.apply();
|
|
1107
|
+
const left2 = floating ? 8 : bounds.left + 8, right2 = floating ? innerWidth - 8 : bounds.right - 8;
|
|
1108
|
+
const x2 = Math.max(
|
|
1109
|
+
left2,
|
|
1110
|
+
Math.min(current.x - current.offset, right2 - tabWidth)
|
|
885
1111
|
);
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
1112
|
+
const y = floating ? Math.max(
|
|
1113
|
+
0,
|
|
1114
|
+
Math.min(current.y - current.offsetY, innerHeight - height - 8)
|
|
1115
|
+
) : navBox.top;
|
|
1116
|
+
if (tab === ghost2) box = new DOMRect(x2, y, tabWidth, height);
|
|
1117
|
+
ghost2.style.translate = `${x2}px ${y}px`;
|
|
1118
|
+
if (preview) {
|
|
1119
|
+
content.move(x2 - preview.offset, y + height - 1);
|
|
1120
|
+
const left3 = preview.offset - 8, right3 = preview.width - preview.offset - tabWidth - 8;
|
|
1121
|
+
pathData(
|
|
1122
|
+
ghost2.querySelector("svg > path"),
|
|
1123
|
+
tabShape(left3, right3, size)[0]
|
|
1124
|
+
);
|
|
1125
|
+
const outline = ghost2.querySelector("[data-tab-outline]");
|
|
1126
|
+
outline.style.visibility = "visible";
|
|
1127
|
+
pathData(
|
|
1128
|
+
outline,
|
|
1129
|
+
paneShape(left3, right3, height + preview.height - 1.5, true, size)
|
|
1130
|
+
);
|
|
1131
|
+
} else release?.();
|
|
1132
|
+
}
|
|
1133
|
+
if (!tab || !box || !bounds || !frame2) {
|
|
1134
|
+
restoreFrame();
|
|
1135
|
+
if (frame2) frame2.style.visibility = "hidden";
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
const attached = Math.abs(box.top - bounds.top) < 0.5 && !!sheet;
|
|
1139
|
+
const left = attached ? box.left - 8 - sheetBox.left : 16, right = attached ? sheetBox.right - box.right - 8 : 16;
|
|
1140
|
+
if (ghost2 && !floating) {
|
|
1141
|
+
const [fill, outline] = tabShape(
|
|
1142
|
+
Math.max(0, left),
|
|
1143
|
+
Math.max(0, right),
|
|
1144
|
+
size
|
|
1145
|
+
);
|
|
1146
|
+
pathData(ghost2.querySelector("svg > path"), fill);
|
|
1147
|
+
pathData(ghost2.querySelector("[data-tab-outline]"), outline);
|
|
1148
|
+
}
|
|
1149
|
+
const stroke = tab.querySelector("[data-tab-outline]");
|
|
1150
|
+
if (maskedOutline.current !== stroke)
|
|
1151
|
+
maskedOutline.current?.style.removeProperty("visibility");
|
|
1152
|
+
stroke.style.visibility = attached ? "hidden" : "visible";
|
|
1153
|
+
maskedOutline.current = stroke;
|
|
1154
|
+
frame2.style.visibility = attached ? "visible" : "hidden";
|
|
1155
|
+
if (maskedSheet.current !== (attached ? sheet : null))
|
|
1156
|
+
maskedSheet.current?.style.removeProperty("border-color");
|
|
1157
|
+
maskedSheet.current = attached ? sheet : null;
|
|
1158
|
+
if (!attached) return;
|
|
1159
|
+
sheet.style.borderColor = "transparent";
|
|
1160
|
+
maskedSheet.current = sheet;
|
|
1161
|
+
const x = box.left - 8, bottom = sheetBox.bottom - box.top - 0.5;
|
|
1162
|
+
frame2.style.left = `${x - origin.left}px`;
|
|
1163
|
+
frame2.style.top = `${box.top - origin.top}px`;
|
|
1164
|
+
const viewport = ghost2 && !floating ? sheetBox : navBox, clipLeft = Math.max(-left, viewport.left - x), clipRight = Math.min(width + right, viewport.right - x);
|
|
1165
|
+
frame2.style.clipPath = `polygon(${clipLeft}px 0px, ${clipRight}px 0px, ${clipRight}px ${height - 1}px, ${width + right}px ${height - 1}px, ${width + right}px ${bottom + 1}px, ${-left}px ${bottom + 1}px, ${-left}px ${height - 1}px, ${clipLeft}px ${height - 1}px)`;
|
|
1166
|
+
pathData(
|
|
1167
|
+
frame2.querySelector("path"),
|
|
1168
|
+
paneShape(left, right, bottom, !!ghost2 && !floating, size) + ((!ghost2 || floating) && clipLeft > 0 ? ` M0 ${height - 0.5} H${Math.min(width, clipLeft)}` : "") + ((!ghost2 || floating) && clipRight < width ? ` M${Math.max(0, clipRight)} ${height - 0.5} H${width}` : "")
|
|
902
1169
|
);
|
|
903
|
-
|
|
904
|
-
ghost2.querySelector("[data-tab-outline]").setAttribute("d", outline);
|
|
905
|
-
}
|
|
906
|
-
const stroke = tab.querySelector("[data-tab-outline]");
|
|
907
|
-
stroke.style.visibility = attached ? "hidden" : "visible";
|
|
908
|
-
maskedOutline.current = stroke;
|
|
909
|
-
frame2.style.visibility = attached ? "visible" : "hidden";
|
|
910
|
-
if (!attached) return;
|
|
911
|
-
sheet.style.borderColor = "transparent";
|
|
912
|
-
maskedSheet.current = sheet;
|
|
913
|
-
const x = box.left - 8, bottom = sheetBox.bottom - box.top - 0.5;
|
|
914
|
-
const origin = frame2.parentElement.getBoundingClientRect();
|
|
915
|
-
frame2.style.left = `${x - origin.left}px`;
|
|
916
|
-
frame2.style.top = `${box.top - origin.top}px`;
|
|
917
|
-
const viewport = ghost2 && !floating ? sheetBox : nav.getBoundingClientRect(), clipLeft = Math.max(-left, viewport.left - x), clipRight = Math.min(width + right, viewport.right - x);
|
|
918
|
-
frame2.style.clipPath = `polygon(${clipLeft}px 0px, ${clipRight}px 0px, ${clipRight}px ${height - 1}px, ${width + right}px ${height - 1}px, ${width + right}px ${bottom + 1}px, ${-left}px ${bottom + 1}px, ${-left}px ${height - 1}px, ${clipLeft}px ${height - 1}px)`;
|
|
919
|
-
frame2.querySelector("path").setAttribute(
|
|
920
|
-
"d",
|
|
921
|
-
paneShape(left, right, bottom, !!ghost2 && !floating, size) + ((!ghost2 || floating) && clipLeft > 0 ? ` M0 ${height - 0.5} H${Math.min(width, clipLeft)}` : "") + ((!ghost2 || floating) && clipRight < width ? ` M${Math.max(0, clipRight)} ${height - 0.5} H${width}` : "")
|
|
922
|
-
);
|
|
1170
|
+
};
|
|
923
1171
|
};
|
|
924
1172
|
const animate = (element, from) => {
|
|
925
|
-
|
|
926
|
-
if (
|
|
927
|
-
|
|
928
|
-
if (!matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
929
|
-
element.animate(
|
|
1173
|
+
animations2.current.get(element)?.cancel();
|
|
1174
|
+
if (!matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
1175
|
+
const animation = element.animate(
|
|
930
1176
|
[{ transform: `translateX(${from}px)` }, { transform: "none" }],
|
|
931
1177
|
motion
|
|
932
1178
|
);
|
|
1179
|
+
animations2.current.set(element, animation);
|
|
1180
|
+
const remove = () => {
|
|
1181
|
+
if (animations2.current.get(element) === animation)
|
|
1182
|
+
animations2.current.delete(element);
|
|
1183
|
+
};
|
|
1184
|
+
animation.onfinish = remove;
|
|
1185
|
+
animation.oncancel = remove;
|
|
1186
|
+
}
|
|
933
1187
|
};
|
|
934
1188
|
const settle = (key2) => requestAnimationFrame(() => {
|
|
935
1189
|
if (drag.current) return;
|
|
@@ -953,25 +1207,34 @@ function WorkspaceTabs({
|
|
|
953
1207
|
latest.current.refresh();
|
|
954
1208
|
});
|
|
955
1209
|
const finish = (cancel = false) => {
|
|
1210
|
+
if (cancel) pointer.current.cancel();
|
|
1211
|
+
else pointer.current.flush();
|
|
956
1212
|
const current = drag.current;
|
|
957
1213
|
if (!current) return;
|
|
958
1214
|
drag.current = void 0;
|
|
1215
|
+
pointer.current.cancel();
|
|
959
1216
|
suppressClick.current = current.moved;
|
|
960
1217
|
content.release();
|
|
961
1218
|
if (cancel) {
|
|
962
1219
|
docking.cancel();
|
|
963
|
-
if (current.moved) onReorder(current.order);
|
|
964
1220
|
announce("");
|
|
965
1221
|
}
|
|
966
|
-
|
|
1222
|
+
const dropped = !cancel && current.moved && docking.drop();
|
|
1223
|
+
if (!cancel && !dropped && current.previewOrder)
|
|
1224
|
+
onReorder(current.previewOrder);
|
|
1225
|
+
setDraftOrder(void 0);
|
|
1226
|
+
if (current.moved && !dropped) settle(current.key);
|
|
967
1227
|
else setDragging(void 0);
|
|
968
1228
|
};
|
|
969
|
-
const move = (from, to) => {
|
|
1229
|
+
const move = (from, to, preview = false) => {
|
|
970
1230
|
const order = links.map(([key2]) => key2), index = order.indexOf(to);
|
|
971
1231
|
if (from === to || index < 0) return;
|
|
972
1232
|
order.splice(order.indexOf(from), 1);
|
|
973
1233
|
order.splice(index, 0, from);
|
|
974
|
-
|
|
1234
|
+
if (preview && drag.current) {
|
|
1235
|
+
drag.current.previewOrder = order;
|
|
1236
|
+
setDraftOrder(order);
|
|
1237
|
+
} else onReorder(order);
|
|
975
1238
|
announce(`${labels.get(from)}: position ${index + 1} of ${order.length}`);
|
|
976
1239
|
};
|
|
977
1240
|
const split = (key2, edge) => {
|
|
@@ -1010,63 +1273,121 @@ function WorkspaceTabs({
|
|
|
1010
1273
|
}
|
|
1011
1274
|
event.preventDefault();
|
|
1012
1275
|
};
|
|
1013
|
-
const
|
|
1276
|
+
const readMetrics = () => {
|
|
1014
1277
|
const nav = navRef.current, strip = stripRef.current;
|
|
1015
1278
|
if (!nav || !strip || !dragBoundary) return;
|
|
1016
|
-
const
|
|
1279
|
+
const toolbarStyle = getComputedStyle(dragBoundary);
|
|
1280
|
+
const gap = parseFloat(toolbarStyle.columnGap) || 0;
|
|
1281
|
+
let trailing = parseFloat(toolbarStyle.paddingRight) || 0;
|
|
1282
|
+
for (let element = strip.parentElement.nextElementSibling; element; element = element.nextElementSibling)
|
|
1283
|
+
trailing += element.getBoundingClientRect().width + gap;
|
|
1017
1284
|
const availableWidth = Math.max(
|
|
1018
1285
|
0,
|
|
1019
|
-
dragBoundary.getBoundingClientRect().right - strip.getBoundingClientRect().left - trailing
|
|
1286
|
+
dragBoundary.getBoundingClientRect().right - strip.getBoundingClientRect().left - trailing
|
|
1020
1287
|
);
|
|
1021
1288
|
const inserting = docking.insertion === void 0 ? 0 : 1;
|
|
1022
1289
|
const count = items.length - (drag.current?.detached ? 1 : 0) + inserting;
|
|
1290
|
+
const fittedWidth = fitTabWidth(
|
|
1291
|
+
density.width,
|
|
1292
|
+
availableWidth,
|
|
1293
|
+
items.length + inserting
|
|
1294
|
+
);
|
|
1023
1295
|
const next = {
|
|
1024
|
-
|
|
1025
|
-
overflow: count *
|
|
1296
|
+
width: fittedWidth,
|
|
1297
|
+
overflow: count * fittedWidth + 16 > availableWidth + 1,
|
|
1026
1298
|
left: nav.scrollLeft > 1,
|
|
1027
1299
|
right: nav.scrollLeft + nav.clientWidth < nav.scrollWidth - 1
|
|
1028
1300
|
};
|
|
1029
1301
|
const current = measured.current;
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1302
|
+
return () => {
|
|
1303
|
+
if (next.width !== current.width || next.overflow !== current.overflow || next.left !== current.left || next.right !== current.right) {
|
|
1304
|
+
measured.current = next;
|
|
1305
|
+
setMetrics(next);
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1034
1308
|
};
|
|
1035
|
-
const
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
)
|
|
1040
|
-
|
|
1309
|
+
const runningAnimations = () => {
|
|
1310
|
+
for (const target of transitions.current.keys())
|
|
1311
|
+
if (target instanceof Node && !target.isConnected)
|
|
1312
|
+
transitions.current.delete(target);
|
|
1313
|
+
return transitions.current.size > 0 || settling.current?.playState === "running" || [...animations2.current.values()].some(
|
|
1314
|
+
(animation) => animation.playState === "running"
|
|
1315
|
+
);
|
|
1041
1316
|
};
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
draw();
|
|
1047
|
-
|
|
1317
|
+
const readFrame = (resized = false) => {
|
|
1318
|
+
const metrics2 = readMetrics();
|
|
1319
|
+
const scroll = resized ? readReveal() : void 0;
|
|
1320
|
+
const follow = runningAnimations();
|
|
1321
|
+
const draw = readDrawing(scroll?.delta);
|
|
1322
|
+
return () => {
|
|
1323
|
+
metrics2?.();
|
|
1324
|
+
scroll?.apply();
|
|
1325
|
+
draw();
|
|
1326
|
+
if (follow) geometry.schedule();
|
|
1327
|
+
};
|
|
1328
|
+
};
|
|
1329
|
+
const refresh = (resized = false) => geometry.commit(resized);
|
|
1330
|
+
const movePointer = () => {
|
|
1331
|
+
const current = drag.current, nav = navRef.current;
|
|
1332
|
+
if (!current?.moved || !nav) return;
|
|
1333
|
+
current.detached = docking.move(current);
|
|
1334
|
+
if (!current.detached) {
|
|
1335
|
+
const { left, right } = nav.getBoundingClientRect();
|
|
1336
|
+
const scroll = current.x < left + 24 ? -16 : current.x > right - 24 ? 16 : 0;
|
|
1337
|
+
const before = nav.scrollLeft;
|
|
1338
|
+
if (scroll) nav.scrollLeft += scroll;
|
|
1339
|
+
const index = Math.max(
|
|
1340
|
+
0,
|
|
1341
|
+
Math.min(
|
|
1342
|
+
items.length - 1,
|
|
1343
|
+
Math.floor(
|
|
1344
|
+
(Math.max(left + 8, Math.min(current.x, right - 8)) - left + nav.scrollLeft - 8) / tabWidth
|
|
1345
|
+
)
|
|
1346
|
+
)
|
|
1347
|
+
);
|
|
1348
|
+
move(current.key, items[index].key, true);
|
|
1349
|
+
if (scroll && before !== nav.scrollLeft)
|
|
1350
|
+
pointer.current.schedule(void 0);
|
|
1351
|
+
}
|
|
1352
|
+
geometry.flush();
|
|
1048
1353
|
};
|
|
1049
|
-
const latest = React.useRef({ refresh, finish });
|
|
1354
|
+
const latest = React.useRef({ refresh, finish, movePointer, readFrame });
|
|
1355
|
+
const [geometry] = React.useState(
|
|
1356
|
+
() => geometryTask((resized) => latest.current.readFrame(resized))
|
|
1357
|
+
);
|
|
1358
|
+
const pointer = React.useRef(
|
|
1359
|
+
void 0
|
|
1360
|
+
);
|
|
1361
|
+
if (!pointer.current)
|
|
1362
|
+
pointer.current = frameTask(() => latest.current.movePointer());
|
|
1050
1363
|
const detached = !!dragging && !!drag.current?.detached;
|
|
1051
1364
|
React.useLayoutEffect(() => {
|
|
1052
|
-
latest.current = { refresh, finish };
|
|
1365
|
+
latest.current = { refresh, finish, movePointer, readFrame };
|
|
1366
|
+
});
|
|
1367
|
+
React.useLayoutEffect(() => {
|
|
1053
1368
|
const order = JSON.stringify([tabOrder, docking.insertion]);
|
|
1054
1369
|
const previous = positions.current;
|
|
1055
1370
|
positions.current = { order, tabs: /* @__PURE__ */ new Map() };
|
|
1056
|
-
|
|
1057
|
-
const
|
|
1058
|
-
if (!key2) continue;
|
|
1371
|
+
const slots = items.map(({ key: key2 }) => {
|
|
1372
|
+
const element = tabElement(key2);
|
|
1059
1373
|
const left = element.offsetLeft, from = previous.tabs.get(key2);
|
|
1060
|
-
|
|
1061
|
-
|
|
1374
|
+
const displaced = previous.order !== order && key2 !== dragging && from !== void 0 && from !== left;
|
|
1375
|
+
const transform = displaced ? getComputedStyle(element).transform : "none";
|
|
1376
|
+
const offset = transform === "none" ? 0 : new DOMMatrixReadOnly(transform).m41;
|
|
1377
|
+
return {
|
|
1378
|
+
key: key2,
|
|
1379
|
+
element,
|
|
1380
|
+
left,
|
|
1381
|
+
delta: displaced ? from - left + offset : 0
|
|
1382
|
+
};
|
|
1383
|
+
});
|
|
1384
|
+
for (const { key: key2, element, left, delta } of slots) {
|
|
1385
|
+
if (delta) animate(element, delta);
|
|
1062
1386
|
positions.current.tabs.set(key2, left);
|
|
1063
1387
|
}
|
|
1064
|
-
|
|
1065
|
-
draw();
|
|
1066
|
-
follow();
|
|
1067
|
-
});
|
|
1388
|
+
}, [tabOrder, docking.insertion, tabWidth, dragging, detached]);
|
|
1068
1389
|
React.useLayoutEffect(
|
|
1069
|
-
() => refresh(),
|
|
1390
|
+
() => refresh(true),
|
|
1070
1391
|
// oxlint-disable-next-line react-hooks/exhaustive-deps -- the inputs refresh measures
|
|
1071
1392
|
[
|
|
1072
1393
|
dragBoundary,
|
|
@@ -1074,43 +1395,84 @@ function WorkspaceTabs({
|
|
|
1074
1395
|
tabOrder,
|
|
1075
1396
|
docking.insertion,
|
|
1076
1397
|
tabWidth,
|
|
1398
|
+
density.width,
|
|
1077
1399
|
height,
|
|
1078
1400
|
metrics.overflow,
|
|
1079
1401
|
dragging,
|
|
1080
1402
|
detached
|
|
1081
1403
|
]
|
|
1082
1404
|
);
|
|
1083
|
-
React.useLayoutEffect(() => reveal(), [active, tabOrder, docking.insertion]);
|
|
1084
1405
|
React.useLayoutEffect(() => {
|
|
1085
1406
|
const nav = navRef.current;
|
|
1086
|
-
const
|
|
1407
|
+
const board = dragBoundary?.closest(".lab-board");
|
|
1408
|
+
const trackedTransitions = transitions.current;
|
|
1409
|
+
const transition = (event) => {
|
|
1410
|
+
const target = event.target;
|
|
1411
|
+
const name = event.propertyName;
|
|
1412
|
+
if ([
|
|
1413
|
+
"color",
|
|
1414
|
+
"background-color",
|
|
1415
|
+
"fill",
|
|
1416
|
+
"stroke",
|
|
1417
|
+
"opacity",
|
|
1418
|
+
"filter",
|
|
1419
|
+
"box-shadow"
|
|
1420
|
+
].includes(name))
|
|
1421
|
+
return;
|
|
1422
|
+
if (event.type === "transitionrun") {
|
|
1423
|
+
if (target !== surface() && !(target instanceof Node && dragBoundary?.contains(target)))
|
|
1424
|
+
return;
|
|
1425
|
+
const properties = transitions.current.get(target) ?? /* @__PURE__ */ new Set();
|
|
1426
|
+
properties.add(name);
|
|
1427
|
+
transitions.current.set(target, properties);
|
|
1428
|
+
geometry.schedule();
|
|
1429
|
+
} else {
|
|
1430
|
+
const properties = transitions.current.get(target);
|
|
1431
|
+
properties?.delete(name);
|
|
1432
|
+
if (!properties?.size) transitions.current.delete(target);
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
for (const name of ["transitionrun", "transitionend", "transitioncancel"])
|
|
1436
|
+
board?.addEventListener(name, transition);
|
|
1437
|
+
const scroll = () => latest.current.refresh(), blur = () => latest.current.finish(true);
|
|
1087
1438
|
const wheel = (event) => {
|
|
1088
1439
|
if (event.ctrlKey || Math.abs(event.deltaX) >= Math.abs(event.deltaY) || nav.scrollWidth <= nav.clientWidth)
|
|
1089
1440
|
return;
|
|
1090
1441
|
event.preventDefault();
|
|
1091
1442
|
nav.scrollLeft += event.deltaY * (event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? nav.clientWidth : 1);
|
|
1092
1443
|
};
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1444
|
+
const unobserve = geometry.observe(
|
|
1445
|
+
[
|
|
1446
|
+
nav,
|
|
1447
|
+
stripRef.current,
|
|
1448
|
+
dragBoundary,
|
|
1449
|
+
...dragBoundary?.children ?? [],
|
|
1450
|
+
surface()
|
|
1451
|
+
].filter((element) => !!element)
|
|
1452
|
+
);
|
|
1102
1453
|
addEventListener("scroll", scroll, true);
|
|
1103
1454
|
addEventListener("blur", blur);
|
|
1104
1455
|
nav.addEventListener("wheel", wheel, { passive: false });
|
|
1105
1456
|
return () => {
|
|
1106
|
-
|
|
1457
|
+
for (const name of ["transitionrun", "transitionend", "transitioncancel"])
|
|
1458
|
+
board?.removeEventListener(name, transition);
|
|
1459
|
+
trackedTransitions.clear();
|
|
1460
|
+
unobserve();
|
|
1107
1461
|
removeEventListener("scroll", scroll, true);
|
|
1108
1462
|
removeEventListener("blur", blur);
|
|
1109
1463
|
nav.removeEventListener("wheel", wheel);
|
|
1110
|
-
|
|
1464
|
+
geometry.cancel();
|
|
1111
1465
|
restoreFrame();
|
|
1112
1466
|
};
|
|
1113
1467
|
}, [active, dragBoundary]);
|
|
1468
|
+
React.useEffect(
|
|
1469
|
+
() => () => {
|
|
1470
|
+
pointer.current.cancel();
|
|
1471
|
+
settling.current?.cancel();
|
|
1472
|
+
for (const animation of animations2.current.values()) animation.cancel();
|
|
1473
|
+
},
|
|
1474
|
+
[]
|
|
1475
|
+
);
|
|
1114
1476
|
const scrollButton = (direction) => metrics.overflow && /* @__PURE__ */ jsx4(
|
|
1115
1477
|
"button",
|
|
1116
1478
|
{
|
|
@@ -1142,6 +1504,8 @@ function WorkspaceTabs({
|
|
|
1142
1504
|
onKeyDownCapture: () => setPointerFocus(false),
|
|
1143
1505
|
onBlurCapture: () => setPointerFocus(false),
|
|
1144
1506
|
onPointerDownCapture: () => {
|
|
1507
|
+
pointer.current.cancel();
|
|
1508
|
+
setDraftOrder(void 0);
|
|
1145
1509
|
content.release(false);
|
|
1146
1510
|
settling.current?.cancel();
|
|
1147
1511
|
setDragging(void 0);
|
|
@@ -1162,36 +1526,24 @@ function WorkspaceTabs({
|
|
|
1162
1526
|
if (!current.moved && Math.hypot(x - current.x, event.clientY - current.y) < 6)
|
|
1163
1527
|
return;
|
|
1164
1528
|
if (!current.moved && active !== current.key) onSelect(current.key);
|
|
1529
|
+
if (!current.moved) setDragging(current.key);
|
|
1165
1530
|
current.moved = true;
|
|
1166
1531
|
if (!nav.hasPointerCapture(event.pointerId))
|
|
1167
1532
|
nav.setPointerCapture(event.pointerId);
|
|
1168
|
-
setDragging(current.key);
|
|
1169
1533
|
event.preventDefault();
|
|
1170
1534
|
current.x = x;
|
|
1171
1535
|
current.y = event.clientY;
|
|
1172
|
-
current.
|
|
1173
|
-
if (!current.detached) {
|
|
1174
|
-
const { left, right } = nav.getBoundingClientRect();
|
|
1175
|
-
nav.scrollLeft += x < left + 24 ? -16 : x > right - 24 ? 16 : 0;
|
|
1176
|
-
const index = Math.max(
|
|
1177
|
-
0,
|
|
1178
|
-
Math.min(
|
|
1179
|
-
items.length - 1,
|
|
1180
|
-
Math.floor(
|
|
1181
|
-
(Math.max(left + 8, Math.min(x, right - 8)) - left + nav.scrollLeft - 8) / tabWidth
|
|
1182
|
-
)
|
|
1183
|
-
)
|
|
1184
|
-
);
|
|
1185
|
-
move(current.key, items[index].key);
|
|
1186
|
-
}
|
|
1187
|
-
refresh();
|
|
1536
|
+
pointer.current.schedule(void 0);
|
|
1188
1537
|
},
|
|
1189
1538
|
onPointerUp: () => finish(),
|
|
1190
1539
|
onPointerCancel: () => finish(true),
|
|
1540
|
+
onLostPointerCapture: (event) => {
|
|
1541
|
+
if (event.target === event.currentTarget) finish(true);
|
|
1542
|
+
},
|
|
1191
1543
|
className: "lab-tablist",
|
|
1192
1544
|
children: [
|
|
1193
1545
|
links.map(([key2, text], index) => {
|
|
1194
|
-
const actions = [
|
|
1546
|
+
const actions = menu ? [
|
|
1195
1547
|
...onDuplicate ? [
|
|
1196
1548
|
{
|
|
1197
1549
|
label: "Duplicate tab",
|
|
@@ -1223,7 +1575,7 @@ function WorkspaceTabs({
|
|
|
1223
1575
|
})),
|
|
1224
1576
|
null,
|
|
1225
1577
|
{ label: "Close tab", onSelect: () => onClose(key2) }
|
|
1226
|
-
];
|
|
1578
|
+
] : [];
|
|
1227
1579
|
const target = /* @__PURE__ */ jsxs3(
|
|
1228
1580
|
"div",
|
|
1229
1581
|
{
|
|
@@ -1283,8 +1635,7 @@ function WorkspaceTabs({
|
|
|
1283
1635
|
x: event.clientX,
|
|
1284
1636
|
y: event.clientY,
|
|
1285
1637
|
detached: false,
|
|
1286
|
-
moved: false
|
|
1287
|
-
order: links.map(([path]) => path)
|
|
1638
|
+
moved: false
|
|
1288
1639
|
};
|
|
1289
1640
|
},
|
|
1290
1641
|
className: "lab-tab-link",
|
|
@@ -1565,7 +1916,7 @@ function useTabHistories(tabs) {
|
|
|
1565
1916
|
}
|
|
1566
1917
|
|
|
1567
1918
|
// browser-history.ts
|
|
1568
|
-
import { useEffect as
|
|
1919
|
+
import { useEffect as useEffect4, useLayoutEffect as useLayoutEffect7, useRef as useRef8 } from "react";
|
|
1569
1920
|
var read = (state) => state?.labpane;
|
|
1570
1921
|
function createBrowserHistory(front) {
|
|
1571
1922
|
const session = Date.now();
|
|
@@ -1642,7 +1993,7 @@ function useBrowserHistory(front) {
|
|
|
1642
1993
|
const browser = useRef8(
|
|
1643
1994
|
void 0
|
|
1644
1995
|
);
|
|
1645
|
-
|
|
1996
|
+
useEffect4(() => {
|
|
1646
1997
|
if (!front) return;
|
|
1647
1998
|
const { sync, pop } = browser.current ??= createBrowserHistory(
|
|
1648
1999
|
() => latest.current?.get()
|
|
@@ -1685,6 +2036,10 @@ function WorkspaceContent({
|
|
|
1685
2036
|
empty
|
|
1686
2037
|
}) {
|
|
1687
2038
|
const links = useTabLinks();
|
|
2039
|
+
const tabsByKey = useMemo3(
|
|
2040
|
+
() => new Map(tabs.map((tab) => [tab.key, tab])),
|
|
2041
|
+
[tabs]
|
|
2042
|
+
);
|
|
1688
2043
|
const { height, contentHeight, logoSize } = useTabSize();
|
|
1689
2044
|
const corner2 = useRef9(null);
|
|
1690
2045
|
const [reserve, setReserve] = useState5(0);
|
|
@@ -1692,9 +2047,9 @@ function WorkspaceContent({
|
|
|
1692
2047
|
useLayoutEffect8(() => {
|
|
1693
2048
|
const element = corner2.current;
|
|
1694
2049
|
if (!element) return setReserve(0);
|
|
1695
|
-
const
|
|
1696
|
-
|
|
1697
|
-
return () =>
|
|
2050
|
+
const observer2 = new ResizeObserver(() => setReserve(element.offsetWidth));
|
|
2051
|
+
observer2.observe(element);
|
|
2052
|
+
return () => observer2.disconnect();
|
|
1698
2053
|
}, [hasTrailing]);
|
|
1699
2054
|
const root = useRef9(null);
|
|
1700
2055
|
const [inset, setInset] = useState5(0);
|
|
@@ -1718,10 +2073,10 @@ function WorkspaceContent({
|
|
|
1718
2073
|
const front = active ?? panes(visibleLayout)[0]?.active;
|
|
1719
2074
|
const openers = useOpeners(tabs, front);
|
|
1720
2075
|
const historyOf = useTabHistories(tabs);
|
|
1721
|
-
const frontTab =
|
|
2076
|
+
const frontTab = tabsByKey.get(front ?? "");
|
|
1722
2077
|
useBrowserHistory(history2 && frontTab ? historyOf(frontTab) : void 0);
|
|
1723
2078
|
const dirty = useRef9(/* @__PURE__ */ new Map());
|
|
1724
|
-
|
|
2079
|
+
useEffect5(() => {
|
|
1725
2080
|
const warn = (event) => {
|
|
1726
2081
|
if (dirty.current.size) event.preventDefault();
|
|
1727
2082
|
};
|
|
@@ -1732,7 +2087,7 @@ function WorkspaceContent({
|
|
|
1732
2087
|
const pane = panes(visibleLayout).find((p) => p.tabs.includes(key2));
|
|
1733
2088
|
if (!pane) return;
|
|
1734
2089
|
const remaining = pane.tabs.filter((k) => k !== key2);
|
|
1735
|
-
const opener =
|
|
2090
|
+
const opener = tabsByKey.get(key2)?.opener;
|
|
1736
2091
|
const neighbor = next ?? remaining.find((key3) => key3 === opener) ?? remaining[Math.min(pane.tabs.indexOf(key2), remaining.length - 1)] ?? tabs.find((t) => t.key !== key2)?.key;
|
|
1737
2092
|
onClose(key2, neighbor);
|
|
1738
2093
|
requestAnimationFrame(
|
|
@@ -1745,7 +2100,7 @@ function WorkspaceContent({
|
|
|
1745
2100
|
}
|
|
1746
2101
|
function requestClose(key2, next) {
|
|
1747
2102
|
if (![...dirty.current.values()].includes(key2)) return close(key2, next);
|
|
1748
|
-
const tab =
|
|
2103
|
+
const tab = tabsByKey.get(key2);
|
|
1749
2104
|
const element = links.get(key2);
|
|
1750
2105
|
Promise.resolve(
|
|
1751
2106
|
confirmClose ? confirmClose(tab) : confirm(`Discard changes in ${tab.label}?`)
|
|
@@ -1755,12 +2110,13 @@ function WorkspaceContent({
|
|
|
1755
2110
|
});
|
|
1756
2111
|
}
|
|
1757
2112
|
function leave(key2) {
|
|
1758
|
-
const opener = openers.get(key2) ??
|
|
1759
|
-
requestClose(
|
|
1760
|
-
key2,
|
|
1761
|
-
tabs.some((tab) => tab.key === opener) ? opener : void 0
|
|
1762
|
-
);
|
|
2113
|
+
const opener = openers.get(key2) ?? tabsByKey.get(key2)?.opener;
|
|
2114
|
+
requestClose(key2, tabsByKey.has(opener ?? "") ? opener : void 0);
|
|
1763
2115
|
}
|
|
2116
|
+
const services = useRef9(leave);
|
|
2117
|
+
useLayoutEffect8(() => {
|
|
2118
|
+
services.current = leave;
|
|
2119
|
+
});
|
|
1764
2120
|
const paneOf = (pane) => ({
|
|
1765
2121
|
id: pane.id,
|
|
1766
2122
|
tabs: pane.tabs,
|
|
@@ -1818,7 +2174,7 @@ function WorkspaceContent({
|
|
|
1818
2174
|
},
|
|
1819
2175
|
docking,
|
|
1820
2176
|
surface,
|
|
1821
|
-
items: pane.tabs.map((key2) =>
|
|
2177
|
+
items: pane.tabs.map((key2) => tabsByKey.get(key2)),
|
|
1822
2178
|
active: pane.active,
|
|
1823
2179
|
onSelect,
|
|
1824
2180
|
onDuplicate: onDuplicate ? (key2) => {
|
|
@@ -1864,19 +2220,17 @@ function WorkspaceContent({
|
|
|
1864
2220
|
if (active !== tab.key) onSelect(tab.key);
|
|
1865
2221
|
},
|
|
1866
2222
|
children: /* @__PURE__ */ jsx6(
|
|
1867
|
-
|
|
2223
|
+
TabBody,
|
|
1868
2224
|
{
|
|
2225
|
+
tab,
|
|
2226
|
+
pane: region.pane,
|
|
2227
|
+
focus: links.focus,
|
|
1869
2228
|
active: tab.key === front,
|
|
1870
2229
|
visible: !hidden,
|
|
1871
|
-
leave: () => leave(tab.key),
|
|
1872
2230
|
history: historyOf(tab),
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
value: (source, changed) => changed ? dirty.current.set(source, tab.key) : dirty.current.delete(source),
|
|
1877
|
-
children: children(tab, paneOf(region.pane))
|
|
1878
|
-
}
|
|
1879
|
-
)
|
|
2231
|
+
services,
|
|
2232
|
+
dirty: dirty.current,
|
|
2233
|
+
render: children
|
|
1880
2234
|
}
|
|
1881
2235
|
)
|
|
1882
2236
|
},
|
|
@@ -1900,16 +2254,39 @@ function WorkspaceContent({
|
|
|
1900
2254
|
}
|
|
1901
2255
|
) });
|
|
1902
2256
|
}
|
|
1903
|
-
function
|
|
2257
|
+
var TabBody = memo3(function TabBody2({
|
|
2258
|
+
tab,
|
|
2259
|
+
pane,
|
|
2260
|
+
focus,
|
|
1904
2261
|
active,
|
|
1905
2262
|
visible,
|
|
1906
|
-
leave,
|
|
1907
2263
|
history: history2,
|
|
1908
|
-
|
|
2264
|
+
services,
|
|
2265
|
+
dirty,
|
|
2266
|
+
render
|
|
1909
2267
|
}) {
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1912
|
-
|
|
2268
|
+
const key2 = tab.key;
|
|
2269
|
+
const [leave] = useState5(() => () => services.current(key2));
|
|
2270
|
+
const report = useCallback2(
|
|
2271
|
+
(source, changed) => {
|
|
2272
|
+
if (changed) dirty.set(source, key2);
|
|
2273
|
+
else dirty.delete(source);
|
|
2274
|
+
},
|
|
2275
|
+
[dirty, key2]
|
|
2276
|
+
);
|
|
2277
|
+
const requested = useMemo3(
|
|
2278
|
+
() => ({ render, tab, pane, focus }),
|
|
2279
|
+
[render, tab, pane, focus]
|
|
2280
|
+
);
|
|
2281
|
+
const deferred = useDeferredValue(requested);
|
|
2282
|
+
const inputs = visible ? requested : deferred;
|
|
2283
|
+
const content = useMemo3(
|
|
2284
|
+
() => inputs.render(inputs.tab, { ...inputs.pane, focus: inputs.focus }),
|
|
2285
|
+
[inputs]
|
|
2286
|
+
);
|
|
2287
|
+
const state = useMemo3(() => ({ active, visible }), [active, visible]);
|
|
2288
|
+
return /* @__PURE__ */ jsx6(TabStateContext.Provider, { value: state, children: /* @__PURE__ */ jsx6(LeaveTab.Provider, { value: leave, children: /* @__PURE__ */ jsx6(TabHistoryContext.Provider, { value: history2, children: /* @__PURE__ */ jsx6(UnsavedChanges.Provider, { value: report, children: content }) }) }) });
|
|
2289
|
+
});
|
|
1913
2290
|
function TabPanel({
|
|
1914
2291
|
tab,
|
|
1915
2292
|
hidden,
|
|
@@ -1986,14 +2363,14 @@ function WorkspaceFrame({
|
|
|
1986
2363
|
setDraft(void 0);
|
|
1987
2364
|
};
|
|
1988
2365
|
useLayoutEffect9(() => {
|
|
1989
|
-
const
|
|
2366
|
+
const observer2 = new ResizeObserver(() => {
|
|
1990
2367
|
setAvailable(viewport.current.clientWidth);
|
|
1991
2368
|
cancel();
|
|
1992
2369
|
});
|
|
1993
|
-
|
|
2370
|
+
observer2.observe(viewport.current);
|
|
1994
2371
|
addEventListener("blur", cancel);
|
|
1995
2372
|
return () => {
|
|
1996
|
-
|
|
2373
|
+
observer2.disconnect();
|
|
1997
2374
|
removeEventListener("blur", cancel);
|
|
1998
2375
|
};
|
|
1999
2376
|
}, []);
|
|
@@ -2072,7 +2449,7 @@ function WorkspaceFrame({
|
|
|
2072
2449
|
|
|
2073
2450
|
// window.tsx
|
|
2074
2451
|
import {
|
|
2075
|
-
useEffect as
|
|
2452
|
+
useEffect as useEffect6,
|
|
2076
2453
|
useLayoutEffect as useLayoutEffect10,
|
|
2077
2454
|
useRef as useRef11,
|
|
2078
2455
|
useState as useState7
|
|
@@ -2090,7 +2467,7 @@ var interactive = "a, button, input, select, textarea, label, summary, [contente
|
|
|
2090
2467
|
var draggable = (target) => target instanceof Element && !target.closest(interactive) && (!!target.closest(".lab-toolbar, [data-window-drag]") || target.matches(".lab-workspace") || !!target.querySelector(".lab-workspace"));
|
|
2091
2468
|
function useFullscreen(host) {
|
|
2092
2469
|
const [full, setFull] = useState7(() => isFullscreen(host));
|
|
2093
|
-
|
|
2470
|
+
useEffect6(() => {
|
|
2094
2471
|
const update = () => setFull(isFullscreen(host));
|
|
2095
2472
|
update();
|
|
2096
2473
|
window.addEventListener("resize", update);
|
|
@@ -2103,7 +2480,7 @@ function useFullscreen(host) {
|
|
|
2103
2480
|
return [full, (on) => setFullscreen(host, on)];
|
|
2104
2481
|
}
|
|
2105
2482
|
function useWindowFrame(host) {
|
|
2106
|
-
|
|
2483
|
+
useEffect6(() => {
|
|
2107
2484
|
if (!host) return;
|
|
2108
2485
|
const root = document.documentElement;
|
|
2109
2486
|
let armed = false;
|
|
@@ -2189,9 +2566,9 @@ function TrafficLights({ host }) {
|
|
|
2189
2566
|
element.style.width = `${end - element.getBoundingClientRect().left - gap}px`;
|
|
2190
2567
|
};
|
|
2191
2568
|
place();
|
|
2192
|
-
const
|
|
2193
|
-
|
|
2194
|
-
return () =>
|
|
2569
|
+
const observer2 = new ResizeObserver(place);
|
|
2570
|
+
observer2.observe(toolbar);
|
|
2571
|
+
return () => observer2.disconnect();
|
|
2195
2572
|
}, [host, shown]);
|
|
2196
2573
|
return shown ? /* @__PURE__ */ jsx8("div", { ref: spacer, className: "lab-traffic-lights" }) : null;
|
|
2197
2574
|
}
|
|
@@ -2213,7 +2590,7 @@ function WindowControls({ host }) {
|
|
|
2213
2590
|
if (spacer.current) setTop(spacer.current.getBoundingClientRect().top);
|
|
2214
2591
|
};
|
|
2215
2592
|
useLayoutEffect10(measure);
|
|
2216
|
-
|
|
2593
|
+
useEffect6(() => {
|
|
2217
2594
|
window.addEventListener("resize", measure);
|
|
2218
2595
|
return () => window.removeEventListener("resize", measure);
|
|
2219
2596
|
}, []);
|