@mintplayer/web-components 1.0.0 → 1.2.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/a11y/index.mjs +2 -56
- package/calendar/index.mjs +2 -363
- package/checkbox/index.mjs +4 -0
- package/checkbox/src/components/index.d.ts +2 -0
- package/checkbox/src/components/mp-checkbox.d.ts +69 -0
- package/checkbox/src/index.d.ts +2 -0
- package/chunks/color-C4VT0EL7.mjs +847 -0
- package/chunks/form-check.styles-jBlHetYX.mjs +151 -0
- package/chunks/live-announcer-CZDTKulf.mjs +58 -0
- package/chunks/mp-calendar.element-UC68iDbi.mjs +365 -0
- package/chunks/mp-checkbox-BokLL7BS.mjs +211 -0
- package/chunks/mp-datatable-Con0yQue.mjs +1125 -0
- package/chunks/mp-pagination-BGxsawFL.mjs +326 -0
- package/chunks/mp-select-BDS1-YGn.mjs +254 -0
- package/chunks/mp-splitter-C8cGCmac.mjs +633 -0
- package/chunks/mp-tab-page-D1b4x-y2.mjs +414 -0
- package/chunks/mp-timepicker.element-BwEiwX92.mjs +428 -0
- package/chunks/mp-toggle-button-dLZNDUVz.mjs +534 -0
- package/chunks/mp-treeview-Bfq4_IVW.mjs +474 -0
- package/code-snippet/index.mjs +16 -13
- package/datatable/index.mjs +7 -0
- package/datatable/src/components/index.d.ts +2 -0
- package/datatable/src/components/mp-datatable.d.ts +260 -0
- package/datatable/src/index.d.ts +6 -0
- package/datatable/src/sort/compute-next-sort.d.ts +18 -0
- package/datatable/src/sort/index.d.ts +3 -0
- package/datatable/src/sort/sort-rows.d.ts +6 -0
- package/datatable/src/styles/datatable.styles.d.ts +2 -0
- package/datatable/src/styles/index.d.ts +1 -0
- package/datatable/src/types/column-def.d.ts +41 -0
- package/datatable/src/types/index.d.ts +2 -0
- package/datatable/src/types/tree.d.ts +42 -0
- package/datepicker/index.mjs +240 -0
- package/datepicker/src/index.d.ts +1 -0
- package/datepicker/src/mp-datepicker.element.d.ts +94 -0
- package/datepicker/src/mp-datepicker.element.template.d.ts +2 -0
- package/datetime-picker/index.mjs +427 -0
- package/datetime-picker/src/index.d.ts +1 -0
- package/datetime-picker/src/mp-datetime-picker.element.d.ts +174 -0
- package/datetime-picker/src/mp-datetime-picker.element.template.d.ts +2 -0
- package/dock/index.mjs +2402 -0
- package/dock/src/components/index.d.ts +1 -0
- package/dock/src/components/mint-dock-manager.element.d.ts +313 -0
- package/dock/src/components/mint-dock-manager.element.template.d.ts +2 -0
- package/dock/src/index.d.ts +2 -0
- package/dock/src/types/dock-layout.d.ts +65 -0
- package/dock/src/types/index.d.ts +1 -0
- package/file-manager/index.mjs +1263 -0
- package/file-manager/src/components/index.d.ts +2 -0
- package/file-manager/src/components/mp-file-manager.d.ts +320 -0
- package/file-manager/src/index.d.ts +5 -0
- package/file-manager/src/styles/file-manager.styles.d.ts +2 -0
- package/file-manager/src/styles/index.d.ts +1 -0
- package/file-manager/src/types/file-system-node.d.ts +24 -0
- package/file-manager/src/types/index.d.ts +3 -0
- package/file-manager/src/types/messages.d.ts +43 -0
- package/multi-range/index.mjs +407 -0
- package/multi-range/src/index.d.ts +2 -0
- package/multi-range/src/mint-multi-range.element.d.ts +124 -0
- package/multi-range/src/mint-multi-range.element.template.d.ts +2 -0
- package/multi-range/src/types/multi-range-orientation.d.ts +1 -0
- package/otp-input/index.mjs +362 -0
- package/otp-input/src/index.d.ts +4 -0
- package/otp-input/src/mint-otp-input.element.d.ts +134 -0
- package/otp-input/src/mint-otp-input.element.template.d.ts +2 -0
- package/otp-input/src/types/otp-input-case.d.ts +1 -0
- package/otp-input/src/types/otp-input-size.d.ts +1 -0
- package/otp-input/src/types/otp-input-type.d.ts +1 -0
- package/overlay/index.mjs +260 -0
- package/overlay/src/index.d.ts +2 -0
- package/overlay/src/overlay-controller.d.ts +205 -0
- package/package.json +1 -1
- package/pagination/index.mjs +5 -0
- package/pagination/src/components/index.d.ts +2 -0
- package/pagination/src/components/mp-pagination.d.ts +95 -0
- package/pagination/src/index.d.ts +2 -0
- package/pagination/src/styles/index.d.ts +1 -0
- package/pagination/src/styles/pagination.styles.d.ts +2 -0
- package/query-builder/index.mjs +3720 -0
- package/query-builder/src/context.d.ts +14 -0
- package/query-builder/src/dnd/drag-controller.d.ts +69 -0
- package/query-builder/src/index.d.ts +23 -0
- package/query-builder/src/model/default-tree.d.ts +7 -0
- package/query-builder/src/model/editor.d.ts +15 -0
- package/query-builder/src/model/errors.d.ts +6 -0
- package/query-builder/src/model/expression.d.ts +22 -0
- package/query-builder/src/model/field-def.d.ts +17 -0
- package/query-builder/src/model/messages.d.ts +17 -0
- package/query-builder/src/model/operator-overrides.d.ts +21 -0
- package/query-builder/src/model/operators.d.ts +8 -0
- package/query-builder/src/model/saved-query.d.ts +6 -0
- package/query-builder/src/model/sort.d.ts +9 -0
- package/query-builder/src/model/tree-ops.d.ts +56 -0
- package/query-builder/src/mp-query-builder.element.d.ts +158 -0
- package/query-builder/src/mp-query-builder.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-condition.element.d.ts +44 -0
- package/query-builder/src/mp-query-condition.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-group.element.d.ts +52 -0
- package/query-builder/src/mp-query-group.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-subquery.element.d.ts +37 -0
- package/query-builder/src/mp-query-subquery.element.template.d.ts +2 -0
- package/query-builder/src/preview/render-expression.d.ts +23 -0
- package/query-builder/src/value-editors/builtin-editors.d.ts +6 -0
- package/query-builder/src/visitor/visit-tree.d.ts +29 -0
- package/query-builder/src/visitor/visitor-types.d.ts +15 -0
- package/radio/index.mjs +162 -0
- package/radio/src/components/index.d.ts +2 -0
- package/radio/src/components/mp-radio.d.ts +63 -0
- package/radio/src/index.d.ts +2 -0
- package/ribbon/index.mjs +3151 -0
- package/ribbon/src/index.d.ts +10 -0
- package/ribbon/src/items/index.d.ts +15 -0
- package/ribbon/src/items/mp-ribbon-button.element.d.ts +10 -0
- package/ribbon/src/items/mp-ribbon-checkbox.element.d.ts +11 -0
- package/ribbon/src/items/mp-ribbon-color-picker.element.d.ts +12 -0
- package/ribbon/src/items/mp-ribbon-combobox.element.d.ts +19 -0
- package/ribbon/src/items/mp-ribbon-dropdown-button.element.d.ts +16 -0
- package/ribbon/src/items/mp-ribbon-gallery-item.element.d.ts +15 -0
- package/ribbon/src/items/mp-ribbon-gallery.element.d.ts +11 -0
- package/ribbon/src/items/mp-ribbon-group-button.element.d.ts +18 -0
- package/ribbon/src/items/mp-ribbon-item-base.d.ts +68 -0
- package/ribbon/src/items/mp-ribbon-menu-item.element.d.ts +13 -0
- package/ribbon/src/items/mp-ribbon-menu-separator.element.d.ts +6 -0
- package/ribbon/src/items/mp-ribbon-split-button.element.d.ts +23 -0
- package/ribbon/src/items/mp-ribbon-template-item.element.d.ts +12 -0
- package/ribbon/src/items/mp-ribbon-toggle-button.element.d.ts +12 -0
- package/ribbon/src/mp-quick-access-toolbar.element.d.ts +35 -0
- package/ribbon/src/mp-ribbon-contextual-tab-set.element.d.ts +18 -0
- package/ribbon/src/mp-ribbon-group.element.d.ts +59 -0
- package/ribbon/src/mp-ribbon-tab.element.d.ts +72 -0
- package/ribbon/src/mp-ribbon.element.d.ts +211 -0
- package/ribbon/src/types/ribbon.types.d.ts +4 -0
- package/scheduler/index.mjs +3567 -0
- package/scheduler/src/components/mp-scheduler.d.ts +238 -0
- package/scheduler/src/drag/drag-manager.d.ts +90 -0
- package/scheduler/src/drag/drag-preview.d.ts +42 -0
- package/scheduler/src/drag/drag-state-machine.d.ts +102 -0
- package/scheduler/src/drag/drag-types.d.ts +104 -0
- package/scheduler/src/drag/index.d.ts +4 -0
- package/scheduler/src/events/event-types.d.ts +58 -0
- package/scheduler/src/events/index.d.ts +2 -0
- package/scheduler/src/events/scheduler-event-emitter.d.ts +52 -0
- package/scheduler/src/index.d.ts +6 -0
- package/scheduler/src/input/index.d.ts +2 -0
- package/scheduler/src/input/input-handler.d.ts +105 -0
- package/scheduler/src/input/pointer-event.d.ts +39 -0
- package/scheduler/src/state/scheduler-state.d.ts +189 -0
- package/scheduler/src/styles/scheduler.styles.d.ts +2 -0
- package/scheduler/src/views/base-view.d.ts +87 -0
- package/scheduler/src/views/day-view.d.ts +25 -0
- package/scheduler/src/views/index.d.ts +6 -0
- package/scheduler/src/views/month-view.d.ts +27 -0
- package/scheduler/src/views/timeline-view.d.ts +23 -0
- package/scheduler/src/views/week-view.d.ts +28 -0
- package/scheduler/src/views/year-view.d.ts +25 -0
- package/scheduler-core/index.mjs +174 -0
- package/scheduler-core/src/index.d.ts +3 -0
- package/scheduler-core/src/models/drag-state.d.ts +43 -0
- package/scheduler-core/src/models/event.d.ts +111 -0
- package/scheduler-core/src/models/events.d.ts +108 -0
- package/scheduler-core/src/models/index.d.ts +7 -0
- package/scheduler-core/src/models/options.d.ts +88 -0
- package/scheduler-core/src/models/resource.d.ts +58 -0
- package/scheduler-core/src/models/time-slot.d.ts +31 -0
- package/scheduler-core/src/models/types.d.ts +20 -0
- package/scheduler-core/src/services/date.service.d.ts +140 -0
- package/scheduler-core/src/services/index.d.ts +4 -0
- package/scheduler-core/src/services/position.service.d.ts +35 -0
- package/scheduler-core/src/services/resource.service.d.ts +83 -0
- package/scheduler-core/src/services/timeline.service.d.ts +103 -0
- package/scheduler-core/src/utils/color.d.ts +24 -0
- package/scheduler-core/src/utils/dom.d.ts +54 -0
- package/scheduler-core/src/utils/id.d.ts +16 -0
- package/scheduler-core/src/utils/index.d.ts +3 -0
- package/select/index.mjs +4 -0
- package/select/src/components/index.d.ts +2 -0
- package/select/src/components/mp-select.d.ts +82 -0
- package/select/src/index.d.ts +2 -0
- package/splitter/index.mjs +10 -0
- package/splitter/src/components/index.d.ts +2 -0
- package/splitter/src/components/mp-splitter.d.ts +109 -0
- package/splitter/src/index.d.ts +11 -0
- package/splitter/src/input/index.d.ts +4 -0
- package/splitter/src/input/input-handler.d.ts +36 -0
- package/splitter/src/input/pointer-event.d.ts +9 -0
- package/splitter/src/managers/index.d.ts +2 -0
- package/splitter/src/managers/resize-manager.d.ts +13 -0
- package/splitter/src/state/index.d.ts +2 -0
- package/splitter/src/state/splitter-state.d.ts +24 -0
- package/splitter/src/styles/index.d.ts +1 -0
- package/splitter/src/styles/splitter.styles.d.ts +2 -0
- package/splitter/src/types/direction.d.ts +1 -0
- package/splitter/src/types/index.d.ts +5 -0
- package/splitter/src/types/panel-info.d.ts +6 -0
- package/splitter/src/types/point.d.ts +4 -0
- package/splitter/src/types/resize-operation.d.ts +13 -0
- package/tab-control/index.mjs +6 -0
- package/tab-control/src/components/index.d.ts +3 -0
- package/tab-control/src/components/mp-tab-control.d.ts +50 -0
- package/tab-control/src/components/mp-tab-page.d.ts +35 -0
- package/tab-control/src/index.d.ts +4 -0
- package/tab-control/src/styles/index.d.ts +1 -0
- package/tab-control/src/styles/tab-control.styles.d.ts +2 -0
- package/tab-control/src/types/index.d.ts +1 -0
- package/tab-control/src/types/tabs-position.d.ts +1 -0
- package/tile-manager/index.mjs +867 -0
- package/tile-manager/src/components/index.d.ts +2 -0
- package/tile-manager/src/components/mint-tile-manager.element.d.ts +204 -0
- package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +2 -0
- package/tile-manager/src/index.d.ts +4 -0
- package/tile-manager/src/types/grid-rect.d.ts +12 -0
- package/tile-manager/src/types/index.d.ts +3 -0
- package/tile-manager/src/types/tile-layout-snapshot.d.ts +15 -0
- package/tile-manager/src/types/tile-position.d.ts +10 -0
- package/tile-manager/src/utils/index.d.ts +1 -0
- package/tile-manager/src/utils/pack.d.ts +24 -0
- package/timepicker/index.mjs +5 -0
- package/timepicker/src/index.d.ts +2 -0
- package/timepicker/src/mp-time-list.element.d.ts +76 -0
- package/timepicker/src/mp-time-list.element.template.d.ts +2 -0
- package/timepicker/src/mp-timepicker.element.d.ts +87 -0
- package/timepicker/src/mp-timepicker.element.template.d.ts +2 -0
- package/toggle-button/index.mjs +5 -0
- package/toggle-button/src/components/index.d.ts +2 -0
- package/toggle-button/src/components/mp-toggle-button.d.ts +50 -0
- package/toggle-button/src/index.d.ts +3 -0
- package/toggle-button/src/styles/index.d.ts +1 -0
- package/toggle-button/src/styles/toggle-button.styles.d.ts +2 -0
- package/treeview/index.mjs +5 -0
- package/treeview/src/components/index.d.ts +2 -0
- package/treeview/src/components/mp-treeview.d.ts +113 -0
- package/treeview/src/index.d.ts +4 -0
- package/treeview/src/styles/index.d.ts +1 -0
- package/treeview/src/styles/treeview.styles.d.ts +2 -0
- package/treeview/src/types/index.d.ts +1 -0
- package/treeview/src/types/tree-node.d.ts +14 -0
- package/custom-elements.json +0 -1774
package/dock/index.mjs
ADDED
|
@@ -0,0 +1,2402 @@
|
|
|
1
|
+
import { html as D, unsafeCSS as E, LitElement as _ } from "lit";
|
|
2
|
+
import "../chunks/mp-tab-page-D1b4x-y2.mjs";
|
|
3
|
+
import "../chunks/mp-splitter-C8cGCmac.mjs";
|
|
4
|
+
import { L as A } from "../chunks/live-announcer-CZDTKulf.mjs";
|
|
5
|
+
const I = D`<div class="dock-root">
|
|
6
|
+
<div class="dock-docked"></div>
|
|
7
|
+
<div class="dock-floating-layer"></div>
|
|
8
|
+
<div class="dock-intersections-layer dock-intersection-layer"></div>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="dock-drop-indicator"></div>
|
|
11
|
+
<div class="dock-drop-joystick" data-visible="false">
|
|
12
|
+
<div class="dock-drop-joystick__spacer"></div>
|
|
13
|
+
<button
|
|
14
|
+
class="dock-drop-joystick__button"
|
|
15
|
+
type="button"
|
|
16
|
+
data-zone="top"
|
|
17
|
+
aria-label="Dock to top"
|
|
18
|
+
>
|
|
19
|
+
↑
|
|
20
|
+
</button>
|
|
21
|
+
<div class="dock-drop-joystick__spacer"></div>
|
|
22
|
+
<button
|
|
23
|
+
class="dock-drop-joystick__button"
|
|
24
|
+
type="button"
|
|
25
|
+
data-zone="left"
|
|
26
|
+
aria-label="Dock to left"
|
|
27
|
+
>
|
|
28
|
+
←
|
|
29
|
+
</button>
|
|
30
|
+
<button
|
|
31
|
+
class="dock-drop-joystick__button"
|
|
32
|
+
type="button"
|
|
33
|
+
data-zone="center"
|
|
34
|
+
aria-label="Dock to center"
|
|
35
|
+
>
|
|
36
|
+
•
|
|
37
|
+
</button>
|
|
38
|
+
<button
|
|
39
|
+
class="dock-drop-joystick__button"
|
|
40
|
+
type="button"
|
|
41
|
+
data-zone="right"
|
|
42
|
+
aria-label="Dock to right"
|
|
43
|
+
>
|
|
44
|
+
→
|
|
45
|
+
</button>
|
|
46
|
+
<div class="dock-drop-joystick__spacer"></div>
|
|
47
|
+
<button
|
|
48
|
+
class="dock-drop-joystick__button"
|
|
49
|
+
type="button"
|
|
50
|
+
data-zone="bottom"
|
|
51
|
+
aria-label="Dock to bottom"
|
|
52
|
+
>
|
|
53
|
+
↓
|
|
54
|
+
</button>
|
|
55
|
+
<div class="dock-drop-joystick__spacer"></div>
|
|
56
|
+
</div>`, C = E(`:host {
|
|
57
|
+
display: block;
|
|
58
|
+
position: relative;
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: 100%;
|
|
61
|
+
contain: layout paint size style;
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
font-family: inherit;
|
|
64
|
+
color: inherit;
|
|
65
|
+
--dock-split-gap: 0.25rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.dock-root,
|
|
69
|
+
.dock-docked,
|
|
70
|
+
.dock-split,
|
|
71
|
+
.dock-stack,
|
|
72
|
+
.dock-stack__pane {
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
min-width: 0;
|
|
75
|
+
min-height: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.dock-root {
|
|
79
|
+
position: relative;
|
|
80
|
+
width: 100%;
|
|
81
|
+
height: 100%;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.dock-docked {
|
|
85
|
+
position: absolute;
|
|
86
|
+
inset: 0;
|
|
87
|
+
display: flex;
|
|
88
|
+
z-index: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.dock-floating-layer {
|
|
92
|
+
position: absolute;
|
|
93
|
+
inset: 0;
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
z-index: 5;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.dock-intersections-layer {
|
|
99
|
+
position: absolute;
|
|
100
|
+
inset: 0;
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
z-index: 120;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.dock-floating {
|
|
106
|
+
position: absolute;
|
|
107
|
+
box-sizing: border-box;
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
pointer-events: auto;
|
|
111
|
+
border: 1px solid var(--bs-border-color);
|
|
112
|
+
border-radius: 0.5rem;
|
|
113
|
+
background: var(--bs-body-bg);
|
|
114
|
+
box-shadow: var(--bs-box-shadow-lg);
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
min-width: 12rem;
|
|
117
|
+
min-height: 8rem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.dock-floating[data-dragging=true] {
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.dock-floating__chrome {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
gap: 0.5rem;
|
|
128
|
+
padding: 0.35rem 0.75rem;
|
|
129
|
+
cursor: move;
|
|
130
|
+
touch-action: none;
|
|
131
|
+
background: linear-gradient(to bottom, rgba(var(--bs-primary-rgb), 0.15), rgba(var(--bs-primary-rgb), 0.05));
|
|
132
|
+
border-bottom: 1px solid var(--bs-primary-border-subtle);
|
|
133
|
+
user-select: none;
|
|
134
|
+
-webkit-user-select: none;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.dock-floating__title {
|
|
138
|
+
flex: 1 1 auto;
|
|
139
|
+
font-size: 0.875rem;
|
|
140
|
+
font-weight: 500;
|
|
141
|
+
color: var(--bs-body-color);
|
|
142
|
+
overflow: hidden;
|
|
143
|
+
text-overflow: ellipsis;
|
|
144
|
+
white-space: nowrap;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.dock-floating__close {
|
|
148
|
+
flex: 0 0 auto;
|
|
149
|
+
appearance: none;
|
|
150
|
+
background: transparent;
|
|
151
|
+
border: 0;
|
|
152
|
+
color: var(--bs-body-color);
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
font-size: 1.25rem;
|
|
155
|
+
line-height: 1;
|
|
156
|
+
padding: 0 0.4rem;
|
|
157
|
+
border-radius: 3px;
|
|
158
|
+
margin-top: -1px;
|
|
159
|
+
}
|
|
160
|
+
.dock-floating__close:hover {
|
|
161
|
+
background: rgba(var(--bs-primary-rgb), 0.15);
|
|
162
|
+
}
|
|
163
|
+
.dock-floating__close:focus-visible {
|
|
164
|
+
outline: 2px solid var(--bs-primary);
|
|
165
|
+
outline-offset: 1px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.dock-floating > .dock-stack {
|
|
169
|
+
flex: 1 1 auto;
|
|
170
|
+
min-width: 12rem;
|
|
171
|
+
min-height: 8rem;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.dock-floating__resizer {
|
|
175
|
+
position: absolute;
|
|
176
|
+
pointer-events: auto;
|
|
177
|
+
z-index: 2;
|
|
178
|
+
background: rgba(var(--bs-primary-rgb), 0.1);
|
|
179
|
+
transition: background 120ms ease;
|
|
180
|
+
touch-action: none;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.dock-floating__resizer:hover,
|
|
184
|
+
.dock-floating__resizer[data-resizing=true] {
|
|
185
|
+
background: rgba(var(--bs-primary-rgb), 0.3);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.dock-floating__resizer--top,
|
|
189
|
+
.dock-floating__resizer--bottom {
|
|
190
|
+
left: 0.75rem;
|
|
191
|
+
right: 0.75rem;
|
|
192
|
+
height: 0.5rem;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.dock-floating__resizer--top {
|
|
196
|
+
top: 0;
|
|
197
|
+
cursor: n-resize;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.dock-floating__resizer--bottom {
|
|
201
|
+
bottom: 0;
|
|
202
|
+
cursor: s-resize;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.dock-floating__resizer--left,
|
|
206
|
+
.dock-floating__resizer--right {
|
|
207
|
+
top: 1.75rem;
|
|
208
|
+
bottom: 0.75rem;
|
|
209
|
+
width: 0.5rem;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.dock-floating__resizer--left {
|
|
213
|
+
left: 0;
|
|
214
|
+
cursor: w-resize;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.dock-floating__resizer--right {
|
|
218
|
+
right: 0;
|
|
219
|
+
cursor: e-resize;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.dock-floating__resizer--top-left,
|
|
223
|
+
.dock-floating__resizer--top-right,
|
|
224
|
+
.dock-floating__resizer--bottom-left,
|
|
225
|
+
.dock-floating__resizer--bottom-right {
|
|
226
|
+
width: 0.75rem;
|
|
227
|
+
height: 0.75rem;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.dock-floating__resizer--top-left {
|
|
231
|
+
top: 0;
|
|
232
|
+
left: 0;
|
|
233
|
+
cursor: nw-resize;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.dock-floating__resizer--top-right {
|
|
237
|
+
top: 0;
|
|
238
|
+
right: 0;
|
|
239
|
+
cursor: ne-resize;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.dock-floating__resizer--bottom-left {
|
|
243
|
+
bottom: 0;
|
|
244
|
+
left: 0;
|
|
245
|
+
cursor: sw-resize;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.dock-floating__resizer--bottom-right {
|
|
249
|
+
right: 0;
|
|
250
|
+
bottom: 0;
|
|
251
|
+
cursor: se-resize;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.dock-split {
|
|
255
|
+
flex: 1 1 0;
|
|
256
|
+
position: relative;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.dock-intersection-handle {
|
|
260
|
+
position: absolute;
|
|
261
|
+
width: 1rem;
|
|
262
|
+
height: 1rem;
|
|
263
|
+
margin-left: -0.5rem;
|
|
264
|
+
margin-top: -0.5rem;
|
|
265
|
+
border-radius: 0.375rem;
|
|
266
|
+
background: rgba(var(--bs-primary-rgb), 0.4);
|
|
267
|
+
border: 1px solid var(--bs-primary);
|
|
268
|
+
box-shadow: var(--bs-box-shadow-sm);
|
|
269
|
+
cursor: all-scroll;
|
|
270
|
+
pointer-events: auto;
|
|
271
|
+
touch-action: none;
|
|
272
|
+
opacity: 0.6;
|
|
273
|
+
transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.dock-intersection-handle:hover,
|
|
277
|
+
.dock-intersection-handle:focus-visible,
|
|
278
|
+
.dock-intersection-handle[data-visible=true],
|
|
279
|
+
.dock-intersection-handle[data-resizing=true] {
|
|
280
|
+
background: rgba(var(--bs-primary-rgb), 0.35);
|
|
281
|
+
border-color: var(--bs-primary);
|
|
282
|
+
opacity: 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.dock-intersection-handle:focus-visible {
|
|
286
|
+
outline: 2px solid var(--bs-primary);
|
|
287
|
+
outline-offset: 1px;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.dock-snap-marker {
|
|
291
|
+
position: absolute;
|
|
292
|
+
width: 6px;
|
|
293
|
+
height: 6px;
|
|
294
|
+
margin-left: -3px;
|
|
295
|
+
margin-top: -3px;
|
|
296
|
+
border-radius: 50%;
|
|
297
|
+
background: var(--bs-primary);
|
|
298
|
+
box-shadow: 0 0 0 2px var(--bs-primary-bg-subtle);
|
|
299
|
+
pointer-events: none;
|
|
300
|
+
z-index: 130;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.dock-stack {
|
|
304
|
+
flex: 1 1 0;
|
|
305
|
+
border: 1px solid var(--bs-border-color);
|
|
306
|
+
border-radius: 0.25rem;
|
|
307
|
+
background: var(--bs-body-bg);
|
|
308
|
+
backdrop-filter: blur(4px);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.dock-tab {
|
|
312
|
+
cursor: grab;
|
|
313
|
+
display: block;
|
|
314
|
+
padding: 0.5rem 1rem;
|
|
315
|
+
margin: -0.5rem -1rem;
|
|
316
|
+
touch-action: none;
|
|
317
|
+
user-select: none;
|
|
318
|
+
-webkit-user-select: none;
|
|
319
|
+
-webkit-touch-callout: none;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.dock-tab:active {
|
|
323
|
+
cursor: grabbing;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.dock-tab[data-pressing=true] {
|
|
327
|
+
background-color: var(--bs-secondary-bg-subtle, rgba(0, 0, 0, 0.05));
|
|
328
|
+
transform: scale(1.02);
|
|
329
|
+
transition: background-color 100ms ease-out, transform 100ms ease-out;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.dock-stack__pane {
|
|
333
|
+
position: relative;
|
|
334
|
+
display: flex;
|
|
335
|
+
flex-direction: column;
|
|
336
|
+
overflow: hidden;
|
|
337
|
+
height: 100%;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.dock-drop-indicator {
|
|
341
|
+
position: absolute;
|
|
342
|
+
pointer-events: none;
|
|
343
|
+
border: 2px solid var(--bs-primary);
|
|
344
|
+
background: rgba(var(--bs-primary-rgb), 0.2);
|
|
345
|
+
border-radius: 0.25rem;
|
|
346
|
+
opacity: 0;
|
|
347
|
+
transition: opacity 120ms ease;
|
|
348
|
+
z-index: 100;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.dock-drop-indicator[data-visible=true] {
|
|
352
|
+
opacity: 1;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.dock-drop-joystick {
|
|
356
|
+
position: absolute;
|
|
357
|
+
display: grid;
|
|
358
|
+
grid-template-columns: repeat(3, min-content);
|
|
359
|
+
grid-template-rows: repeat(3, min-content);
|
|
360
|
+
gap: 0.125rem;
|
|
361
|
+
padding: 0.125rem;
|
|
362
|
+
border-radius: 999px;
|
|
363
|
+
background: var(--bs-tertiary-bg);
|
|
364
|
+
box-shadow: var(--bs-box-shadow);
|
|
365
|
+
pointer-events: none;
|
|
366
|
+
transform: translate(-50%, -50%);
|
|
367
|
+
z-index: 110;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.dock-drop-joystick__spacer {
|
|
371
|
+
width: 1.75rem;
|
|
372
|
+
height: 1.75rem;
|
|
373
|
+
pointer-events: none;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.dock-drop-joystick__button {
|
|
377
|
+
width: 1.75rem;
|
|
378
|
+
height: 1.75rem;
|
|
379
|
+
display: inline-flex;
|
|
380
|
+
align-items: center;
|
|
381
|
+
justify-content: center;
|
|
382
|
+
border-radius: 0.375rem;
|
|
383
|
+
border: 1px solid var(--bs-primary-border-subtle);
|
|
384
|
+
background: var(--bs-body-bg);
|
|
385
|
+
color: var(--bs-primary);
|
|
386
|
+
font-size: 0.75rem;
|
|
387
|
+
line-height: 1;
|
|
388
|
+
font-weight: 600;
|
|
389
|
+
pointer-events: auto;
|
|
390
|
+
cursor: pointer;
|
|
391
|
+
transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.dock-drop-joystick__button[data-active=true],
|
|
395
|
+
.dock-drop-joystick__button:hover,
|
|
396
|
+
.dock-drop-joystick__button:focus-visible {
|
|
397
|
+
background: var(--bs-primary-bg-subtle);
|
|
398
|
+
border-color: var(--bs-primary);
|
|
399
|
+
color: var(--bs-primary);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.dock-drop-joystick__button:focus-visible {
|
|
403
|
+
outline: 2px solid var(--bs-primary);
|
|
404
|
+
outline-offset: 1px;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.dock-drop-joystick__button[data-zone=center] {
|
|
408
|
+
border-radius: 0.5rem;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
::slotted(*) {
|
|
412
|
+
flex: 1 1 auto;
|
|
413
|
+
display: block;
|
|
414
|
+
min-width: 0;
|
|
415
|
+
min-height: 0;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
@media (prefers-reduced-motion: reduce) {
|
|
419
|
+
.dock-floating,
|
|
420
|
+
.dock-floating__resizer,
|
|
421
|
+
.dock-floating__close,
|
|
422
|
+
.dock-intersection-handle,
|
|
423
|
+
.dock-drop-indicator,
|
|
424
|
+
.dock-drop-joystick__button {
|
|
425
|
+
transition: none !important;
|
|
426
|
+
animation: none !important;
|
|
427
|
+
}
|
|
428
|
+
}`);
|
|
429
|
+
class v extends _ {
|
|
430
|
+
constructor() {
|
|
431
|
+
super(), this.liveAnnouncer = new A(this), this.paneMoveMode = 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.instanceId = `mint-dock-${++v.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);
|
|
432
|
+
}
|
|
433
|
+
static {
|
|
434
|
+
this.styles = [C];
|
|
435
|
+
}
|
|
436
|
+
static {
|
|
437
|
+
this.documentRef = typeof document < "u" ? document : null;
|
|
438
|
+
}
|
|
439
|
+
static configureDocument(t) {
|
|
440
|
+
t && (v.documentRef = t);
|
|
441
|
+
}
|
|
442
|
+
static get observedAttributes() {
|
|
443
|
+
return [...super.observedAttributes ?? [], "layout", "debug-layout-integrity"];
|
|
444
|
+
}
|
|
445
|
+
static {
|
|
446
|
+
this.instanceCounter = 0;
|
|
447
|
+
}
|
|
448
|
+
static {
|
|
449
|
+
this.TOUCH_LONG_PRESS_MS = 600;
|
|
450
|
+
}
|
|
451
|
+
static {
|
|
452
|
+
this.TOUCH_LONG_PRESS_SLOP_PX = 10;
|
|
453
|
+
}
|
|
454
|
+
static {
|
|
455
|
+
this.TOUCH_PRESS_FEEDBACK_DELAY_MS = 150;
|
|
456
|
+
}
|
|
457
|
+
renderSnapMarkersForCorner() {
|
|
458
|
+
if (!this.showSnapMarkers) return;
|
|
459
|
+
const t = this.shadowRoot?.querySelector(".dock-intersections-layer, .dock-intersection-layer");
|
|
460
|
+
if (!t || (Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((r) => r.remove()), !this.cornerResizeState)) return;
|
|
461
|
+
const e = this.rootEl.getBoundingClientRect();
|
|
462
|
+
let i = null, o = null;
|
|
463
|
+
const n = this.cornerResizeState;
|
|
464
|
+
if (n.vs.length > 0) {
|
|
465
|
+
const r = n.vs[0], l = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
|
|
466
|
+
l && (i = l.left + l.width / 2 - e.left);
|
|
467
|
+
}
|
|
468
|
+
if (n.hs.length > 0) {
|
|
469
|
+
const r = n.hs[0], l = this.getSplitterDividers(r.container)[r.index]?.getBoundingClientRect();
|
|
470
|
+
l && (o = l.top + l.height / 2 - e.top);
|
|
471
|
+
}
|
|
472
|
+
o != null && this.cornerSnapXTargets.forEach((r) => {
|
|
473
|
+
const c = this.documentRef.createElement("div");
|
|
474
|
+
c.className = "dock-snap-marker", c.style.left = `${r}px`, c.style.top = `${o}px`, t.appendChild(c);
|
|
475
|
+
}), i != null && this.cornerSnapYTargets.forEach((r) => {
|
|
476
|
+
const c = this.documentRef.createElement("div");
|
|
477
|
+
c.className = "dock-snap-marker", c.style.left = `${i}px`, c.style.top = `${r}px`, t.appendChild(c);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
clearSnapMarkers() {
|
|
481
|
+
if (!this.showSnapMarkers) return;
|
|
482
|
+
const t = this.shadowRoot?.querySelector(".dock-intersections-layer, .dock-intersection-layer");
|
|
483
|
+
t && Array.from(t.querySelectorAll(".dock-snap-marker")).forEach((e) => e.remove());
|
|
484
|
+
}
|
|
485
|
+
render() {
|
|
486
|
+
return D`${I}${this.liveAnnouncer.template()}`;
|
|
487
|
+
}
|
|
488
|
+
firstUpdated() {
|
|
489
|
+
const t = this.resolveDocument();
|
|
490
|
+
this.documentRef = t, this.windowRef = this.resolveWindow(t);
|
|
491
|
+
const e = this.shadowRoot, i = e.querySelector(".dock-root");
|
|
492
|
+
if (!i)
|
|
493
|
+
throw new Error("mint-dock-manager template is missing the root element.");
|
|
494
|
+
const o = e.querySelector(".dock-docked");
|
|
495
|
+
if (!o)
|
|
496
|
+
throw new Error("mint-dock-manager template is missing the docked surface element.");
|
|
497
|
+
const n = e.querySelector(".dock-floating-layer");
|
|
498
|
+
if (!n)
|
|
499
|
+
throw new Error("mint-dock-manager template is missing the floating layer element.");
|
|
500
|
+
const r = e.querySelector(".dock-drop-indicator");
|
|
501
|
+
if (!r)
|
|
502
|
+
throw new Error("mint-dock-manager template is missing the drop indicator element.");
|
|
503
|
+
const c = e.querySelector(".dock-drop-joystick");
|
|
504
|
+
if (!c)
|
|
505
|
+
throw new Error("mint-dock-manager template is missing the drop joystick element.");
|
|
506
|
+
const l = Array.from(
|
|
507
|
+
c.querySelectorAll(".dock-drop-joystick__button[data-zone]")
|
|
508
|
+
);
|
|
509
|
+
if (l.length === 0)
|
|
510
|
+
throw new Error("mint-dock-manager template is missing drop joystick buttons.");
|
|
511
|
+
this.rootEl = i, this.dockedEl = o, this.floatingLayerEl = n, this.dropIndicator = r, this.dropJoystick = c, this.dropJoystickButtons = l, this.dockedEl.dataset.path = this.formatPath({ type: "docked", segments: [] }), i.addEventListener("keydown", (s) => this.onRootKeyDown(s), { capture: !0 }), this.renderLayout(), this.rootResizeObserver = new ResizeObserver(() => {
|
|
512
|
+
this.scheduleRenderIntersectionHandles(), this.updateFloatingPanePositions();
|
|
513
|
+
}), 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);
|
|
514
|
+
}
|
|
515
|
+
connectedCallback() {
|
|
516
|
+
super.connectedCallback(), this.hasAttribute("role") || this.setAttribute("role", "application");
|
|
517
|
+
}
|
|
518
|
+
disconnectedCallback() {
|
|
519
|
+
const t = this.windowRef;
|
|
520
|
+
this.stopDragPointerTracking(), t?.removeEventListener("pointermove", this.onPointerMove), t?.removeEventListener("pointerup", this.onPointerUp), t?.removeEventListener("pointercancel", this.onPointerCancel), this.pointerTrackingActive = !1, this.rootResizeObserver?.disconnect(), this.rootResizeObserver = null, this.dockedMutationObserver?.disconnect(), this.dockedMutationObserver = null, this.dockedEl?.removeEventListener("resizing", this.onSplitterResize), this.dockedEl?.removeEventListener("resize-end", this.onSplitterResize), this.intersectionRaf !== null && (this.windowRef?.clearTimeout(this.intersectionRaf), this.intersectionRaf = null), super.disconnectedCallback();
|
|
521
|
+
}
|
|
522
|
+
attributeChangedCallback(t, e, i) {
|
|
523
|
+
super.attributeChangedCallback(t, e, i), t === "layout" ? this.layout = i ? this.parseLayout(i) : null : t === "debug-snap-markers" ? (this.showSnapMarkers = !(i === null || i === "false" || i === "0"), this.showSnapMarkers || this.clearSnapMarkers()) : t === "debug-layout-integrity" && (this.debugLayoutIntegrity = !(i === null || i === "false" || i === "0"));
|
|
524
|
+
}
|
|
525
|
+
get layout() {
|
|
526
|
+
return {
|
|
527
|
+
root: this.cloneLayoutNode(this.rootLayout),
|
|
528
|
+
floating: this.cloneFloatingArray(this.floatingLayouts),
|
|
529
|
+
titles: { ...this.titles }
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
set layout(t) {
|
|
533
|
+
const e = this.ensureSnapshot(t);
|
|
534
|
+
if (this.isInteracting()) return;
|
|
535
|
+
const i = JSON.stringify({
|
|
536
|
+
root: this.rootLayout,
|
|
537
|
+
floating: this.floatingLayouts,
|
|
538
|
+
titles: this.titles
|
|
539
|
+
}), o = JSON.stringify(e);
|
|
540
|
+
i !== o && (this.rootLayout = this.cloneLayoutNode(e.root), this.floatingLayouts = this.cloneFloatingArray(e.floating), this.titles = e.titles ? { ...e.titles } : {}, this.normalizeAllLayouts(), this.renderLayout());
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* True while the user is actively interacting with the dock — pane drag,
|
|
544
|
+
* floating window drag, floating window resize, or intersection corner
|
|
545
|
+
* resize. The `set layout` setter consults this to refuse external
|
|
546
|
+
* round-trips that would overwrite in-progress drag state.
|
|
547
|
+
*/
|
|
548
|
+
isInteracting() {
|
|
549
|
+
return !!(this.dragState || this.floatingDragState || this.floatingResizeState || this.cornerResizeState);
|
|
550
|
+
}
|
|
551
|
+
get snapshot() {
|
|
552
|
+
return this.layout;
|
|
553
|
+
}
|
|
554
|
+
toJSON() {
|
|
555
|
+
return this.snapshot;
|
|
556
|
+
}
|
|
557
|
+
resolveDocument() {
|
|
558
|
+
const t = v.documentRef, e = this.ownerDocument ?? null, o = t ?? e ?? (typeof document < "u" ? document : null);
|
|
559
|
+
if (!o)
|
|
560
|
+
throw new Error("mint-dock-manager requires a Document to initialize.");
|
|
561
|
+
return v.documentRef || (v.documentRef = o), o;
|
|
562
|
+
}
|
|
563
|
+
resolveWindow(t) {
|
|
564
|
+
return typeof window < "u" ? window : t.defaultView ?? null;
|
|
565
|
+
}
|
|
566
|
+
parseLayout(t) {
|
|
567
|
+
try {
|
|
568
|
+
const e = JSON.parse(t);
|
|
569
|
+
return this.ensureSnapshot(e);
|
|
570
|
+
} catch (e) {
|
|
571
|
+
return console.warn("mint-dock-manager: failed to parse layout attribute", e), null;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
ensureSnapshot(t) {
|
|
575
|
+
if (!t)
|
|
576
|
+
return { root: null, floating: [], titles: {} };
|
|
577
|
+
if (t.kind)
|
|
578
|
+
return { root: t, floating: [], titles: {} };
|
|
579
|
+
const e = t;
|
|
580
|
+
return {
|
|
581
|
+
root: e.root ?? null,
|
|
582
|
+
floating: Array.isArray(e.floating) ? e.floating.map((i) => this.normalizeFloatingLayout(i)) : [],
|
|
583
|
+
titles: e.titles ? { ...e.titles } : {}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
renderLayout() {
|
|
587
|
+
if (this.dockedEl) {
|
|
588
|
+
if (this.dockedEl.innerHTML = "", this.floatingLayerEl.innerHTML = "", this.hideDropIndicator(), this.rootLayout) {
|
|
589
|
+
const t = this.renderNode(this.rootLayout, []);
|
|
590
|
+
this.dockedEl.appendChild(t);
|
|
591
|
+
}
|
|
592
|
+
this.renderFloatingPanes(), this.verifyProjectionSlots();
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
renderNode(t, e, i) {
|
|
596
|
+
return t.kind === "split" ? this.renderSplit(t, e, i) : this.renderStack(t, e, i);
|
|
597
|
+
}
|
|
598
|
+
renderFloatingPanes() {
|
|
599
|
+
this.floatingLayerEl.innerHTML = "";
|
|
600
|
+
const t = this.getHostSize();
|
|
601
|
+
this.floatingLayouts.forEach((e, i) => {
|
|
602
|
+
const o = this.documentRef.createElement("div");
|
|
603
|
+
o.classList.add("dock-floating"), o.dataset.path = this.formatPath({
|
|
604
|
+
type: "floating",
|
|
605
|
+
index: i,
|
|
606
|
+
segments: []
|
|
607
|
+
});
|
|
608
|
+
const n = this.getFloatingWindowTitle(e), r = `${this.instanceId}-floating-${i}-title`;
|
|
609
|
+
o.setAttribute("role", "dialog"), o.setAttribute("aria-labelledby", r), o.setAttribute("aria-modal", "false");
|
|
610
|
+
const { left: c, top: l, width: s, height: a } = this.clampBoundsToHost(e.bounds, t);
|
|
611
|
+
o.style.left = `${c}px`, o.style.top = `${l}px`, o.style.width = `${s}px`, o.style.height = `${a}px`, o.style.minWidth = "0", o.style.minHeight = "0";
|
|
612
|
+
const h = this.getFloatingPaneZIndex(i);
|
|
613
|
+
o.style.zIndex = String(h);
|
|
614
|
+
const u = this.documentRef.createElement("div");
|
|
615
|
+
u.classList.add("dock-floating__chrome"), u.addEventListener(
|
|
616
|
+
"pointerdown",
|
|
617
|
+
(p) => this.beginFloatingDrag(p, i, o, u)
|
|
618
|
+
);
|
|
619
|
+
const d = this.documentRef.createElement("div");
|
|
620
|
+
d.classList.add("dock-floating__title"), d.id = r, d.textContent = n, u.appendChild(d);
|
|
621
|
+
const g = this.documentRef.createElement("button");
|
|
622
|
+
if (g.type = "button", g.classList.add("dock-floating__close"), g.setAttribute("aria-label", `Close pane: ${n}`), g.textContent = "×", g.addEventListener("click", (p) => {
|
|
623
|
+
p.stopPropagation(), this.closeFloatingPane(i);
|
|
624
|
+
}), g.addEventListener("pointerdown", (p) => p.stopPropagation()), u.appendChild(g), o.appendChild(u), e.root) {
|
|
625
|
+
const p = this.renderNode(e.root, [], i);
|
|
626
|
+
p.classList.add("dock-floating__stack"), o.appendChild(p);
|
|
627
|
+
} else {
|
|
628
|
+
const p = this.documentRef.createElement("div");
|
|
629
|
+
p.classList.add("dock-stack"), p.dataset.path = this.formatPath({
|
|
630
|
+
type: "floating",
|
|
631
|
+
index: i,
|
|
632
|
+
segments: []
|
|
633
|
+
});
|
|
634
|
+
const m = this.documentRef.createElement("div");
|
|
635
|
+
m.classList.add("dock-stack__pane"), m.textContent = "No panes configured", p.appendChild(m), o.appendChild(p);
|
|
636
|
+
}
|
|
637
|
+
[
|
|
638
|
+
{
|
|
639
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--top-left"],
|
|
640
|
+
edges: { horizontal: "left", vertical: "top" }
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--top"],
|
|
644
|
+
edges: { horizontal: "none", vertical: "top" }
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--top-right"],
|
|
648
|
+
edges: { horizontal: "right", vertical: "top" }
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--right"],
|
|
652
|
+
edges: { horizontal: "right", vertical: "none" }
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--bottom-right"],
|
|
656
|
+
edges: { horizontal: "right", vertical: "bottom" }
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--bottom"],
|
|
660
|
+
edges: { horizontal: "none", vertical: "bottom" }
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--bottom-left"],
|
|
664
|
+
edges: { horizontal: "left", vertical: "bottom" }
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
classes: ["dock-floating__resizer", "dock-floating__resizer--left"],
|
|
668
|
+
edges: { horizontal: "left", vertical: "none" }
|
|
669
|
+
}
|
|
670
|
+
].forEach(({ classes: p, edges: m }) => {
|
|
671
|
+
const y = this.documentRef.createElement("div");
|
|
672
|
+
y.classList.add(...p), y.setAttribute("role", "separator");
|
|
673
|
+
const b = m.horizontal === "none" && m.vertical !== "none", z = m.vertical === "none" && m.horizontal !== "none";
|
|
674
|
+
b ? y.setAttribute("aria-orientation", "horizontal") : z && y.setAttribute("aria-orientation", "vertical");
|
|
675
|
+
const S = [];
|
|
676
|
+
m.vertical === "top" ? S.push("top") : m.vertical === "bottom" && S.push("bottom"), m.horizontal === "left" ? S.push("left") : m.horizontal === "right" && S.push("right"), y.setAttribute(
|
|
677
|
+
"aria-label",
|
|
678
|
+
`Resize pane ${S.length === 2 ? "corner " : "edge "}${S.join("-")}`
|
|
679
|
+
), y.addEventListener(
|
|
680
|
+
"pointerdown",
|
|
681
|
+
(P) => this.beginFloatingResize(P, i, o, y, m)
|
|
682
|
+
), o.appendChild(y);
|
|
683
|
+
}), this.floatingLayerEl.appendChild(o);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
onSplitterResize() {
|
|
687
|
+
this.scheduleRenderIntersectionHandles();
|
|
688
|
+
}
|
|
689
|
+
scheduleRenderIntersectionHandles() {
|
|
690
|
+
if (this.intersectionRaf !== null) return;
|
|
691
|
+
const t = this.windowRef;
|
|
692
|
+
t && (this.intersectionRaf = t.setTimeout(() => {
|
|
693
|
+
this.intersectionRaf = null, this.renderIntersectionHandles();
|
|
694
|
+
}, 5));
|
|
695
|
+
}
|
|
696
|
+
renderIntersectionHandles() {
|
|
697
|
+
const t = this.shadowRoot?.querySelector(".dock-intersections-layer, .dock-intersection-layer");
|
|
698
|
+
if (!t) return;
|
|
699
|
+
const e = this.rootEl.getBoundingClientRect();
|
|
700
|
+
if (this.cornerResizeState) {
|
|
701
|
+
const l = this.cornerResizeState, s = l.hs[0], a = l.vs[0], h = this.findSplitterByPath(s.path.segments), u = this.findSplitterByPath(a.path.segments), d = h ? this.getSplitterDividers(h)[s.index] : null, g = u ? this.getSplitterDividers(u)[a.index] : null;
|
|
702
|
+
if (d && g) {
|
|
703
|
+
const f = d.getBoundingClientRect(), p = g.getBoundingClientRect(), m = p.left + p.width / 2 - e.left, y = f.top + f.height / 2 - e.top;
|
|
704
|
+
l.handle.style.left = `${m}px`, l.handle.style.top = `${y}px`, Array.from(t.querySelectorAll(".dock-intersection-handle")).forEach((b) => {
|
|
705
|
+
b !== l.handle && b.remove();
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
t.replaceChildren();
|
|
711
|
+
const i = [], o = [];
|
|
712
|
+
Array.from(
|
|
713
|
+
this.shadowRoot?.querySelectorAll(".dock-split") ?? []
|
|
714
|
+
).forEach((l) => {
|
|
715
|
+
const s = l.dataset.direction, a = l.dataset.path ?? "", h = this.splitterLayerKey(l);
|
|
716
|
+
this.getSplitterDividers(l).forEach((u, d) => {
|
|
717
|
+
const g = { rect: u.getBoundingClientRect(), pathStr: a, index: d, layerKey: h };
|
|
718
|
+
s === "horizontal" ? o.push(g) : s === "vertical" && i.push(g);
|
|
719
|
+
});
|
|
720
|
+
});
|
|
721
|
+
const r = 24, c = /* @__PURE__ */ new Map();
|
|
722
|
+
i.forEach((l) => {
|
|
723
|
+
const s = l.rect.top + l.rect.height / 2;
|
|
724
|
+
o.forEach((a) => {
|
|
725
|
+
if (l.layerKey !== a.layerKey) return;
|
|
726
|
+
const h = a.rect.left + a.rect.width / 2, u = h < l.rect.left ? l.rect.left - h : h > l.rect.right ? h - l.rect.right : 0, d = s < a.rect.top ? a.rect.top - s : s > a.rect.bottom ? s - a.rect.bottom : 0;
|
|
727
|
+
if (u > r || d > r) return;
|
|
728
|
+
const g = h - e.left, f = s - e.top, p = `${Math.round(g)}:${Math.round(f)}`, m = c.get(p) ?? { x: g, y: f, pairs: [] };
|
|
729
|
+
m.pairs.push({ h: { pathStr: l.pathStr, index: l.index }, v: { pathStr: a.pathStr, index: a.index } }), c.set(p, m);
|
|
730
|
+
});
|
|
731
|
+
}), c.forEach((l, s) => {
|
|
732
|
+
const a = this.documentRef.createElement("div");
|
|
733
|
+
a.classList.add("dock-intersection-handle", "glyph"), a.setAttribute("role", "separator"), a.setAttribute("aria-label", "Resize split intersection"), a.setAttribute("tabindex", "0");
|
|
734
|
+
const h = l.pairs[0], u = `${h.h.pathStr}:${h.h.index}|${h.v.pathStr}:${h.v.index}`;
|
|
735
|
+
a.dataset.key = u, a.dataset.pairs = JSON.stringify(l.pairs), a.style.left = `${l.x}px`, a.style.top = `${l.y}px`;
|
|
736
|
+
const d = { path: this.parsePath(h.h.pathStr), index: h.h.index, container: this.findSplitterByPath(this.parsePath(h.h.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() }, g = { path: this.parsePath(h.v.pathStr), index: h.v.index, container: this.findSplitterByPath(this.parsePath(h.v.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() };
|
|
737
|
+
a.addEventListener("pointerdown", (f) => this.beginCornerResize(f, d, g, a)), a.addEventListener("dblclick", (f) => this.onIntersectionDoubleClick(f, a)), a.addEventListener("keydown", (f) => this.onIntersectionKeyDown(f, a)), t.appendChild(a);
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Keyboard resize on a focused intersection handle. ArrowLeft/Right resize
|
|
742
|
+
* the vertical divider the handle sits on; ArrowUp/Down resize the
|
|
743
|
+
* horizontal divider. Home/End shrink/grow the leading panel of whichever
|
|
744
|
+
* axis is implied by the key. Shift = fine 1% step.
|
|
745
|
+
*
|
|
746
|
+
* Internally delegates to mp-splitter.resizeDividerBy() so the percent-step
|
|
747
|
+
* + clamp math lives in one place. If a 2D handle straddles multiple split
|
|
748
|
+
* pairs (sibling splitters whose dividers happen to overlap), the first
|
|
749
|
+
* pair drives — same precedence as the pointer drag path.
|
|
750
|
+
*/
|
|
751
|
+
onIntersectionKeyDown(t, e) {
|
|
752
|
+
const i = t.key === "ArrowLeft" || t.key === "ArrowRight", o = t.key === "ArrowUp" || t.key === "ArrowDown", n = t.key === "Home" || t.key === "End";
|
|
753
|
+
if (!i && !o && !n) return;
|
|
754
|
+
const r = e.dataset.pairs;
|
|
755
|
+
if (!r) return;
|
|
756
|
+
let c;
|
|
757
|
+
try {
|
|
758
|
+
c = JSON.parse(r);
|
|
759
|
+
} catch {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
if (c.length === 0) return;
|
|
763
|
+
t.preventDefault();
|
|
764
|
+
const l = t.shiftKey, a = i || n ? c[0].v : c[0].h, h = this.parsePath(a.pathStr);
|
|
765
|
+
this.findSplitterByPath(h?.segments ?? [])?.resizeDividerBy?.(a.index, t.key, l);
|
|
766
|
+
}
|
|
767
|
+
beginCornerResize(t, e, i, o) {
|
|
768
|
+
t.preventDefault();
|
|
769
|
+
const n = o.dataset.pairs, r = n ? JSON.parse(n) : [], c = [], l = [], s = (a, h, u) => {
|
|
770
|
+
const d = this.parsePath(a);
|
|
771
|
+
if (!d) return;
|
|
772
|
+
const g = this.findSplitterByPath(d.segments);
|
|
773
|
+
if (!g) return;
|
|
774
|
+
const f = this.getSplitterPanels(g);
|
|
775
|
+
if (f.length === 0) return;
|
|
776
|
+
const p = u === "h" ? "height" : "width", m = f.map((b) => b.getBoundingClientRect()[p]), y = { path: d, index: h, container: g, initialSizes: m, before: m[h], after: m[h + 1] };
|
|
777
|
+
u === "h" ? c.push(y) : l.push(y);
|
|
778
|
+
};
|
|
779
|
+
if (r.length > 0 ? r.forEach((a) => {
|
|
780
|
+
s(a.h.pathStr, a.h.index, "h"), s(a.v.pathStr, a.v.index, "v");
|
|
781
|
+
}) : e.path && i.path && (s(this.formatPath(e.path), e.index, "h"), s(this.formatPath(i.path), i.index, "v")), !(c.length === 0 && l.length === 0)) {
|
|
782
|
+
try {
|
|
783
|
+
o.setPointerCapture(t.pointerId), o.dataset.resizing = "true", o.classList.add("hovering");
|
|
784
|
+
} catch {
|
|
785
|
+
}
|
|
786
|
+
this.cornerResizeState = {
|
|
787
|
+
pointerId: t.pointerId,
|
|
788
|
+
handle: o,
|
|
789
|
+
hs: c.map((a) => ({ path: this.clonePath(a.path), index: a.index, container: a.container, beforeSize: a.before, afterSize: a.after, initialSizes: a.initialSizes, startY: t.clientY })),
|
|
790
|
+
vs: l.map((a) => ({ path: this.clonePath(a.path), index: a.index, container: a.container, beforeSize: a.before, afterSize: a.after, initialSizes: a.initialSizes, startX: t.clientX }))
|
|
791
|
+
}, this.startPointerTracking(), o.dataset.key || (o.dataset.key = o.dataset.group ?? ""), this.renderSnapMarkersForCorner();
|
|
792
|
+
try {
|
|
793
|
+
const a = this.rootEl.getBoundingClientRect();
|
|
794
|
+
let h = null, u = null;
|
|
795
|
+
if (l.length > 0) {
|
|
796
|
+
const p = l[0], y = this.getSplitterDividers(p.container)[p.index]?.getBoundingClientRect();
|
|
797
|
+
y && (h = y.left + y.width / 2);
|
|
798
|
+
}
|
|
799
|
+
if (c.length > 0) {
|
|
800
|
+
const p = c[0], y = this.getSplitterDividers(p.container)[p.index]?.getBoundingClientRect();
|
|
801
|
+
y && (u = y.top + y.height / 2);
|
|
802
|
+
}
|
|
803
|
+
const d = [], g = [];
|
|
804
|
+
Array.from(
|
|
805
|
+
this.shadowRoot?.querySelectorAll(".dock-split") ?? []
|
|
806
|
+
).forEach((p) => {
|
|
807
|
+
const m = p.dataset.direction ?? void 0;
|
|
808
|
+
this.getSplitterDividers(p).forEach((y) => {
|
|
809
|
+
const b = y.getBoundingClientRect();
|
|
810
|
+
m === "horizontal" && u != null ? u >= b.top && u <= b.bottom && d.push(b.left + b.width / 2 - a.left) : m === "vertical" && h != null && h >= b.left && h <= b.right && g.push(b.top + b.height / 2 - a.top);
|
|
811
|
+
});
|
|
812
|
+
}), this.cornerSnapXTargets = d, this.cornerSnapYTargets = g;
|
|
813
|
+
} catch {
|
|
814
|
+
this.cornerSnapXTargets = [], this.cornerSnapYTargets = [];
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
handleCornerResizeMove(t) {
|
|
819
|
+
const e = this.cornerResizeState;
|
|
820
|
+
if (!e || e.pointerId !== t.pointerId) return;
|
|
821
|
+
const i = (s, a, h) => {
|
|
822
|
+
if (!h || a <= 0) return s;
|
|
823
|
+
const u = [1 / 3, 1 / 2, 2 / 3], d = s / a;
|
|
824
|
+
let g = u[0], f = Math.abs(d - g);
|
|
825
|
+
for (let p = 1; p < u.length; p++) {
|
|
826
|
+
const m = Math.abs(d - u[p]);
|
|
827
|
+
m < f && (f = m, g = u[p]);
|
|
828
|
+
}
|
|
829
|
+
return g * a;
|
|
830
|
+
}, o = 10, n = this.rootEl.getBoundingClientRect();
|
|
831
|
+
let r = t.clientX, c = t.clientY;
|
|
832
|
+
if (this.cornerSnapXTargets.length) {
|
|
833
|
+
let s = r, a = o + 1;
|
|
834
|
+
this.cornerSnapXTargets.forEach((h) => {
|
|
835
|
+
const u = n.left + h, d = Math.abs(u - r);
|
|
836
|
+
d < a && (a = d, s = u);
|
|
837
|
+
}), a <= o && (r = s);
|
|
838
|
+
}
|
|
839
|
+
if (this.cornerSnapYTargets.length) {
|
|
840
|
+
let s = c, a = o + 1;
|
|
841
|
+
this.cornerSnapYTargets.forEach((h) => {
|
|
842
|
+
const u = n.top + h, d = Math.abs(u - c);
|
|
843
|
+
d < a && (a = d, s = u);
|
|
844
|
+
}), a <= o && (c = s);
|
|
845
|
+
}
|
|
846
|
+
const l = (s, a) => {
|
|
847
|
+
const h = this.resolveSplitNode(s.path);
|
|
848
|
+
if (!h) return;
|
|
849
|
+
const u = 48, d = s.beforeSize + s.afterSize;
|
|
850
|
+
let g = Math.min(Math.max(s.beforeSize + a, u), d - u);
|
|
851
|
+
g = i(g, d, t.shiftKey);
|
|
852
|
+
const f = d - g, p = [...s.initialSizes];
|
|
853
|
+
p[s.index] = g, p[s.index + 1] = f;
|
|
854
|
+
const m = p.reduce((y, b) => y + b, 0);
|
|
855
|
+
h.sizes = m > 0 ? p.map((y) => y / m) : [], s.container.setPanelSizes?.(p);
|
|
856
|
+
};
|
|
857
|
+
e.hs.forEach((s) => l(s, c - s.startY)), e.vs.forEach((s) => l(s, r - s.startX)), this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
|
|
858
|
+
}
|
|
859
|
+
endCornerResize(t) {
|
|
860
|
+
const e = this.cornerResizeState;
|
|
861
|
+
if (!(!e || t !== e.pointerId)) {
|
|
862
|
+
try {
|
|
863
|
+
e.handle.releasePointerCapture(e.pointerId);
|
|
864
|
+
} catch {
|
|
865
|
+
}
|
|
866
|
+
e.handle.dataset.resizing = "false", this.cornerResizeState = null, this.scheduleRenderIntersectionHandles(), this.cornerSnapXTargets = [], this.cornerSnapYTargets = [];
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
onIntersectionDoubleClick(t, e) {
|
|
870
|
+
t.preventDefault();
|
|
871
|
+
const i = e.dataset.pairs, o = i ? JSON.parse(i) : [];
|
|
872
|
+
if (!Array.isArray(o) || o.length === 0) {
|
|
873
|
+
const a = (e.dataset.key ?? "").split("|");
|
|
874
|
+
if (a.length === 2) {
|
|
875
|
+
const [h, u] = a, d = h.lastIndexOf(":"), g = u.lastIndexOf(":");
|
|
876
|
+
if (d > 0 && g > 0) {
|
|
877
|
+
const f = h.slice(0, d), p = u.slice(0, g), m = Number.parseInt(h.slice(d + 1), 10), y = Number.parseInt(u.slice(g + 1), 10);
|
|
878
|
+
o.push({ h: { pathStr: f, index: m }, v: { pathStr: p, index: y } });
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
if (o.length === 0) return;
|
|
883
|
+
const n = /* @__PURE__ */ new Set();
|
|
884
|
+
o.forEach((s) => {
|
|
885
|
+
n.add(s.h.pathStr), n.add(s.v.pathStr);
|
|
886
|
+
});
|
|
887
|
+
let r = !1;
|
|
888
|
+
n.forEach((s) => {
|
|
889
|
+
this.previousSplitSizes.has(s) && (r = !0);
|
|
890
|
+
});
|
|
891
|
+
const c = (s, a) => {
|
|
892
|
+
const h = this.findSplitterByPath(s.segments);
|
|
893
|
+
if (!h) return;
|
|
894
|
+
const d = (h.dataset.direction ?? "horizontal") === "horizontal" ? h.getBoundingClientRect().width : h.getBoundingClientRect().height;
|
|
895
|
+
if (!Number.isFinite(d) || d <= 0) return;
|
|
896
|
+
const g = a.reduce((p, m) => p + Math.max(m, 0), 0);
|
|
897
|
+
if (g <= 0) return;
|
|
898
|
+
const f = a.map((p) => Math.max(p, 0) / g * d);
|
|
899
|
+
h.setPanelSizes?.(f);
|
|
900
|
+
}, l = (s, a, h) => {
|
|
901
|
+
const u = this.parsePath(s);
|
|
902
|
+
if (!u) return;
|
|
903
|
+
const d = this.resolveSplitNode(u);
|
|
904
|
+
if (!d) return;
|
|
905
|
+
const g = this.normalizeSizesArray(d.sizes ?? [], d.children.length), f = h([...g], a);
|
|
906
|
+
d.sizes = f, c(u, f);
|
|
907
|
+
};
|
|
908
|
+
if (r)
|
|
909
|
+
this.previousSplitSizes.forEach((s, a) => {
|
|
910
|
+
const h = this.parsePath(a), u = h ? this.resolveSplitNode(h) : null;
|
|
911
|
+
if (!u || !h) return;
|
|
912
|
+
const d = this.normalizeSizesArray(s, u.children.length);
|
|
913
|
+
u.sizes = d, c(h, d);
|
|
914
|
+
}), this.previousSplitSizes.clear();
|
|
915
|
+
else {
|
|
916
|
+
const s = /* @__PURE__ */ new Set();
|
|
917
|
+
o.forEach((a) => {
|
|
918
|
+
[a.h.pathStr, a.v.pathStr].forEach((u) => {
|
|
919
|
+
if (s.has(u)) return;
|
|
920
|
+
const d = this.parsePath(u), g = d ? this.resolveSplitNode(d) : null;
|
|
921
|
+
g && Array.isArray(g.sizes) && this.previousSplitSizes.set(u, [...g.sizes]), s.add(u);
|
|
922
|
+
});
|
|
923
|
+
const h = (u, d) => {
|
|
924
|
+
const g = (u[d] ?? 0) + (u[d + 1] ?? 0);
|
|
925
|
+
if (g <= 0) return u;
|
|
926
|
+
u[d] = g / 2, u[d + 1] = g / 2;
|
|
927
|
+
const f = u.reduce((p, m) => p + m, 0);
|
|
928
|
+
return f > 0 ? u.map((p) => p / f) : u;
|
|
929
|
+
};
|
|
930
|
+
l(a.h.pathStr, a.h.index, h), l(a.v.pathStr, a.v.index, h);
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
this.dispatchLayoutChanged(), this.scheduleRenderIntersectionHandles();
|
|
934
|
+
}
|
|
935
|
+
beginFloatingDrag(t, e, i, o) {
|
|
936
|
+
const n = this.floatingLayouts[e];
|
|
937
|
+
if (!n)
|
|
938
|
+
return;
|
|
939
|
+
t.preventDefault(), t.stopPropagation(), n.bounds = this.clampBoundsToHost(n.bounds, this.getHostSize());
|
|
940
|
+
const { left: r, top: c } = n.bounds;
|
|
941
|
+
try {
|
|
942
|
+
o.setPointerCapture(t.pointerId);
|
|
943
|
+
} catch {
|
|
944
|
+
}
|
|
945
|
+
this.promoteFloatingPane(e, i), i.dataset.dragging = "true", this.floatingDragState = {
|
|
946
|
+
index: e,
|
|
947
|
+
pointerId: t.pointerId,
|
|
948
|
+
startX: t.clientX,
|
|
949
|
+
startY: t.clientY,
|
|
950
|
+
startLeft: r,
|
|
951
|
+
startTop: c,
|
|
952
|
+
wrapper: i,
|
|
953
|
+
handle: o
|
|
954
|
+
}, this.startPointerTracking();
|
|
955
|
+
}
|
|
956
|
+
beginFloatingResize(t, e, i, o, n) {
|
|
957
|
+
const r = this.floatingLayouts[e];
|
|
958
|
+
if (r) {
|
|
959
|
+
t.preventDefault(), t.stopPropagation();
|
|
960
|
+
try {
|
|
961
|
+
o.setPointerCapture(t.pointerId), o.dataset.resizing = "true";
|
|
962
|
+
} catch {
|
|
963
|
+
}
|
|
964
|
+
this.promoteFloatingPane(e, i), r.bounds = this.clampBoundsToHost(r.bounds, this.getHostSize()), this.floatingResizeState = {
|
|
965
|
+
index: e,
|
|
966
|
+
pointerId: t.pointerId,
|
|
967
|
+
startX: t.clientX,
|
|
968
|
+
startY: t.clientY,
|
|
969
|
+
startWidth: r.bounds.width,
|
|
970
|
+
startHeight: r.bounds.height,
|
|
971
|
+
startLeft: r.bounds.left,
|
|
972
|
+
startTop: r.bounds.top,
|
|
973
|
+
wrapper: i,
|
|
974
|
+
handle: o,
|
|
975
|
+
edges: n
|
|
976
|
+
}, this.startPointerTracking();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
handleFloatingDragMove(t) {
|
|
980
|
+
const e = this.floatingDragState;
|
|
981
|
+
if (!e || t.pointerId !== e.pointerId)
|
|
982
|
+
return;
|
|
983
|
+
const i = this.floatingLayouts[e.index];
|
|
984
|
+
if (!i) return;
|
|
985
|
+
const o = t.clientX - e.startX, n = t.clientY - e.startY, r = this.clampBoundsToHost(
|
|
986
|
+
{
|
|
987
|
+
left: e.startLeft + o,
|
|
988
|
+
top: e.startTop + n,
|
|
989
|
+
width: i.bounds.width,
|
|
990
|
+
height: i.bounds.height
|
|
991
|
+
},
|
|
992
|
+
this.getHostSize()
|
|
993
|
+
);
|
|
994
|
+
e.wrapper.style.left = `${r.left}px`, e.wrapper.style.top = `${r.top}px`, i.bounds = r, this.updateFloatingDragDropTarget(t);
|
|
995
|
+
}
|
|
996
|
+
endFloatingDrag(t) {
|
|
997
|
+
const e = this.floatingDragState;
|
|
998
|
+
if (!e || t !== e.pointerId)
|
|
999
|
+
return;
|
|
1000
|
+
try {
|
|
1001
|
+
e.handle.releasePointerCapture(e.pointerId);
|
|
1002
|
+
} catch {
|
|
1003
|
+
}
|
|
1004
|
+
delete e.handle.dataset.resizing, delete e.wrapper.dataset.dragging;
|
|
1005
|
+
const i = e.dropTarget ? this.handleFloatingStackDrop(e.index, e.dropTarget.path, e.dropTarget.zone) : !1;
|
|
1006
|
+
this.floatingDragState = null, this.hideDropIndicator(), i || this.dispatchLayoutChanged();
|
|
1007
|
+
}
|
|
1008
|
+
updateFloatingDragDropTarget(t) {
|
|
1009
|
+
const e = this.floatingDragState;
|
|
1010
|
+
if (!e)
|
|
1011
|
+
return;
|
|
1012
|
+
const i = this.findStackAtPoint(t.clientX, t.clientY);
|
|
1013
|
+
if (!i) {
|
|
1014
|
+
e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
const o = this.parsePath(i.dataset.path);
|
|
1018
|
+
if (!o || o.type === "floating" && o.index === e.index) {
|
|
1019
|
+
e.dropTarget && (delete e.dropTarget, this.hideDropIndicator());
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null));
|
|
1023
|
+
const n = this.computeDropZone(i, t, this.extractDropZoneFromEvent(t));
|
|
1024
|
+
n ? e.dropTarget = { path: o, zone: n } : e.dropTarget && delete e.dropTarget, this.showDropIndicator(i, n);
|
|
1025
|
+
}
|
|
1026
|
+
handleFloatingResizeMove(t) {
|
|
1027
|
+
const e = this.floatingResizeState;
|
|
1028
|
+
if (!e || t.pointerId !== e.pointerId)
|
|
1029
|
+
return;
|
|
1030
|
+
const i = t.clientX - e.startX, o = t.clientY - e.startY, n = this.getHostSize(), r = n.width > 0 ? Math.min(192, n.width) : 192, c = n.height > 0 ? Math.min(128, n.height) : 128;
|
|
1031
|
+
let l = e.startWidth, s = e.startHeight, a = e.startLeft, h = e.startTop;
|
|
1032
|
+
e.edges.horizontal === "right" ? (l = Math.max(r, e.startWidth + i), n.width > 0 && (l = Math.min(l, n.width - e.startLeft))) : e.edges.horizontal === "left" && (l = Math.max(r, e.startWidth - i), l = Math.min(l, e.startLeft + e.startWidth), a = e.startLeft + e.startWidth - l), e.edges.vertical === "bottom" ? (s = Math.max(c, e.startHeight + o), n.height > 0 && (s = Math.min(s, n.height - e.startTop))) : e.edges.vertical === "top" && (s = Math.max(c, e.startHeight - o), s = Math.min(s, e.startTop + e.startHeight), h = e.startTop + e.startHeight - s), e.wrapper.style.width = `${l}px`, e.wrapper.style.height = `${s}px`, e.wrapper.style.left = `${a}px`, e.wrapper.style.top = `${h}px`;
|
|
1033
|
+
const u = this.floatingLayouts[e.index];
|
|
1034
|
+
u && (u.bounds = { left: a, top: h, width: l, height: s });
|
|
1035
|
+
}
|
|
1036
|
+
endFloatingResize(t) {
|
|
1037
|
+
const e = this.floatingResizeState;
|
|
1038
|
+
if (!(!e || t !== e.pointerId)) {
|
|
1039
|
+
try {
|
|
1040
|
+
e.handle.releasePointerCapture(e.pointerId);
|
|
1041
|
+
} catch {
|
|
1042
|
+
}
|
|
1043
|
+
delete e.handle.dataset.resizing, this.floatingResizeState = null, this.dispatchLayoutChanged();
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
getFloatingPaneZIndex(t) {
|
|
1047
|
+
const e = this.floatingLayouts[t];
|
|
1048
|
+
return e && typeof e.zIndex == "number" && Number.isFinite(e.zIndex) ? e.zIndex : 10 + t;
|
|
1049
|
+
}
|
|
1050
|
+
getHostSize() {
|
|
1051
|
+
return {
|
|
1052
|
+
width: this.rootEl.clientWidth,
|
|
1053
|
+
height: this.rootEl.clientHeight
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
clampBoundsToHost(t, e) {
|
|
1057
|
+
if (e.width <= 0 || e.height <= 0) return t;
|
|
1058
|
+
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);
|
|
1059
|
+
return { left: n, top: r, width: i, height: o };
|
|
1060
|
+
}
|
|
1061
|
+
// Re-clamp existing floating-pane wrappers in place. Avoids the full
|
|
1062
|
+
// renderFloatingPanes() teardown (which would release pointer capture if
|
|
1063
|
+
// a user is mid-drag when the host resizes).
|
|
1064
|
+
updateFloatingPanePositions() {
|
|
1065
|
+
if (!this.floatingLayerEl) return;
|
|
1066
|
+
const t = this.getHostSize();
|
|
1067
|
+
this.floatingLayouts.forEach((e, i) => {
|
|
1068
|
+
const o = this.floatingLayerEl.children[i];
|
|
1069
|
+
if (!o) return;
|
|
1070
|
+
const { left: n, top: r, width: c, height: l } = this.clampBoundsToHost(e.bounds, t);
|
|
1071
|
+
o.style.left = `${n}px`, o.style.top = `${r}px`, o.style.width = `${c}px`, o.style.height = `${l}px`, o.style.minWidth = "0", o.style.minHeight = "0";
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
promoteFloatingPane(t, e) {
|
|
1075
|
+
const i = this.floatingLayouts[t];
|
|
1076
|
+
if (!i)
|
|
1077
|
+
return;
|
|
1078
|
+
const o = this.floatingLayouts.reduce((r, c, l) => {
|
|
1079
|
+
if (!c)
|
|
1080
|
+
return r;
|
|
1081
|
+
const s = l === t ? Number.NEGATIVE_INFINITY : this.getFloatingPaneZIndex(l);
|
|
1082
|
+
return Math.max(r, s);
|
|
1083
|
+
}, 0), n = Math.max(o + 2, 12);
|
|
1084
|
+
i.zIndex = n, e.style.zIndex = String(n);
|
|
1085
|
+
}
|
|
1086
|
+
getFloatingWrapper(t) {
|
|
1087
|
+
const e = `.dock-floating[data-path="${this.formatPath({
|
|
1088
|
+
type: "floating",
|
|
1089
|
+
index: t,
|
|
1090
|
+
segments: []
|
|
1091
|
+
})}"]`;
|
|
1092
|
+
return this.floatingLayerEl.querySelector(e);
|
|
1093
|
+
}
|
|
1094
|
+
startPointerTracking() {
|
|
1095
|
+
if (this.pointerTrackingActive)
|
|
1096
|
+
return;
|
|
1097
|
+
const t = this.windowRef;
|
|
1098
|
+
t?.addEventListener("pointermove", this.onPointerMove), t?.addEventListener("pointerup", this.onPointerUp), t?.addEventListener("pointercancel", this.onPointerCancel), this.pointerTrackingActive = !0;
|
|
1099
|
+
}
|
|
1100
|
+
stopPointerTrackingIfIdle() {
|
|
1101
|
+
if (this.pointerTrackingActive && !this.floatingDragState && !this.floatingResizeState && !this.cornerResizeState) {
|
|
1102
|
+
const t = this.windowRef;
|
|
1103
|
+
t?.removeEventListener("pointermove", this.onPointerMove), t?.removeEventListener("pointerup", this.onPointerUp), t?.removeEventListener("pointercancel", this.onPointerCancel), this.pointerTrackingActive = !1;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
getFloatingWindowTitle(t) {
|
|
1107
|
+
const e = "Floating Pane";
|
|
1108
|
+
if (!t || !t.root)
|
|
1109
|
+
return e;
|
|
1110
|
+
const i = t.activePane ?? this.findFirstPaneName(t.root);
|
|
1111
|
+
return i ? this.titles[i] ?? i ?? e : e;
|
|
1112
|
+
}
|
|
1113
|
+
updateFloatingWindowTitle(t) {
|
|
1114
|
+
const e = this.floatingLayouts[t];
|
|
1115
|
+
if (!e)
|
|
1116
|
+
return;
|
|
1117
|
+
const i = `.dock-floating[data-path="${this.formatPath({
|
|
1118
|
+
type: "floating",
|
|
1119
|
+
index: t,
|
|
1120
|
+
segments: []
|
|
1121
|
+
})}"]`, o = this.floatingLayerEl.querySelector(i);
|
|
1122
|
+
if (!o)
|
|
1123
|
+
return;
|
|
1124
|
+
const n = o.querySelector(".dock-floating__title");
|
|
1125
|
+
n && (n.textContent = this.getFloatingWindowTitle(e));
|
|
1126
|
+
}
|
|
1127
|
+
renderSplit(t, e, i) {
|
|
1128
|
+
const o = this.documentRef.createElement("mp-splitter");
|
|
1129
|
+
o.classList.add("dock-split"), o.dataset.direction = t.direction, o.dataset.path = e.join("/"), o.setAttribute("orientation", t.direction);
|
|
1130
|
+
const n = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
|
|
1131
|
+
t.children.forEach((c, l) => {
|
|
1132
|
+
o.appendChild(this.renderNode(c, [...e, l], i));
|
|
1133
|
+
});
|
|
1134
|
+
const r = Array.isArray(t.sizes) ? t.sizes : [];
|
|
1135
|
+
return r.length > 0 && requestAnimationFrame(() => {
|
|
1136
|
+
const c = r.reduce((a, h) => a + Math.max(h, 0), 0);
|
|
1137
|
+
if (c <= 0) return;
|
|
1138
|
+
const l = t.direction === "horizontal" ? o.getBoundingClientRect().width : o.getBoundingClientRect().height;
|
|
1139
|
+
if (!Number.isFinite(l) || l <= 0) return;
|
|
1140
|
+
const s = r.map((a) => Math.max(a, 0) / c * l);
|
|
1141
|
+
o.setPanelSizes?.(s), requestAnimationFrame(() => this.scheduleRenderIntersectionHandles());
|
|
1142
|
+
}), o.addEventListener("resize-end", (c) => {
|
|
1143
|
+
if (c.target !== o) return;
|
|
1144
|
+
const l = c.detail;
|
|
1145
|
+
if (!Array.isArray(l?.sizes) || l.sizes.length === 0) return;
|
|
1146
|
+
const s = this.resolveSplitNode(n);
|
|
1147
|
+
if (!s) return;
|
|
1148
|
+
const a = (s.sizes ?? []).reduce(
|
|
1149
|
+
(d, g) => d + Math.max(g, 0),
|
|
1150
|
+
0
|
|
1151
|
+
), h = l.sizes.reduce((d, g) => d + Math.max(g, 0), 0), u = a > 0 ? a : l.sizes.length;
|
|
1152
|
+
h > 0 && (s.sizes = l.sizes.map(
|
|
1153
|
+
(d) => Math.max(d, 0) / h * u
|
|
1154
|
+
), this.dispatchLayoutChanged());
|
|
1155
|
+
}), o;
|
|
1156
|
+
}
|
|
1157
|
+
renderStack(t, e, i) {
|
|
1158
|
+
const o = this.documentRef.createElement("mp-tab-control");
|
|
1159
|
+
o.classList.add("dock-stack"), o.setAttribute("select-first-tab", "false"), o.setAttribute("border", "top");
|
|
1160
|
+
const n = typeof i == "number" ? { type: "floating", index: i, segments: [...e] } : { type: "docked", segments: [...e] };
|
|
1161
|
+
o.dataset.path = this.formatPath(n);
|
|
1162
|
+
const r = Array.from(new Set(t.panes));
|
|
1163
|
+
if (r.length === 0) {
|
|
1164
|
+
const a = this.documentRef.createElement("span");
|
|
1165
|
+
a.setAttribute("slot", "__empty__-header"), a.textContent = "(empty)";
|
|
1166
|
+
const h = this.documentRef.createElement("div");
|
|
1167
|
+
return h.setAttribute("slot", "__empty__-content"), h.classList.add("dock-stack__pane"), h.textContent = "No panes configured", o.append(a, h), o.setAttribute("active-tab", "__empty__"), o;
|
|
1168
|
+
}
|
|
1169
|
+
const c = r.includes(t.activePane ?? "") ? t.activePane : r[0], l = e.length ? e.join("-") : "root", s = typeof i == "number" ? `f${i}-${l}` : l;
|
|
1170
|
+
return r.forEach((a) => {
|
|
1171
|
+
const h = a.replace(/[^a-zA-Z0-9_-]/g, "-"), u = h.length > 0 ? h : "pane", d = `${this.instanceId}-tab-${s}-${u}`, g = `${this.instanceId}-panel-${s}-${u}`, f = this.documentRef.createElement("span");
|
|
1172
|
+
f.setAttribute("slot", `${d}-header`), f.classList.add("dock-tab"), f.dataset.pane = a, f.dataset.tabId = d, f.textContent = this.titles[a] ?? a, f.addEventListener("pointerdown", (y) => {
|
|
1173
|
+
this.captureTabDragMetrics(y, o), this.armPaneDragGesture(y, this.clonePath(n), a, o), y.stopPropagation();
|
|
1174
|
+
});
|
|
1175
|
+
const p = this.documentRef.createElement("div");
|
|
1176
|
+
p.setAttribute("slot", `${d}-content`), p.classList.add("dock-stack__pane"), p.dataset.pane = a, p.dataset.tabId = d, p.id = g;
|
|
1177
|
+
const m = this.documentRef.createElement("slot");
|
|
1178
|
+
m.name = a, p.appendChild(m), o.append(f, p), a === c && o.setAttribute("active-tab", d);
|
|
1179
|
+
}), o.dataset.activePane = c, o.addEventListener("tab-activate", (a) => {
|
|
1180
|
+
const h = a.detail, d = o.querySelector(
|
|
1181
|
+
`:scope > [data-tab-id="${h.tabId}"]`
|
|
1182
|
+
)?.dataset.pane;
|
|
1183
|
+
d && (this.activatePane(o, d, this.clonePath(n)), this.dispatchEvent(
|
|
1184
|
+
new CustomEvent("dock-pane-activated", {
|
|
1185
|
+
detail: { pane: d },
|
|
1186
|
+
bubbles: !0,
|
|
1187
|
+
composed: !0
|
|
1188
|
+
})
|
|
1189
|
+
));
|
|
1190
|
+
}), o;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Returns the strip (`.tsc`) element inside an `<mp-tab-control>`'s shadow
|
|
1194
|
+
* DOM. Used by drag/drop logic that needs the strip's geometry instead of
|
|
1195
|
+
* the host element's bounds.
|
|
1196
|
+
*/
|
|
1197
|
+
getStackStripEl(t) {
|
|
1198
|
+
return t.tagName !== "MP-TAB-CONTROL" ? null : t.shadowRoot?.querySelector(".tsc") ?? null;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Returns the rendered tab buttons inside an `<mp-tab-control>`'s shadow
|
|
1202
|
+
* strip — the light-DOM `.dock-tab` spans the dock owns are projected into
|
|
1203
|
+
* these buttons via `<slot>`. Use these for geometry / position queries
|
|
1204
|
+
* (insert-index computation, drop-indicator placement). Use the light-DOM
|
|
1205
|
+
* `.dock-tab` spans for data queries (paneName, drag listeners).
|
|
1206
|
+
*/
|
|
1207
|
+
getStackTabButtons(t) {
|
|
1208
|
+
return t.tagName !== "MP-TAB-CONTROL" ? [] : Array.from(
|
|
1209
|
+
t.shadowRoot?.querySelectorAll("button.nav-link") ?? []
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Returns the dividers inside an `<mp-splitter>`'s shadow DOM, in DOM order.
|
|
1214
|
+
* mp-splitter renders one `.divider` between each pair of adjacent panels,
|
|
1215
|
+
* so for an N-child split, length N-1.
|
|
1216
|
+
*/
|
|
1217
|
+
getSplitterDividers(t) {
|
|
1218
|
+
return t.tagName !== "MP-SPLITTER" ? [] : Array.from(
|
|
1219
|
+
t.shadowRoot?.querySelectorAll(".divider") ?? []
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Returns the panel wrappers inside an `<mp-splitter>`'s shadow DOM, in
|
|
1224
|
+
* DOM order. These are the elements mp-splitter sizes (via setPanelSizes)
|
|
1225
|
+
* during a divider drag — the dock reads their geometry for intersection
|
|
1226
|
+
* handle math and snap markers.
|
|
1227
|
+
*/
|
|
1228
|
+
getSplitterPanels(t) {
|
|
1229
|
+
return t.tagName !== "MP-SPLITTER" ? [] : Array.from(
|
|
1230
|
+
t.shadowRoot?.querySelectorAll(".panel-wrapper") ?? []
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Locate the rendered `<mp-splitter>` element for a given DockPath
|
|
1235
|
+
* `segments` value (the split-tree path). Searches the dock's shadow.
|
|
1236
|
+
*/
|
|
1237
|
+
findSplitterByPath(t) {
|
|
1238
|
+
return this.shadowRoot?.querySelector(
|
|
1239
|
+
`.dock-split[data-path="${t.join("/")}"]`
|
|
1240
|
+
) ?? null;
|
|
1241
|
+
}
|
|
1242
|
+
onPointerMove(t) {
|
|
1243
|
+
this.cornerResizeState && t.pointerId === this.cornerResizeState.pointerId && this.handleCornerResizeMove(t), this.floatingResizeState && t.pointerId === this.floatingResizeState.pointerId && this.handleFloatingResizeMove(t), this.floatingDragState && t.pointerId === this.floatingDragState.pointerId && this.handleFloatingDragMove(t);
|
|
1244
|
+
}
|
|
1245
|
+
onPointerUp(t) {
|
|
1246
|
+
this.cornerResizeState && t.pointerId === this.cornerResizeState.pointerId && this.endCornerResize(t.pointerId), this.floatingDragState && t.pointerId === this.floatingDragState.pointerId && this.endFloatingDrag(t.pointerId), this.floatingResizeState && t.pointerId === this.floatingResizeState.pointerId && this.endFloatingResize(t.pointerId), this.stopPointerTrackingIfIdle();
|
|
1247
|
+
}
|
|
1248
|
+
// OS-level cancel (pointer capture lost to a back-swipe, multi-touch
|
|
1249
|
+
// arbitration, palm rejection, etc.). Without this, the wrapper's
|
|
1250
|
+
// data-dragging marker stays set after the gesture is yanked away from
|
|
1251
|
+
// us, leaving the pane permanently transparent to pointer events and
|
|
1252
|
+
// ungrabbable. Cleans up the same states onPointerUp does but
|
|
1253
|
+
// explicitly drops state.dropTarget for the floating drag so cancel
|
|
1254
|
+
// never commits a phantom drop (mirrors onDragPointerCancel for the
|
|
1255
|
+
// tab-drag path).
|
|
1256
|
+
onPointerCancel(t) {
|
|
1257
|
+
this.floatingDragState && t.pointerId === this.floatingDragState.pointerId && (delete this.floatingDragState.dropTarget, this.endFloatingDrag(t.pointerId)), this.floatingResizeState && t.pointerId === this.floatingResizeState.pointerId && this.endFloatingResize(t.pointerId), this.cornerResizeState && t.pointerId === this.cornerResizeState.pointerId && this.endCornerResize(t.pointerId), this.stopPointerTrackingIfIdle();
|
|
1258
|
+
}
|
|
1259
|
+
captureTabDragMetrics(t, e) {
|
|
1260
|
+
if (!e) {
|
|
1261
|
+
this.pendingTabDragMetrics = null;
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
if (!Number.isFinite(t.clientX) || !Number.isFinite(t.clientY)) {
|
|
1265
|
+
this.pendingTabDragMetrics = null;
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
const i = this.getBoundingClientRect(), o = e.getBoundingClientRect(), n = t.clientX - o.left, r = t.clientY - o.top, c = o.left - i.left, l = o.top - i.top, s = Number.isFinite(o.width) ? o.width : 0, a = Number.isFinite(o.height) ? o.height : 0;
|
|
1269
|
+
this.pendingTabDragMetrics = {
|
|
1270
|
+
pointerOffsetX: n,
|
|
1271
|
+
pointerOffsetY: r,
|
|
1272
|
+
left: c,
|
|
1273
|
+
top: l,
|
|
1274
|
+
width: s,
|
|
1275
|
+
height: a,
|
|
1276
|
+
startClientX: t.clientX,
|
|
1277
|
+
startClientY: t.clientY
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
clearPendingTabDragMetrics() {
|
|
1281
|
+
this.pendingTabDragMetrics = null;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Pointerdown handler arms a "may become a drag" gesture. Mouse / pen use a
|
|
1285
|
+
* 5 px distance threshold and arm immediately; touch dispatches to
|
|
1286
|
+
* {@link armPaneDragGestureTouch} which requires a 600 ms stationary hold
|
|
1287
|
+
* (so the user can scroll the tabstrip natively without undocking).
|
|
1288
|
+
* Once armed, both paths converge on {@link beginPaneDrag}. All listeners
|
|
1289
|
+
* self-clean on resolve so the gesture stays scoped to a single pointerdown.
|
|
1290
|
+
*/
|
|
1291
|
+
armPaneDragGesture(t, e, i, o) {
|
|
1292
|
+
if (t.pointerType === "touch") {
|
|
1293
|
+
this.armPaneDragGestureTouch(t, e, i, o);
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
if (t.pointerType === "mouse" && t.button !== 0) return;
|
|
1297
|
+
const n = this.windowRef;
|
|
1298
|
+
if (!n) return;
|
|
1299
|
+
const r = t.clientX, c = t.clientY, l = t.pointerId, s = 5;
|
|
1300
|
+
let a = !1;
|
|
1301
|
+
const h = () => {
|
|
1302
|
+
a = !0, n.removeEventListener("pointermove", u, !0), n.removeEventListener("pointerup", d, !0), n.removeEventListener("pointercancel", d, !0);
|
|
1303
|
+
}, u = (g) => {
|
|
1304
|
+
if (a || g.pointerId !== l) return;
|
|
1305
|
+
const f = g.clientX - r, p = g.clientY - c;
|
|
1306
|
+
Math.hypot(f, p) < s || (h(), this.beginPaneDrag(g, e, i, o));
|
|
1307
|
+
}, d = (g) => {
|
|
1308
|
+
a || g.pointerId !== l || (h(), this.clearPendingTabDragMetrics());
|
|
1309
|
+
};
|
|
1310
|
+
n.addEventListener("pointermove", u, !0), n.addEventListener("pointerup", d, !0), n.addEventListener("pointercancel", d, !0);
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Touch-specific gesture arming. With `.dock-tab` set to `touch-action:
|
|
1314
|
+
* none`, the browser never arbitrates the gesture itself, so JS owns it
|
|
1315
|
+
* from frame 1. Three outcomes from the pending state:
|
|
1316
|
+
*
|
|
1317
|
+
* - User holds within {@link TOUCH_LONG_PRESS_SLOP_PX} for
|
|
1318
|
+
* {@link TOUCH_LONG_PRESS_MS} → timer fires → drag arms via
|
|
1319
|
+
* {@link beginPaneDrag}.
|
|
1320
|
+
* - User moves past slop and the move is mostly horizontal, and the
|
|
1321
|
+
* strip's `<ul>` is scrollable → enter `scrolling` mode and drive
|
|
1322
|
+
* `ul.scrollLeft` from JS for the rest of the gesture (no drag, no
|
|
1323
|
+
* momentum — direct 1:1 finger follow).
|
|
1324
|
+
* - User moves past slop in any other direction, releases, or
|
|
1325
|
+
* pointercancel fires → abandoned, no drag, no scroll. Releases
|
|
1326
|
+
* under slop fire the synthesized click that drives `tab-activate`.
|
|
1327
|
+
*
|
|
1328
|
+
* `touch-action: pan-x` was the original PRD design but doesn't work:
|
|
1329
|
+
* the policy is frozen at touchstart and `setPointerCapture` doesn't
|
|
1330
|
+
* promote it, so first move after a long-press fires pointercancel and
|
|
1331
|
+
* strands the panel. JS-driven scroll is the only model that holds.
|
|
1332
|
+
*/
|
|
1333
|
+
armPaneDragGestureTouch(t, e, i, o) {
|
|
1334
|
+
const n = this.windowRef;
|
|
1335
|
+
if (!n) return;
|
|
1336
|
+
const r = t.clientX, c = t.clientY, l = t.pointerId;
|
|
1337
|
+
let s = r, a = c, h = r, u = !1, d = !1, g = !1;
|
|
1338
|
+
const f = t.currentTarget instanceof HTMLElement ? t.currentTarget : t.target instanceof HTMLElement ? t.target.closest(".dock-tab") : null, p = o ? this.getStackStripEl(o)?.querySelector(
|
|
1339
|
+
"ul.nav.nav-tabs"
|
|
1340
|
+
) ?? null : null, m = () => {
|
|
1341
|
+
u || (u = !0, n.clearTimeout(S), n.clearTimeout(P), n.removeEventListener("pointermove", y, !0), n.removeEventListener("pointerup", b, !0), n.removeEventListener("pointercancel", z, !0), g && f && f.removeAttribute("data-pressing"));
|
|
1342
|
+
}, y = (k) => {
|
|
1343
|
+
if (u || k.pointerId !== l) return;
|
|
1344
|
+
if (d) {
|
|
1345
|
+
const R = k.clientX - h;
|
|
1346
|
+
h = k.clientX, p && (p.scrollLeft -= R);
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
s = k.clientX, a = k.clientY;
|
|
1350
|
+
const L = k.clientX - r, x = k.clientY - c;
|
|
1351
|
+
if (Math.hypot(L, x) <= v.TOUCH_LONG_PRESS_SLOP_PX)
|
|
1352
|
+
return;
|
|
1353
|
+
const T = !!p && p.scrollWidth > p.clientWidth;
|
|
1354
|
+
if (Math.abs(L) > Math.abs(x) && T) {
|
|
1355
|
+
n.clearTimeout(S), n.clearTimeout(P), g && f && (f.removeAttribute("data-pressing"), g = !1), d = !0, h = k.clientX, p.scrollLeft -= L, this.clearPendingTabDragMetrics();
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
m(), this.clearPendingTabDragMetrics();
|
|
1359
|
+
}, b = (k) => {
|
|
1360
|
+
u || k.pointerId !== l || (m(), this.clearPendingTabDragMetrics());
|
|
1361
|
+
}, z = (k) => {
|
|
1362
|
+
u || k.pointerId !== l || (m(), this.clearPendingTabDragMetrics());
|
|
1363
|
+
}, S = n.setTimeout(() => {
|
|
1364
|
+
if (u) return;
|
|
1365
|
+
m();
|
|
1366
|
+
try {
|
|
1367
|
+
this.setPointerCapture(l);
|
|
1368
|
+
} catch {
|
|
1369
|
+
}
|
|
1370
|
+
if (typeof navigator < "u" && typeof navigator.vibrate == "function")
|
|
1371
|
+
try {
|
|
1372
|
+
navigator.vibrate(10);
|
|
1373
|
+
} catch {
|
|
1374
|
+
}
|
|
1375
|
+
const k = new PointerEvent("pointermove", {
|
|
1376
|
+
pointerId: l,
|
|
1377
|
+
pointerType: "touch",
|
|
1378
|
+
isPrimary: !0,
|
|
1379
|
+
clientX: s,
|
|
1380
|
+
clientY: a,
|
|
1381
|
+
bubbles: !1,
|
|
1382
|
+
cancelable: !1
|
|
1383
|
+
});
|
|
1384
|
+
this.beginPaneDrag(k, e, i, o);
|
|
1385
|
+
}, v.TOUCH_LONG_PRESS_MS), P = n.setTimeout(() => {
|
|
1386
|
+
u || !f || (g = !0, f.setAttribute("data-pressing", "true"));
|
|
1387
|
+
}, v.TOUCH_PRESS_FEEDBACK_DELAY_MS);
|
|
1388
|
+
n.addEventListener("pointermove", y, !0), n.addEventListener("pointerup", b, !0), n.addEventListener("pointercancel", z, !0);
|
|
1389
|
+
}
|
|
1390
|
+
beginPaneDrag(t, e, i, o) {
|
|
1391
|
+
const {
|
|
1392
|
+
path: n,
|
|
1393
|
+
floatingIndex: r,
|
|
1394
|
+
pointerOffsetX: c,
|
|
1395
|
+
pointerOffsetY: l
|
|
1396
|
+
} = this.preparePaneDragSource(e, i, o, t), s = o ? this.getStackStripEl(o) : null, a = s ? s.getBoundingClientRect() : null, h = a ? { left: a.left, top: a.top, right: a.right, bottom: a.bottom } : null, u = this.pendingTabDragMetrics;
|
|
1397
|
+
if (this.dragState = {
|
|
1398
|
+
pane: i,
|
|
1399
|
+
sourcePath: this.clonePath(n),
|
|
1400
|
+
floatingIndex: r,
|
|
1401
|
+
pointerOffsetX: c,
|
|
1402
|
+
pointerOffsetY: l,
|
|
1403
|
+
dropHandled: !1,
|
|
1404
|
+
sourceStackEl: o,
|
|
1405
|
+
sourceHeaderBounds: h,
|
|
1406
|
+
startClientX: u && Number.isFinite(u.startClientX) ? u.startClientX : t.clientX,
|
|
1407
|
+
startClientY: u && Number.isFinite(u.startClientY) ? u.startClientY : t.clientY
|
|
1408
|
+
}, this.lastDragPointerPosition = {
|
|
1409
|
+
x: this.dragState.startClientX,
|
|
1410
|
+
y: this.dragState.startClientY
|
|
1411
|
+
}, this.updateDraggedFloatingPositionFromPoint(t.clientX, t.clientY), this.startDragPointerTracking(), this.markDraggedFloatingWrapper(), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
|
|
1412
|
+
const d = this.resolveStackLocation(this.dragState.sourcePath);
|
|
1413
|
+
if (d && Array.isArray(d.node.panes) && d.node.panes.length === 1) {
|
|
1414
|
+
let g = !1;
|
|
1415
|
+
if (d.context === "docked")
|
|
1416
|
+
g = !0;
|
|
1417
|
+
else if (d.context === "floating") {
|
|
1418
|
+
const f = this.floatingLayouts[d.index];
|
|
1419
|
+
g = (f && f.root ? this.countPanesInTree(f.root) : 0) > 1;
|
|
1420
|
+
}
|
|
1421
|
+
g && this.convertPendingTabDragToFloating(t.clientX, t.clientY);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
preparePaneDragSource(t, e, i, o) {
|
|
1426
|
+
const n = this.resolveStackLocation(t);
|
|
1427
|
+
if (!n || !n.node.panes.includes(e))
|
|
1428
|
+
return {
|
|
1429
|
+
path: t,
|
|
1430
|
+
floatingIndex: null,
|
|
1431
|
+
pointerOffsetX: 0,
|
|
1432
|
+
pointerOffsetY: 0
|
|
1433
|
+
};
|
|
1434
|
+
const r = this.pendingTabDragMetrics, c = !!i && Array.from(i.querySelectorAll(".dock-tab")).some(
|
|
1435
|
+
(g) => g.dataset.pane && g.dataset.pane !== e
|
|
1436
|
+
), l = n.node.panes.some((g) => g !== e), s = n.context === "floating" ? this.floatingLayouts[n.index] : null, a = s && s.root ? this.countPanesInTree(s.root) : l ? 2 : 1;
|
|
1437
|
+
if (n.context === "floating" && !!s && !l && !c && a <= 1) {
|
|
1438
|
+
if (s) {
|
|
1439
|
+
s.activePane = e, this.updateFloatingWindowTitle(n.index);
|
|
1440
|
+
const g = this.getFloatingWrapper(n.index);
|
|
1441
|
+
g && this.promoteFloatingPane(n.index, g);
|
|
1442
|
+
const f = this.getBoundingClientRect(), p = r && Number.isFinite(r.pointerOffsetX) && Number.isFinite(r.left) && Number.isFinite(s.bounds.left) ? r.pointerOffsetX + (r.left - s.bounds.left) : Number.isFinite(o.clientX) && Number.isFinite(s.bounds.left) ? o.clientX - f.left - s.bounds.left : s.bounds.width / 2, m = r && Number.isFinite(r.pointerOffsetY) && Number.isFinite(r.top) && Number.isFinite(s.bounds.top) ? r.pointerOffsetY + (r.top - s.bounds.top) : Number.isFinite(o.clientY) && Number.isFinite(s.bounds.top) ? o.clientY - f.top - s.bounds.top : s.bounds.height / 2;
|
|
1443
|
+
return {
|
|
1444
|
+
path: t,
|
|
1445
|
+
floatingIndex: n.index,
|
|
1446
|
+
pointerOffsetX: p,
|
|
1447
|
+
pointerOffsetY: m
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
return {
|
|
1451
|
+
path: t,
|
|
1452
|
+
floatingIndex: null,
|
|
1453
|
+
pointerOffsetX: 0,
|
|
1454
|
+
pointerOffsetY: 0
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
const u = r && Number.isFinite(r.pointerOffsetX) ? r.pointerOffsetX : 0, d = r && Number.isFinite(r.pointerOffsetY) ? r.pointerOffsetY : 0;
|
|
1458
|
+
return {
|
|
1459
|
+
path: t,
|
|
1460
|
+
floatingIndex: -1,
|
|
1461
|
+
pointerOffsetX: u,
|
|
1462
|
+
pointerOffsetY: d
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
endPaneDrag() {
|
|
1466
|
+
this.clearPendingDragEndTimeout(), this.clearHeaderDragPlaceholder(), this.clearDraggedFloatingWrapperMarkers();
|
|
1467
|
+
const t = this.dragState;
|
|
1468
|
+
this.dragState = null, this.hideDropIndicator(), this.stopDragPointerTracking(), this.lastDragPointerPosition = null, t && t.floatingIndex !== null && !t.dropHandled && this.dispatchLayoutChanged();
|
|
1469
|
+
}
|
|
1470
|
+
updateDraggedFloatingPositionFromPoint(t, e) {
|
|
1471
|
+
if (!this.dragState || !Number.isFinite(t) || !Number.isFinite(e))
|
|
1472
|
+
return;
|
|
1473
|
+
if (this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
|
|
1474
|
+
const h = this.dragState.sourceHeaderBounds, u = this.dragState.startClientX ?? t, d = this.dragState.startClientY ?? e, g = Math.hypot(t - u, e - d), f = 8;
|
|
1475
|
+
let p = !0;
|
|
1476
|
+
const m = h ? this.isPointWithinBounds(h, t, e) : !0, y = this.isPointerOverSourceHeader(t, e);
|
|
1477
|
+
p = m || y, !p && g > f && this.convertPendingTabDragToFloating(t, e);
|
|
1478
|
+
}
|
|
1479
|
+
this.updatePaneDragDropTargetFromPoint(t, e);
|
|
1480
|
+
const { floatingIndex: i, pointerOffsetX: o, pointerOffsetY: n } = this.dragState;
|
|
1481
|
+
if (i === null || i < 0)
|
|
1482
|
+
return;
|
|
1483
|
+
const r = this.floatingLayouts[i];
|
|
1484
|
+
if (!r)
|
|
1485
|
+
return;
|
|
1486
|
+
const c = this.getBoundingClientRect(), l = t - c.left - o, s = e - c.top - n;
|
|
1487
|
+
r.bounds.left = l, r.bounds.top = s;
|
|
1488
|
+
const a = this.getFloatingWrapper(i);
|
|
1489
|
+
a && (a.style.left = `${l}px`, a.style.top = `${s}px`);
|
|
1490
|
+
}
|
|
1491
|
+
updatePaneDragDropTargetFromPoint(t, e) {
|
|
1492
|
+
if (!this.dragState)
|
|
1493
|
+
return;
|
|
1494
|
+
const i = this.findStackAtPoint(t, e), o = i ? this.parsePath(i.dataset.path) : null;
|
|
1495
|
+
if (!i || !o) {
|
|
1496
|
+
this.dropJoystick.dataset.visible !== "true" && this.hideDropIndicator(), this.clearHeaderDragPlaceholder();
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
if (this.dropJoystickTarget && this.dropJoystickTarget !== i && (delete this.dropJoystick.dataset.zone, this.updateDropJoystickActiveZone(null)), this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && o && this.pathsEqual(o, this.dragState.sourcePath)) {
|
|
1500
|
+
const c = !!this.dragState.sourceHeaderBounds && this.isPointWithinBounds(this.dragState.sourceHeaderBounds, t, e), l = this.isPointerOverSourceHeader(t, e);
|
|
1501
|
+
if (c || l) {
|
|
1502
|
+
this.ensureHeaderDragPlaceholder(i, this.dragState.pane);
|
|
1503
|
+
const s = this.computeHeaderInsertIndex(i, t);
|
|
1504
|
+
this.dragState.liveReorderIndex !== s && (this.updateHeaderDragPlaceholderPosition(i, s), this.dragState.liveReorderIndex = s), this.hideDropIndicator();
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
this.clearHeaderDragPlaceholder();
|
|
1509
|
+
const n = this.findDropZoneByPoint(t, e), r = this.computeDropZone(i, { clientX: t, clientY: e }, n);
|
|
1510
|
+
this.showDropIndicator(i, r);
|
|
1511
|
+
}
|
|
1512
|
+
// Returns true when the pointer is currently over the source stack's header (tab strip).
|
|
1513
|
+
// The strip lives inside the mp-tab-control's shadow as `.tsc`, so we test
|
|
1514
|
+
// bounds directly rather than using elementsFromPoint(/contains) which won't
|
|
1515
|
+
// pierce the shadow boundary cleanly.
|
|
1516
|
+
isPointerOverSourceHeader(t, e) {
|
|
1517
|
+
const i = this.dragState;
|
|
1518
|
+
if (!i)
|
|
1519
|
+
return !1;
|
|
1520
|
+
const o = i.sourceStackEl ?? null, n = o ? this.getStackStripEl(o) : null;
|
|
1521
|
+
if (!n)
|
|
1522
|
+
return !0;
|
|
1523
|
+
const r = n.getBoundingClientRect();
|
|
1524
|
+
return t >= r.left && t <= r.right && e >= r.top && e <= r.bottom;
|
|
1525
|
+
}
|
|
1526
|
+
isPointWithinBounds(t, e, i) {
|
|
1527
|
+
return e >= t.left && e <= t.right && i >= t.top && i <= t.bottom;
|
|
1528
|
+
}
|
|
1529
|
+
// Ensure a placeholder tab exists during in-header drag and hide the real dragged tab visually.
|
|
1530
|
+
// Operates on the mp-tab-control stack: the dragged content div gets `data-hidden`
|
|
1531
|
+
// (mp-tab-control then skips its tab in the strip), and a placeholder header+content
|
|
1532
|
+
// pair is appended as light-DOM children of the stack. mp-tab-control's mutation
|
|
1533
|
+
// observer picks up the change and renders the placeholder as a tab.
|
|
1534
|
+
ensureHeaderDragPlaceholder(t, e) {
|
|
1535
|
+
if (t.tagName !== "MP-TAB-CONTROL" || this.dragState?.placeholderHeader === t && this.dragState.placeholderEl)
|
|
1536
|
+
return;
|
|
1537
|
+
const i = t.querySelector(
|
|
1538
|
+
`:scope > .dock-tab[data-pane="${CSS.escape(e)}"]`
|
|
1539
|
+
), o = t.querySelector(
|
|
1540
|
+
`:scope > .dock-stack__pane[data-pane="${CSS.escape(e)}"]`
|
|
1541
|
+
);
|
|
1542
|
+
if (!i || !o) return;
|
|
1543
|
+
const n = this.windowRef ? this.windowRef.getComputedStyle(i) : globalThis.getComputedStyle(i), r = parseFloat(n.paddingLeft) + parseFloat(n.paddingRight), c = Math.max(
|
|
1544
|
+
0,
|
|
1545
|
+
i.offsetWidth - r
|
|
1546
|
+
);
|
|
1547
|
+
o.setAttribute("data-hidden", "");
|
|
1548
|
+
const l = "__dock-placeholder__", s = this.documentRef.createElement("span");
|
|
1549
|
+
s.setAttribute("slot", `${l}-header`), s.classList.add("dock-tab"), s.dataset.placeholder = "true", s.dataset.tabId = l, s.setAttribute("aria-hidden", "true"), s.textContent = i.textContent, s.style.display = "inline-block", s.style.minWidth = `${c}px`, s.style.opacity = "0.5";
|
|
1550
|
+
const a = this.documentRef.createElement("div");
|
|
1551
|
+
a.setAttribute("slot", `${l}-content`), a.classList.add("dock-stack__pane"), a.dataset.placeholder = "true", t.insertBefore(s, i), t.insertBefore(a, o), this.dragState && (this.dragState.placeholderHeader = t, this.dragState.placeholderEl = s);
|
|
1552
|
+
}
|
|
1553
|
+
// Move the placeholder to the computed target index within the strip.
|
|
1554
|
+
// We reorder light-DOM children (header span + matching content div); the
|
|
1555
|
+
// mp-tab-control then re-renders the strip in the new order on slotchange.
|
|
1556
|
+
updateHeaderDragPlaceholderPosition(t, e) {
|
|
1557
|
+
if (t.tagName !== "MP-TAB-CONTROL") return;
|
|
1558
|
+
const i = this.dragState?.placeholderEl ?? null;
|
|
1559
|
+
if (!i) return;
|
|
1560
|
+
const o = this.dragState?.pane ?? null, n = Array.from(
|
|
1561
|
+
t.querySelectorAll(":scope > .dock-tab")
|
|
1562
|
+
).filter(
|
|
1563
|
+
(s) => s !== i && (!o || s.dataset.pane !== o)
|
|
1564
|
+
), r = Math.max(0, Math.min(e, n.length)), c = n[r] ?? null;
|
|
1565
|
+
t.insertBefore(i, c);
|
|
1566
|
+
const l = t.querySelector(
|
|
1567
|
+
':scope > .dock-stack__pane[data-placeholder="true"]'
|
|
1568
|
+
);
|
|
1569
|
+
l && i.nextElementSibling !== l && t.insertBefore(l, i.nextElementSibling);
|
|
1570
|
+
}
|
|
1571
|
+
// Remove placeholder and restore the dragged tab's visibility.
|
|
1572
|
+
clearHeaderDragPlaceholder() {
|
|
1573
|
+
const t = this.dragState?.placeholderEl ?? null, e = this.dragState?.placeholderHeader ?? null;
|
|
1574
|
+
e && (this.dragState?.pane && e.querySelector(
|
|
1575
|
+
`:scope > .dock-stack__pane[data-pane="${CSS.escape(this.dragState.pane)}"]`
|
|
1576
|
+
)?.removeAttribute("data-hidden"), e.querySelector(
|
|
1577
|
+
':scope > .dock-stack__pane[data-placeholder="true"]'
|
|
1578
|
+
)?.remove()), t && t.parentElement && t.parentElement.removeChild(t), this.dragState && (this.dragState.placeholderEl = null, this.dragState.placeholderHeader = null);
|
|
1579
|
+
}
|
|
1580
|
+
startDragPointerTracking() {
|
|
1581
|
+
if (this.dragPointerTrackingActive)
|
|
1582
|
+
return;
|
|
1583
|
+
this.lastDragPointerPosition = null;
|
|
1584
|
+
const t = this.windowRef;
|
|
1585
|
+
t?.addEventListener("pointermove", this.onDragPointerMove, !0), t?.addEventListener("pointerup", this.onDragPointerUp, !0), t?.addEventListener("pointercancel", this.onDragPointerCancel, !0), this.dragPointerTrackingActive = !0;
|
|
1586
|
+
}
|
|
1587
|
+
stopDragPointerTracking() {
|
|
1588
|
+
if (!this.dragPointerTrackingActive)
|
|
1589
|
+
return;
|
|
1590
|
+
const t = this.windowRef;
|
|
1591
|
+
t?.removeEventListener("pointermove", this.onDragPointerMove, !0), t?.removeEventListener("pointerup", this.onDragPointerUp, !0), t?.removeEventListener("pointercancel", this.onDragPointerCancel, !0), this.dragPointerTrackingActive = !1, this.lastDragPointerPosition = null, this.clearPendingDragEndTimeout();
|
|
1592
|
+
}
|
|
1593
|
+
onDragPointerMove(t) {
|
|
1594
|
+
if (!this.dragState) {
|
|
1595
|
+
this.stopDragPointerTracking();
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
this.lastDragPointerPosition = { x: t.clientX, y: t.clientY }, this.updateDraggedFloatingPositionFromPoint(t.clientX, t.clientY);
|
|
1599
|
+
}
|
|
1600
|
+
onDragPointerUp(t) {
|
|
1601
|
+
if (this.dragState) {
|
|
1602
|
+
const e = Number.isFinite(t.clientX) ? t.clientX : this.lastDragPointerPosition?.x, i = Number.isFinite(t.clientY) ? t.clientY : this.lastDragPointerPosition?.y;
|
|
1603
|
+
e !== void 0 && i !== void 0 && this.finalizeDropFromPoint(e, i);
|
|
1604
|
+
}
|
|
1605
|
+
this.handleDragPointerUpCommon();
|
|
1606
|
+
}
|
|
1607
|
+
onDragPointerCancel() {
|
|
1608
|
+
this.handleDragPointerUpCommon();
|
|
1609
|
+
}
|
|
1610
|
+
// Convert a currently in-header tab drag into a floating window
|
|
1611
|
+
convertPendingTabDragToFloating(t, e) {
|
|
1612
|
+
if (!this.dragState)
|
|
1613
|
+
return;
|
|
1614
|
+
const i = this.dragState;
|
|
1615
|
+
if (i.floatingIndex !== null && i.floatingIndex >= 0)
|
|
1616
|
+
return;
|
|
1617
|
+
this.clearHeaderDragPlaceholder();
|
|
1618
|
+
const o = this.resolveStackLocation(i.sourcePath);
|
|
1619
|
+
if (!o)
|
|
1620
|
+
return;
|
|
1621
|
+
const n = i.pane, r = i.sourceStackEl ?? null, c = this.getBoundingClientRect(), l = r?.getBoundingClientRect() ?? null, s = this.pendingTabDragMetrics, a = 320, h = 240, u = s && Number.isFinite(s.width) && s.width > 0 ? s.width : l && Number.isFinite(l.width) ? l.width : a, d = s && Number.isFinite(s.height) && s.height > 0 ? s.height : l && Number.isFinite(l.height) ? l.height : h, g = 1, f = s && Number.isFinite(s.left) ? s.left - g : Number.isFinite(t) ? t - c.left - u / 2 : 0, p = s && Number.isFinite(s.top) ? s.top - g : Number.isFinite(e) ? e - c.top - d / 2 : 0, m = this.clampBoundsToHost(
|
|
1622
|
+
{ left: f, top: p, width: u, height: d },
|
|
1623
|
+
this.getHostSize()
|
|
1624
|
+
), y = Number.isFinite(t) ? t - c.left - m.left : m.width / 2, b = Number.isFinite(e) ? e - c.top - m.top : m.height / 2;
|
|
1625
|
+
this.removePaneFromLocation(o, n);
|
|
1626
|
+
const S = {
|
|
1627
|
+
bounds: m,
|
|
1628
|
+
root: {
|
|
1629
|
+
kind: "stack",
|
|
1630
|
+
panes: [n],
|
|
1631
|
+
activePane: n
|
|
1632
|
+
},
|
|
1633
|
+
activePane: n
|
|
1634
|
+
};
|
|
1635
|
+
this.floatingLayouts.push(S);
|
|
1636
|
+
const P = this.floatingLayouts.length - 1;
|
|
1637
|
+
this.renderLayout();
|
|
1638
|
+
const k = this.getFloatingWrapper(P);
|
|
1639
|
+
k && this.promoteFloatingPane(P, k), this.liveAnnouncer.announce(`Pane ${this.titles[n] ?? n} torn off into a floating window.`), i.sourcePath = { type: "floating", index: P, segments: [] }, i.floatingIndex = P, i.pointerOffsetX = y, i.pointerOffsetY = b, this.markDraggedFloatingWrapper(), this.dispatchLayoutChanged();
|
|
1640
|
+
}
|
|
1641
|
+
// Toggle data-dragging on the floating wrapper currently associated with
|
|
1642
|
+
// the active pane drag (dragState.floatingIndex), if any. Used to make the
|
|
1643
|
+
// wrapper transparent to elementsFromPoint so drop zones can be shown on
|
|
1644
|
+
// stacks underneath. clearDraggedFloatingWrapper() is the inverse.
|
|
1645
|
+
markDraggedFloatingWrapper() {
|
|
1646
|
+
const t = this.dragState?.floatingIndex;
|
|
1647
|
+
if (t == null || t < 0) return;
|
|
1648
|
+
const e = this.getFloatingWrapper(t);
|
|
1649
|
+
e && (e.dataset.dragging = "true");
|
|
1650
|
+
}
|
|
1651
|
+
clearDraggedFloatingWrapperMarkers() {
|
|
1652
|
+
const t = this.floatingLayerEl;
|
|
1653
|
+
t && t.querySelectorAll('.dock-floating[data-dragging="true"]').forEach((e) => {
|
|
1654
|
+
delete e.dataset.dragging;
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
// Compute the intended tab insert index within a stack's strip based on pointer X.
|
|
1658
|
+
// Uses the rendered tab buttons inside mp-tab-control's shadow strip for geometry;
|
|
1659
|
+
// the dragged tab is hidden during drag (its content has data-hidden), and the
|
|
1660
|
+
// placeholder button (if present) gives us the dragged-position reference.
|
|
1661
|
+
computeHeaderInsertIndex(t, e) {
|
|
1662
|
+
if (t.tagName !== "MP-TAB-CONTROL") return 0;
|
|
1663
|
+
const i = this.getStackTabButtons(t);
|
|
1664
|
+
if (i.length === 0)
|
|
1665
|
+
return 0;
|
|
1666
|
+
const n = t.querySelector(
|
|
1667
|
+
':scope > .dock-tab[data-placeholder="true"]'
|
|
1668
|
+
)?.dataset.tabId, r = n ? i.find((p) => p.id === `${n}-header-button`) ?? null : null, c = this.dragState?.pane ?? null;
|
|
1669
|
+
let l = null;
|
|
1670
|
+
if (c) {
|
|
1671
|
+
for (const p of Array.from(t.children))
|
|
1672
|
+
if (p instanceof HTMLElement && p.classList.contains("dock-tab") && !p.hasAttribute("data-placeholder") && p.dataset.pane === c) {
|
|
1673
|
+
l = p.dataset.tabId ?? null;
|
|
1674
|
+
break;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
const s = l ? i.find((p) => p.id === `${l}-header-button`) ?? null : null, a = i.filter(
|
|
1678
|
+
(p) => p !== r && p !== s
|
|
1679
|
+
);
|
|
1680
|
+
if (a.length === 0)
|
|
1681
|
+
return 0;
|
|
1682
|
+
const h = 12, u = 0, d = r ? r.getBoundingClientRect() : null, f = !!d && Number.isFinite(d.width) && d.width > 0 && d ? d.left + d.width / 2 : null;
|
|
1683
|
+
for (let p = 0; p < a.length; p += 1) {
|
|
1684
|
+
const m = a[p].getBoundingClientRect(), y = m.left + m.width / 2, z = (f !== null ? y >= f : !1) ? y + h : y - u;
|
|
1685
|
+
if (e < z)
|
|
1686
|
+
return p;
|
|
1687
|
+
}
|
|
1688
|
+
return a.length;
|
|
1689
|
+
}
|
|
1690
|
+
reorderPaneInLocationAtIndex(t, e, i) {
|
|
1691
|
+
const o = t.node.panes, n = o.indexOf(e);
|
|
1692
|
+
if (n === -1)
|
|
1693
|
+
return;
|
|
1694
|
+
const r = Math.max(0, Math.min(i, o.length - 1));
|
|
1695
|
+
if (r !== n && (o.splice(n, 1), o.splice(r, 0, e), t.node.activePane = e, t.context === "floating")) {
|
|
1696
|
+
const c = this.floatingLayouts[t.index];
|
|
1697
|
+
c && (c.activePane = e);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
// Commit a drop using current pointer coordinates and joystick state
|
|
1701
|
+
finalizeDropFromPoint(t, e) {
|
|
1702
|
+
if (!this.dragState)
|
|
1703
|
+
return;
|
|
1704
|
+
const i = this.findStackAtPoint(t, e), o = i ? this.parsePath(i.dataset.path) : null, n = this.dropJoystick.dataset.visible === "true", r = this.parsePath(this.dropJoystick.dataset.path), c = this.dropJoystickTarget, l = c ? this.parsePath(c.dataset.path) : null, s = (n ? r ?? l : null) ?? o, a = this.dropJoystick.dataset.zone, h = this.isDropZone(a) ? a : i ? this.computeDropZone(i, { clientX: t, clientY: e }, null) : null;
|
|
1705
|
+
if (this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0 && i && s && o && this.pathsEqual(o, this.dragState.sourcePath) && (!h || h === "center")) {
|
|
1706
|
+
const u = this.resolveStackLocation(s);
|
|
1707
|
+
if (u) {
|
|
1708
|
+
const d = this.computeHeaderInsertIndex(i, t);
|
|
1709
|
+
this.reorderPaneInLocationAtIndex(u, this.dragState.pane, d), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState.dropHandled = !0;
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
s && this.isDropZone(h) && (this.handleDrop(s, h), this.dragState.dropHandled = !0);
|
|
1714
|
+
}
|
|
1715
|
+
clearPendingDragEndTimeout() {
|
|
1716
|
+
if (this.pendingDragEndTimeout !== null) {
|
|
1717
|
+
const t = this.windowRef;
|
|
1718
|
+
t && typeof this.pendingDragEndTimeout == "number" ? t.clearTimeout(this.pendingDragEndTimeout) : globalThis.clearTimeout(this.pendingDragEndTimeout), this.pendingDragEndTimeout = null;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
scheduleDeferredDragEnd() {
|
|
1722
|
+
if (this.pendingDragEndTimeout !== null)
|
|
1723
|
+
return;
|
|
1724
|
+
const t = () => {
|
|
1725
|
+
if (this.pendingDragEndTimeout = null, this.hideDropIndicator(), !this.dragState) {
|
|
1726
|
+
this.clearPendingTabDragMetrics();
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
this.endPaneDrag(), this.clearPendingTabDragMetrics();
|
|
1730
|
+
}, e = this.windowRef;
|
|
1731
|
+
this.pendingDragEndTimeout = e ? e.setTimeout(t, 0) : setTimeout(t, 0);
|
|
1732
|
+
}
|
|
1733
|
+
handleDrop(t, e) {
|
|
1734
|
+
if (!this.dragState || !t)
|
|
1735
|
+
return;
|
|
1736
|
+
const { pane: i, sourcePath: o } = this.dragState, n = this.resolveStackLocation(o), r = this.resolveStackLocation(t);
|
|
1737
|
+
if (!r && t.type === "docked" && !this.rootLayout) {
|
|
1738
|
+
if (!n)
|
|
1739
|
+
return;
|
|
1740
|
+
this.removePaneFromLocation(n, i, !0);
|
|
1741
|
+
const l = {
|
|
1742
|
+
kind: "stack",
|
|
1743
|
+
panes: [i],
|
|
1744
|
+
activePane: i
|
|
1745
|
+
};
|
|
1746
|
+
this.rootLayout = l, this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
if (!n || !r)
|
|
1750
|
+
return;
|
|
1751
|
+
if (e === "center" && this.pathsEqual(o, t)) {
|
|
1752
|
+
if (!n.node.panes.includes(i))
|
|
1753
|
+
return;
|
|
1754
|
+
this.reorderPaneInLocation(n, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
if (this.removePaneFromLocation(n, i, !0), e === "center") {
|
|
1758
|
+
this.addPaneToLocation(r, i), this.setActivePaneForLocation(r, i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
const c = {
|
|
1762
|
+
kind: "stack",
|
|
1763
|
+
panes: [i],
|
|
1764
|
+
activePane: i
|
|
1765
|
+
};
|
|
1766
|
+
if (r.context === "docked")
|
|
1767
|
+
this.rootLayout = this.dockNodeBeside(this.rootLayout, r.node, c, e);
|
|
1768
|
+
else {
|
|
1769
|
+
const l = this.floatingLayouts[r.index];
|
|
1770
|
+
if (!l) {
|
|
1771
|
+
this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged();
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
l.root = this.dockNodeBeside(l.root, r.node, c, e), l.activePane = i;
|
|
1775
|
+
}
|
|
1776
|
+
this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.dragState && (this.dragState.dropHandled = !0);
|
|
1777
|
+
}
|
|
1778
|
+
handleFloatingStackDrop(t, e, i) {
|
|
1779
|
+
const o = this.floatingLayouts[t];
|
|
1780
|
+
if (!o || !o.root)
|
|
1781
|
+
return !1;
|
|
1782
|
+
const n = this.resolveStackLocation(e);
|
|
1783
|
+
if (!n && e.type === "docked" && !this.rootLayout)
|
|
1784
|
+
return this.rootLayout = this.cloneLayoutNode(o.root), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
|
|
1785
|
+
if (!n || n.context === "floating" && n.index === t)
|
|
1786
|
+
return !1;
|
|
1787
|
+
if (i === "center") {
|
|
1788
|
+
const r = this.collectPaneNames(o.root);
|
|
1789
|
+
if (r.length === 0)
|
|
1790
|
+
return !1;
|
|
1791
|
+
r.forEach((l) => {
|
|
1792
|
+
this.addPaneToLocation(n, l);
|
|
1793
|
+
});
|
|
1794
|
+
const c = o.activePane && r.includes(o.activePane) ? o.activePane : this.findFirstPaneName(o.root) ?? r[0];
|
|
1795
|
+
return c && this.setActivePaneForLocation(n, c), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
|
|
1796
|
+
}
|
|
1797
|
+
if (n.context === "floating") {
|
|
1798
|
+
const r = this.floatingLayouts[n.index];
|
|
1799
|
+
return r ? (r.root = this.dockNodeBeside(r.root, n.node, o.root, i), r.activePane = o.activePane ?? this.findFirstPaneName(o.root) ?? void 0, this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0) : !1;
|
|
1800
|
+
}
|
|
1801
|
+
return this.rootLayout = this.dockNodeBeside(this.rootLayout, n.node, o.root, i), this.removeFloatingAt(t), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), !0;
|
|
1802
|
+
}
|
|
1803
|
+
insertWeight(t, e, i) {
|
|
1804
|
+
const o = i - 1, n = this.normalizeSizesArray(t, o), r = 1 / i, c = 1 - r, l = [];
|
|
1805
|
+
for (let s = 0; s < i; s += 1)
|
|
1806
|
+
if (s === e)
|
|
1807
|
+
l.push(r);
|
|
1808
|
+
else {
|
|
1809
|
+
const a = s < e ? s : s - 1;
|
|
1810
|
+
l.push(n[a] * c);
|
|
1811
|
+
}
|
|
1812
|
+
return l;
|
|
1813
|
+
}
|
|
1814
|
+
removePaneFromStack(t, e, i = !1) {
|
|
1815
|
+
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);
|
|
1816
|
+
}
|
|
1817
|
+
findParentSplit(t, e) {
|
|
1818
|
+
if (!t || t === e || t.kind !== "split")
|
|
1819
|
+
return null;
|
|
1820
|
+
const i = t.children.indexOf(e);
|
|
1821
|
+
if (i !== -1)
|
|
1822
|
+
return { parent: t, index: i };
|
|
1823
|
+
for (let o = 0; o < t.children.length; o += 1) {
|
|
1824
|
+
const n = this.findParentSplit(t.children[o], e);
|
|
1825
|
+
if (n)
|
|
1826
|
+
return n;
|
|
1827
|
+
}
|
|
1828
|
+
return null;
|
|
1829
|
+
}
|
|
1830
|
+
computeDropZone(t, e, i) {
|
|
1831
|
+
const o = this.isDropZone(i) ? i : null;
|
|
1832
|
+
if (o)
|
|
1833
|
+
return this.updateDropJoystickActiveZone(o), o;
|
|
1834
|
+
const n = e && Number.isFinite(e.clientX) && Number.isFinite(e.clientY) ? this.findDropZoneByPoint(e.clientX, e.clientY) : null;
|
|
1835
|
+
if (n)
|
|
1836
|
+
return this.updateDropJoystickActiveZone(n), n;
|
|
1837
|
+
if (this.dropJoystickTarget === t) {
|
|
1838
|
+
const r = this.dropJoystick.dataset.zone;
|
|
1839
|
+
if (this.isDropZone(r))
|
|
1840
|
+
return this.updateDropJoystickActiveZone(r), r;
|
|
1841
|
+
this.updateDropJoystickActiveZone(null);
|
|
1842
|
+
}
|
|
1843
|
+
return null;
|
|
1844
|
+
}
|
|
1845
|
+
extractDropZoneFromEvent(t) {
|
|
1846
|
+
if (!t)
|
|
1847
|
+
return null;
|
|
1848
|
+
if (typeof t.composedPath == "function") {
|
|
1849
|
+
const e = t.composedPath(), i = this.findDropZoneInTargets(e);
|
|
1850
|
+
if (i)
|
|
1851
|
+
return i;
|
|
1852
|
+
}
|
|
1853
|
+
if ("clientX" in t && "clientY" in t) {
|
|
1854
|
+
const e = t, i = this.findDropZoneByPoint(e.clientX, e.clientY);
|
|
1855
|
+
if (i)
|
|
1856
|
+
return i;
|
|
1857
|
+
}
|
|
1858
|
+
return null;
|
|
1859
|
+
}
|
|
1860
|
+
handleDragPointerUpCommon() {
|
|
1861
|
+
if (!this.dragState) {
|
|
1862
|
+
this.stopDragPointerTracking();
|
|
1863
|
+
return;
|
|
1864
|
+
}
|
|
1865
|
+
this.scheduleDeferredDragEnd();
|
|
1866
|
+
}
|
|
1867
|
+
findDropZoneInTargets(t) {
|
|
1868
|
+
for (const e of t)
|
|
1869
|
+
if (e instanceof HTMLElement && e.classList.contains("dock-drop-joystick__button")) {
|
|
1870
|
+
const i = e.dataset?.zone;
|
|
1871
|
+
if (this.isDropZone(i))
|
|
1872
|
+
return i;
|
|
1873
|
+
}
|
|
1874
|
+
return null;
|
|
1875
|
+
}
|
|
1876
|
+
findDropZoneByPoint(t, e) {
|
|
1877
|
+
if (!this.dropJoystickButtons || this.dropJoystick.dataset.visible !== "true" || !this.dropJoystickTarget)
|
|
1878
|
+
return null;
|
|
1879
|
+
for (const i of this.dropJoystickButtons) {
|
|
1880
|
+
if (i.dataset.hidden === "true" || i.style.visibility === "hidden" || i.style.display === "none")
|
|
1881
|
+
continue;
|
|
1882
|
+
const o = i.getBoundingClientRect();
|
|
1883
|
+
if (t >= o.left && t <= o.right && e >= o.top && e <= o.bottom) {
|
|
1884
|
+
const n = i.dataset.zone;
|
|
1885
|
+
if (this.isDropZone(n))
|
|
1886
|
+
return n;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
return null;
|
|
1890
|
+
}
|
|
1891
|
+
updateDropJoystickActiveZone(t) {
|
|
1892
|
+
const i = this.dropJoystick.dataset.visible === "true" ? this.dropJoystick.dataset.zone : void 0, o = t ?? (this.isDropZone(i) ? i : null);
|
|
1893
|
+
this.dropJoystickButtons.forEach((n) => {
|
|
1894
|
+
o !== null && n.dataset.zone === o ? n.dataset.active = "true" : delete n.dataset.active;
|
|
1895
|
+
}), o ? this.dropJoystick.dataset.zone = o : delete this.dropJoystick.dataset.zone;
|
|
1896
|
+
}
|
|
1897
|
+
isDropZone(t) {
|
|
1898
|
+
return t === "left" || t === "right" || t === "top" || t === "bottom" || t === "center";
|
|
1899
|
+
}
|
|
1900
|
+
showDropIndicator(t, e) {
|
|
1901
|
+
const i = this.parsePath(t.dataset.path), o = this.dragState?.sourcePath ?? null;
|
|
1902
|
+
if (i && o && this.isOrIsAncestorOf(i, o))
|
|
1903
|
+
return;
|
|
1904
|
+
const n = t.getBoundingClientRect(), r = this.getBoundingClientRect(), c = this.dropIndicator, l = this.dropJoystick;
|
|
1905
|
+
l.hidden = !1;
|
|
1906
|
+
const s = this.parsePath(t.dataset.path);
|
|
1907
|
+
let a = 100;
|
|
1908
|
+
s && s.type === "floating" && (a = this.getFloatingPaneZIndex(s.index) + 100), c.style.zIndex = String(a), l.style.zIndex = String(a + 1);
|
|
1909
|
+
let h = n.left - r.left, u = n.top - r.top, d = n.width, g = n.height;
|
|
1910
|
+
const f = 0.5;
|
|
1911
|
+
if (e) {
|
|
1912
|
+
switch (e) {
|
|
1913
|
+
case "left":
|
|
1914
|
+
d = n.width * f;
|
|
1915
|
+
break;
|
|
1916
|
+
case "right":
|
|
1917
|
+
d = n.width * f, h += n.width * (1 - f);
|
|
1918
|
+
break;
|
|
1919
|
+
case "top":
|
|
1920
|
+
g = n.height * f;
|
|
1921
|
+
break;
|
|
1922
|
+
case "bottom":
|
|
1923
|
+
g = n.height * f, u += n.height * (1 - f);
|
|
1924
|
+
break;
|
|
1925
|
+
}
|
|
1926
|
+
c.style.left = `${h}px`, c.style.top = `${u}px`, c.style.width = `${d}px`, c.style.height = `${g}px`, c.dataset.visible = "true";
|
|
1927
|
+
} else
|
|
1928
|
+
c.dataset.visible = "false";
|
|
1929
|
+
l.style.left = `${n.left - r.left + n.width / 2}px`, l.style.top = `${n.top - r.top + n.height / 2}px`, l.dataset.visible = "true", this.dropJoystick.style.display = "grid", l.dataset.path = t.dataset.path ?? "";
|
|
1930
|
+
const p = this.dropJoystickTarget && this.dropJoystickTarget !== t;
|
|
1931
|
+
this.dropJoystickTarget = t, p && delete this.dropJoystick.dataset.zone;
|
|
1932
|
+
const m = !this.rootLayout && (t === this.dockedEl || i && i.type === "docked" && i.segments.length === 0), y = Array.from(this.dropJoystick.querySelectorAll(".dock-drop-joystick__spacer"));
|
|
1933
|
+
m ? (y.forEach((b) => {
|
|
1934
|
+
b.style.display = "";
|
|
1935
|
+
}), this.dropJoystickButtons.forEach((b) => {
|
|
1936
|
+
b.dataset.zone === "center" ? (b.style.visibility = "", b.style.pointerEvents = "", delete b.dataset.hidden, b.style.display = "") : (b.style.visibility = "hidden", b.style.pointerEvents = "none", b.dataset.hidden = "true", b.style.display = "");
|
|
1937
|
+
}), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = "") : (this.dropJoystickButtons.forEach((b) => {
|
|
1938
|
+
b.style.visibility = "", b.style.pointerEvents = "", delete b.dataset.hidden, b.style.display = "";
|
|
1939
|
+
}), y.forEach((b) => b.style.display = ""), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = ""), this.updateDropJoystickActiveZone(e);
|
|
1940
|
+
}
|
|
1941
|
+
hideDropIndicator() {
|
|
1942
|
+
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) => {
|
|
1943
|
+
t.style.display = "", t.style.visibility = "", t.style.pointerEvents = "", delete t.dataset.hidden;
|
|
1944
|
+
}), Array.from(this.dropJoystick.querySelectorAll(".dock-drop-joystick__spacer")).forEach((t) => t.style.display = ""), this.dropJoystick.style.gridTemplateColumns = "", this.dropJoystick.style.gridTemplateRows = "";
|
|
1945
|
+
}
|
|
1946
|
+
findStackAtPoint(t, e) {
|
|
1947
|
+
const i = this.shadowRoot;
|
|
1948
|
+
if (!i)
|
|
1949
|
+
return null;
|
|
1950
|
+
const o = i.elementsFromPoint(t, e), n = this.findStackInTargets(o);
|
|
1951
|
+
if (n)
|
|
1952
|
+
return n;
|
|
1953
|
+
if (!this.rootLayout) {
|
|
1954
|
+
const r = this.dockedEl.getBoundingClientRect();
|
|
1955
|
+
if (t >= r.left && t <= r.right && e >= r.top && e <= r.bottom)
|
|
1956
|
+
return this.dockedEl;
|
|
1957
|
+
}
|
|
1958
|
+
return null;
|
|
1959
|
+
}
|
|
1960
|
+
findStackInTargets(t) {
|
|
1961
|
+
for (const e of t)
|
|
1962
|
+
if (e instanceof HTMLElement) {
|
|
1963
|
+
if (e.classList.contains("dock-stack"))
|
|
1964
|
+
return e;
|
|
1965
|
+
if (this.dropJoystickTarget && (e.classList.contains("dock-drop-joystick") || e.classList.contains("dock-drop-joystick__button") || e.classList.contains("dock-drop-joystick__spacer")))
|
|
1966
|
+
return this.dropJoystickTarget;
|
|
1967
|
+
}
|
|
1968
|
+
return null;
|
|
1969
|
+
}
|
|
1970
|
+
activatePane(t, e, i) {
|
|
1971
|
+
if (t.dataset.activePane = e, t.tagName === "MP-TAB-CONTROL") {
|
|
1972
|
+
const r = t.querySelector(
|
|
1973
|
+
`:scope > .dock-tab[data-pane="${CSS.escape(e)}"]`
|
|
1974
|
+
)?.dataset.tabId;
|
|
1975
|
+
r && t.setAttribute("active-tab", r);
|
|
1976
|
+
}
|
|
1977
|
+
const o = this.resolveStackLocation(i);
|
|
1978
|
+
if (o) {
|
|
1979
|
+
if (o.node.activePane = e, i.type === "floating") {
|
|
1980
|
+
const n = this.floatingLayouts[i.index];
|
|
1981
|
+
n && (n.activePane = e), this.updateFloatingWindowTitle(i.index);
|
|
1982
|
+
}
|
|
1983
|
+
this.dispatchLayoutChanged();
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
getNodeAtPath(t, e) {
|
|
1987
|
+
if (!t)
|
|
1988
|
+
return null;
|
|
1989
|
+
let i = t;
|
|
1990
|
+
if (e.length === 0)
|
|
1991
|
+
return i;
|
|
1992
|
+
for (const o of e) {
|
|
1993
|
+
if (!i || i.kind !== "split")
|
|
1994
|
+
return null;
|
|
1995
|
+
i = i.children[o] ?? null;
|
|
1996
|
+
}
|
|
1997
|
+
return i;
|
|
1998
|
+
}
|
|
1999
|
+
resolveSplitNode(t) {
|
|
2000
|
+
if (t.type === "docked") {
|
|
2001
|
+
const o = this.getNodeAtPath(this.rootLayout, t.segments);
|
|
2002
|
+
return o && o.kind === "split" ? o : null;
|
|
2003
|
+
}
|
|
2004
|
+
const e = this.floatingLayouts[t.index];
|
|
2005
|
+
if (!e || !e.root)
|
|
2006
|
+
return null;
|
|
2007
|
+
const i = this.getNodeAtPath(e.root, t.segments);
|
|
2008
|
+
return i && i.kind === "split" ? i : null;
|
|
2009
|
+
}
|
|
2010
|
+
replaceNodeInTree(t, e, i) {
|
|
2011
|
+
if (!t || t === e)
|
|
2012
|
+
return i;
|
|
2013
|
+
const o = this.findParentSplit(t, e);
|
|
2014
|
+
return o && (o.parent.children[o.index] = i, this.normalizeSplitNode(o.parent)), t;
|
|
2015
|
+
}
|
|
2016
|
+
dockNodeBeside(t, e, i, o) {
|
|
2017
|
+
const n = o === "left" || o === "right" ? "horizontal" : "vertical", r = o === "left" || o === "top", c = this.findParentSplit(t, e);
|
|
2018
|
+
if (c && c.parent.direction === n) {
|
|
2019
|
+
const s = r ? c.index : c.index + 1;
|
|
2020
|
+
return c.parent.children.splice(s, 0, i), c.parent.sizes = this.insertWeight(
|
|
2021
|
+
c.parent.sizes,
|
|
2022
|
+
s,
|
|
2023
|
+
c.parent.children.length
|
|
2024
|
+
), t ?? i;
|
|
2025
|
+
}
|
|
2026
|
+
const l = {
|
|
2027
|
+
kind: "split",
|
|
2028
|
+
direction: n,
|
|
2029
|
+
children: r ? [i, e] : [e, i],
|
|
2030
|
+
sizes: [0.5, 0.5]
|
|
2031
|
+
};
|
|
2032
|
+
return this.replaceNodeInTree(t, e, l);
|
|
2033
|
+
}
|
|
2034
|
+
forEachStack(t, e, i = []) {
|
|
2035
|
+
if (t) {
|
|
2036
|
+
if (t.kind === "stack") {
|
|
2037
|
+
e(t, i);
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
t.children.forEach(
|
|
2041
|
+
(o, n) => this.forEachStack(o, e, [...i, n])
|
|
2042
|
+
);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
findStackContainingPane(t, e) {
|
|
2046
|
+
let i = null;
|
|
2047
|
+
return this.forEachStack(t, (o) => {
|
|
2048
|
+
!i && o.panes.includes(e) && (i = o);
|
|
2049
|
+
}), i;
|
|
2050
|
+
}
|
|
2051
|
+
findFirstPaneName(t) {
|
|
2052
|
+
let e = null;
|
|
2053
|
+
return this.forEachStack(t, (i) => {
|
|
2054
|
+
e || i.panes.length === 0 || (i.activePane && i.panes.includes(i.activePane) ? e = i.activePane : e = i.panes[0]);
|
|
2055
|
+
}), e;
|
|
2056
|
+
}
|
|
2057
|
+
collectFloatingPaneMetadata(t) {
|
|
2058
|
+
const e = this.collectPaneNames(t), i = {};
|
|
2059
|
+
return e.forEach((o) => {
|
|
2060
|
+
const n = this.titles[o];
|
|
2061
|
+
n && (i[o] = n);
|
|
2062
|
+
}), { panes: e, titles: i };
|
|
2063
|
+
}
|
|
2064
|
+
collectPaneNames(t) {
|
|
2065
|
+
const e = [];
|
|
2066
|
+
return this.forEachStack(t, (i) => {
|
|
2067
|
+
i.panes.forEach((o) => e.push(o));
|
|
2068
|
+
}), e;
|
|
2069
|
+
}
|
|
2070
|
+
normalizeFloatingLayout(t) {
|
|
2071
|
+
const e = t.bounds ?? { left: 0, top: 0, width: 320, height: 200 }, i = {
|
|
2072
|
+
left: Number.isFinite(e.left) ? e.left : 0,
|
|
2073
|
+
top: Number.isFinite(e.top) ? e.top : 0,
|
|
2074
|
+
width: Number.isFinite(e.width) ? Math.max(e.width, 160) : 320,
|
|
2075
|
+
height: Number.isFinite(e.height) ? Math.max(e.height, 120) : 200
|
|
2076
|
+
}, o = t.root ? this.cloneLayoutNode(t.root) : null;
|
|
2077
|
+
return {
|
|
2078
|
+
id: t.id,
|
|
2079
|
+
bounds: i,
|
|
2080
|
+
zIndex: t.zIndex,
|
|
2081
|
+
root: o,
|
|
2082
|
+
activePane: t.activePane
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
formatPath(t) {
|
|
2086
|
+
if (t.type === "floating") {
|
|
2087
|
+
const i = t.segments.length > 0 ? `/${t.segments.map((o) => o.toString()).join("/")}` : "";
|
|
2088
|
+
return `f:${t.index}${i}`;
|
|
2089
|
+
}
|
|
2090
|
+
const e = t.segments.join("/");
|
|
2091
|
+
return e.length > 0 ? `d:${e}` : "d:";
|
|
2092
|
+
}
|
|
2093
|
+
// Layer identity of a splitter in the rendered shadow tree. Splitters inside
|
|
2094
|
+
// floating pane N are nested under `.dock-floating[data-path="f:N"]`;
|
|
2095
|
+
// docked-layer splitters have no such ancestor. Two splitters share a layer
|
|
2096
|
+
// iff their layer keys match — used by renderIntersectionHandles() to reject
|
|
2097
|
+
// coincidental cross-layer (h, v) pairs that would otherwise produce a
|
|
2098
|
+
// phantom intersection glyph between unrelated splitters.
|
|
2099
|
+
splitterLayerKey(t) {
|
|
2100
|
+
const e = t.closest(".dock-floating");
|
|
2101
|
+
return e ? e.dataset.path ?? "f:?" : "d";
|
|
2102
|
+
}
|
|
2103
|
+
clonePath(t) {
|
|
2104
|
+
return t.type === "floating" ? { type: "floating", index: t.index, segments: [...t.segments] } : { type: "docked", segments: [...t.segments] };
|
|
2105
|
+
}
|
|
2106
|
+
parsePath(t) {
|
|
2107
|
+
if (t == null)
|
|
2108
|
+
return null;
|
|
2109
|
+
if (t.startsWith("f:")) {
|
|
2110
|
+
const o = t.slice(2), [n, ...r] = o.split("/"), c = Number.parseInt(n, 10);
|
|
2111
|
+
if (!Number.isFinite(c))
|
|
2112
|
+
return null;
|
|
2113
|
+
const l = r.filter((s) => s.length > 0).map((s) => Number.parseInt(s, 10)).filter((s) => Number.isFinite(s));
|
|
2114
|
+
return { type: "floating", index: c, segments: l };
|
|
2115
|
+
}
|
|
2116
|
+
const e = t.startsWith("d:") ? t.slice(2) : t;
|
|
2117
|
+
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)) };
|
|
2118
|
+
}
|
|
2119
|
+
pathsEqual(t, e) {
|
|
2120
|
+
if (t.type !== e.type)
|
|
2121
|
+
return !1;
|
|
2122
|
+
if (t.type === "floating") {
|
|
2123
|
+
const o = e;
|
|
2124
|
+
return t.index !== o.index || t.segments.length !== o.segments.length ? !1 : t.segments.every((n, r) => n === o.segments[r]);
|
|
2125
|
+
}
|
|
2126
|
+
const i = e;
|
|
2127
|
+
return t.segments.length !== i.segments.length ? !1 : t.segments.every((o, n) => o === i.segments[n]);
|
|
2128
|
+
}
|
|
2129
|
+
isOrIsAncestorOf(t, e) {
|
|
2130
|
+
return t.type !== e.type || t.type === "floating" && e.index !== t.index || t.segments.length > e.segments.length ? !1 : t.segments.every((i, o) => i === e.segments[o]);
|
|
2131
|
+
}
|
|
2132
|
+
countPanesInTree(t) {
|
|
2133
|
+
return t ? t.kind === "stack" ? t.panes.length : t.children.reduce((e, i) => e + this.countPanesInTree(i), 0) : 0;
|
|
2134
|
+
}
|
|
2135
|
+
resolveStackLocation(t) {
|
|
2136
|
+
if (t.type === "floating") {
|
|
2137
|
+
const i = this.floatingLayouts[t.index];
|
|
2138
|
+
if (!i || !i.root)
|
|
2139
|
+
return null;
|
|
2140
|
+
const o = this.getNodeAtPath(i.root, t.segments);
|
|
2141
|
+
return !o || o.kind !== "stack" ? null : { context: "floating", index: t.index, path: [...t.segments], node: o };
|
|
2142
|
+
}
|
|
2143
|
+
const e = this.getNodeAtPath(this.rootLayout, t.segments);
|
|
2144
|
+
return !e || e.kind !== "stack" ? null : { context: "docked", path: [...t.segments], node: e };
|
|
2145
|
+
}
|
|
2146
|
+
removePaneFromLocation(t, e, i = !1) {
|
|
2147
|
+
return t.context === "docked" ? this.removePaneFromStack(t.node, e, i) : this.removePaneFromFloating(t.index, t.path, e, i);
|
|
2148
|
+
}
|
|
2149
|
+
addPaneToLocation(t, e) {
|
|
2150
|
+
const i = t.node.panes, o = i.indexOf(e);
|
|
2151
|
+
o !== -1 && i.splice(o, 1), i.push(e);
|
|
2152
|
+
}
|
|
2153
|
+
setActivePaneForLocation(t, e) {
|
|
2154
|
+
if (t.node.activePane = e, t.context === "floating") {
|
|
2155
|
+
const i = this.floatingLayouts[t.index];
|
|
2156
|
+
i && (i.activePane = e);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
reorderPaneInLocation(t, e) {
|
|
2160
|
+
const i = t.node.panes, o = i.indexOf(e);
|
|
2161
|
+
if (o !== -1 && (i.splice(o, 1), i.push(e), t.node.activePane = e, t.context === "floating")) {
|
|
2162
|
+
const n = this.floatingLayouts[t.index];
|
|
2163
|
+
n && (n.activePane = e);
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
removeFloatingAt(t) {
|
|
2167
|
+
t < 0 || t >= this.floatingLayouts.length || this.floatingLayouts.splice(t, 1);
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Keyboard handler on the dock root, registered in capture phase so it
|
|
2171
|
+
* runs before mp-tab-control's shadow-internal handlers swallow Arrow /
|
|
2172
|
+
* Home / End / Enter. M opens move mode on a focused tab; subsequent
|
|
2173
|
+
* letter keys (T/R/B/L/F) commit the move; Escape cancels.
|
|
2174
|
+
*/
|
|
2175
|
+
onRootKeyDown(t) {
|
|
2176
|
+
if (this.paneMoveMode) {
|
|
2177
|
+
this.handlePaneMoveModeKey(t);
|
|
2178
|
+
return;
|
|
2179
|
+
}
|
|
2180
|
+
if (t.key !== "m" && t.key !== "M") return;
|
|
2181
|
+
const e = this.findFocusedPaneOrigin();
|
|
2182
|
+
if (!e) return;
|
|
2183
|
+
t.preventDefault(), t.stopPropagation(), this.paneMoveMode = e;
|
|
2184
|
+
const i = this.titles[e.paneName] ?? e.paneName;
|
|
2185
|
+
this.liveAnnouncer.announce(
|
|
2186
|
+
`Move mode for pane ${i}. Press T, R, B, or L to dock to top, right, bottom, or left of the current stack. Press F to float. Escape to cancel.`
|
|
2187
|
+
);
|
|
2188
|
+
}
|
|
2189
|
+
handlePaneMoveModeKey(t) {
|
|
2190
|
+
if (t.key === "Escape") {
|
|
2191
|
+
t.preventDefault(), t.stopPropagation(), this.paneMoveMode = null, this.liveAnnouncer.announce("Move cancelled.");
|
|
2192
|
+
return;
|
|
2193
|
+
}
|
|
2194
|
+
const e = t.key.toLowerCase(), o = {
|
|
2195
|
+
t: "top",
|
|
2196
|
+
r: "right",
|
|
2197
|
+
b: "bottom",
|
|
2198
|
+
l: "left",
|
|
2199
|
+
f: "float"
|
|
2200
|
+
}[e];
|
|
2201
|
+
o && (t.preventDefault(), t.stopPropagation(), o === "float" ? this.commitPaneMoveAsFloat() : this.commitPaneMoveToZone(o));
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Walk the focused element through nested shadow roots to find a focused
|
|
2205
|
+
* tab button, then map it back to the dock's pane name + source path via
|
|
2206
|
+
* the data attributes on the slotted .dock-tab span.
|
|
2207
|
+
*/
|
|
2208
|
+
findFocusedPaneOrigin() {
|
|
2209
|
+
if (!this.shadowRoot) return null;
|
|
2210
|
+
let t = this.shadowRoot.activeElement;
|
|
2211
|
+
for (; t && t.shadowRoot && t.shadowRoot.activeElement; )
|
|
2212
|
+
t = t.shadowRoot.activeElement;
|
|
2213
|
+
if (!t || t.getAttribute("role") !== "tab") return null;
|
|
2214
|
+
const e = t.id.replace(/-header-button$/, ""), i = this.shadowRoot.querySelector(
|
|
2215
|
+
`.dock-tab[data-tab-id="${e}"]`
|
|
2216
|
+
);
|
|
2217
|
+
if (!i) return null;
|
|
2218
|
+
const o = i.closest(".dock-stack");
|
|
2219
|
+
if (!o) return null;
|
|
2220
|
+
const n = this.parsePath(o.dataset.path);
|
|
2221
|
+
return n ? { paneName: i.dataset.pane, sourcePath: n } : null;
|
|
2222
|
+
}
|
|
2223
|
+
/**
|
|
2224
|
+
* Synthesise a minimal dragState so handleDrop's existing pipeline can
|
|
2225
|
+
* commit the keyboard-driven move. handleDrop reads {pane, sourcePath,
|
|
2226
|
+
* dropHandled} — the rest of dragState is pointer-drag bookkeeping that
|
|
2227
|
+
* doesn't apply here.
|
|
2228
|
+
*/
|
|
2229
|
+
synthesiseDragStateForKeyboardMove() {
|
|
2230
|
+
this.paneMoveMode && (this.dragState = {
|
|
2231
|
+
pane: this.paneMoveMode.paneName,
|
|
2232
|
+
sourcePath: this.clonePath(this.paneMoveMode.sourcePath),
|
|
2233
|
+
floatingIndex: this.paneMoveMode.sourcePath.type === "floating" ? this.paneMoveMode.sourcePath.index : null,
|
|
2234
|
+
pointerOffsetX: 0,
|
|
2235
|
+
pointerOffsetY: 0,
|
|
2236
|
+
dropHandled: !1,
|
|
2237
|
+
sourceStackEl: null,
|
|
2238
|
+
sourceHeaderBounds: null,
|
|
2239
|
+
startClientX: 0,
|
|
2240
|
+
startClientY: 0
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
commitPaneMoveToZone(t) {
|
|
2244
|
+
if (!this.paneMoveMode) return;
|
|
2245
|
+
const e = this.paneMoveMode;
|
|
2246
|
+
this.synthesiseDragStateForKeyboardMove(), this.handleDrop(e.sourcePath, t), this.dragState = null, this.paneMoveMode = null;
|
|
2247
|
+
const i = this.titles[e.paneName] ?? e.paneName;
|
|
2248
|
+
this.liveAnnouncer.announce(`Pane ${i} docked to ${t}.`);
|
|
2249
|
+
}
|
|
2250
|
+
commitPaneMoveAsFloat() {
|
|
2251
|
+
if (!this.paneMoveMode) return;
|
|
2252
|
+
const t = this.paneMoveMode, e = this.resolveStackLocation(t.sourcePath);
|
|
2253
|
+
if (!e) {
|
|
2254
|
+
this.paneMoveMode = null;
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
this.removePaneFromLocation(e, t.paneName, !0);
|
|
2258
|
+
const i = {
|
|
2259
|
+
bounds: {
|
|
2260
|
+
left: 100 + this.floatingLayouts.length * 24,
|
|
2261
|
+
top: 100 + this.floatingLayouts.length * 24,
|
|
2262
|
+
width: 320,
|
|
2263
|
+
height: 200
|
|
2264
|
+
},
|
|
2265
|
+
root: { kind: "stack", panes: [t.paneName], activePane: t.paneName },
|
|
2266
|
+
activePane: t.paneName
|
|
2267
|
+
};
|
|
2268
|
+
this.floatingLayouts.push(i), this.normalizeAllLayouts(), this.renderLayout(), this.dispatchLayoutChanged(), this.paneMoveMode = null;
|
|
2269
|
+
const o = this.titles[t.paneName] ?? t.paneName;
|
|
2270
|
+
this.liveAnnouncer.announce(`Pane ${o} torn off into a floating window.`);
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* Close a floating pane via the chrome's close button (or any external
|
|
2274
|
+
* caller). Announces the close to SR users, redraws the dock, and emits a
|
|
2275
|
+
* layout-changed event. Phase 4 of the WC ARIA PRD — the floating chrome
|
|
2276
|
+
* had no close affordance before this; users had to programmatically pop
|
|
2277
|
+
* the pane out of `floatingLayouts`.
|
|
2278
|
+
*/
|
|
2279
|
+
closeFloatingPane(t) {
|
|
2280
|
+
const e = this.floatingLayouts[t];
|
|
2281
|
+
if (!e) return;
|
|
2282
|
+
const i = this.getFloatingWindowTitle(e);
|
|
2283
|
+
this.removeFloatingAt(t), this.renderLayout(), this.dispatchLayoutChanged(), this.liveAnnouncer.announce(`Closed floating pane ${i}.`);
|
|
2284
|
+
}
|
|
2285
|
+
removePaneFromFloating(t, e, i, o = !1) {
|
|
2286
|
+
const n = this.floatingLayouts[t];
|
|
2287
|
+
if (!n || !n.root)
|
|
2288
|
+
return !1;
|
|
2289
|
+
const r = this.getNodeAtPath(n.root, e);
|
|
2290
|
+
if (!r || r.kind !== "stack")
|
|
2291
|
+
return !1;
|
|
2292
|
+
if (r.panes = r.panes.filter((c) => c !== i), r.panes.includes(r.activePane ?? "") || (r.panes.length > 0 ? r.activePane = r.panes[0] : delete r.activePane), n.activePane === i) {
|
|
2293
|
+
const c = this.findFirstPaneName(n.root);
|
|
2294
|
+
c ? n.activePane = c : delete n.activePane;
|
|
2295
|
+
}
|
|
2296
|
+
return r.panes.length > 0 ? !1 : (o || this.normalizeAllLayouts(), !0);
|
|
2297
|
+
}
|
|
2298
|
+
normalizeSizesArray(t, e) {
|
|
2299
|
+
if (e <= 0)
|
|
2300
|
+
return [];
|
|
2301
|
+
if (!Array.isArray(t) || t.length !== e)
|
|
2302
|
+
return Array.from({ length: e }, () => 1 / e);
|
|
2303
|
+
const i = t.map((n) => Number.isFinite(n) ? Math.max(n, 0) : 0), o = i.reduce((n, r) => n + r, 0);
|
|
2304
|
+
return o <= 0 ? Array.from({ length: e }, () => 1 / e) : i.map((n) => n / o);
|
|
2305
|
+
}
|
|
2306
|
+
normalizeSplitNode(t) {
|
|
2307
|
+
t.sizes = this.normalizeSizesArray(t.sizes, t.children.length);
|
|
2308
|
+
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Bottom-up layout sanitizer. Returns a normalized version of `node` where:
|
|
2311
|
+
* - Empty stacks (panes.length === 0) are dropped (returned as null).
|
|
2312
|
+
* - A stack's `activePane` is repaired if it no longer references one of `panes`.
|
|
2313
|
+
* - Splits whose direction matches a child split are flattened, with sizes
|
|
2314
|
+
* combined multiplicatively so the resulting on-screen pixel layout is
|
|
2315
|
+
* identical to the pre-merge one.
|
|
2316
|
+
* - Splits with 0 children become null. Splits with 1 child are unwrapped.
|
|
2317
|
+
*
|
|
2318
|
+
* Idempotent: passing the result back through this method yields the same
|
|
2319
|
+
* structure. Mutates the input tree in place but only returns nodes that
|
|
2320
|
+
* remain part of the layout.
|
|
2321
|
+
*/
|
|
2322
|
+
normalizeLayoutNode(t) {
|
|
2323
|
+
if (!t) return null;
|
|
2324
|
+
if (t.kind === "stack")
|
|
2325
|
+
return t.panes.length === 0 ? null : ((!t.activePane || !t.panes.includes(t.activePane)) && (t.activePane = t.panes[0]), t);
|
|
2326
|
+
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 }) => {
|
|
2327
|
+
if (o.kind === "split" && o.direction === t.direction) {
|
|
2328
|
+
const r = this.normalizeSizesArray(o.sizes, o.children.length);
|
|
2329
|
+
return o.children.map((c, l) => ({
|
|
2330
|
+
child: c,
|
|
2331
|
+
slot: n * r[l]
|
|
2332
|
+
}));
|
|
2333
|
+
}
|
|
2334
|
+
return [{ child: o, slot: n }];
|
|
2335
|
+
});
|
|
2336
|
+
return i.length === 0 ? null : i.length === 1 ? i[0].child : (t.children = i.map((o) => o.child), t.sizes = this.normalizeSizesArray(
|
|
2337
|
+
i.map((o) => o.slot),
|
|
2338
|
+
i.length
|
|
2339
|
+
), t);
|
|
2340
|
+
}
|
|
2341
|
+
/**
|
|
2342
|
+
* Apply `normalizeLayoutNode` to `rootLayout` and every floating window's
|
|
2343
|
+
* root, drop floating windows whose root collapses to null, and repair
|
|
2344
|
+
* stale `activePane` references on each floating window. Run this at the
|
|
2345
|
+
* end of every public mutation entry point (drop handlers, layout setter,
|
|
2346
|
+
* pane removal) so the tree the renderer sees is always in canonical form.
|
|
2347
|
+
*/
|
|
2348
|
+
normalizeAllLayouts() {
|
|
2349
|
+
this.rootLayout = this.normalizeLayoutNode(this.rootLayout), this.floatingLayouts = this.floatingLayouts.map((t) => {
|
|
2350
|
+
if (t.root = this.normalizeLayoutNode(t.root), !t.root) return null;
|
|
2351
|
+
const e = this.collectPaneNames(t.root);
|
|
2352
|
+
if (!t.activePane || !e.includes(t.activePane)) {
|
|
2353
|
+
const i = this.findFirstPaneName(t.root);
|
|
2354
|
+
i ? t.activePane = i : delete t.activePane;
|
|
2355
|
+
}
|
|
2356
|
+
return t;
|
|
2357
|
+
}).filter((t) => t !== null);
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Dev-mode integrity guard: walks every pane referenced by the current
|
|
2361
|
+
* layout and asserts that the rendered shadow DOM contains a matching
|
|
2362
|
+
* `<slot name="${pane}">`. A missing slot means the layout tree got into
|
|
2363
|
+
* a state the renderer can't display — typically a missed normalize() call
|
|
2364
|
+
* or a render bug. Opt in via the `debug-layout-integrity` attribute or
|
|
2365
|
+
* the `debugLayoutIntegrity` property; off by default.
|
|
2366
|
+
*/
|
|
2367
|
+
verifyProjectionSlots() {
|
|
2368
|
+
if (!this.debugLayoutIntegrity) return;
|
|
2369
|
+
const t = this.shadowRoot;
|
|
2370
|
+
if (!t) return;
|
|
2371
|
+
const e = new Set(
|
|
2372
|
+
Array.from(t.querySelectorAll("slot")).map((n) => n.getAttribute("name")).filter((n) => !!n)
|
|
2373
|
+
), o = [
|
|
2374
|
+
...this.collectPaneNames(this.rootLayout),
|
|
2375
|
+
...this.floatingLayouts.flatMap((n) => this.collectPaneNames(n.root))
|
|
2376
|
+
].find((n) => !e.has(n));
|
|
2377
|
+
if (o)
|
|
2378
|
+
throw new Error(
|
|
2379
|
+
`mint-dock-manager: pane "${o}" 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.`
|
|
2380
|
+
);
|
|
2381
|
+
}
|
|
2382
|
+
dispatchLayoutChanged() {
|
|
2383
|
+
this.dispatchEvent(
|
|
2384
|
+
new CustomEvent("dock-layout-changed", {
|
|
2385
|
+
detail: this.snapshot,
|
|
2386
|
+
bubbles: !0,
|
|
2387
|
+
composed: !0
|
|
2388
|
+
})
|
|
2389
|
+
);
|
|
2390
|
+
}
|
|
2391
|
+
cloneLayoutNode(t) {
|
|
2392
|
+
return t ? JSON.parse(JSON.stringify(t)) : null;
|
|
2393
|
+
}
|
|
2394
|
+
cloneFloatingArray(t) {
|
|
2395
|
+
return JSON.parse(JSON.stringify(t));
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
const w = "mint-dock-manager";
|
|
2399
|
+
typeof customElements < "u" && !customElements.get(w) && customElements.define(w, v);
|
|
2400
|
+
export {
|
|
2401
|
+
v as MintDockManagerElement
|
|
2402
|
+
};
|