@mintplayer/web-components 2.13.0 → 2.14.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/chunks/{mp-splitter-LszuRDbR.mjs → mp-splitter-Ckn1kN4v.mjs} +33 -19
- package/dock/index.mjs +841 -830
- package/dock/src/components/mint-dock-manager.element.d.ts +6 -34
- package/dock/src/core/geometry.d.ts +36 -0
- package/dock/src/core/index.d.ts +5 -0
- package/dock/src/core/layout-tree.d.ts +84 -0
- package/dock/src/core/resize.d.ts +83 -0
- package/dock/src/core/sizes.d.ts +31 -0
- package/dock/src/core/types.d.ts +44 -0
- package/file-manager/index.mjs +1 -1
- package/navbar/index.mjs +71 -44
- package/navbar/src/components/mp-navbar.d.ts +17 -1
- package/package.json +1 -1
- package/ribbon/index.mjs +7 -3
- package/ribbon/src/mp-quick-access-toolbar.element.d.ts +11 -0
- package/splitter/index.mjs +1 -1
- package/splitter/src/state/splitter-state.d.ts +9 -0
package/dock/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { html as
|
|
1
|
+
import { html as W, unsafeCSS as U, LitElement as G } from "lit";
|
|
2
2
|
import "../chunks/mp-tab-page-CaCzX1ym.mjs";
|
|
3
|
-
import "../chunks/mp-splitter-
|
|
4
|
-
import { L as
|
|
5
|
-
import { F as
|
|
6
|
-
const
|
|
3
|
+
import "../chunks/mp-splitter-Ckn1kN4v.mjs";
|
|
4
|
+
import { L as V } from "../chunks/live-announcer-Bi0orG4n.mjs";
|
|
5
|
+
import { F as Q } from "../chunks/focus-restore-DxuP1Oe2.mjs";
|
|
6
|
+
const tt = W`<div class="dock-root">
|
|
7
7
|
<div class="dock-docked"></div>
|
|
8
8
|
<div class="dock-floating-layer"></div>
|
|
9
9
|
<div class="dock-intersections-layer dock-intersection-layer"></div>
|
|
@@ -54,7 +54,7 @@ const I = D`<div class="dock-root">
|
|
|
54
54
|
↓
|
|
55
55
|
</button>
|
|
56
56
|
<div class="dock-drop-joystick__spacer"></div>
|
|
57
|
-
</div>`,
|
|
57
|
+
</div>`, et = U(`:host {
|
|
58
58
|
display: block;
|
|
59
59
|
position: relative;
|
|
60
60
|
width: 100%;
|
|
@@ -427,21 +427,221 @@ const I = D`<div class="dock-root">
|
|
|
427
427
|
animation: none !important;
|
|
428
428
|
}
|
|
429
429
|
}`);
|
|
430
|
-
|
|
430
|
+
function R(a, t) {
|
|
431
|
+
if (t.width <= 0 || t.height <= 0) return a;
|
|
432
|
+
const e = Math.min(a.width, t.width), i = Math.min(a.height, t.height), n = Math.min(Math.max(a.left, 0), t.width - e), o = Math.min(Math.max(a.top, 0), t.height - i);
|
|
433
|
+
return { left: n, top: o, width: e, height: i };
|
|
434
|
+
}
|
|
435
|
+
function J(a, t, e) {
|
|
436
|
+
return t >= a.left && t <= a.right && e >= a.top && e <= a.bottom;
|
|
437
|
+
}
|
|
438
|
+
function N(a, t) {
|
|
439
|
+
return a && typeof a.zIndex == "number" && Number.isFinite(a.zIndex) ? a.zIndex : 10 + t;
|
|
440
|
+
}
|
|
441
|
+
function x(a, t) {
|
|
442
|
+
if (t <= 0)
|
|
443
|
+
return [];
|
|
444
|
+
if (!Array.isArray(a) || a.length !== t)
|
|
445
|
+
return Array.from({ length: t }, () => 1 / t);
|
|
446
|
+
const e = a.map((n) => Number.isFinite(n) ? Math.max(n, 0) : 0), i = e.reduce((n, o) => n + o, 0);
|
|
447
|
+
return i <= 0 ? Array.from({ length: t }, () => 1 / t) : e.map((n) => n / i);
|
|
448
|
+
}
|
|
449
|
+
function it(a) {
|
|
450
|
+
a.sizes = x(a.sizes, a.children.length);
|
|
451
|
+
}
|
|
452
|
+
function nt(a, t, e) {
|
|
453
|
+
const i = e - 1, n = x(a, i), o = 1 / e, r = 1 - o, d = [];
|
|
454
|
+
for (let s = 0; s < e; s += 1)
|
|
455
|
+
if (s === t)
|
|
456
|
+
d.push(o);
|
|
457
|
+
else {
|
|
458
|
+
const c = s < t ? s : s - 1;
|
|
459
|
+
d.push(n[c] * r);
|
|
460
|
+
}
|
|
461
|
+
return d;
|
|
462
|
+
}
|
|
463
|
+
function T(a, t) {
|
|
464
|
+
if (!a)
|
|
465
|
+
return null;
|
|
466
|
+
let e = a;
|
|
467
|
+
if (t.length === 0)
|
|
468
|
+
return e;
|
|
469
|
+
for (const i of t) {
|
|
470
|
+
if (!e || e.kind !== "split")
|
|
471
|
+
return null;
|
|
472
|
+
e = e.children[i] ?? null;
|
|
473
|
+
}
|
|
474
|
+
return e;
|
|
475
|
+
}
|
|
476
|
+
function B(a, t) {
|
|
477
|
+
if (!a || a === t || a.kind !== "split")
|
|
478
|
+
return null;
|
|
479
|
+
const e = a.children.indexOf(t);
|
|
480
|
+
if (e !== -1)
|
|
481
|
+
return { parent: a, index: e };
|
|
482
|
+
for (let i = 0; i < a.children.length; i += 1) {
|
|
483
|
+
const n = B(a.children[i], t);
|
|
484
|
+
if (n)
|
|
485
|
+
return n;
|
|
486
|
+
}
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
function ot(a, t, e) {
|
|
490
|
+
if (!a || a === t)
|
|
491
|
+
return e;
|
|
492
|
+
const i = B(a, t);
|
|
493
|
+
return i && (i.parent.children[i.index] = e, it(i.parent)), a;
|
|
494
|
+
}
|
|
495
|
+
function A(a, t, e, i) {
|
|
496
|
+
const n = i === "left" || i === "right" ? "horizontal" : "vertical", o = i === "left" || i === "top", r = B(a, t);
|
|
497
|
+
if (r && r.parent.direction === n) {
|
|
498
|
+
const s = o ? r.index : r.index + 1;
|
|
499
|
+
return r.parent.children.splice(s, 0, e), r.parent.sizes = nt(
|
|
500
|
+
r.parent.sizes,
|
|
501
|
+
s,
|
|
502
|
+
r.parent.children.length
|
|
503
|
+
), a ?? e;
|
|
504
|
+
}
|
|
505
|
+
return ot(a, t, {
|
|
506
|
+
kind: "split",
|
|
507
|
+
direction: n,
|
|
508
|
+
children: o ? [e, t] : [t, e],
|
|
509
|
+
sizes: [0.5, 0.5]
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
function M(a, t, e = []) {
|
|
513
|
+
if (a) {
|
|
514
|
+
if (a.kind === "stack") {
|
|
515
|
+
t(a, e);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
a.children.forEach((i, n) => M(i, t, [...e, n]));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function E(a) {
|
|
522
|
+
let t = null;
|
|
523
|
+
return M(a, (e) => {
|
|
524
|
+
t || e.panes.length === 0 || (e.activePane && e.panes.includes(e.activePane) ? t = e.activePane : t = e.panes[0]);
|
|
525
|
+
}), t;
|
|
526
|
+
}
|
|
527
|
+
function I(a) {
|
|
528
|
+
const t = [];
|
|
529
|
+
return M(a, (e) => {
|
|
530
|
+
e.panes.forEach((i) => t.push(i));
|
|
531
|
+
}), t;
|
|
532
|
+
}
|
|
533
|
+
function rt(a, t) {
|
|
534
|
+
return a.panes = a.panes.filter((e) => e !== t), a.panes.includes(a.activePane ?? "") || (a.panes.length > 0 ? a.activePane = a.panes[0] : delete a.activePane), a.panes.length === 0;
|
|
535
|
+
}
|
|
536
|
+
function H(a) {
|
|
537
|
+
if (!a) return null;
|
|
538
|
+
if (a.kind === "stack")
|
|
539
|
+
return a.panes.length === 0 ? null : ((!a.activePane || !a.panes.includes(a.activePane)) && (a.activePane = a.panes[0]), a);
|
|
540
|
+
const t = x(a.sizes, a.children.length), e = a.children.map((i, n) => ({ child: H(i), slot: t[n] })).filter((i) => i.child !== null).flatMap(({ child: i, slot: n }) => {
|
|
541
|
+
if (i.kind === "split" && i.direction === a.direction) {
|
|
542
|
+
const o = x(i.sizes, i.children.length);
|
|
543
|
+
return i.children.map((r, d) => ({
|
|
544
|
+
child: r,
|
|
545
|
+
slot: n * o[d]
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
return [{ child: i, slot: n }];
|
|
549
|
+
});
|
|
550
|
+
return e.length === 0 ? null : e.length === 1 ? e[0].child : (a.children = e.map((i) => i.child), a.sizes = x(
|
|
551
|
+
e.map((i) => i.slot),
|
|
552
|
+
e.length
|
|
553
|
+
), a);
|
|
554
|
+
}
|
|
555
|
+
function _(a) {
|
|
556
|
+
return a ? JSON.parse(JSON.stringify(a)) : null;
|
|
557
|
+
}
|
|
558
|
+
const st = 192, at = 128;
|
|
559
|
+
function X(a, t) {
|
|
560
|
+
return t > 0 ? Math.min(a, t) : a;
|
|
561
|
+
}
|
|
562
|
+
function Y(a, t, e, i) {
|
|
563
|
+
const n = X(st, i.width), o = X(at, i.height);
|
|
564
|
+
let r = a.width, d = a.height, s = a.left, c = a.top;
|
|
565
|
+
return t.horizontal === "right" ? (r = Math.max(n, a.width + e.x), i.width > 0 && (r = Math.min(r, i.width - a.left))) : t.horizontal === "left" && (r = Math.max(n, a.width - e.x), r = Math.min(r, a.left + a.width), s = a.left + a.width - r), t.vertical === "bottom" ? (d = Math.max(o, a.height + e.y), i.height > 0 && (d = Math.min(d, i.height - a.top))) : t.vertical === "top" && (d = Math.max(o, a.height - e.y), d = Math.min(d, a.top + a.height), c = a.top + a.height - d), { left: s, top: c, width: r, height: d };
|
|
566
|
+
}
|
|
567
|
+
const C = [1 / 3, 1 / 2, 2 / 3];
|
|
568
|
+
function lt(a, t) {
|
|
569
|
+
if (t <= 0) return a;
|
|
570
|
+
const e = a / t;
|
|
571
|
+
let i = C[0], n = Math.abs(e - i);
|
|
572
|
+
for (let o = 1; o < C.length; o += 1) {
|
|
573
|
+
const r = Math.abs(e - C[o]);
|
|
574
|
+
r < n && (n = r, i = C[o]);
|
|
575
|
+
}
|
|
576
|
+
return i * t;
|
|
577
|
+
}
|
|
578
|
+
function j(a, t, e) {
|
|
579
|
+
let i = a, n = e + 1;
|
|
580
|
+
for (const o of t) {
|
|
581
|
+
const r = Math.abs(o - a);
|
|
582
|
+
r < n && (n = r, i = o);
|
|
583
|
+
}
|
|
584
|
+
return n <= e ? i : a;
|
|
585
|
+
}
|
|
586
|
+
function ct(a, t, e, i, n = !1) {
|
|
587
|
+
const o = a + t;
|
|
588
|
+
let r = Math.min(Math.max(a + e, i), o - i);
|
|
589
|
+
return n && (r = lt(r, o)), { before: r, after: o - r };
|
|
590
|
+
}
|
|
591
|
+
function dt(a, t, e, i = 12) {
|
|
592
|
+
for (let n = 0; n < a.length; n += 1) {
|
|
593
|
+
const r = (e !== null ? a[n] >= e : !1) ? a[n] + i : a[n];
|
|
594
|
+
if (t < r)
|
|
595
|
+
return n;
|
|
596
|
+
}
|
|
597
|
+
return a.length;
|
|
598
|
+
}
|
|
599
|
+
function w(a) {
|
|
600
|
+
if (a.type === "floating") {
|
|
601
|
+
const e = a.segments.length > 0 ? `/${a.segments.map((i) => i.toString()).join("/")}` : "";
|
|
602
|
+
return `f:${a.index}${e}`;
|
|
603
|
+
}
|
|
604
|
+
const t = a.segments.join("/");
|
|
605
|
+
return t.length > 0 ? `d:${t}` : "d:";
|
|
606
|
+
}
|
|
607
|
+
function S(a) {
|
|
608
|
+
if (a == null)
|
|
609
|
+
return null;
|
|
610
|
+
if (a.startsWith("f:")) {
|
|
611
|
+
const i = a.slice(2), [n, ...o] = i.split("/"), r = Number.parseInt(n, 10);
|
|
612
|
+
if (!Number.isFinite(r))
|
|
613
|
+
return null;
|
|
614
|
+
const d = o.filter((s) => s.length > 0).map((s) => Number.parseInt(s, 10)).filter((s) => Number.isFinite(s));
|
|
615
|
+
return { type: "floating", index: r, segments: d };
|
|
616
|
+
}
|
|
617
|
+
const t = a.startsWith("d:") ? a.slice(2) : a;
|
|
618
|
+
return t.length === 0 ? { type: "docked", segments: [] } : { type: "docked", segments: t.split("/").filter((i) => i.length > 0).map((i) => Number.parseInt(i, 10)).filter((i) => Number.isFinite(i)) };
|
|
619
|
+
}
|
|
620
|
+
function O(a, t) {
|
|
621
|
+
if (a.type !== t.type)
|
|
622
|
+
return !1;
|
|
623
|
+
if (a.type === "floating") {
|
|
624
|
+
const i = t;
|
|
625
|
+
return a.index !== i.index || a.segments.length !== i.segments.length ? !1 : a.segments.every((n, o) => n === i.segments[o]);
|
|
626
|
+
}
|
|
627
|
+
const e = t;
|
|
628
|
+
return a.segments.length !== e.segments.length ? !1 : a.segments.every((i, n) => i === e.segments[n]);
|
|
629
|
+
}
|
|
630
|
+
class L extends G {
|
|
431
631
|
constructor() {
|
|
432
|
-
super(), this.liveAnnouncer = new
|
|
632
|
+
super(), this.liveAnnouncer = new V(this), this.paneMoveMode = null, this.paneMoveCandidateIndex = null, this.dropJoystickTarget = null, this.rootLayout = null, this.floatingLayouts = [], this.titles = {}, this.pendingTabDragMetrics = null, this.dragState = null, this.floatingDragState = null, this.floatingResizeState = null, this.intersectionRaf = null, this.rootResizeObserver = null, this.dockedMutationObserver = null, this.cornerResizeState = null, this.pointerTrackingActive = !1, this.dragPointerTrackingActive = !1, this.lastDragPointerPosition = null, this.cornerSnapXTargets = [], this.cornerSnapYTargets = [], this.showSnapMarkers = !1, this.debugLayoutIntegrity = !1, this.pendingDragEndTimeout = null, this.previousSplitSizes = /* @__PURE__ */ new Map(), this.layoutFocusRestore = new Q(() => this.shadowRoot, {
|
|
433
633
|
selector: ".dock-intersection-handle[data-key], mp-tab-control, .dock-tab[data-tab-id]",
|
|
434
634
|
keyOf: (t) => t.dataset.key ?? t.dataset.tabId ?? (t.id || null)
|
|
435
|
-
}), this.instanceId = `mint-dock-${++
|
|
635
|
+
}), this.instanceId = `mint-dock-${++L.instanceCounter}`, this.windowRef = typeof window < "u" ? window : null, this.onPointerMove = this.onPointerMove.bind(this), this.onPointerUp = this.onPointerUp.bind(this), this.onPointerCancel = this.onPointerCancel.bind(this), this.onDragPointerMove = this.onDragPointerMove.bind(this), this.onDragPointerUp = this.onDragPointerUp.bind(this), this.onDragPointerCancel = this.onDragPointerCancel.bind(this), this.onSplitterResize = this.onSplitterResize.bind(this);
|
|
436
636
|
}
|
|
437
637
|
static {
|
|
438
|
-
this.styles = [
|
|
638
|
+
this.styles = [et];
|
|
439
639
|
}
|
|
440
640
|
static {
|
|
441
641
|
this.documentRef = typeof document < "u" ? document : null;
|
|
442
642
|
}
|
|
443
643
|
static configureDocument(t) {
|
|
444
|
-
t && (
|
|
644
|
+
t && (L.documentRef = t);
|
|
445
645
|
}
|
|
446
646
|
static get observedAttributes() {
|
|
447
647
|
return [...super.observedAttributes ?? [], "layout", "debug-layout-integrity"];
|
|
@@ -466,22 +666,22 @@ class P extends A {
|
|
|
466
666
|
const t = this.shadowRoot?.querySelector(".dock-intersections-layer, .dock-intersection-layer");
|
|
467
667
|
if (!t || (Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((r) => r.remove()), !this.cornerResizeState)) return;
|
|
468
668
|
const e = this.rootEl.getBoundingClientRect();
|
|
469
|
-
let i = null,
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
const r =
|
|
473
|
-
|
|
669
|
+
let i = null, n = null;
|
|
670
|
+
const o = this.cornerResizeState;
|
|
671
|
+
if (o.vs.length > 0) {
|
|
672
|
+
const r = o.vs[0], s = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
|
|
673
|
+
s && (i = s.left + s.width / 2 - e.left);
|
|
474
674
|
}
|
|
475
|
-
if (
|
|
476
|
-
const r =
|
|
477
|
-
|
|
675
|
+
if (o.hs.length > 0) {
|
|
676
|
+
const r = o.hs[0], s = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
|
|
677
|
+
s && (n = s.top + s.height / 2 - e.top);
|
|
478
678
|
}
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
|
|
679
|
+
n != null && this.cornerSnapXTargets.forEach((r) => {
|
|
680
|
+
const d = this.documentRef.createElement("div");
|
|
681
|
+
d.className = "dock-snap-marker", d.style.left = `${r}px`, d.style.top = `${n}px`, t.appendChild(d);
|
|
482
682
|
}), i != null && this.cornerSnapYTargets.forEach((r) => {
|
|
483
|
-
const
|
|
484
|
-
|
|
683
|
+
const d = this.documentRef.createElement("div");
|
|
684
|
+
d.className = "dock-snap-marker", d.style.left = `${i}px`, d.style.top = `${r}px`, t.appendChild(d);
|
|
485
685
|
});
|
|
486
686
|
}
|
|
487
687
|
clearSnapMarkers() {
|
|
@@ -490,7 +690,7 @@ class P extends A {
|
|
|
490
690
|
t && Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((e) => e.remove());
|
|
491
691
|
}
|
|
492
692
|
render() {
|
|
493
|
-
return
|
|
693
|
+
return W`${tt}${this.liveAnnouncer.template()}`;
|
|
494
694
|
}
|
|
495
695
|
firstUpdated() {
|
|
496
696
|
const t = this.resolveDocument();
|
|
@@ -498,24 +698,24 @@ class P extends A {
|
|
|
498
698
|
const e = this.shadowRoot, i = e.querySelector(".dock-root");
|
|
499
699
|
if (!i)
|
|
500
700
|
throw new Error("mint-dock-manager template is missing the root element.");
|
|
501
|
-
const
|
|
502
|
-
if (!o)
|
|
503
|
-
throw new Error("mint-dock-manager template is missing the docked surface element.");
|
|
504
|
-
const n = e.querySelector(".dock-floating-layer");
|
|
701
|
+
const n = e.querySelector(".dock-docked");
|
|
505
702
|
if (!n)
|
|
703
|
+
throw new Error("mint-dock-manager template is missing the docked surface element.");
|
|
704
|
+
const o = e.querySelector(".dock-floating-layer");
|
|
705
|
+
if (!o)
|
|
506
706
|
throw new Error("mint-dock-manager template is missing the floating layer element.");
|
|
507
707
|
const r = e.querySelector(".dock-drop-indicator");
|
|
508
708
|
if (!r)
|
|
509
709
|
throw new Error("mint-dock-manager template is missing the drop indicator element.");
|
|
510
|
-
const
|
|
511
|
-
if (!
|
|
710
|
+
const d = e.querySelector(".dock-drop-joystick");
|
|
711
|
+
if (!d)
|
|
512
712
|
throw new Error("mint-dock-manager template is missing the drop joystick element.");
|
|
513
|
-
const
|
|
514
|
-
|
|
713
|
+
const s = Array.from(
|
|
714
|
+
d.querySelectorAll(".dock-drop-joystick__button[data-zone]")
|
|
515
715
|
);
|
|
516
|
-
if (
|
|
716
|
+
if (s.length === 0)
|
|
517
717
|
throw new Error("mint-dock-manager template is missing drop joystick buttons.");
|
|
518
|
-
this.rootEl = i, this.dockedEl =
|
|
718
|
+
this.rootEl = i, this.dockedEl = n, this.floatingLayerEl = o, this.dropIndicator = r, this.dropJoystick = d, this.dropJoystickButtons = s, this.dockedEl.dataset.path = w({ type: "docked", segments: [] }), i.addEventListener("keydown", (c) => this.onRootKeyDown(c), { capture: !0 }), i.addEventListener("focusout", (c) => this.onRootFocusOut(c)), this.renderLayout(), this.rootResizeObserver = new ResizeObserver(() => {
|
|
519
719
|
this.scheduleRenderIntersectionHandles(), this.updateFloatingPanePositions();
|
|
520
720
|
}), this.rootResizeObserver.observe(this.rootEl), this.dockedMutationObserver = new MutationObserver(() => this.scheduleRenderIntersectionHandles()), this.dockedMutationObserver.observe(this.dockedEl, { childList: !0, subtree: !0 }), this.dockedEl.addEventListener("resizing", this.onSplitterResize), this.dockedEl.addEventListener("resize-end", this.onSplitterResize);
|
|
521
721
|
}
|
|
@@ -531,7 +731,7 @@ class P extends A {
|
|
|
531
731
|
}
|
|
532
732
|
get layout() {
|
|
533
733
|
return {
|
|
534
|
-
root:
|
|
734
|
+
root: _(this.rootLayout),
|
|
535
735
|
floating: this.cloneFloatingArray(this.floatingLayouts),
|
|
536
736
|
titles: { ...this.titles }
|
|
537
737
|
};
|
|
@@ -543,8 +743,8 @@ class P extends A {
|
|
|
543
743
|
root: this.rootLayout,
|
|
544
744
|
floating: this.floatingLayouts,
|
|
545
745
|
titles: this.titles
|
|
546
|
-
}),
|
|
547
|
-
i !==
|
|
746
|
+
}), n = JSON.stringify(e);
|
|
747
|
+
i !== n && (this.rootLayout = _(e.root), this.floatingLayouts = this.cloneFloatingArray(e.floating), this.titles = e.titles ? { ...e.titles } : {}, this.normalizeAllLayouts(), this.renderLayout());
|
|
548
748
|
}
|
|
549
749
|
/**
|
|
550
750
|
* True while the user is actively interacting with the dock — pane drag,
|
|
@@ -562,10 +762,10 @@ class P extends A {
|
|
|
562
762
|
return this.snapshot;
|
|
563
763
|
}
|
|
564
764
|
resolveDocument() {
|
|
565
|
-
const t =
|
|
566
|
-
if (!
|
|
765
|
+
const t = L.documentRef, e = this.ownerDocument ?? null, n = t ?? e ?? (typeof document < "u" ? document : null);
|
|
766
|
+
if (!n)
|
|
567
767
|
throw new Error("mint-dock-manager requires a Document to initialize.");
|
|
568
|
-
return
|
|
768
|
+
return L.documentRef || (L.documentRef = n), n;
|
|
569
769
|
}
|
|
570
770
|
resolveWindow(t) {
|
|
571
771
|
return typeof window < "u" ? window : t.defaultView ?? null;
|
|
@@ -606,40 +806,40 @@ class P extends A {
|
|
|
606
806
|
this.floatingLayerEl.innerHTML = "";
|
|
607
807
|
const t = this.getHostSize();
|
|
608
808
|
this.floatingLayouts.forEach((e, i) => {
|
|
609
|
-
const
|
|
610
|
-
|
|
809
|
+
const n = this.documentRef.createElement("div");
|
|
810
|
+
n.classList.add("dock-floating"), n.dataset.path = w({
|
|
611
811
|
type: "floating",
|
|
612
812
|
index: i,
|
|
613
813
|
segments: []
|
|
614
814
|
});
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
const { left:
|
|
618
|
-
|
|
619
|
-
const
|
|
620
|
-
|
|
815
|
+
const o = this.getFloatingWindowTitle(e), r = `${this.instanceId}-floating-${i}-title`;
|
|
816
|
+
n.setAttribute("role", "dialog"), n.setAttribute("aria-labelledby", r), n.setAttribute("aria-modal", "false");
|
|
817
|
+
const { left: d, top: s, width: c, height: l } = R(e.bounds, t);
|
|
818
|
+
n.style.left = `${d}px`, n.style.top = `${s}px`, n.style.width = `${c}px`, n.style.height = `${l}px`, n.style.minWidth = "0", n.style.minHeight = "0";
|
|
819
|
+
const u = N(this.floatingLayouts[i], i);
|
|
820
|
+
n.style.zIndex = String(u);
|
|
621
821
|
const h = this.documentRef.createElement("div");
|
|
622
822
|
h.classList.add("dock-floating__chrome"), h.addEventListener(
|
|
623
823
|
"pointerdown",
|
|
624
|
-
(
|
|
824
|
+
(f) => this.beginFloatingDrag(f, i, n, h)
|
|
625
825
|
);
|
|
626
|
-
const
|
|
627
|
-
|
|
826
|
+
const p = this.documentRef.createElement("div");
|
|
827
|
+
p.classList.add("dock-floating__title"), p.id = r, p.textContent = o, h.appendChild(p);
|
|
628
828
|
const g = this.documentRef.createElement("button");
|
|
629
|
-
if (g.type = "button", g.classList.add("dock-floating__close"), g.setAttribute("aria-label", `Close pane: ${
|
|
630
|
-
|
|
631
|
-
}), g.addEventListener("pointerdown", (
|
|
632
|
-
const
|
|
633
|
-
|
|
829
|
+
if (g.type = "button", g.classList.add("dock-floating__close"), g.setAttribute("aria-label", `Close pane: ${o}`), g.textContent = "×", g.addEventListener("click", (f) => {
|
|
830
|
+
f.stopPropagation(), this.closeFloatingPane(i);
|
|
831
|
+
}), g.addEventListener("pointerdown", (f) => f.stopPropagation()), h.appendChild(g), n.appendChild(h), e.root) {
|
|
832
|
+
const f = this.renderNode(e.root, [], i);
|
|
833
|
+
f.classList.add("dock-floating__stack"), n.appendChild(f);
|
|
634
834
|
} else {
|
|
635
|
-
const
|
|
636
|
-
|
|
835
|
+
const f = this.documentRef.createElement("div");
|
|
836
|
+
f.classList.add("dock-stack"), f.dataset.path = w({
|
|
637
837
|
type: "floating",
|
|
638
838
|
index: i,
|
|
639
839
|
segments: []
|
|
640
840
|
});
|
|
641
|
-
const
|
|
642
|
-
|
|
841
|
+
const y = this.documentRef.createElement("div");
|
|
842
|
+
y.classList.add("dock-stack__pane"), y.textContent = "No panes configured", f.appendChild(y), n.appendChild(f);
|
|
643
843
|
}
|
|
644
844
|
[
|
|
645
845
|
{
|
|
@@ -674,23 +874,23 @@ class P extends A {
|
|
|
674
874
|
classes: ["dock-floating__resizer", "dock-floating__resizer--left"],
|
|
675
875
|
edges: { horizontal: "left", vertical: "none" }
|
|
676
876
|
}
|
|
677
|
-
].forEach(({ classes:
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
877
|
+
].forEach(({ classes: f, edges: y }) => {
|
|
878
|
+
const b = this.documentRef.createElement("div");
|
|
879
|
+
b.classList.add(...f), b.setAttribute("role", "separator");
|
|
880
|
+
const k = y.horizontal === "none" && y.vertical !== "none", D = y.vertical === "none" && y.horizontal !== "none";
|
|
881
|
+
k ? b.setAttribute("aria-orientation", "horizontal") : D && b.setAttribute("aria-orientation", "vertical");
|
|
882
|
+
const P = [];
|
|
883
|
+
y.vertical === "top" ? P.push("top") : y.vertical === "bottom" && P.push("bottom"), y.horizontal === "left" ? P.push("left") : y.horizontal === "right" && P.push("right"), b.setAttribute(
|
|
684
884
|
"aria-label",
|
|
685
|
-
`Resize pane ${
|
|
686
|
-
),
|
|
885
|
+
`Resize pane ${P.length === 2 ? "corner " : "edge "}${P.join("-")}`
|
|
886
|
+
), b.addEventListener(
|
|
687
887
|
"pointerdown",
|
|
688
|
-
(
|
|
689
|
-
),
|
|
888
|
+
(z) => this.beginFloatingResize(z, i, n, b, y)
|
|
889
|
+
), b.setAttribute("tabindex", "0"), b.setAttribute("aria-valuemin", "0"), b.setAttribute("aria-valuemax", "100"), this.syncFloatingResizerValue(b, i, y), b.addEventListener(
|
|
690
890
|
"keydown",
|
|
691
|
-
(
|
|
692
|
-
),
|
|
693
|
-
}), this.floatingLayerEl.appendChild(
|
|
891
|
+
(z) => this.onFloatingResizeKeydown(z, i, n, b, y)
|
|
892
|
+
), n.appendChild(b);
|
|
893
|
+
}), this.floatingLayerEl.appendChild(n);
|
|
694
894
|
});
|
|
695
895
|
}
|
|
696
896
|
onSplitterResize() {
|
|
@@ -708,45 +908,45 @@ class P extends A {
|
|
|
708
908
|
if (!t) return;
|
|
709
909
|
const e = this.rootEl.getBoundingClientRect();
|
|
710
910
|
if (this.cornerResizeState) {
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
911
|
+
const s = this.cornerResizeState, c = s.hs[0], l = s.vs[0], u = this.findSplitterByPath(c.path.segments), h = this.findSplitterByPath(l.path.segments), p = u ? this.getSplitterDividers(u)[c.index] : null, g = h ? this.getSplitterDividers(h)[l.index] : null;
|
|
912
|
+
if (p && g) {
|
|
913
|
+
const m = p.getBoundingClientRect(), f = g.getBoundingClientRect(), y = f.left + f.width / 2 - e.left, b = m.top + m.height / 2 - e.top;
|
|
914
|
+
s.handle.style.left = `${y}px`, s.handle.style.top = `${b}px`, Array.from(t.querySelectorAll(".dock-intersection-handle")).forEach((k) => {
|
|
915
|
+
k !== s.handle && k.remove();
|
|
716
916
|
});
|
|
717
917
|
}
|
|
718
918
|
return;
|
|
719
919
|
}
|
|
720
920
|
t.replaceChildren();
|
|
721
|
-
const i = [],
|
|
921
|
+
const i = [], n = [];
|
|
722
922
|
Array.from(
|
|
723
923
|
this.shadowRoot?.querySelectorAll(".dock-split") ?? []
|
|
724
|
-
).forEach((
|
|
725
|
-
const
|
|
726
|
-
this.getSplitterDividers(
|
|
727
|
-
const g = { rect: h.getBoundingClientRect(), pathStr:
|
|
728
|
-
|
|
924
|
+
).forEach((s) => {
|
|
925
|
+
const c = s.dataset.direction, l = s.dataset.path ?? "", u = this.splitterLayerKey(s);
|
|
926
|
+
this.getSplitterDividers(s).forEach((h, p) => {
|
|
927
|
+
const g = { rect: h.getBoundingClientRect(), pathStr: l, index: p, layerKey: u };
|
|
928
|
+
c === "horizontal" ? n.push(g) : c === "vertical" && i.push(g);
|
|
729
929
|
});
|
|
730
930
|
});
|
|
731
|
-
const r = 24,
|
|
732
|
-
i.forEach((
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
if (
|
|
736
|
-
const
|
|
737
|
-
if (h > r ||
|
|
738
|
-
const g =
|
|
739
|
-
|
|
931
|
+
const r = 24, d = /* @__PURE__ */ new Map();
|
|
932
|
+
i.forEach((s) => {
|
|
933
|
+
const c = s.rect.top + s.rect.height / 2;
|
|
934
|
+
n.forEach((l) => {
|
|
935
|
+
if (s.layerKey !== l.layerKey) return;
|
|
936
|
+
const u = l.rect.left + l.rect.width / 2, h = u < s.rect.left ? s.rect.left - u : u > s.rect.right ? u - s.rect.right : 0, p = c < l.rect.top ? l.rect.top - c : c > l.rect.bottom ? c - l.rect.bottom : 0;
|
|
937
|
+
if (h > r || p > r) return;
|
|
938
|
+
const g = u - e.left, m = c - e.top, f = `${Math.round(g)}:${Math.round(m)}`, y = d.get(f) ?? { x: g, y: m, pairs: [] };
|
|
939
|
+
y.pairs.push({ h: { pathStr: s.pathStr, index: s.index }, v: { pathStr: l.pathStr, index: l.index } }), d.set(f, y);
|
|
740
940
|
});
|
|
741
|
-
}),
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
const h =
|
|
747
|
-
|
|
748
|
-
const g = { path:
|
|
749
|
-
|
|
941
|
+
}), d.forEach((s, c) => {
|
|
942
|
+
const l = this.documentRef.createElement("div");
|
|
943
|
+
l.classList.add("dock-intersection-handle", "glyph"), l.setAttribute("role", "separator"), l.setAttribute("aria-label", "Resize split intersection");
|
|
944
|
+
const u = e.width > 0 ? Math.round(s.x / e.width * 100) : 0;
|
|
945
|
+
l.setAttribute("aria-valuemin", "0"), l.setAttribute("aria-valuemax", "100"), l.setAttribute("aria-valuenow", String(Math.min(100, Math.max(0, u)))), l.setAttribute("tabindex", "0");
|
|
946
|
+
const h = s.pairs[0], p = `${h.h.pathStr}:${h.h.index}|${h.v.pathStr}:${h.v.index}`;
|
|
947
|
+
l.dataset.key = p, l.dataset.pairs = JSON.stringify(s.pairs), l.style.left = `${s.x}px`, l.style.top = `${s.y}px`;
|
|
948
|
+
const g = { path: S(h.h.pathStr), index: h.h.index, container: this.findSplitterByPath(S(h.h.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() }, m = { path: S(h.v.pathStr), index: h.v.index, container: this.findSplitterByPath(S(h.v.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() };
|
|
949
|
+
l.addEventListener("pointerdown", (f) => this.beginCornerResize(f, g, m, l)), l.addEventListener("dblclick", (f) => this.onIntersectionDoubleClick(f, l)), l.addEventListener("keydown", (f) => this.onIntersectionKeyDown(f, l)), t.appendChild(l);
|
|
750
950
|
});
|
|
751
951
|
}
|
|
752
952
|
/**
|
|
@@ -761,67 +961,67 @@ class P extends A {
|
|
|
761
961
|
* pair drives — same precedence as the pointer drag path.
|
|
762
962
|
*/
|
|
763
963
|
onIntersectionKeyDown(t, e) {
|
|
764
|
-
const i = t.key === "ArrowLeft" || t.key === "ArrowRight",
|
|
765
|
-
if (!i && !
|
|
964
|
+
const i = t.key === "ArrowLeft" || t.key === "ArrowRight", n = t.key === "ArrowUp" || t.key === "ArrowDown", o = t.key === "Home" || t.key === "End";
|
|
965
|
+
if (!i && !n && !o) return;
|
|
766
966
|
const r = e.dataset.pairs;
|
|
767
967
|
if (!r) return;
|
|
768
|
-
let
|
|
968
|
+
let d;
|
|
769
969
|
try {
|
|
770
|
-
|
|
970
|
+
d = JSON.parse(r);
|
|
771
971
|
} catch {
|
|
772
972
|
return;
|
|
773
973
|
}
|
|
774
|
-
if (
|
|
974
|
+
if (d.length === 0) return;
|
|
775
975
|
t.preventDefault();
|
|
776
|
-
const
|
|
777
|
-
this.findSplitterByPath(
|
|
976
|
+
const s = t.shiftKey, l = i || o ? d[0].v : d[0].h, u = S(l.pathStr);
|
|
977
|
+
this.findSplitterByPath(u?.segments ?? [])?.resizeDividerBy?.(l.index, t.key, s);
|
|
778
978
|
}
|
|
779
|
-
beginCornerResize(t, e, i,
|
|
979
|
+
beginCornerResize(t, e, i, n) {
|
|
780
980
|
t.preventDefault();
|
|
781
|
-
const
|
|
782
|
-
const
|
|
783
|
-
if (!
|
|
784
|
-
const g = this.findSplitterByPath(
|
|
981
|
+
const o = n.dataset.pairs, r = o ? JSON.parse(o) : [], d = [], s = [], c = (l, u, h) => {
|
|
982
|
+
const p = S(l);
|
|
983
|
+
if (!p) return;
|
|
984
|
+
const g = this.findSplitterByPath(p.segments);
|
|
785
985
|
if (!g) return;
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
788
|
-
const
|
|
789
|
-
h === "h" ?
|
|
986
|
+
const m = this.getSplitterPanels(g);
|
|
987
|
+
if (m.length === 0) return;
|
|
988
|
+
const f = h === "h" ? "height" : "width", y = m.map((k) => k.getBoundingClientRect()[f]), b = { path: p, index: u, container: g, initialSizes: y, before: y[u], after: y[u + 1] };
|
|
989
|
+
h === "h" ? d.push(b) : s.push(b);
|
|
790
990
|
};
|
|
791
|
-
if (r.length > 0 ? r.forEach((
|
|
792
|
-
|
|
793
|
-
}) : e.path && i.path && (
|
|
991
|
+
if (r.length > 0 ? r.forEach((l) => {
|
|
992
|
+
c(l.h.pathStr, l.h.index, "h"), c(l.v.pathStr, l.v.index, "v");
|
|
993
|
+
}) : e.path && i.path && (c(w(e.path), e.index, "h"), c(w(i.path), i.index, "v")), !(d.length === 0 && s.length === 0)) {
|
|
794
994
|
try {
|
|
795
|
-
|
|
995
|
+
n.setPointerCapture(t.pointerId), n.dataset.resizing = "true", n.classList.add("hovering");
|
|
796
996
|
} catch {
|
|
797
997
|
}
|
|
798
998
|
this.cornerResizeState = {
|
|
799
999
|
pointerId: t.pointerId,
|
|
800
|
-
handle:
|
|
801
|
-
hs:
|
|
802
|
-
vs:
|
|
803
|
-
}, this.startPointerTracking(),
|
|
1000
|
+
handle: n,
|
|
1001
|
+
hs: d.map((l) => ({ path: this.clonePath(l.path), index: l.index, container: l.container, beforeSize: l.before, afterSize: l.after, initialSizes: l.initialSizes, startY: t.clientY })),
|
|
1002
|
+
vs: s.map((l) => ({ path: this.clonePath(l.path), index: l.index, container: l.container, beforeSize: l.before, afterSize: l.after, initialSizes: l.initialSizes, startX: t.clientX }))
|
|
1003
|
+
}, this.startPointerTracking(), n.dataset.key || (n.dataset.key = n.dataset.group ?? ""), this.renderSnapMarkersForCorner();
|
|
804
1004
|
try {
|
|
805
|
-
const
|
|
806
|
-
let
|
|
807
|
-
if (
|
|
808
|
-
const
|
|
809
|
-
|
|
1005
|
+
const l = this.rootEl.getBoundingClientRect();
|
|
1006
|
+
let u = null, h = null;
|
|
1007
|
+
if (s.length > 0) {
|
|
1008
|
+
const f = s[0], b = this.getSplitterDividers(f.container)[f.index]?.getBoundingClientRect();
|
|
1009
|
+
b && (u = b.left + b.width / 2);
|
|
810
1010
|
}
|
|
811
|
-
if (
|
|
812
|
-
const
|
|
813
|
-
|
|
1011
|
+
if (d.length > 0) {
|
|
1012
|
+
const f = d[0], b = this.getSplitterDividers(f.container)[f.index]?.getBoundingClientRect();
|
|
1013
|
+
b && (h = b.top + b.height / 2);
|
|
814
1014
|
}
|
|
815
|
-
const
|
|
1015
|
+
const p = [], g = [];
|
|
816
1016
|
Array.from(
|
|
817
1017
|
this.shadowRoot?.querySelectorAll(".dock-split") ?? []
|
|
818
|
-
).forEach((
|
|
819
|
-
const
|
|
820
|
-
this.getSplitterDividers(
|
|
821
|
-
const
|
|
822
|
-
|
|
1018
|
+
).forEach((f) => {
|
|
1019
|
+
const y = f.dataset.direction ?? void 0;
|
|
1020
|
+
this.getSplitterDividers(f).forEach((b) => {
|
|
1021
|
+
const k = b.getBoundingClientRect();
|
|
1022
|
+
y === "horizontal" && h != null ? h >= k.top && h <= k.bottom && p.push(k.left + k.width / 2 - l.left) : y === "vertical" && u != null && u >= k.left && u <= k.right && g.push(k.top + k.height / 2 - l.top);
|
|
823
1023
|
});
|
|
824
|
-
}), this.cornerSnapXTargets =
|
|
1024
|
+
}), this.cornerSnapXTargets = p, this.cornerSnapYTargets = g;
|
|
825
1025
|
} catch {
|
|
826
1026
|
this.cornerSnapXTargets = [], this.cornerSnapYTargets = [];
|
|
827
1027
|
}
|
|
@@ -830,43 +1030,29 @@ class P extends A {
|
|
|
830
1030
|
handleCornerResizeMove(t) {
|
|
831
1031
|
const e = this.cornerResizeState;
|
|
832
1032
|
if (!e || e.pointerId !== t.pointerId) return;
|
|
833
|
-
const i =
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
const h = n.top + p, d = Math.abs(h - c);
|
|
855
|
-
d < a && (a = d, s = h);
|
|
856
|
-
}), a <= o && (c = s);
|
|
857
|
-
}
|
|
858
|
-
const l = (s, a) => {
|
|
859
|
-
const p = this.resolveSplitNode(s.path);
|
|
860
|
-
if (!p) return;
|
|
861
|
-
const h = 48, d = s.beforeSize + s.afterSize;
|
|
862
|
-
let g = Math.min(Math.max(s.beforeSize + a, h), d - h);
|
|
863
|
-
g = i(g, d, t.shiftKey);
|
|
864
|
-
const f = d - g, u = [...s.initialSizes];
|
|
865
|
-
u[s.index] = g, u[s.index + 1] = f;
|
|
866
|
-
const m = u.reduce((y, b) => y + b, 0);
|
|
867
|
-
p.sizes = m > 0 ? u.map((y) => y / m) : [], s.container.setPanelSizes?.(u);
|
|
1033
|
+
const i = 10, n = this.rootEl.getBoundingClientRect(), o = j(
|
|
1034
|
+
t.clientX,
|
|
1035
|
+
this.cornerSnapXTargets.map((s) => n.left + s),
|
|
1036
|
+
i
|
|
1037
|
+
), r = j(
|
|
1038
|
+
t.clientY,
|
|
1039
|
+
this.cornerSnapYTargets.map((s) => n.top + s),
|
|
1040
|
+
i
|
|
1041
|
+
), d = (s, c) => {
|
|
1042
|
+
const l = this.resolveSplitNode(s.path);
|
|
1043
|
+
if (!l) return;
|
|
1044
|
+
const u = 48, { before: h, after: p } = ct(
|
|
1045
|
+
s.beforeSize,
|
|
1046
|
+
s.afterSize,
|
|
1047
|
+
c,
|
|
1048
|
+
u,
|
|
1049
|
+
t.shiftKey
|
|
1050
|
+
), g = [...s.initialSizes];
|
|
1051
|
+
g[s.index] = h, g[s.index + 1] = p;
|
|
1052
|
+
const m = g.reduce((f, y) => f + y, 0);
|
|
1053
|
+
l.sizes = m > 0 ? g.map((f) => f / m) : [], s.container.setPanelSizes?.(g);
|
|
868
1054
|
};
|
|
869
|
-
e.hs.forEach((s) =>
|
|
1055
|
+
e.hs.forEach((s) => d(s, r - s.startY)), e.vs.forEach((s) => d(s, o - s.startX)), this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
|
|
870
1056
|
}
|
|
871
1057
|
endCornerResize(t) {
|
|
872
1058
|
const e = this.cornerResizeState;
|
|
@@ -880,78 +1066,78 @@ class P extends A {
|
|
|
880
1066
|
}
|
|
881
1067
|
onIntersectionDoubleClick(t, e) {
|
|
882
1068
|
t.preventDefault();
|
|
883
|
-
const i = e.dataset.pairs,
|
|
884
|
-
if (!Array.isArray(
|
|
885
|
-
const
|
|
886
|
-
if (
|
|
887
|
-
const [
|
|
888
|
-
if (
|
|
889
|
-
const
|
|
890
|
-
|
|
1069
|
+
const i = e.dataset.pairs, n = i ? JSON.parse(i) : [];
|
|
1070
|
+
if (!Array.isArray(n) || n.length === 0) {
|
|
1071
|
+
const l = (e.dataset.key ?? "").split("|");
|
|
1072
|
+
if (l.length === 2) {
|
|
1073
|
+
const [u, h] = l, p = u.lastIndexOf(":"), g = h.lastIndexOf(":");
|
|
1074
|
+
if (p > 0 && g > 0) {
|
|
1075
|
+
const m = u.slice(0, p), f = h.slice(0, g), y = Number.parseInt(u.slice(p + 1), 10), b = Number.parseInt(h.slice(g + 1), 10);
|
|
1076
|
+
n.push({ h: { pathStr: m, index: y }, v: { pathStr: f, index: b } });
|
|
891
1077
|
}
|
|
892
1078
|
}
|
|
893
1079
|
}
|
|
894
|
-
if (
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
|
|
1080
|
+
if (n.length === 0) return;
|
|
1081
|
+
const o = /* @__PURE__ */ new Set();
|
|
1082
|
+
n.forEach((c) => {
|
|
1083
|
+
o.add(c.h.pathStr), o.add(c.v.pathStr);
|
|
898
1084
|
});
|
|
899
1085
|
let r = !1;
|
|
900
|
-
|
|
901
|
-
this.previousSplitSizes.has(
|
|
1086
|
+
o.forEach((c) => {
|
|
1087
|
+
this.previousSplitSizes.has(c) && (r = !0);
|
|
902
1088
|
});
|
|
903
|
-
const
|
|
904
|
-
const
|
|
905
|
-
if (!
|
|
906
|
-
const
|
|
907
|
-
if (!Number.isFinite(
|
|
908
|
-
const g =
|
|
1089
|
+
const d = (c, l) => {
|
|
1090
|
+
const u = this.findSplitterByPath(c.segments);
|
|
1091
|
+
if (!u) return;
|
|
1092
|
+
const p = (u.dataset.direction ?? "horizontal") === "horizontal" ? u.getBoundingClientRect().width : u.getBoundingClientRect().height;
|
|
1093
|
+
if (!Number.isFinite(p) || p <= 0) return;
|
|
1094
|
+
const g = l.reduce((f, y) => f + Math.max(y, 0), 0);
|
|
909
1095
|
if (g <= 0) return;
|
|
910
|
-
const
|
|
911
|
-
|
|
912
|
-
},
|
|
913
|
-
const h =
|
|
1096
|
+
const m = l.map((f) => Math.max(f, 0) / g * p);
|
|
1097
|
+
u.setPanelSizes?.(m);
|
|
1098
|
+
}, s = (c, l, u) => {
|
|
1099
|
+
const h = S(c);
|
|
914
1100
|
if (!h) return;
|
|
915
|
-
const
|
|
916
|
-
if (!
|
|
917
|
-
const g =
|
|
918
|
-
|
|
1101
|
+
const p = this.resolveSplitNode(h);
|
|
1102
|
+
if (!p) return;
|
|
1103
|
+
const g = x(p.sizes ?? [], p.children.length), m = u([...g], l);
|
|
1104
|
+
p.sizes = m, d(h, m);
|
|
919
1105
|
};
|
|
920
1106
|
if (r)
|
|
921
|
-
this.previousSplitSizes.forEach((
|
|
922
|
-
const
|
|
923
|
-
if (!h || !
|
|
924
|
-
const
|
|
925
|
-
h.sizes =
|
|
1107
|
+
this.previousSplitSizes.forEach((c, l) => {
|
|
1108
|
+
const u = S(l), h = u ? this.resolveSplitNode(u) : null;
|
|
1109
|
+
if (!h || !u) return;
|
|
1110
|
+
const p = x(c, h.children.length);
|
|
1111
|
+
h.sizes = p, d(u, p);
|
|
926
1112
|
}), this.previousSplitSizes.clear();
|
|
927
1113
|
else {
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
[
|
|
931
|
-
if (
|
|
932
|
-
const
|
|
933
|
-
g && Array.isArray(g.sizes) && this.previousSplitSizes.set(h, [...g.sizes]),
|
|
1114
|
+
const c = /* @__PURE__ */ new Set();
|
|
1115
|
+
n.forEach((l) => {
|
|
1116
|
+
[l.h.pathStr, l.v.pathStr].forEach((h) => {
|
|
1117
|
+
if (c.has(h)) return;
|
|
1118
|
+
const p = S(h), g = p ? this.resolveSplitNode(p) : null;
|
|
1119
|
+
g && Array.isArray(g.sizes) && this.previousSplitSizes.set(h, [...g.sizes]), c.add(h);
|
|
934
1120
|
});
|
|
935
|
-
const
|
|
936
|
-
const g = (h[
|
|
1121
|
+
const u = (h, p) => {
|
|
1122
|
+
const g = (h[p] ?? 0) + (h[p + 1] ?? 0);
|
|
937
1123
|
if (g <= 0) return h;
|
|
938
|
-
h[
|
|
939
|
-
const
|
|
940
|
-
return
|
|
1124
|
+
h[p] = g / 2, h[p + 1] = g / 2;
|
|
1125
|
+
const m = h.reduce((f, y) => f + y, 0);
|
|
1126
|
+
return m > 0 ? h.map((f) => f / m) : h;
|
|
941
1127
|
};
|
|
942
|
-
l
|
|
1128
|
+
s(l.h.pathStr, l.h.index, u), s(l.v.pathStr, l.v.index, u);
|
|
943
1129
|
});
|
|
944
1130
|
}
|
|
945
1131
|
this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
|
|
946
1132
|
}
|
|
947
|
-
beginFloatingDrag(t, e, i,
|
|
948
|
-
const
|
|
949
|
-
if (!
|
|
1133
|
+
beginFloatingDrag(t, e, i, n) {
|
|
1134
|
+
const o = this.floatingLayouts[e];
|
|
1135
|
+
if (!o)
|
|
950
1136
|
return;
|
|
951
|
-
t.preventDefault(), t.stopPropagation(),
|
|
952
|
-
const { left: r, top:
|
|
1137
|
+
t.preventDefault(), t.stopPropagation(), o.bounds = R(o.bounds, this.getHostSize());
|
|
1138
|
+
const { left: r, top: d } = o.bounds;
|
|
953
1139
|
try {
|
|
954
|
-
|
|
1140
|
+
n.setPointerCapture(t.pointerId);
|
|
955
1141
|
} catch {
|
|
956
1142
|
}
|
|
957
1143
|
this.promoteFloatingPane(e, i), i.dataset.dragging = "true", this.floatingDragState = {
|
|
@@ -960,17 +1146,17 @@ class P extends A {
|
|
|
960
1146
|
startX: t.clientX,
|
|
961
1147
|
startY: t.clientY,
|
|
962
1148
|
startLeft: r,
|
|
963
|
-
startTop:
|
|
1149
|
+
startTop: d,
|
|
964
1150
|
wrapper: i,
|
|
965
|
-
handle:
|
|
1151
|
+
handle: n
|
|
966
1152
|
}, this.startPointerTracking();
|
|
967
1153
|
}
|
|
968
1154
|
/** The percent-of-host size of the dimension a handle drives (width for
|
|
969
1155
|
* horizontal/corner handles, height for pure-vertical ones). */
|
|
970
1156
|
syncFloatingResizerValue(t, e, i) {
|
|
971
|
-
const
|
|
972
|
-
if (!
|
|
973
|
-
const r = i.horizontal !== "none" ?
|
|
1157
|
+
const n = this.floatingLayouts[e], o = this.getHostSize();
|
|
1158
|
+
if (!n || o.width <= 0 || o.height <= 0) return;
|
|
1159
|
+
const r = i.horizontal !== "none" ? n.bounds.width / o.width * 100 : n.bounds.height / o.height * 100;
|
|
974
1160
|
t.setAttribute("aria-valuenow", String(Math.round(Math.min(100, Math.max(0, r)))));
|
|
975
1161
|
}
|
|
976
1162
|
/**
|
|
@@ -979,35 +1165,30 @@ class P extends A {
|
|
|
979
1165
|
* ±10px per arrow, Shift for 1px. Off-axis arrows and modifier chords pass
|
|
980
1166
|
* through untouched.
|
|
981
1167
|
*/
|
|
982
|
-
onFloatingResizeKeydown(t, e, i,
|
|
1168
|
+
onFloatingResizeKeydown(t, e, i, n, o) {
|
|
983
1169
|
if (t.altKey || t.ctrlKey || t.metaKey) return;
|
|
984
|
-
const r = t.key === "ArrowLeft" ? -1 : t.key === "ArrowRight" ? 1 : 0,
|
|
985
|
-
if (r === 0 &&
|
|
986
|
-
const
|
|
987
|
-
if (!
|
|
1170
|
+
const r = t.key === "ArrowLeft" ? -1 : t.key === "ArrowRight" ? 1 : 0, d = t.key === "ArrowUp" ? -1 : t.key === "ArrowDown" ? 1 : 0;
|
|
1171
|
+
if (r === 0 && d === 0 || r !== 0 && o.horizontal === "none" || d !== 0 && o.vertical === "none") return;
|
|
1172
|
+
const s = this.floatingLayouts[e];
|
|
1173
|
+
if (!s) return;
|
|
988
1174
|
t.preventDefault(), t.stopPropagation();
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
const g = n.vertical === "top" ? -c * s : c * s;
|
|
997
|
-
let f = Math.max(h, d.height + g);
|
|
998
|
-
n.vertical === "top" ? (f = Math.min(f, d.top + d.height), d.top = d.top + d.height - f) : a.height > 0 && (f = Math.min(f, a.height - d.top)), d.height = f;
|
|
999
|
-
}
|
|
1000
|
-
l.bounds = d, i.style.left = `${d.left}px`, i.style.top = `${d.top}px`, i.style.width = `${d.width}px`, i.style.height = `${d.height}px`, this.syncFloatingResizerValue(o, e, n), this.dispatchLayoutChanged();
|
|
1175
|
+
const c = t.shiftKey ? 1 : 10, l = Y(
|
|
1176
|
+
s.bounds,
|
|
1177
|
+
o,
|
|
1178
|
+
{ x: r * c, y: d * c },
|
|
1179
|
+
this.getHostSize()
|
|
1180
|
+
);
|
|
1181
|
+
this.applyFloatingBounds(i, e, l), this.syncFloatingResizerValue(n, e, o), this.dispatchLayoutChanged();
|
|
1001
1182
|
}
|
|
1002
|
-
beginFloatingResize(t, e, i,
|
|
1183
|
+
beginFloatingResize(t, e, i, n, o) {
|
|
1003
1184
|
const r = this.floatingLayouts[e];
|
|
1004
1185
|
if (r) {
|
|
1005
1186
|
t.preventDefault(), t.stopPropagation();
|
|
1006
1187
|
try {
|
|
1007
|
-
|
|
1188
|
+
n.setPointerCapture(t.pointerId), n.dataset.resizing = "true";
|
|
1008
1189
|
} catch {
|
|
1009
1190
|
}
|
|
1010
|
-
this.promoteFloatingPane(e, i), r.bounds =
|
|
1191
|
+
this.promoteFloatingPane(e, i), r.bounds = R(r.bounds, this.getHostSize()), this.floatingResizeState = {
|
|
1011
1192
|
index: e,
|
|
1012
1193
|
pointerId: t.pointerId,
|
|
1013
1194
|
startX: t.clientX,
|
|
@@ -1017,8 +1198,8 @@ class P extends A {
|
|
|
1017
1198
|
startLeft: r.bounds.left,
|
|
1018
1199
|
startTop: r.bounds.top,
|
|
1019
1200
|
wrapper: i,
|
|
1020
|
-
handle:
|
|
1021
|
-
edges:
|
|
1201
|
+
handle: n,
|
|
1202
|
+
edges: o
|
|
1022
1203
|
}, this.startPointerTracking();
|
|
1023
1204
|
}
|
|
1024
1205
|
}
|
|
@@ -1028,10 +1209,10 @@ class P extends A {
|
|
|
1028
1209
|
return;
|
|
1029
1210
|
const i = this.floatingLayouts[e.index];
|
|
1030
1211
|
if (!i) return;
|
|
1031
|
-
const
|
|
1212
|
+
const n = t.clientX - e.startX, o = t.clientY - e.startY, r = R(
|
|
1032
1213
|
{
|
|
1033
|
-
left: e.startLeft +
|
|
1034
|
-
top: e.startTop +
|
|
1214
|
+
left: e.startLeft + n,
|
|
1215
|
+
top: e.startTop + o,
|
|
1035
1216
|
width: i.bounds.width,
|
|
1036
1217
|
height: i.bounds.height
|
|
1037
1218
|
},
|
|
@@ -1060,24 +1241,41 @@ class P extends A {
|
|
|
1060
1241
|
e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
|
|
1061
1242
|
return;
|
|
1062
1243
|
}
|
|
1063
|
-
const
|
|
1064
|
-
if (!
|
|
1244
|
+
const n = S(i.dataset.path);
|
|
1245
|
+
if (!n || n.type === "floating" && n.index === e.index) {
|
|
1065
1246
|
e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
|
|
1066
1247
|
return;
|
|
1067
1248
|
}
|
|
1068
1249
|
this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null));
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1250
|
+
const o = this.computeDropZone(i, t, this.extractDropZoneFromEvent(t));
|
|
1251
|
+
o ? e.dropTarget = { path: n, zone: o } : e.dropTarget && delete e.dropTarget, this.showDropIndicator(i, o);
|
|
1071
1252
|
}
|
|
1072
1253
|
handleFloatingResizeMove(t) {
|
|
1073
1254
|
const e = this.floatingResizeState;
|
|
1074
1255
|
if (!e || t.pointerId !== e.pointerId)
|
|
1075
1256
|
return;
|
|
1076
|
-
const i =
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1257
|
+
const i = Y(
|
|
1258
|
+
{
|
|
1259
|
+
left: e.startLeft,
|
|
1260
|
+
top: e.startTop,
|
|
1261
|
+
width: e.startWidth,
|
|
1262
|
+
height: e.startHeight
|
|
1263
|
+
},
|
|
1264
|
+
e.edges,
|
|
1265
|
+
{ x: t.clientX - e.startX, y: t.clientY - e.startY },
|
|
1266
|
+
this.getHostSize()
|
|
1267
|
+
);
|
|
1268
|
+
this.applyFloatingBounds(e.wrapper, e.index, i);
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Commit resolved bounds to both the DOM and the layout. Written directly
|
|
1272
|
+
* rather than through a re-render: a resize runs once per pointer move, and
|
|
1273
|
+
* tearing the wrapper down would drop the pointer capture mid-gesture.
|
|
1274
|
+
*/
|
|
1275
|
+
applyFloatingBounds(t, e, i) {
|
|
1276
|
+
t.style.left = `${i.left}px`, t.style.top = `${i.top}px`, t.style.width = `${i.width}px`, t.style.height = `${i.height}px`;
|
|
1277
|
+
const n = this.floatingLayouts[e];
|
|
1278
|
+
n && (n.bounds = i);
|
|
1081
1279
|
}
|
|
1082
1280
|
endFloatingResize(t) {
|
|
1083
1281
|
const e = this.floatingResizeState;
|
|
@@ -1089,21 +1287,12 @@ class P extends A {
|
|
|
1089
1287
|
delete e.handle.dataset.resizing, this.syncFloatingResizerValue(e.handle, e.index, e.edges), this.floatingResizeState = null, this.dispatchLayoutChanged();
|
|
1090
1288
|
}
|
|
1091
1289
|
}
|
|
1092
|
-
getFloatingPaneZIndex(t) {
|
|
1093
|
-
const e = this.floatingLayouts[t];
|
|
1094
|
-
return e && typeof e.zIndex == "number" && Number.isFinite(e.zIndex) ? e.zIndex : 10 + t;
|
|
1095
|
-
}
|
|
1096
1290
|
getHostSize() {
|
|
1097
1291
|
return {
|
|
1098
1292
|
width: this.rootEl.clientWidth,
|
|
1099
1293
|
height: this.rootEl.clientHeight
|
|
1100
1294
|
};
|
|
1101
1295
|
}
|
|
1102
|
-
clampBoundsToHost(t, e) {
|
|
1103
|
-
if (e.width <= 0 || e.height <= 0) return t;
|
|
1104
|
-
const i = Math.min(t.width, e.width), o = Math.min(t.height, e.height), n = Math.min(Math.max(t.left, 0), e.width - i), r = Math.min(Math.max(t.top, 0), e.height - o);
|
|
1105
|
-
return { left: n, top: r, width: i, height: o };
|
|
1106
|
-
}
|
|
1107
1296
|
// Re-clamp existing floating-pane wrappers in place. Avoids the full
|
|
1108
1297
|
// renderFloatingPanes() teardown (which would release pointer capture if
|
|
1109
1298
|
// a user is mid-drag when the host resizes).
|
|
@@ -1111,26 +1300,26 @@ class P extends A {
|
|
|
1111
1300
|
if (!this.floatingLayerEl) return;
|
|
1112
1301
|
const t = this.getHostSize();
|
|
1113
1302
|
this.floatingLayouts.forEach((e, i) => {
|
|
1114
|
-
const
|
|
1115
|
-
if (!
|
|
1116
|
-
const { left:
|
|
1117
|
-
|
|
1303
|
+
const n = this.floatingLayerEl.children[i];
|
|
1304
|
+
if (!n) return;
|
|
1305
|
+
const { left: o, top: r, width: d, height: s } = R(e.bounds, t);
|
|
1306
|
+
n.style.left = `${o}px`, n.style.top = `${r}px`, n.style.width = `${d}px`, n.style.height = `${s}px`, n.style.minWidth = "0", n.style.minHeight = "0";
|
|
1118
1307
|
});
|
|
1119
1308
|
}
|
|
1120
1309
|
promoteFloatingPane(t, e) {
|
|
1121
1310
|
const i = this.floatingLayouts[t];
|
|
1122
1311
|
if (!i)
|
|
1123
1312
|
return;
|
|
1124
|
-
const
|
|
1125
|
-
if (!
|
|
1313
|
+
const n = this.floatingLayouts.reduce((r, d, s) => {
|
|
1314
|
+
if (!d)
|
|
1126
1315
|
return r;
|
|
1127
|
-
const
|
|
1128
|
-
return Math.max(r,
|
|
1129
|
-
}, 0),
|
|
1130
|
-
i.zIndex =
|
|
1316
|
+
const c = s === t ? Number.NEGATIVE_INFINITY : N(this.floatingLayouts[s], s);
|
|
1317
|
+
return Math.max(r, c);
|
|
1318
|
+
}, 0), o = Math.max(n + 2, 12);
|
|
1319
|
+
i.zIndex = o, e.style.zIndex = String(o);
|
|
1131
1320
|
}
|
|
1132
1321
|
getFloatingWrapper(t) {
|
|
1133
|
-
const e = `.dock-floating[data-path="${
|
|
1322
|
+
const e = `.dock-floating[data-path="${w({
|
|
1134
1323
|
type: "floating",
|
|
1135
1324
|
index: t,
|
|
1136
1325
|
segments: []
|
|
@@ -1153,87 +1342,87 @@ class P extends A {
|
|
|
1153
1342
|
const e = "Floating Pane";
|
|
1154
1343
|
if (!t || !t.root)
|
|
1155
1344
|
return e;
|
|
1156
|
-
const i = t.activePane ??
|
|
1345
|
+
const i = t.activePane ?? E(t.root);
|
|
1157
1346
|
return i ? this.titles[i] ?? i ?? e : e;
|
|
1158
1347
|
}
|
|
1159
1348
|
updateFloatingWindowTitle(t) {
|
|
1160
1349
|
const e = this.floatingLayouts[t];
|
|
1161
1350
|
if (!e)
|
|
1162
1351
|
return;
|
|
1163
|
-
const i = `.dock-floating[data-path="${
|
|
1352
|
+
const i = `.dock-floating[data-path="${w({
|
|
1164
1353
|
type: "floating",
|
|
1165
1354
|
index: t,
|
|
1166
1355
|
segments: []
|
|
1167
|
-
})}"]`,
|
|
1168
|
-
if (!
|
|
1356
|
+
})}"]`, n = this.floatingLayerEl.querySelector(i);
|
|
1357
|
+
if (!n)
|
|
1169
1358
|
return;
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1359
|
+
const o = n.querySelector(".dock-floating__title");
|
|
1360
|
+
o && (o.textContent = this.getFloatingWindowTitle(e));
|
|
1172
1361
|
}
|
|
1173
1362
|
renderSplit(t, e, i) {
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1177
|
-
t.children.forEach((
|
|
1178
|
-
|
|
1363
|
+
const n = this.documentRef.createElement("mp-splitter");
|
|
1364
|
+
n.classList.add("dock-split"), n.dataset.direction = t.direction, n.dataset.path = e.join("/"), n.setAttribute("orientation", t.direction);
|
|
1365
|
+
const o = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
|
|
1366
|
+
t.children.forEach((d, s) => {
|
|
1367
|
+
n.appendChild(this.renderNode(d, [...e, s], i));
|
|
1179
1368
|
});
|
|
1180
1369
|
const r = Array.isArray(t.sizes) ? t.sizes : [];
|
|
1181
1370
|
return r.length > 0 && requestAnimationFrame(() => {
|
|
1182
|
-
const
|
|
1183
|
-
if (
|
|
1184
|
-
const
|
|
1185
|
-
if (!Number.isFinite(
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
}),
|
|
1189
|
-
if (
|
|
1190
|
-
const
|
|
1191
|
-
if (!Array.isArray(
|
|
1192
|
-
const
|
|
1193
|
-
if (!
|
|
1194
|
-
const
|
|
1195
|
-
(
|
|
1371
|
+
const d = r.reduce((l, u) => l + Math.max(u, 0), 0);
|
|
1372
|
+
if (d <= 0) return;
|
|
1373
|
+
const s = t.direction === "horizontal" ? n.getBoundingClientRect().width : n.getBoundingClientRect().height;
|
|
1374
|
+
if (!Number.isFinite(s) || s <= 0) return;
|
|
1375
|
+
const c = r.map((l) => Math.max(l, 0) / d * s);
|
|
1376
|
+
n.setPanelSizes?.(c), requestAnimationFrame(() => this.scheduleRenderIntersectionHandles());
|
|
1377
|
+
}), n.addEventListener("resize-end", (d) => {
|
|
1378
|
+
if (d.target !== n) return;
|
|
1379
|
+
const s = d.detail;
|
|
1380
|
+
if (!Array.isArray(s?.sizes) || s.sizes.length === 0) return;
|
|
1381
|
+
const c = this.resolveSplitNode(o);
|
|
1382
|
+
if (!c) return;
|
|
1383
|
+
const l = (c.sizes ?? []).reduce(
|
|
1384
|
+
(p, g) => p + Math.max(g, 0),
|
|
1196
1385
|
0
|
|
1197
|
-
),
|
|
1198
|
-
|
|
1199
|
-
(
|
|
1386
|
+
), u = s.sizes.reduce((p, g) => p + Math.max(g, 0), 0), h = l > 0 ? l : s.sizes.length;
|
|
1387
|
+
u > 0 && (c.sizes = s.sizes.map(
|
|
1388
|
+
(p) => Math.max(p, 0) / u * h
|
|
1200
1389
|
), this.dispatchLayoutChanged());
|
|
1201
|
-
}),
|
|
1390
|
+
}), n;
|
|
1202
1391
|
}
|
|
1203
1392
|
renderStack(t, e, i) {
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1393
|
+
const n = this.documentRef.createElement("mp-tab-control");
|
|
1394
|
+
n.classList.add("dock-stack"), n.setAttribute("select-first-tab", "false"), n.setAttribute("border", "top");
|
|
1395
|
+
const o = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
|
|
1396
|
+
n.dataset.path = w(o);
|
|
1208
1397
|
const r = Array.from(new Set(t.panes));
|
|
1209
1398
|
if (r.length === 0) {
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1212
|
-
const
|
|
1213
|
-
return
|
|
1399
|
+
const l = this.documentRef.createElement("span");
|
|
1400
|
+
l.setAttribute("slot", "__empty__-header"), l.textContent = "(empty)";
|
|
1401
|
+
const u = this.documentRef.createElement("div");
|
|
1402
|
+
return u.setAttribute("slot", "__empty__-content"), u.classList.add("dock-stack__pane"), u.textContent = "No panes configured", n.append(l, u), n.setAttribute("active-tab", "__empty__"), n;
|
|
1214
1403
|
}
|
|
1215
|
-
const
|
|
1216
|
-
return r.forEach((
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
this.captureTabDragMetrics(
|
|
1404
|
+
const d = r.includes(t.activePane ?? "") ? t.activePane : r[0], s = e.length ? e.join("-") : "root", c = typeof i == "number" ? `f${i}-${s}` : s;
|
|
1405
|
+
return r.forEach((l) => {
|
|
1406
|
+
const u = l.replace(/[^a-zA-Z0-9_-]/g, "-"), h = u.length > 0 ? u : "pane", p = `${this.instanceId}-tab-${c}-${h}`, g = `${this.instanceId}-panel-${c}-${h}`, m = this.documentRef.createElement("span");
|
|
1407
|
+
m.setAttribute("slot", `${p}-header`), m.classList.add("dock-tab"), m.dataset.pane = l, m.dataset.tabId = p, m.textContent = this.titles[l] ?? l, m.addEventListener("pointerdown", (b) => {
|
|
1408
|
+
this.captureTabDragMetrics(b, n), this.armPaneDragGesture(b, this.clonePath(o), l, n), b.stopPropagation();
|
|
1220
1409
|
});
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1225
|
-
}),
|
|
1226
|
-
const
|
|
1227
|
-
`:scope > [data-tab-id="${
|
|
1410
|
+
const f = this.documentRef.createElement("div");
|
|
1411
|
+
f.setAttribute("slot", `${p}-content`), f.classList.add("dock-stack__pane"), f.dataset.pane = l, f.dataset.tabId = p, f.id = g;
|
|
1412
|
+
const y = this.documentRef.createElement("slot");
|
|
1413
|
+
y.name = l, f.appendChild(y), n.append(m, f), l === d && n.setAttribute("active-tab", p);
|
|
1414
|
+
}), n.dataset.activePane = d, n.addEventListener("tab-activate", (l) => {
|
|
1415
|
+
const u = l.detail, p = n.querySelector(
|
|
1416
|
+
`:scope > [data-tab-id="${u.tabId}"]`
|
|
1228
1417
|
)?.dataset.pane;
|
|
1229
|
-
|
|
1418
|
+
p && (this.activatePane(n, p, this.clonePath(o)), this.dispatchEvent(
|
|
1230
1419
|
new CustomEvent("dock-pane-activated", {
|
|
1231
|
-
detail: { pane:
|
|
1420
|
+
detail: { pane: p },
|
|
1232
1421
|
bubbles: !0,
|
|
1233
1422
|
composed: !0
|
|
1234
1423
|
})
|
|
1235
1424
|
));
|
|
1236
|
-
}),
|
|
1425
|
+
}), n;
|
|
1237
1426
|
}
|
|
1238
1427
|
/**
|
|
1239
1428
|
* Returns the strip (`.tsc`) element inside an `<mp-tab-control>`'s shadow
|
|
@@ -1311,14 +1500,14 @@ class P extends A {
|
|
|
1311
1500
|
this.pendingTabDragMetrics = null;
|
|
1312
1501
|
return;
|
|
1313
1502
|
}
|
|
1314
|
-
const i = this.getBoundingClientRect(),
|
|
1503
|
+
const i = this.getBoundingClientRect(), n = e.getBoundingClientRect(), o = t.clientX - n.left, r = t.clientY - n.top, d = n.left - i.left, s = n.top - i.top, c = Number.isFinite(n.width) ? n.width : 0, l = Number.isFinite(n.height) ? n.height : 0;
|
|
1315
1504
|
this.pendingTabDragMetrics = {
|
|
1316
|
-
pointerOffsetX:
|
|
1505
|
+
pointerOffsetX: o,
|
|
1317
1506
|
pointerOffsetY: r,
|
|
1318
|
-
left:
|
|
1319
|
-
top:
|
|
1320
|
-
width:
|
|
1321
|
-
height:
|
|
1507
|
+
left: d,
|
|
1508
|
+
top: s,
|
|
1509
|
+
width: c,
|
|
1510
|
+
height: l,
|
|
1322
1511
|
startClientX: t.clientX,
|
|
1323
1512
|
startClientY: t.clientY
|
|
1324
1513
|
};
|
|
@@ -1334,26 +1523,26 @@ class P extends A {
|
|
|
1334
1523
|
* Once armed, both paths converge on {@link beginPaneDrag}. All listeners
|
|
1335
1524
|
* self-clean on resolve so the gesture stays scoped to a single pointerdown.
|
|
1336
1525
|
*/
|
|
1337
|
-
armPaneDragGesture(t, e, i,
|
|
1526
|
+
armPaneDragGesture(t, e, i, n) {
|
|
1338
1527
|
if (t.pointerType === "touch") {
|
|
1339
|
-
this.armPaneDragGestureTouch(t, e, i,
|
|
1528
|
+
this.armPaneDragGestureTouch(t, e, i, n);
|
|
1340
1529
|
return;
|
|
1341
1530
|
}
|
|
1342
1531
|
if (t.pointerType === "mouse" && t.button !== 0) return;
|
|
1343
|
-
const
|
|
1344
|
-
if (!
|
|
1345
|
-
const r = t.clientX,
|
|
1346
|
-
let
|
|
1347
|
-
const
|
|
1348
|
-
|
|
1532
|
+
const o = this.windowRef;
|
|
1533
|
+
if (!o) return;
|
|
1534
|
+
const r = t.clientX, d = t.clientY, s = t.pointerId, c = 5;
|
|
1535
|
+
let l = !1;
|
|
1536
|
+
const u = () => {
|
|
1537
|
+
l = !0, o.removeEventListener("pointermove", h, !0), o.removeEventListener("pointerup", p, !0), o.removeEventListener("pointercancel", p, !0);
|
|
1349
1538
|
}, h = (g) => {
|
|
1350
|
-
if (
|
|
1351
|
-
const
|
|
1352
|
-
Math.hypot(
|
|
1353
|
-
},
|
|
1354
|
-
|
|
1539
|
+
if (l || g.pointerId !== s) return;
|
|
1540
|
+
const m = g.clientX - r, f = g.clientY - d;
|
|
1541
|
+
Math.hypot(m, f) < c || (u(), this.beginPaneDrag(g, e, i, n));
|
|
1542
|
+
}, p = (g) => {
|
|
1543
|
+
l || g.pointerId !== s || (u(), this.clearPendingTabDragMetrics());
|
|
1355
1544
|
};
|
|
1356
|
-
|
|
1545
|
+
o.addEventListener("pointermove", h, !0), o.addEventListener("pointerup", p, !0), o.addEventListener("pointercancel", p, !0);
|
|
1357
1546
|
}
|
|
1358
1547
|
/**
|
|
1359
1548
|
* Touch-specific gesture arming. With `.dock-tab` set to `touch-action:
|
|
@@ -1376,41 +1565,41 @@ class P extends A {
|
|
|
1376
1565
|
* promote it, so first move after a long-press fires pointercancel and
|
|
1377
1566
|
* strands the panel. JS-driven scroll is the only model that holds.
|
|
1378
1567
|
*/
|
|
1379
|
-
armPaneDragGestureTouch(t, e, i,
|
|
1380
|
-
const
|
|
1381
|
-
if (!
|
|
1382
|
-
const r = t.clientX,
|
|
1383
|
-
let
|
|
1384
|
-
const
|
|
1568
|
+
armPaneDragGestureTouch(t, e, i, n) {
|
|
1569
|
+
const o = this.windowRef;
|
|
1570
|
+
if (!o) return;
|
|
1571
|
+
const r = t.clientX, d = t.clientY, s = t.pointerId;
|
|
1572
|
+
let c = r, l = d, u = r, h = !1, p = !1, g = !1;
|
|
1573
|
+
const m = t.currentTarget instanceof HTMLElement ? t.currentTarget : t.target instanceof HTMLElement ? t.target.closest(".dock-tab") : null, f = n ? this.getStackStripEl(n)?.querySelector(
|
|
1385
1574
|
"ul.nav.nav-tabs"
|
|
1386
|
-
) ?? null : null,
|
|
1387
|
-
h || (h = !0,
|
|
1388
|
-
},
|
|
1389
|
-
if (h ||
|
|
1390
|
-
if (
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1575
|
+
) ?? null : null, y = () => {
|
|
1576
|
+
h || (h = !0, o.clearTimeout(P), o.clearTimeout(z), o.removeEventListener("pointermove", b, !0), o.removeEventListener("pointerup", k, !0), o.removeEventListener("pointercancel", D, !0), g && m && m.removeAttribute("data-pressing"));
|
|
1577
|
+
}, b = (v) => {
|
|
1578
|
+
if (h || v.pointerId !== s) return;
|
|
1579
|
+
if (p) {
|
|
1580
|
+
const K = v.clientX - u;
|
|
1581
|
+
u = v.clientX, f && (f.scrollLeft -= K);
|
|
1393
1582
|
return;
|
|
1394
1583
|
}
|
|
1395
|
-
|
|
1396
|
-
const
|
|
1397
|
-
if (Math.hypot(
|
|
1584
|
+
c = v.clientX, l = v.clientY;
|
|
1585
|
+
const F = v.clientX - r, $ = v.clientY - d;
|
|
1586
|
+
if (Math.hypot(F, $) <= L.TOUCH_LONG_PRESS_SLOP_PX)
|
|
1398
1587
|
return;
|
|
1399
|
-
const
|
|
1400
|
-
if (Math.abs(
|
|
1401
|
-
|
|
1588
|
+
const Z = !!f && f.scrollWidth > f.clientWidth;
|
|
1589
|
+
if (Math.abs(F) > Math.abs($) && Z) {
|
|
1590
|
+
o.clearTimeout(P), o.clearTimeout(z), g && m && (m.removeAttribute("data-pressing"), g = !1), p = !0, u = v.clientX, f.scrollLeft -= F, this.clearPendingTabDragMetrics();
|
|
1402
1591
|
return;
|
|
1403
1592
|
}
|
|
1404
|
-
|
|
1405
|
-
},
|
|
1406
|
-
h ||
|
|
1407
|
-
},
|
|
1408
|
-
h ||
|
|
1409
|
-
},
|
|
1593
|
+
y(), this.clearPendingTabDragMetrics();
|
|
1594
|
+
}, k = (v) => {
|
|
1595
|
+
h || v.pointerId !== s || (y(), this.clearPendingTabDragMetrics());
|
|
1596
|
+
}, D = (v) => {
|
|
1597
|
+
h || v.pointerId !== s || (y(), this.clearPendingTabDragMetrics());
|
|
1598
|
+
}, P = o.setTimeout(() => {
|
|
1410
1599
|
if (h) return;
|
|
1411
|
-
|
|
1600
|
+
y();
|
|
1412
1601
|
try {
|
|
1413
|
-
this.setPointerCapture(
|
|
1602
|
+
this.setPointerCapture(s);
|
|
1414
1603
|
} catch {
|
|
1415
1604
|
}
|
|
1416
1605
|
if (typeof navigator < "u" && typeof navigator.vibrate == "function")
|
|
@@ -1418,79 +1607,79 @@ class P extends A {
|
|
|
1418
1607
|
navigator.vibrate(10);
|
|
1419
1608
|
} catch {
|
|
1420
1609
|
}
|
|
1421
|
-
const
|
|
1422
|
-
pointerId:
|
|
1610
|
+
const v = new PointerEvent("pointermove", {
|
|
1611
|
+
pointerId: s,
|
|
1423
1612
|
pointerType: "touch",
|
|
1424
1613
|
isPrimary: !0,
|
|
1425
|
-
clientX:
|
|
1426
|
-
clientY:
|
|
1614
|
+
clientX: c,
|
|
1615
|
+
clientY: l,
|
|
1427
1616
|
bubbles: !1,
|
|
1428
1617
|
cancelable: !1
|
|
1429
1618
|
});
|
|
1430
|
-
this.beginPaneDrag(
|
|
1431
|
-
},
|
|
1432
|
-
h || !
|
|
1433
|
-
},
|
|
1434
|
-
|
|
1619
|
+
this.beginPaneDrag(v, e, i, n);
|
|
1620
|
+
}, L.TOUCH_LONG_PRESS_MS), z = o.setTimeout(() => {
|
|
1621
|
+
h || !m || (g = !0, m.setAttribute("data-pressing", "true"));
|
|
1622
|
+
}, L.TOUCH_PRESS_FEEDBACK_DELAY_MS);
|
|
1623
|
+
o.addEventListener("pointermove", b, !0), o.addEventListener("pointerup", k, !0), o.addEventListener("pointercancel", D, !0);
|
|
1435
1624
|
}
|
|
1436
|
-
beginPaneDrag(t, e, i,
|
|
1625
|
+
beginPaneDrag(t, e, i, n) {
|
|
1437
1626
|
const {
|
|
1438
|
-
path:
|
|
1627
|
+
path: o,
|
|
1439
1628
|
floatingIndex: r,
|
|
1440
|
-
pointerOffsetX:
|
|
1441
|
-
pointerOffsetY:
|
|
1442
|
-
} = this.preparePaneDragSource(e, i,
|
|
1629
|
+
pointerOffsetX: d,
|
|
1630
|
+
pointerOffsetY: s
|
|
1631
|
+
} = this.preparePaneDragSource(e, i, n, t), c = n ? this.getStackStripEl(n) : null, l = c ? c.getBoundingClientRect() : null, u = l ? { left: l.left, top: l.top, right: l.right, bottom: l.bottom } : null, h = this.pendingTabDragMetrics;
|
|
1443
1632
|
if (this.dragState = {
|
|
1444
1633
|
pane: i,
|
|
1445
|
-
sourcePath: this.clonePath(
|
|
1634
|
+
sourcePath: this.clonePath(o),
|
|
1446
1635
|
floatingIndex: r,
|
|
1447
|
-
pointerOffsetX:
|
|
1448
|
-
pointerOffsetY:
|
|
1636
|
+
pointerOffsetX: d,
|
|
1637
|
+
pointerOffsetY: s,
|
|
1449
1638
|
dropHandled: !1,
|
|
1450
|
-
sourceStackEl:
|
|
1451
|
-
sourceHeaderBounds:
|
|
1639
|
+
sourceStackEl: n,
|
|
1640
|
+
sourceHeaderBounds: u,
|
|
1452
1641
|
startClientX: h && Number.isFinite(h.startClientX) ? h.startClientX : t.clientX,
|
|
1453
1642
|
startClientY: h && Number.isFinite(h.startClientY) ? h.startClientY : t.clientY
|
|
1454
1643
|
}, this.lastDragPointerPosition = {
|
|
1455
1644
|
x: this.dragState.startClientX,
|
|
1456
1645
|
y: this.dragState.startClientY
|
|
1457
1646
|
}, this.updateDraggedFloatingPositionFromPoint(t.clientX, t.clientY), this.startDragPointerTracking(), this.markDraggedFloatingWrapper(), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
|
|
1458
|
-
const
|
|
1459
|
-
if (
|
|
1647
|
+
const p = this.resolveStackLocation(this.dragState.sourcePath);
|
|
1648
|
+
if (p && Array.isArray(p.node.panes) && p.node.panes.length === 1) {
|
|
1460
1649
|
let g = !1;
|
|
1461
|
-
if (
|
|
1650
|
+
if (p.context === "docked")
|
|
1462
1651
|
g = !0;
|
|
1463
|
-
else if (
|
|
1464
|
-
const
|
|
1465
|
-
g = (
|
|
1652
|
+
else if (p.context === "floating") {
|
|
1653
|
+
const m = this.floatingLayouts[p.index];
|
|
1654
|
+
g = (m && m.root ? this.countPanesInTree(m.root) : 0) > 1;
|
|
1466
1655
|
}
|
|
1467
1656
|
g && this.convertPendingTabDragToFloating(t.clientX, t.clientY);
|
|
1468
1657
|
}
|
|
1469
1658
|
}
|
|
1470
1659
|
}
|
|
1471
|
-
preparePaneDragSource(t, e, i,
|
|
1472
|
-
const
|
|
1473
|
-
if (!
|
|
1660
|
+
preparePaneDragSource(t, e, i, n) {
|
|
1661
|
+
const o = this.resolveStackLocation(t);
|
|
1662
|
+
if (!o || !o.node.panes.includes(e))
|
|
1474
1663
|
return {
|
|
1475
1664
|
path: t,
|
|
1476
1665
|
floatingIndex: null,
|
|
1477
1666
|
pointerOffsetX: 0,
|
|
1478
1667
|
pointerOffsetY: 0
|
|
1479
1668
|
};
|
|
1480
|
-
const r = this.pendingTabDragMetrics,
|
|
1669
|
+
const r = this.pendingTabDragMetrics, d = !!i && Array.from(i.querySelectorAll(".dock-tab")).some(
|
|
1481
1670
|
(g) => g.dataset.pane && g.dataset.pane !== e
|
|
1482
|
-
),
|
|
1483
|
-
if (
|
|
1484
|
-
if (
|
|
1485
|
-
|
|
1486
|
-
const g = this.getFloatingWrapper(
|
|
1487
|
-
g && this.promoteFloatingPane(
|
|
1488
|
-
const
|
|
1671
|
+
), s = o.node.panes.some((g) => g !== e), c = o.context === "floating" ? this.floatingLayouts[o.index] : null, l = c && c.root ? this.countPanesInTree(c.root) : s ? 2 : 1;
|
|
1672
|
+
if (o.context === "floating" && !!c && !s && !d && l <= 1) {
|
|
1673
|
+
if (c) {
|
|
1674
|
+
c.activePane = e, this.updateFloatingWindowTitle(o.index);
|
|
1675
|
+
const g = this.getFloatingWrapper(o.index);
|
|
1676
|
+
g && this.promoteFloatingPane(o.index, g);
|
|
1677
|
+
const m = this.getBoundingClientRect(), f = r && Number.isFinite(r.pointerOffsetX) && Number.isFinite(r.left) && Number.isFinite(c.bounds.left) ? r.pointerOffsetX + (r.left - c.bounds.left) : Number.isFinite(n.clientX) && Number.isFinite(c.bounds.left) ? n.clientX - m.left - c.bounds.left : c.bounds.width / 2, y = r && Number.isFinite(r.pointerOffsetY) && Number.isFinite(r.top) && Number.isFinite(c.bounds.top) ? r.pointerOffsetY + (r.top - c.bounds.top) : Number.isFinite(n.clientY) && Number.isFinite(c.bounds.top) ? n.clientY - m.top - c.bounds.top : c.bounds.height / 2;
|
|
1489
1678
|
return {
|
|
1490
1679
|
path: t,
|
|
1491
|
-
floatingIndex:
|
|
1492
|
-
pointerOffsetX:
|
|
1493
|
-
pointerOffsetY:
|
|
1680
|
+
floatingIndex: o.index,
|
|
1681
|
+
pointerOffsetX: f,
|
|
1682
|
+
pointerOffsetY: y
|
|
1494
1683
|
};
|
|
1495
1684
|
}
|
|
1496
1685
|
return {
|
|
@@ -1500,12 +1689,12 @@ class P extends A {
|
|
|
1500
1689
|
pointerOffsetY: 0
|
|
1501
1690
|
};
|
|
1502
1691
|
}
|
|
1503
|
-
const h = r && Number.isFinite(r.pointerOffsetX) ? r.pointerOffsetX : 0,
|
|
1692
|
+
const h = r && Number.isFinite(r.pointerOffsetX) ? r.pointerOffsetX : 0, p = r && Number.isFinite(r.pointerOffsetY) ? r.pointerOffsetY : 0;
|
|
1504
1693
|
return {
|
|
1505
1694
|
path: t,
|
|
1506
1695
|
floatingIndex: -1,
|
|
1507
1696
|
pointerOffsetX: h,
|
|
1508
|
-
pointerOffsetY:
|
|
1697
|
+
pointerOffsetY: p
|
|
1509
1698
|
};
|
|
1510
1699
|
}
|
|
1511
1700
|
endPaneDrag() {
|
|
@@ -1517,42 +1706,42 @@ class P extends A {
|
|
|
1517
1706
|
if (!this.dragState || !Number.isFinite(t) || !Number.isFinite(e))
|
|
1518
1707
|
return;
|
|
1519
1708
|
if (this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
|
|
1520
|
-
const
|
|
1521
|
-
let
|
|
1522
|
-
const
|
|
1523
|
-
|
|
1709
|
+
const u = this.dragState.sourceHeaderBounds, h = this.dragState.startClientX ?? t, p = this.dragState.startClientY ?? e, g = Math.hypot(t - h, e - p), m = 8;
|
|
1710
|
+
let f = !0;
|
|
1711
|
+
const y = u ? J(u, t, e) : !0, b = this.isPointerOverSourceHeader(t, e);
|
|
1712
|
+
f = y || b, !f && g > m && this.convertPendingTabDragToFloating(t, e);
|
|
1524
1713
|
}
|
|
1525
1714
|
this.updatePaneDragDropTargetFromPoint(t, e);
|
|
1526
|
-
const { floatingIndex: i, pointerOffsetX:
|
|
1715
|
+
const { floatingIndex: i, pointerOffsetX: n, pointerOffsetY: o } = this.dragState;
|
|
1527
1716
|
if (i === null || i < 0)
|
|
1528
1717
|
return;
|
|
1529
1718
|
const r = this.floatingLayouts[i];
|
|
1530
1719
|
if (!r)
|
|
1531
1720
|
return;
|
|
1532
|
-
const
|
|
1533
|
-
r.bounds.left =
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1721
|
+
const d = this.getBoundingClientRect(), s = t - d.left - n, c = e - d.top - o;
|
|
1722
|
+
r.bounds.left = s, r.bounds.top = c;
|
|
1723
|
+
const l = this.getFloatingWrapper(i);
|
|
1724
|
+
l && (l.style.left = `${s}px`, l.style.top = `${c}px`);
|
|
1536
1725
|
}
|
|
1537
1726
|
updatePaneDragDropTargetFromPoint(t, e) {
|
|
1538
1727
|
if (!this.dragState)
|
|
1539
1728
|
return;
|
|
1540
|
-
const i = this.findStackAtPoint(t, e),
|
|
1541
|
-
if (!i || !
|
|
1729
|
+
const i = this.findStackAtPoint(t, e), n = i ? S(i.dataset.path) : null;
|
|
1730
|
+
if (!i || !n) {
|
|
1542
1731
|
this.dropJoystick.dataset.visible !== "true" && this.hideDropIndicator(), this.clearHeaderDragPlaceholder();
|
|
1543
1732
|
return;
|
|
1544
1733
|
}
|
|
1545
|
-
if (this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null)), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 &&
|
|
1546
|
-
const
|
|
1547
|
-
if (
|
|
1734
|
+
if (this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null)), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && n && O(n, this.dragState.sourcePath)) {
|
|
1735
|
+
const d = !!this.dragState.sourceHeaderBounds && J(this.dragState.sourceHeaderBounds, t, e), s = this.isPointerOverSourceHeader(t, e);
|
|
1736
|
+
if (d || s) {
|
|
1548
1737
|
this.ensureHeaderDragPlaceholder(i, this.dragState.pane);
|
|
1549
|
-
const
|
|
1550
|
-
this.dragState.liveReorderIndex !==
|
|
1738
|
+
const c = this.computeHeaderInsertIndex(i, t);
|
|
1739
|
+
this.dragState.liveReorderIndex !== c && (this.updateHeaderDragPlaceholderPosition(i, c), this.dragState.liveReorderIndex = c), this.hideDropIndicator();
|
|
1551
1740
|
return;
|
|
1552
1741
|
}
|
|
1553
1742
|
}
|
|
1554
1743
|
this.clearHeaderDragPlaceholder();
|
|
1555
|
-
const
|
|
1744
|
+
const o = this.findDropZoneByPoint(t, e), r = this.computeDropZone(i, { clientX: t, clientY: e }, o);
|
|
1556
1745
|
this.showDropIndicator(i, r);
|
|
1557
1746
|
}
|
|
1558
1747
|
// Returns true when the pointer is currently over the source stack's header (tab strip).
|
|
@@ -1563,15 +1752,12 @@ class P extends A {
|
|
|
1563
1752
|
const i = this.dragState;
|
|
1564
1753
|
if (!i)
|
|
1565
1754
|
return !1;
|
|
1566
|
-
const
|
|
1567
|
-
if (!
|
|
1755
|
+
const n = i.sourceStackEl ?? null, o = n ? this.getStackStripEl(n) : null;
|
|
1756
|
+
if (!o)
|
|
1568
1757
|
return !0;
|
|
1569
|
-
const r =
|
|
1758
|
+
const r = o.getBoundingClientRect();
|
|
1570
1759
|
return t >= r.left && t <= r.right && e >= r.top && e <= r.bottom;
|
|
1571
1760
|
}
|
|
1572
|
-
isPointWithinBounds(t, e, i) {
|
|
1573
|
-
return e >= t.left && e <= t.right && i >= t.top && i <= t.bottom;
|
|
1574
|
-
}
|
|
1575
1761
|
// Ensure a placeholder tab exists during in-header drag and hide the real dragged tab visually.
|
|
1576
1762
|
// Operates on the mp-tab-control stack: the dragged content div gets `data-hidden`
|
|
1577
1763
|
// (mp-tab-control then skips its tab in the strip), and a placeholder header+content
|
|
@@ -1582,19 +1768,19 @@ class P extends A {
|
|
|
1582
1768
|
return;
|
|
1583
1769
|
const i = t.querySelector(
|
|
1584
1770
|
`:scope > .dock-tab[data-pane="${CSS.escape(e)}"]`
|
|
1585
|
-
),
|
|
1771
|
+
), n = t.querySelector(
|
|
1586
1772
|
`:scope > .dock-stack__pane[data-pane="${CSS.escape(e)}"]`
|
|
1587
1773
|
);
|
|
1588
|
-
if (!i || !
|
|
1589
|
-
const
|
|
1774
|
+
if (!i || !n) return;
|
|
1775
|
+
const o = this.windowRef ? this.windowRef.getComputedStyle(i) : globalThis.getComputedStyle(i), r = parseFloat(o.paddingLeft) + parseFloat(o.paddingRight), d = Math.max(
|
|
1590
1776
|
0,
|
|
1591
1777
|
i.offsetWidth - r
|
|
1592
1778
|
);
|
|
1593
|
-
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1779
|
+
n.setAttribute("data-hidden", "");
|
|
1780
|
+
const s = "__dock-placeholder__", c = this.documentRef.createElement("span");
|
|
1781
|
+
c.setAttribute("slot", `${s}-header`), c.classList.add("dock-tab"), c.dataset.placeholder = "true", c.dataset.tabId = s, c.setAttribute("aria-hidden", "true"), c.textContent = i.textContent, c.style.display = "inline-block", c.style.minWidth = `${d}px`, c.style.opacity = "0.5";
|
|
1782
|
+
const l = this.documentRef.createElement("div");
|
|
1783
|
+
l.setAttribute("slot", `${s}-content`), l.classList.add("dock-stack__pane"), l.dataset.placeholder = "true", t.insertBefore(c, i), t.insertBefore(l, n), this.dragState && (this.dragState.placeholderHeader = t, this.dragState.placeholderEl = c);
|
|
1598
1784
|
}
|
|
1599
1785
|
// Move the placeholder to the computed target index within the strip.
|
|
1600
1786
|
// We reorder light-DOM children (header span + matching content div); the
|
|
@@ -1603,16 +1789,16 @@ class P extends A {
|
|
|
1603
1789
|
if (t.tagName !== "MP-TAB-CONTROL") return;
|
|
1604
1790
|
const i = this.dragState?.placeholderEl ?? null;
|
|
1605
1791
|
if (!i) return;
|
|
1606
|
-
const
|
|
1792
|
+
const n = this.dragState?.pane ?? null, o = Array.from(
|
|
1607
1793
|
t.querySelectorAll(":scope > .dock-tab")
|
|
1608
1794
|
).filter(
|
|
1609
|
-
(
|
|
1610
|
-
), r = Math.max(0, Math.min(e,
|
|
1611
|
-
t.insertBefore(i,
|
|
1612
|
-
const
|
|
1795
|
+
(c) => c !== i && (!n || c.dataset.pane !== n)
|
|
1796
|
+
), r = Math.max(0, Math.min(e, o.length)), d = o[r] ?? null;
|
|
1797
|
+
t.insertBefore(i, d);
|
|
1798
|
+
const s = t.querySelector(
|
|
1613
1799
|
':scope > .dock-stack__pane[data-placeholder="true"]'
|
|
1614
1800
|
);
|
|
1615
|
-
|
|
1801
|
+
s && i.nextElementSibling !== s && t.insertBefore(s, i.nextElementSibling);
|
|
1616
1802
|
}
|
|
1617
1803
|
// Remove placeholder and restore the dragged tab's visibility.
|
|
1618
1804
|
clearHeaderDragPlaceholder() {
|
|
@@ -1661,28 +1847,28 @@ class P extends A {
|
|
|
1661
1847
|
if (i.floatingIndex !== null && i.floatingIndex >= 0)
|
|
1662
1848
|
return;
|
|
1663
1849
|
this.clearHeaderDragPlaceholder();
|
|
1664
|
-
const
|
|
1665
|
-
if (!
|
|
1850
|
+
const n = this.resolveStackLocation(i.sourcePath);
|
|
1851
|
+
if (!n)
|
|
1666
1852
|
return;
|
|
1667
|
-
const
|
|
1668
|
-
{ left:
|
|
1853
|
+
const o = i.pane, r = i.sourceStackEl ?? null, d = this.getBoundingClientRect(), s = r?.getBoundingClientRect() ?? null, c = this.pendingTabDragMetrics, l = 320, u = 240, h = c && Number.isFinite(c.width) && c.width > 0 ? c.width : s && Number.isFinite(s.width) ? s.width : l, p = c && Number.isFinite(c.height) && c.height > 0 ? c.height : s && Number.isFinite(s.height) ? s.height : u, g = 1, m = c && Number.isFinite(c.left) ? c.left - g : Number.isFinite(t) ? t - d.left - h / 2 : 0, f = c && Number.isFinite(c.top) ? c.top - g : Number.isFinite(e) ? e - d.top - p / 2 : 0, y = R(
|
|
1854
|
+
{ left: m, top: f, width: h, height: p },
|
|
1669
1855
|
this.getHostSize()
|
|
1670
|
-
),
|
|
1671
|
-
this.removePaneFromLocation(
|
|
1672
|
-
const
|
|
1673
|
-
bounds:
|
|
1856
|
+
), b = Number.isFinite(t) ? t - d.left - y.left : y.width / 2, k = Number.isFinite(e) ? e - d.top - y.top : y.height / 2;
|
|
1857
|
+
this.removePaneFromLocation(n, o);
|
|
1858
|
+
const P = {
|
|
1859
|
+
bounds: y,
|
|
1674
1860
|
root: {
|
|
1675
1861
|
kind: "stack",
|
|
1676
|
-
panes: [
|
|
1677
|
-
activePane:
|
|
1862
|
+
panes: [o],
|
|
1863
|
+
activePane: o
|
|
1678
1864
|
},
|
|
1679
|
-
activePane:
|
|
1865
|
+
activePane: o
|
|
1680
1866
|
};
|
|
1681
|
-
this.floatingLayouts.push(
|
|
1682
|
-
const
|
|
1867
|
+
this.floatingLayouts.push(P);
|
|
1868
|
+
const z = this.floatingLayouts.length - 1;
|
|
1683
1869
|
this.renderLayout();
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1870
|
+
const v = this.getFloatingWrapper(z);
|
|
1871
|
+
v && this.promoteFloatingPane(z, v), this.liveAnnouncer.announce(`Pane ${this.titles[o] ?? o} torn off into a floating window.`), i.sourcePath = { type: "floating", index: z, segments: [] }, i.floatingIndex = z, i.pointerOffsetX = b, i.pointerOffsetY = k, this.markDraggedFloatingWrapper(), this.dispatchLayoutChanged();
|
|
1686
1872
|
}
|
|
1687
1873
|
// Toggle data-dragging on the floating wrapper currently associated with
|
|
1688
1874
|
// the active pane drag (dragState.floatingIndex), if any. Used to make the
|
|
@@ -1709,54 +1895,52 @@ class P extends A {
|
|
|
1709
1895
|
const i = this.getStackTabButtons(t);
|
|
1710
1896
|
if (i.length === 0)
|
|
1711
1897
|
return 0;
|
|
1712
|
-
const
|
|
1898
|
+
const o = t.querySelector(
|
|
1713
1899
|
':scope > .dock-tab[data-placeholder="true"]'
|
|
1714
|
-
)?.dataset.tabId, r =
|
|
1715
|
-
let
|
|
1716
|
-
if (
|
|
1717
|
-
for (const
|
|
1718
|
-
if (
|
|
1719
|
-
|
|
1900
|
+
)?.dataset.tabId, r = o ? i.find((m) => m.id === `${o}-header-button`) ?? null : null, d = this.dragState?.pane ?? null;
|
|
1901
|
+
let s = null;
|
|
1902
|
+
if (d) {
|
|
1903
|
+
for (const m of Array.from(t.children))
|
|
1904
|
+
if (m instanceof HTMLElement && m.classList.contains("dock-tab") && !m.hasAttribute("data-placeholder") && m.dataset.pane === d) {
|
|
1905
|
+
s = m.dataset.tabId ?? null;
|
|
1720
1906
|
break;
|
|
1721
1907
|
}
|
|
1722
1908
|
}
|
|
1723
|
-
const
|
|
1724
|
-
(
|
|
1909
|
+
const c = s ? i.find((m) => m.id === `${s}-header-button`) ?? null : null, l = i.filter(
|
|
1910
|
+
(m) => m !== r && m !== c
|
|
1725
1911
|
);
|
|
1726
|
-
if (
|
|
1912
|
+
if (l.length === 0)
|
|
1727
1913
|
return 0;
|
|
1728
|
-
const
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
}
|
|
1734
|
-
return a.length;
|
|
1914
|
+
const u = r ? r.getBoundingClientRect() : null, p = !!u && Number.isFinite(u.width) && u.width > 0 && u ? u.left + u.width / 2 : null, g = l.map((m) => {
|
|
1915
|
+
const f = m.getBoundingClientRect();
|
|
1916
|
+
return f.left + f.width / 2;
|
|
1917
|
+
});
|
|
1918
|
+
return dt(g, e, p);
|
|
1735
1919
|
}
|
|
1736
1920
|
reorderPaneInLocationAtIndex(t, e, i) {
|
|
1737
|
-
const
|
|
1738
|
-
if (
|
|
1921
|
+
const n = t.node.panes, o = n.indexOf(e);
|
|
1922
|
+
if (o === -1)
|
|
1739
1923
|
return;
|
|
1740
|
-
const r = Math.max(0, Math.min(i,
|
|
1741
|
-
if (r !==
|
|
1742
|
-
const
|
|
1743
|
-
|
|
1924
|
+
const r = Math.max(0, Math.min(i, n.length - 1));
|
|
1925
|
+
if (r !== o && (n.splice(o, 1), n.splice(r, 0, e), t.node.activePane = e, t.context === "floating")) {
|
|
1926
|
+
const d = this.floatingLayouts[t.index];
|
|
1927
|
+
d && (d.activePane = e);
|
|
1744
1928
|
}
|
|
1745
1929
|
}
|
|
1746
1930
|
// Commit a drop using current pointer coordinates and joystick state
|
|
1747
1931
|
finalizeDropFromPoint(t, e) {
|
|
1748
1932
|
if (!this.dragState)
|
|
1749
1933
|
return;
|
|
1750
|
-
const i = this.findStackAtPoint(t, e),
|
|
1751
|
-
if (this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && i &&
|
|
1752
|
-
const h = this.resolveStackLocation(
|
|
1934
|
+
const i = this.findStackAtPoint(t, e), n = i ? S(i.dataset.path) : null, o = this.dropJoystick.dataset.visible === "true", r = S(this.dropJoystick.dataset.path), d = this.dropJoystickTarget, s = d ? S(d.dataset.path) : null, c = (o ? r ?? s : null) ?? n, l = this.dropJoystick.dataset.zone, u = this.isDropZone(l) ? l : i ? this.computeDropZone(i, { clientX: t, clientY: e }, null) : null;
|
|
1935
|
+
if (this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && i && c && n && O(n, this.dragState.sourcePath) && (!u || u === "center")) {
|
|
1936
|
+
const h = this.resolveStackLocation(c);
|
|
1753
1937
|
if (h) {
|
|
1754
|
-
const
|
|
1755
|
-
this.reorderPaneInLocationAtIndex(h, this.dragState.pane,
|
|
1938
|
+
const p = this.computeHeaderInsertIndex(i, t);
|
|
1939
|
+
this.reorderPaneInLocationAtIndex(h, this.dragState.pane, p), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState.dropHandled = !0;
|
|
1756
1940
|
return;
|
|
1757
1941
|
}
|
|
1758
1942
|
}
|
|
1759
|
-
|
|
1943
|
+
c && this.isDropZone(u) && (this.handleDrop(c, u), this.dragState.dropHandled = !0);
|
|
1760
1944
|
}
|
|
1761
1945
|
clearPendingDragEndTimeout() {
|
|
1762
1946
|
if (this.pendingDragEndTimeout !== null) {
|
|
@@ -1779,107 +1963,80 @@ class P extends A {
|
|
|
1779
1963
|
handleDrop(t, e) {
|
|
1780
1964
|
if (!this.dragState || !t)
|
|
1781
1965
|
return;
|
|
1782
|
-
const { pane: i, sourcePath:
|
|
1966
|
+
const { pane: i, sourcePath: n } = this.dragState, o = this.resolveStackLocation(n), r = this.resolveStackLocation(t);
|
|
1783
1967
|
if (!r && t.type === "docked" && !this.rootLayout) {
|
|
1784
|
-
if (!
|
|
1968
|
+
if (!o)
|
|
1785
1969
|
return;
|
|
1786
|
-
this.removePaneFromLocation(
|
|
1787
|
-
const
|
|
1970
|
+
this.removePaneFromLocation(o, i, !0);
|
|
1971
|
+
const s = {
|
|
1788
1972
|
kind: "stack",
|
|
1789
1973
|
panes: [i],
|
|
1790
1974
|
activePane: i
|
|
1791
1975
|
};
|
|
1792
|
-
this.rootLayout =
|
|
1976
|
+
this.rootLayout = s, this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1793
1977
|
return;
|
|
1794
1978
|
}
|
|
1795
|
-
if (!
|
|
1979
|
+
if (!o || !r)
|
|
1796
1980
|
return;
|
|
1797
|
-
if (e === "center" &&
|
|
1798
|
-
if (!
|
|
1981
|
+
if (e === "center" && O(n, t)) {
|
|
1982
|
+
if (!o.node.panes.includes(i))
|
|
1799
1983
|
return;
|
|
1800
|
-
this.reorderPaneInLocation(
|
|
1984
|
+
this.reorderPaneInLocation(o, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1801
1985
|
return;
|
|
1802
1986
|
}
|
|
1803
|
-
if (this.removePaneFromLocation(
|
|
1987
|
+
if (this.removePaneFromLocation(o, i, !0), e === "center") {
|
|
1804
1988
|
this.addPaneToLocation(r, i), this.setActivePaneForLocation(r, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1805
1989
|
return;
|
|
1806
1990
|
}
|
|
1807
|
-
const
|
|
1991
|
+
const d = {
|
|
1808
1992
|
kind: "stack",
|
|
1809
1993
|
panes: [i],
|
|
1810
1994
|
activePane: i
|
|
1811
1995
|
};
|
|
1812
1996
|
if (r.context === "docked")
|
|
1813
|
-
this.rootLayout =
|
|
1997
|
+
this.rootLayout = A(this.rootLayout, r.node, d, e);
|
|
1814
1998
|
else {
|
|
1815
|
-
const
|
|
1816
|
-
if (!
|
|
1999
|
+
const s = this.floatingLayouts[r.index];
|
|
2000
|
+
if (!s) {
|
|
1817
2001
|
this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged();
|
|
1818
2002
|
return;
|
|
1819
2003
|
}
|
|
1820
|
-
|
|
2004
|
+
s.root = A(s.root, r.node, d, e), s.activePane = i;
|
|
1821
2005
|
}
|
|
1822
2006
|
this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1823
2007
|
}
|
|
1824
2008
|
handleFloatingStackDrop(t, e, i) {
|
|
1825
|
-
const
|
|
1826
|
-
if (!
|
|
2009
|
+
const n = this.floatingLayouts[t];
|
|
2010
|
+
if (!n || !n.root)
|
|
1827
2011
|
return !1;
|
|
1828
|
-
const
|
|
1829
|
-
if (!
|
|
1830
|
-
return this.rootLayout =
|
|
1831
|
-
if (!
|
|
2012
|
+
const o = this.resolveStackLocation(e);
|
|
2013
|
+
if (!o && e.type === "docked" && !this.rootLayout)
|
|
2014
|
+
return this.rootLayout = _(n.root), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
|
|
2015
|
+
if (!o || o.context === "floating" && o.index === t)
|
|
1832
2016
|
return !1;
|
|
1833
2017
|
if (i === "center") {
|
|
1834
|
-
const r =
|
|
2018
|
+
const r = I(n.root);
|
|
1835
2019
|
if (r.length === 0)
|
|
1836
2020
|
return !1;
|
|
1837
|
-
r.forEach((
|
|
1838
|
-
this.addPaneToLocation(
|
|
2021
|
+
r.forEach((s) => {
|
|
2022
|
+
this.addPaneToLocation(o, s);
|
|
1839
2023
|
});
|
|
1840
|
-
const
|
|
1841
|
-
return
|
|
2024
|
+
const d = n.activePane && r.includes(n.activePane) ? n.activePane : E(n.root) ?? r[0];
|
|
2025
|
+
return d && this.setActivePaneForLocation(o, d), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
|
|
1842
2026
|
}
|
|
1843
|
-
if (
|
|
1844
|
-
const r = this.floatingLayouts[
|
|
1845
|
-
return r ? (r.root =
|
|
1846
|
-
}
|
|
1847
|
-
return this.rootLayout = this.dockNodeBeside(this.rootLayout, n.node, o.root, i), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
|
|
1848
|
-
}
|
|
1849
|
-
insertWeight(t, e, i) {
|
|
1850
|
-
const o = i - 1, n = this.normalizeSizesArray(t, o), r = 1 / i, c = 1 - r, l = [];
|
|
1851
|
-
for (let s = 0; s < i; s += 1)
|
|
1852
|
-
if (s === e)
|
|
1853
|
-
l.push(r);
|
|
1854
|
-
else {
|
|
1855
|
-
const a = s < e ? s : s - 1;
|
|
1856
|
-
l.push(n[a] * c);
|
|
1857
|
-
}
|
|
1858
|
-
return l;
|
|
1859
|
-
}
|
|
1860
|
-
removePaneFromStack(t, e, i = !1) {
|
|
1861
|
-
return t.panes = t.panes.filter((o) => o !== e), t.panes.includes(t.activePane ?? "") || (t.panes.length > 0 ? t.activePane = t.panes[0] : delete t.activePane), t.panes.length > 0 ? !1 : (i || this.normalizeAllLayouts(), !0);
|
|
1862
|
-
}
|
|
1863
|
-
findParentSplit(t, e) {
|
|
1864
|
-
if (!t || t === e || t.kind !== "split")
|
|
1865
|
-
return null;
|
|
1866
|
-
const i = t.children.indexOf(e);
|
|
1867
|
-
if (i !== -1)
|
|
1868
|
-
return { parent: t, index: i };
|
|
1869
|
-
for (let o = 0; o < t.children.length; o += 1) {
|
|
1870
|
-
const n = this.findParentSplit(t.children[o], e);
|
|
1871
|
-
if (n)
|
|
1872
|
-
return n;
|
|
2027
|
+
if (o.context === "floating") {
|
|
2028
|
+
const r = this.floatingLayouts[o.index];
|
|
2029
|
+
return r ? (r.root = A(r.root, o.node, n.root, i), r.activePane = n.activePane ?? E(n.root) ?? void 0, this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0) : !1;
|
|
1873
2030
|
}
|
|
1874
|
-
return
|
|
2031
|
+
return this.rootLayout = A(this.rootLayout, o.node, n.root, i), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
|
|
1875
2032
|
}
|
|
1876
2033
|
computeDropZone(t, e, i) {
|
|
1877
|
-
const
|
|
1878
|
-
if (o)
|
|
1879
|
-
return this.updateDropJoystickActiveZone(o), o;
|
|
1880
|
-
const n = e && Number.isFinite(e.clientX) && Number.isFinite(e.clientY) ? this.findDropZoneByPoint(e.clientX, e.clientY) : null;
|
|
2034
|
+
const n = this.isDropZone(i) ? i : null;
|
|
1881
2035
|
if (n)
|
|
1882
2036
|
return this.updateDropJoystickActiveZone(n), n;
|
|
2037
|
+
const o = e && Number.isFinite(e.clientX) && Number.isFinite(e.clientY) ? this.findDropZoneByPoint(e.clientX, e.clientY) : null;
|
|
2038
|
+
if (o)
|
|
2039
|
+
return this.updateDropJoystickActiveZone(o), o;
|
|
1883
2040
|
if (this.dropJoystickTarget === t) {
|
|
1884
2041
|
const r = this.dropJoystick.dataset.zone;
|
|
1885
2042
|
if (this.isDropZone(r))
|
|
@@ -1925,64 +2082,64 @@ class P extends A {
|
|
|
1925
2082
|
for (const i of this.dropJoystickButtons) {
|
|
1926
2083
|
if (i.dataset.hidden === "true" || i.style.visibility === "hidden" || i.style.display === "none")
|
|
1927
2084
|
continue;
|
|
1928
|
-
const
|
|
1929
|
-
if (t >=
|
|
1930
|
-
const
|
|
1931
|
-
if (this.isDropZone(
|
|
1932
|
-
return
|
|
2085
|
+
const n = i.getBoundingClientRect();
|
|
2086
|
+
if (t >= n.left && t <= n.right && e >= n.top && e <= n.bottom) {
|
|
2087
|
+
const o = i.dataset.zone;
|
|
2088
|
+
if (this.isDropZone(o))
|
|
2089
|
+
return o;
|
|
1933
2090
|
}
|
|
1934
2091
|
}
|
|
1935
2092
|
return null;
|
|
1936
2093
|
}
|
|
1937
2094
|
updateDropJoystickActiveZone(t) {
|
|
1938
|
-
const i = this.dropJoystick.dataset.visible === "true" ? this.dropJoystick.dataset.zone : void 0,
|
|
1939
|
-
this.dropJoystickButtons.forEach((
|
|
1940
|
-
|
|
1941
|
-
}),
|
|
2095
|
+
const i = this.dropJoystick.dataset.visible === "true" ? this.dropJoystick.dataset.zone : void 0, n = t ?? (this.isDropZone(i) ? i : null);
|
|
2096
|
+
this.dropJoystickButtons.forEach((o) => {
|
|
2097
|
+
n !== null && o.dataset.zone === n ? o.dataset.active = "true" : delete o.dataset.active;
|
|
2098
|
+
}), n ? this.dropJoystick.dataset.zone = n : delete this.dropJoystick.dataset.zone;
|
|
1942
2099
|
}
|
|
1943
2100
|
isDropZone(t) {
|
|
1944
2101
|
return t === "left" || t === "right" || t === "top" || t === "bottom" || t === "center";
|
|
1945
2102
|
}
|
|
1946
2103
|
showDropIndicator(t, e) {
|
|
1947
|
-
const i =
|
|
1948
|
-
if (i &&
|
|
2104
|
+
const i = S(t.dataset.path), n = this.dragState?.sourcePath ?? null;
|
|
2105
|
+
if (i && n && this.isOrIsAncestorOf(i, n))
|
|
1949
2106
|
return;
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
const
|
|
1953
|
-
let
|
|
1954
|
-
|
|
1955
|
-
let
|
|
1956
|
-
const
|
|
2107
|
+
const o = t.getBoundingClientRect(), r = this.getBoundingClientRect(), d = this.dropIndicator, s = this.dropJoystick;
|
|
2108
|
+
s.hidden = !1;
|
|
2109
|
+
const c = S(t.dataset.path);
|
|
2110
|
+
let l = 100;
|
|
2111
|
+
c && c.type === "floating" && (l = N(this.floatingLayouts[c.index], c.index) + 100), d.style.zIndex = String(l), s.style.zIndex = String(l + 1);
|
|
2112
|
+
let u = o.left - r.left, h = o.top - r.top, p = o.width, g = o.height;
|
|
2113
|
+
const m = 0.5;
|
|
1957
2114
|
if (e) {
|
|
1958
2115
|
switch (e) {
|
|
1959
2116
|
case "left":
|
|
1960
|
-
|
|
2117
|
+
p = o.width * m;
|
|
1961
2118
|
break;
|
|
1962
2119
|
case "right":
|
|
1963
|
-
|
|
2120
|
+
p = o.width * m, u += o.width * (1 - m);
|
|
1964
2121
|
break;
|
|
1965
2122
|
case "top":
|
|
1966
|
-
g =
|
|
2123
|
+
g = o.height * m;
|
|
1967
2124
|
break;
|
|
1968
2125
|
case "bottom":
|
|
1969
|
-
g =
|
|
2126
|
+
g = o.height * m, h += o.height * (1 - m);
|
|
1970
2127
|
break;
|
|
1971
2128
|
}
|
|
1972
|
-
|
|
2129
|
+
d.style.left = `${u}px`, d.style.top = `${h}px`, d.style.width = `${p}px`, d.style.height = `${g}px`, d.dataset.visible = "true";
|
|
1973
2130
|
} else
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
const
|
|
1977
|
-
this.dropJoystickTarget = t,
|
|
1978
|
-
const
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
}), this.dropJoystickButtons.forEach((
|
|
1982
|
-
|
|
1983
|
-
}), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = "") : (this.dropJoystickButtons.forEach((
|
|
1984
|
-
|
|
1985
|
-
}),
|
|
2131
|
+
d.dataset.visible = "false";
|
|
2132
|
+
s.style.left = `${o.left - r.left + o.width / 2}px`, s.style.top = `${o.top - r.top + o.height / 2}px`, s.dataset.visible = "true", this.dropJoystick.style.display = "grid", s.dataset.path = t.dataset.path ?? "";
|
|
2133
|
+
const f = this.dropJoystickTarget && this.dropJoystickTarget !== t;
|
|
2134
|
+
this.dropJoystickTarget = t, f && delete this.dropJoystick.dataset.zone;
|
|
2135
|
+
const y = !this.rootLayout && (t === this.dockedEl || i && i.type === "docked" && i.segments.length === 0), b = Array.from(this.dropJoystick.querySelectorAll(".dock-drop-joystick__spacer"));
|
|
2136
|
+
y ? (b.forEach((k) => {
|
|
2137
|
+
k.style.display = "";
|
|
2138
|
+
}), this.dropJoystickButtons.forEach((k) => {
|
|
2139
|
+
k.dataset.zone === "center" ? (k.style.visibility = "", k.style.pointerEvents = "", delete k.dataset.hidden, k.style.display = "") : (k.style.visibility = "hidden", k.style.pointerEvents = "none", k.dataset.hidden = "true", k.style.display = "");
|
|
2140
|
+
}), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = "") : (this.dropJoystickButtons.forEach((k) => {
|
|
2141
|
+
k.style.visibility = "", k.style.pointerEvents = "", delete k.dataset.hidden, k.style.display = "";
|
|
2142
|
+
}), b.forEach((k) => k.style.display = ""), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = ""), this.updateDropJoystickActiveZone(e);
|
|
1986
2143
|
}
|
|
1987
2144
|
hideDropIndicator() {
|
|
1988
2145
|
this.dropIndicator.dataset.visible = "false", this.dropJoystick.dataset.visible = "false", this.dropJoystick.style.display = "none", delete this.dropJoystick.dataset.path, this.dropJoystickTarget = null, this.updateDropJoystickActiveZone(null), this.dropJoystickButtons.forEach((t) => {
|
|
@@ -1993,9 +2150,9 @@ class P extends A {
|
|
|
1993
2150
|
const i = this.shadowRoot;
|
|
1994
2151
|
if (!i)
|
|
1995
2152
|
return null;
|
|
1996
|
-
const
|
|
1997
|
-
if (
|
|
1998
|
-
return
|
|
2153
|
+
const n = i.elementsFromPoint(t, e), o = this.findStackInTargets(n);
|
|
2154
|
+
if (o)
|
|
2155
|
+
return o;
|
|
1999
2156
|
if (!this.rootLayout) {
|
|
2000
2157
|
const r = this.dockedEl.getBoundingClientRect();
|
|
2001
2158
|
if (t >= r.left && t <= r.right && e >= r.top && e <= r.bottom)
|
|
@@ -2020,122 +2177,41 @@ class P extends A {
|
|
|
2020
2177
|
)?.dataset.tabId;
|
|
2021
2178
|
r && t.setAttribute("active-tab", r);
|
|
2022
2179
|
}
|
|
2023
|
-
const
|
|
2024
|
-
if (
|
|
2025
|
-
if (
|
|
2026
|
-
const
|
|
2027
|
-
|
|
2180
|
+
const n = this.resolveStackLocation(i);
|
|
2181
|
+
if (n) {
|
|
2182
|
+
if (n.node.activePane = e, i.type === "floating") {
|
|
2183
|
+
const o = this.floatingLayouts[i.index];
|
|
2184
|
+
o && (o.activePane = e), this.updateFloatingWindowTitle(i.index);
|
|
2028
2185
|
}
|
|
2029
2186
|
this.dispatchLayoutChanged();
|
|
2030
2187
|
}
|
|
2031
2188
|
}
|
|
2032
|
-
getNodeAtPath(t, e) {
|
|
2033
|
-
if (!t)
|
|
2034
|
-
return null;
|
|
2035
|
-
let i = t;
|
|
2036
|
-
if (e.length === 0)
|
|
2037
|
-
return i;
|
|
2038
|
-
for (const o of e) {
|
|
2039
|
-
if (!i || i.kind !== "split")
|
|
2040
|
-
return null;
|
|
2041
|
-
i = i.children[o] ?? null;
|
|
2042
|
-
}
|
|
2043
|
-
return i;
|
|
2044
|
-
}
|
|
2045
2189
|
resolveSplitNode(t) {
|
|
2046
2190
|
if (t.type === "docked") {
|
|
2047
|
-
const
|
|
2048
|
-
return
|
|
2191
|
+
const n = T(this.rootLayout, t.segments);
|
|
2192
|
+
return n && n.kind === "split" ? n : null;
|
|
2049
2193
|
}
|
|
2050
2194
|
const e = this.floatingLayouts[t.index];
|
|
2051
2195
|
if (!e || !e.root)
|
|
2052
2196
|
return null;
|
|
2053
|
-
const i =
|
|
2197
|
+
const i = T(e.root, t.segments);
|
|
2054
2198
|
return i && i.kind === "split" ? i : null;
|
|
2055
2199
|
}
|
|
2056
|
-
replaceNodeInTree(t, e, i) {
|
|
2057
|
-
if (!t || t === e)
|
|
2058
|
-
return i;
|
|
2059
|
-
const o = this.findParentSplit(t, e);
|
|
2060
|
-
return o && (o.parent.children[o.index] = i, this.normalizeSplitNode(o.parent)), t;
|
|
2061
|
-
}
|
|
2062
|
-
dockNodeBeside(t, e, i, o) {
|
|
2063
|
-
const n = o === "left" || o === "right" ? "horizontal" : "vertical", r = o === "left" || o === "top", c = this.findParentSplit(t, e);
|
|
2064
|
-
if (c && c.parent.direction === n) {
|
|
2065
|
-
const s = r ? c.index : c.index + 1;
|
|
2066
|
-
return c.parent.children.splice(s, 0, i), c.parent.sizes = this.insertWeight(
|
|
2067
|
-
c.parent.sizes,
|
|
2068
|
-
s,
|
|
2069
|
-
c.parent.children.length
|
|
2070
|
-
), t ?? i;
|
|
2071
|
-
}
|
|
2072
|
-
const l = {
|
|
2073
|
-
kind: "split",
|
|
2074
|
-
direction: n,
|
|
2075
|
-
children: r ? [i, e] : [e, i],
|
|
2076
|
-
sizes: [0.5, 0.5]
|
|
2077
|
-
};
|
|
2078
|
-
return this.replaceNodeInTree(t, e, l);
|
|
2079
|
-
}
|
|
2080
|
-
forEachStack(t, e, i = []) {
|
|
2081
|
-
if (t) {
|
|
2082
|
-
if (t.kind === "stack") {
|
|
2083
|
-
e(t, i);
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
t.children.forEach(
|
|
2087
|
-
(o, n) => this.forEachStack(o, e, [...i, n])
|
|
2088
|
-
);
|
|
2089
|
-
}
|
|
2090
|
-
}
|
|
2091
|
-
findStackContainingPane(t, e) {
|
|
2092
|
-
let i = null;
|
|
2093
|
-
return this.forEachStack(t, (o) => {
|
|
2094
|
-
!i && o.panes.includes(e) && (i = o);
|
|
2095
|
-
}), i;
|
|
2096
|
-
}
|
|
2097
|
-
findFirstPaneName(t) {
|
|
2098
|
-
let e = null;
|
|
2099
|
-
return this.forEachStack(t, (i) => {
|
|
2100
|
-
e || i.panes.length === 0 || (i.activePane && i.panes.includes(i.activePane) ? e = i.activePane : e = i.panes[0]);
|
|
2101
|
-
}), e;
|
|
2102
|
-
}
|
|
2103
|
-
collectFloatingPaneMetadata(t) {
|
|
2104
|
-
const e = this.collectPaneNames(t), i = {};
|
|
2105
|
-
return e.forEach((o) => {
|
|
2106
|
-
const n = this.titles[o];
|
|
2107
|
-
n && (i[o] = n);
|
|
2108
|
-
}), { panes: e, titles: i };
|
|
2109
|
-
}
|
|
2110
|
-
collectPaneNames(t) {
|
|
2111
|
-
const e = [];
|
|
2112
|
-
return this.forEachStack(t, (i) => {
|
|
2113
|
-
i.panes.forEach((o) => e.push(o));
|
|
2114
|
-
}), e;
|
|
2115
|
-
}
|
|
2116
2200
|
normalizeFloatingLayout(t) {
|
|
2117
2201
|
const e = t.bounds ?? { left: 0, top: 0, width: 320, height: 200 }, i = {
|
|
2118
2202
|
left: Number.isFinite(e.left) ? e.left : 0,
|
|
2119
2203
|
top: Number.isFinite(e.top) ? e.top : 0,
|
|
2120
2204
|
width: Number.isFinite(e.width) ? Math.max(e.width, 160) : 320,
|
|
2121
2205
|
height: Number.isFinite(e.height) ? Math.max(e.height, 120) : 200
|
|
2122
|
-
},
|
|
2206
|
+
}, n = t.root ? _(t.root) : null;
|
|
2123
2207
|
return {
|
|
2124
2208
|
id: t.id,
|
|
2125
2209
|
bounds: i,
|
|
2126
2210
|
zIndex: t.zIndex,
|
|
2127
|
-
root:
|
|
2211
|
+
root: n,
|
|
2128
2212
|
activePane: t.activePane
|
|
2129
2213
|
};
|
|
2130
2214
|
}
|
|
2131
|
-
formatPath(t) {
|
|
2132
|
-
if (t.type === "floating") {
|
|
2133
|
-
const i = t.segments.length > 0 ? `/${t.segments.map((o) => o.toString()).join("/")}` : "";
|
|
2134
|
-
return `f:${t.index}${i}`;
|
|
2135
|
-
}
|
|
2136
|
-
const e = t.segments.join("/");
|
|
2137
|
-
return e.length > 0 ? `d:${e}` : "d:";
|
|
2138
|
-
}
|
|
2139
2215
|
// Layer identity of a splitter in the rendered shadow tree. Splitters inside
|
|
2140
2216
|
// floating pane N are nested under `.dock-floating[data-path="f:N"]`;
|
|
2141
2217
|
// docked-layer splitters have no such ancestor. Two splitters share a layer
|
|
@@ -2149,31 +2225,8 @@ class P extends A {
|
|
|
2149
2225
|
clonePath(t) {
|
|
2150
2226
|
return t.type === "floating" ? { type: "floating", index: t.index, segments: [...t.segments] } : { type: "docked", segments: [...t.segments] };
|
|
2151
2227
|
}
|
|
2152
|
-
parsePath(t) {
|
|
2153
|
-
if (t == null)
|
|
2154
|
-
return null;
|
|
2155
|
-
if (t.startsWith("f:")) {
|
|
2156
|
-
const o = t.slice(2), [n, ...r] = o.split("/"), c = Number.parseInt(n, 10);
|
|
2157
|
-
if (!Number.isFinite(c))
|
|
2158
|
-
return null;
|
|
2159
|
-
const l = r.filter((s) => s.length > 0).map((s) => Number.parseInt(s, 10)).filter((s) => Number.isFinite(s));
|
|
2160
|
-
return { type: "floating", index: c, segments: l };
|
|
2161
|
-
}
|
|
2162
|
-
const e = t.startsWith("d:") ? t.slice(2) : t;
|
|
2163
|
-
return e.length === 0 ? { type: "docked", segments: [] } : { type: "docked", segments: e.split("/").filter((o) => o.length > 0).map((o) => Number.parseInt(o, 10)).filter((o) => Number.isFinite(o)) };
|
|
2164
|
-
}
|
|
2165
|
-
pathsEqual(t, e) {
|
|
2166
|
-
if (t.type !== e.type)
|
|
2167
|
-
return !1;
|
|
2168
|
-
if (t.type === "floating") {
|
|
2169
|
-
const o = e;
|
|
2170
|
-
return t.index !== o.index || t.segments.length !== o.segments.length ? !1 : t.segments.every((n, r) => n === o.segments[r]);
|
|
2171
|
-
}
|
|
2172
|
-
const i = e;
|
|
2173
|
-
return t.segments.length !== i.segments.length ? !1 : t.segments.every((o, n) => o === i.segments[n]);
|
|
2174
|
-
}
|
|
2175
2228
|
isOrIsAncestorOf(t, e) {
|
|
2176
|
-
return t.type !== e.type || t.type === "floating" && e.index !== t.index || t.segments.length > e.segments.length ? !1 : t.segments.every((i,
|
|
2229
|
+
return t.type !== e.type || t.type === "floating" && e.index !== t.index || t.segments.length > e.segments.length ? !1 : t.segments.every((i, n) => i === e.segments[n]);
|
|
2177
2230
|
}
|
|
2178
2231
|
countPanesInTree(t) {
|
|
2179
2232
|
return t ? t.kind === "stack" ? t.panes.length : t.children.reduce((e, i) => e + this.countPanesInTree(i), 0) : 0;
|
|
@@ -2183,18 +2236,22 @@ class P extends A {
|
|
|
2183
2236
|
const i = this.floatingLayouts[t.index];
|
|
2184
2237
|
if (!i || !i.root)
|
|
2185
2238
|
return null;
|
|
2186
|
-
const
|
|
2187
|
-
return !
|
|
2239
|
+
const n = T(i.root, t.segments);
|
|
2240
|
+
return !n || n.kind !== "stack" ? null : { context: "floating", index: t.index, path: [...t.segments], node: n };
|
|
2188
2241
|
}
|
|
2189
|
-
const e =
|
|
2242
|
+
const e = T(this.rootLayout, t.segments);
|
|
2190
2243
|
return !e || e.kind !== "stack" ? null : { context: "docked", path: [...t.segments], node: e };
|
|
2191
2244
|
}
|
|
2192
2245
|
removePaneFromLocation(t, e, i = !1) {
|
|
2193
|
-
|
|
2246
|
+
if (t.context === "docked") {
|
|
2247
|
+
const n = rt(t.node, e);
|
|
2248
|
+
return n && !i && this.normalizeAllLayouts(), n;
|
|
2249
|
+
}
|
|
2250
|
+
return this.removePaneFromFloating(t.index, t.path, e, i);
|
|
2194
2251
|
}
|
|
2195
2252
|
addPaneToLocation(t, e) {
|
|
2196
|
-
const i = t.node.panes,
|
|
2197
|
-
|
|
2253
|
+
const i = t.node.panes, n = i.indexOf(e);
|
|
2254
|
+
n !== -1 && i.splice(n, 1), i.push(e);
|
|
2198
2255
|
}
|
|
2199
2256
|
setActivePaneForLocation(t, e) {
|
|
2200
2257
|
if (t.node.activePane = e, t.context === "floating") {
|
|
@@ -2203,10 +2260,10 @@ class P extends A {
|
|
|
2203
2260
|
}
|
|
2204
2261
|
}
|
|
2205
2262
|
reorderPaneInLocation(t, e) {
|
|
2206
|
-
const i = t.node.panes,
|
|
2207
|
-
if (
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2263
|
+
const i = t.node.panes, n = i.indexOf(e);
|
|
2264
|
+
if (n !== -1 && (i.splice(n, 1), i.push(e), t.node.activePane = e, t.context === "floating")) {
|
|
2265
|
+
const o = this.floatingLayouts[t.index];
|
|
2266
|
+
o && (o.activePane = e);
|
|
2210
2267
|
}
|
|
2211
2268
|
}
|
|
2212
2269
|
removeFloatingAt(t) {
|
|
@@ -2259,14 +2316,14 @@ class P extends A {
|
|
|
2259
2316
|
const e = t.composedPath()[0];
|
|
2260
2317
|
if (e instanceof HTMLElement && (e.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(e.tagName)))
|
|
2261
2318
|
return;
|
|
2262
|
-
const
|
|
2319
|
+
const n = {
|
|
2263
2320
|
ArrowRight: 1,
|
|
2264
2321
|
ArrowDown: 1,
|
|
2265
2322
|
ArrowLeft: -1,
|
|
2266
2323
|
ArrowUp: -1
|
|
2267
2324
|
}[t.key];
|
|
2268
|
-
if (
|
|
2269
|
-
t.preventDefault(), t.stopPropagation(), this.cyclePaneMoveCandidate(
|
|
2325
|
+
if (n) {
|
|
2326
|
+
t.preventDefault(), t.stopPropagation(), this.cyclePaneMoveCandidate(n);
|
|
2270
2327
|
return;
|
|
2271
2328
|
}
|
|
2272
2329
|
if (t.key === "Enter") {
|
|
@@ -2274,14 +2331,14 @@ class P extends A {
|
|
|
2274
2331
|
t.preventDefault(), t.stopPropagation(), this.commitHighlightedPaneMoveCandidate();
|
|
2275
2332
|
return;
|
|
2276
2333
|
}
|
|
2277
|
-
const
|
|
2334
|
+
const o = t.key.toLowerCase(), d = {
|
|
2278
2335
|
t: "top",
|
|
2279
2336
|
r: "right",
|
|
2280
2337
|
b: "bottom",
|
|
2281
2338
|
l: "left",
|
|
2282
2339
|
f: "float"
|
|
2283
|
-
}[
|
|
2284
|
-
|
|
2340
|
+
}[o];
|
|
2341
|
+
d && (t.preventDefault(), t.stopPropagation(), d === "float" ? this.commitPaneMoveAsFloat() : this.commitPaneMoveToZone(d));
|
|
2285
2342
|
}
|
|
2286
2343
|
/**
|
|
2287
2344
|
* Enumerated keyboard drop targets, in cycle order: every docked leaf stack
|
|
@@ -2296,16 +2353,16 @@ class P extends A {
|
|
|
2296
2353
|
* land exactly where a pointer drop on that stack would.
|
|
2297
2354
|
*/
|
|
2298
2355
|
buildPaneMoveCandidates() {
|
|
2299
|
-
const t = this.paneMoveMode ?
|
|
2300
|
-
return
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2303
|
-
pathStr:
|
|
2356
|
+
const t = this.paneMoveMode ? w(this.paneMoveMode.sourcePath) : null, e = [];
|
|
2357
|
+
return M(this.rootLayout, (i, n) => {
|
|
2358
|
+
const o = w({ type: "docked", segments: n });
|
|
2359
|
+
o !== t && e.push({
|
|
2360
|
+
pathStr: o,
|
|
2304
2361
|
targetTitles: i.panes.map((r) => this.titles[r] ?? r).join(", ")
|
|
2305
2362
|
});
|
|
2306
2363
|
}), [
|
|
2307
2364
|
...e.flatMap(
|
|
2308
|
-
({ pathStr: i, targetTitles:
|
|
2365
|
+
({ pathStr: i, targetTitles: n }) => L.PANE_MOVE_ZONE_ORDER.map((o) => ({ pathStr: i, zone: o, targetTitles: n }))
|
|
2309
2366
|
),
|
|
2310
2367
|
{ pathStr: null, zone: "float", targetTitles: "" }
|
|
2311
2368
|
];
|
|
@@ -2313,12 +2370,12 @@ class P extends A {
|
|
|
2313
2370
|
cyclePaneMoveCandidate(t) {
|
|
2314
2371
|
const e = this.buildPaneMoveCandidates();
|
|
2315
2372
|
if (e.length === 0) return;
|
|
2316
|
-
const i = this.paneMoveCandidateIndex,
|
|
2317
|
-
this.paneMoveCandidateIndex =
|
|
2318
|
-
const
|
|
2319
|
-
this.highlightPaneMoveCandidate(
|
|
2320
|
-
const r =
|
|
2321
|
-
this.liveAnnouncer.announce(`${r}, option ${
|
|
2373
|
+
const i = this.paneMoveCandidateIndex, n = i === null ? t > 0 ? 0 : e.length - 1 : (i + t + e.length) % e.length;
|
|
2374
|
+
this.paneMoveCandidateIndex = n;
|
|
2375
|
+
const o = e[n];
|
|
2376
|
+
this.highlightPaneMoveCandidate(o);
|
|
2377
|
+
const r = o.zone === "float" ? "Float" : `${o.zone[0].toUpperCase()}${o.zone.slice(1)} of ${o.targetTitles}`;
|
|
2378
|
+
this.liveAnnouncer.announce(`${r}, option ${n + 1} of ${e.length}.`);
|
|
2322
2379
|
}
|
|
2323
2380
|
highlightPaneMoveCandidate(t) {
|
|
2324
2381
|
if (this.hideDropIndicator(), t.zone === "float" || !t.pathStr) return;
|
|
@@ -2341,7 +2398,7 @@ class P extends A {
|
|
|
2341
2398
|
this.commitPaneMoveAsFloat();
|
|
2342
2399
|
return;
|
|
2343
2400
|
}
|
|
2344
|
-
this.commitPaneMoveToZone(e.zone,
|
|
2401
|
+
this.commitPaneMoveToZone(e.zone, S(e.pathStr));
|
|
2345
2402
|
}
|
|
2346
2403
|
/** Sole exit point for move mode: drops the arming AND any highlight together. */
|
|
2347
2404
|
clearPaneMoveState() {
|
|
@@ -2362,10 +2419,10 @@ class P extends A {
|
|
|
2362
2419
|
`.dock-tab[data-tab-id="${e}"]`
|
|
2363
2420
|
);
|
|
2364
2421
|
if (!i) return null;
|
|
2365
|
-
const
|
|
2366
|
-
if (!
|
|
2367
|
-
const
|
|
2368
|
-
return
|
|
2422
|
+
const n = i.closest(".dock-stack");
|
|
2423
|
+
if (!n) return null;
|
|
2424
|
+
const o = S(n.dataset.path);
|
|
2425
|
+
return o ? { paneName: i.dataset.pane, sourcePath: o } : null;
|
|
2369
2426
|
}
|
|
2370
2427
|
/**
|
|
2371
2428
|
* Synthesise a minimal dragState so handleDrop's existing pipeline can
|
|
@@ -2396,11 +2453,11 @@ class P extends A {
|
|
|
2396
2453
|
if (!this.paneMoveMode) return;
|
|
2397
2454
|
const i = this.paneMoveMode;
|
|
2398
2455
|
this.synthesiseDragStateForKeyboardMove(), this.handleDrop(e ?? i.sourcePath, t);
|
|
2399
|
-
const
|
|
2456
|
+
const n = this.dragState?.dropHandled === !0;
|
|
2400
2457
|
this.dragState = null, this.clearPaneMoveState();
|
|
2401
|
-
const
|
|
2458
|
+
const o = this.titles[i.paneName] ?? i.paneName;
|
|
2402
2459
|
this.liveAnnouncer.announce(
|
|
2403
|
-
|
|
2460
|
+
n ? `Pane ${o} docked to ${t}.` : `Move failed. Pane ${o} was not moved.`
|
|
2404
2461
|
);
|
|
2405
2462
|
}
|
|
2406
2463
|
commitPaneMoveAsFloat() {
|
|
@@ -2422,8 +2479,8 @@ class P extends A {
|
|
|
2422
2479
|
activePane: t.paneName
|
|
2423
2480
|
};
|
|
2424
2481
|
this.floatingLayouts.push(i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.clearPaneMoveState();
|
|
2425
|
-
const
|
|
2426
|
-
this.liveAnnouncer.announce(`Pane ${
|
|
2482
|
+
const n = this.titles[t.paneName] ?? t.paneName;
|
|
2483
|
+
this.liveAnnouncer.announce(`Pane ${n} torn off into a floating window.`);
|
|
2427
2484
|
}
|
|
2428
2485
|
/**
|
|
2429
2486
|
* Close a floating pane via the chrome's close button (or any external
|
|
@@ -2438,61 +2495,18 @@ class P extends A {
|
|
|
2438
2495
|
const i = this.getFloatingWindowTitle(e);
|
|
2439
2496
|
this.removeFloatingAt(t), this.renderLayout(), this.dispatchLayoutChanged(), this.liveAnnouncer.announce(`Closed floating pane ${i}.`);
|
|
2440
2497
|
}
|
|
2441
|
-
removePaneFromFloating(t, e, i,
|
|
2442
|
-
const
|
|
2443
|
-
if (!
|
|
2498
|
+
removePaneFromFloating(t, e, i, n = !1) {
|
|
2499
|
+
const o = this.floatingLayouts[t];
|
|
2500
|
+
if (!o || !o.root)
|
|
2444
2501
|
return !1;
|
|
2445
|
-
const r =
|
|
2502
|
+
const r = T(o.root, e);
|
|
2446
2503
|
if (!r || r.kind !== "stack")
|
|
2447
2504
|
return !1;
|
|
2448
|
-
if (r.panes = r.panes.filter((
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2505
|
+
if (r.panes = r.panes.filter((d) => d !== i), r.panes.includes(r.activePane ?? "") || (r.panes.length > 0 ? r.activePane = r.panes[0] : delete r.activePane), o.activePane === i) {
|
|
2506
|
+
const d = E(o.root);
|
|
2507
|
+
d ? o.activePane = d : delete o.activePane;
|
|
2451
2508
|
}
|
|
2452
|
-
return r.panes.length > 0 ? !1 : (
|
|
2453
|
-
}
|
|
2454
|
-
normalizeSizesArray(t, e) {
|
|
2455
|
-
if (e <= 0)
|
|
2456
|
-
return [];
|
|
2457
|
-
if (!Array.isArray(t) || t.length !== e)
|
|
2458
|
-
return Array.from({ length: e }, () => 1 / e);
|
|
2459
|
-
const i = t.map((n) => Number.isFinite(n) ? Math.max(n, 0) : 0), o = i.reduce((n, r) => n + r, 0);
|
|
2460
|
-
return o <= 0 ? Array.from({ length: e }, () => 1 / e) : i.map((n) => n / o);
|
|
2461
|
-
}
|
|
2462
|
-
normalizeSplitNode(t) {
|
|
2463
|
-
t.sizes = this.normalizeSizesArray(t.sizes, t.children.length);
|
|
2464
|
-
}
|
|
2465
|
-
/**
|
|
2466
|
-
* Bottom-up layout sanitizer. Returns a normalized version of `node` where:
|
|
2467
|
-
* - Empty stacks (panes.length === 0) are dropped (returned as null).
|
|
2468
|
-
* - A stack's `activePane` is repaired if it no longer references one of `panes`.
|
|
2469
|
-
* - Splits whose direction matches a child split are flattened, with sizes
|
|
2470
|
-
* combined multiplicatively so the resulting on-screen pixel layout is
|
|
2471
|
-
* identical to the pre-merge one.
|
|
2472
|
-
* - Splits with 0 children become null. Splits with 1 child are unwrapped.
|
|
2473
|
-
*
|
|
2474
|
-
* Idempotent: passing the result back through this method yields the same
|
|
2475
|
-
* structure. Mutates the input tree in place but only returns nodes that
|
|
2476
|
-
* remain part of the layout.
|
|
2477
|
-
*/
|
|
2478
|
-
normalizeLayoutNode(t) {
|
|
2479
|
-
if (!t) return null;
|
|
2480
|
-
if (t.kind === "stack")
|
|
2481
|
-
return t.panes.length === 0 ? null : ((!t.activePane || !t.panes.includes(t.activePane)) && (t.activePane = t.panes[0]), t);
|
|
2482
|
-
const e = this.normalizeSizesArray(t.sizes, t.children.length), i = t.children.map((o, n) => ({ child: this.normalizeLayoutNode(o), slot: e[n] })).filter((o) => o.child !== null).flatMap(({ child: o, slot: n }) => {
|
|
2483
|
-
if (o.kind === "split" && o.direction === t.direction) {
|
|
2484
|
-
const r = this.normalizeSizesArray(o.sizes, o.children.length);
|
|
2485
|
-
return o.children.map((c, l) => ({
|
|
2486
|
-
child: c,
|
|
2487
|
-
slot: n * r[l]
|
|
2488
|
-
}));
|
|
2489
|
-
}
|
|
2490
|
-
return [{ child: o, slot: n }];
|
|
2491
|
-
});
|
|
2492
|
-
return i.length === 0 ? null : i.length === 1 ? i[0].child : (t.children = i.map((o) => o.child), t.sizes = this.normalizeSizesArray(
|
|
2493
|
-
i.map((o) => o.slot),
|
|
2494
|
-
i.length
|
|
2495
|
-
), t);
|
|
2509
|
+
return r.panes.length > 0 ? !1 : (n || this.normalizeAllLayouts(), !0);
|
|
2496
2510
|
}
|
|
2497
2511
|
/**
|
|
2498
2512
|
* Apply `normalizeLayoutNode` to `rootLayout` and every floating window's
|
|
@@ -2502,11 +2516,11 @@ class P extends A {
|
|
|
2502
2516
|
* pane removal) so the tree the renderer sees is always in canonical form.
|
|
2503
2517
|
*/
|
|
2504
2518
|
normalizeAllLayouts() {
|
|
2505
|
-
this.rootLayout =
|
|
2506
|
-
if (t.root =
|
|
2507
|
-
const e =
|
|
2519
|
+
this.rootLayout = H(this.rootLayout), this.floatingLayouts = this.floatingLayouts.map((t) => {
|
|
2520
|
+
if (t.root = H(t.root), !t.root) return null;
|
|
2521
|
+
const e = I(t.root);
|
|
2508
2522
|
if (!t.activePane || !e.includes(t.activePane)) {
|
|
2509
|
-
const i =
|
|
2523
|
+
const i = E(t.root);
|
|
2510
2524
|
i ? t.activePane = i : delete t.activePane;
|
|
2511
2525
|
}
|
|
2512
2526
|
return t;
|
|
@@ -2525,14 +2539,14 @@ class P extends A {
|
|
|
2525
2539
|
const t = this.shadowRoot;
|
|
2526
2540
|
if (!t) return;
|
|
2527
2541
|
const e = new Set(
|
|
2528
|
-
Array.from(t.querySelectorAll("slot")).map((
|
|
2529
|
-
),
|
|
2530
|
-
...
|
|
2531
|
-
...this.floatingLayouts.flatMap((
|
|
2532
|
-
].find((
|
|
2533
|
-
if (
|
|
2542
|
+
Array.from(t.querySelectorAll("slot")).map((o) => o.getAttribute("name")).filter((o) => !!o)
|
|
2543
|
+
), n = [
|
|
2544
|
+
...I(this.rootLayout),
|
|
2545
|
+
...this.floatingLayouts.flatMap((o) => I(o.root))
|
|
2546
|
+
].find((o) => !e.has(o));
|
|
2547
|
+
if (n)
|
|
2534
2548
|
throw new Error(
|
|
2535
|
-
`mint-dock-manager: pane "${
|
|
2549
|
+
`mint-dock-manager: pane "${n}" has no projection slot in the shadow DOM. The layout tree got into a state the renderer can't display — likely a missing normalize() call or a render bug.`
|
|
2536
2550
|
);
|
|
2537
2551
|
}
|
|
2538
2552
|
dispatchLayoutChanged() {
|
|
@@ -2544,15 +2558,12 @@ class P extends A {
|
|
|
2544
2558
|
})
|
|
2545
2559
|
);
|
|
2546
2560
|
}
|
|
2547
|
-
cloneLayoutNode(t) {
|
|
2548
|
-
return t ? JSON.parse(JSON.stringify(t)) : null;
|
|
2549
|
-
}
|
|
2550
2561
|
cloneFloatingArray(t) {
|
|
2551
2562
|
return JSON.parse(JSON.stringify(t));
|
|
2552
2563
|
}
|
|
2553
2564
|
}
|
|
2554
|
-
const
|
|
2555
|
-
typeof customElements < "u" && !customElements.get(
|
|
2565
|
+
const q = "mint-dock-manager";
|
|
2566
|
+
typeof customElements < "u" && !customElements.get(q) && customElements.define(q, L);
|
|
2556
2567
|
export {
|
|
2557
|
-
|
|
2568
|
+
L as MintDockManagerElement
|
|
2558
2569
|
};
|