bwin 0.3.4-dev.0 → 0.4.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/README.md +5 -2
- package/dist/bwin.css +1 -1
- package/dist/bwin.js +487 -181
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# Binary Window
|
|
2
2
|
|
|
3
|
+
[](https://github.com/bhjsdev/bwin/actions/workflows/publish.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/bwin)
|
|
5
|
+
|
|
3
6
|
A lightweight window-tiling JavaScript library for the browser, featuring resizable panes, drag-and-drop, and more.
|
|
4
7
|
|
|
5
|
-
[](https://bhjsdev.github.io/bwin-docs
|
|
8
|
+
[](https://bhjsdev.github.io/bwin-docs?theme=light)
|
|
6
9
|
|
|
7
|
-
[Documentation](https://bhjsdev.github.io/bwin-docs/
|
|
10
|
+
[Documentation](https://bhjsdev.github.io/bwin-docs/javascript/get-started)
|
|
8
11
|
|
|
9
12
|
## Development
|
|
10
13
|
|
package/dist/bwin.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
bw-window{--bw-font-family:system-ui;--bw-font-size:14px;--bw-drop-area-bg-color:#0000000d;--bw-glass-clearance:2px;--bw-glass-border-radius:2px;--bw-glass-border-color:#1a1a1a;--bw-glass-border-color-disabled:#ccc;--bw-glass-bg-color-disabled:#f7f7f7;--bw-glass-header-height:30px;--bw-glass-header-gap:4px;--bw-glass-header-bg-color:#f7f7f7;--bw-sill-gap:6px}bw-window[theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bw-glass-border-color:#666;--bw-glass-border-color-disabled:#4d4d4d;--bw-glass-header-bg-color:#2e2e2e;--bw-glass-bg-color-disabled:#292929;--bw-drop-area-bg-color:#ffffff1a}bw-window[theme=dark] bw-pane,bw-window[theme=dark] bw-muntin{background-color:#242424}bw-window[theme=dark] bw-glass{color:#e6e6e6;background-color:#292929}bw-window[theme=dark] .bw-glass-tab:hover,bw-window[theme=dark] .bw-glass-action:hover,bw-window[theme=dark] .bw-minimized-glass:hover{background-color:#424242}.body--bw-resize-x{-webkit-user-select:none;user-select:none;cursor:ew-resize}.body--bw-resize-y{-webkit-user-select:none;user-select:none;cursor:ns-resize}bw-window{box-sizing:border-box;display:block;position:absolute}bw-window:has(>bw-pane[maximized])>:is(bw-pane,bw-muntin):not([maximized]){display:none}bw-pane{box-sizing:border-box;background-color:#f2f2f2;position:absolute;overflow:auto}bw-pane[drop-area]:before{content:"";background-color:var(--bw-drop-area-bg-color);position:absolute}bw-pane[drop-area=top]:before{height:50%;top:0;left:0;right:0}bw-pane[drop-area=right]:before{width:50%;top:0;bottom:0;right:0}bw-pane[drop-area=bottom]:before{height:50%;bottom:0;left:0;right:0}bw-pane[drop-area=left]:before{width:50%;top:0;bottom:0;left:0}bw-pane[drop-area=center]:before{inset:0}bw-muntin{box-sizing:border-box;background-color:#fff;position:absolute}bw-muntin[horizontal]{cursor:ns-resize}bw-muntin[vertical]{cursor:ew-resize}bw-muntin[resizable=false]{cursor:auto}bw-window:has(bw-glass) bw-pane{background-color:#0000}bw-window:has(bw-glass) bw-pane[drop-area]:before{z-index:1}bw-window:has(bw-glass) bw-pane[drop-area=top]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=right]:before{top:var(--bw-glass-clearance);right:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=bottom]:before{bottom:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=left]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=center]:before{inset:var(--bw-glass-clearance)}bw-window:has(bw-glass) bw-muntin{background-color:#0000}bw-glass{inset:var(--bw-glass-clearance);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);font-family:var(--bw-font-family);font-size:var(--bw-font-size);box-sizing:border-box;background-color:#fff;flex-direction:column;display:flex;position:absolute}bw-glass[draggable=true]:active{cursor:move;opacity:.4}bw-glass-header{box-sizing:border-box;flex-basis:var(--bw-glass-header-height);align-items:center;gap:var(--bw-glass-header-gap);padding-inline:var(--bw-glass-header-gap);border-bottom:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);background-color:var(--bw-glass-header-bg-color);flex-shrink:0;display:flex;overflow:hidden}bw-glass-title{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}bw-glass-tab-container{align-self:flex-end;gap:var(--bw-glass-header-gap);display:flex}.bw-glass-tab{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);cursor:pointer;border-bottom:none}.bw-glass-tab:hover{background-color:#fff}.bw-glass-tab:active{transform:translateY(1px)}bw-glass-action-container{flex-shrink:0;gap:2px;margin-left:auto;display:flex}.bw-glass-action{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer}.bw-glass-action:hover{background-color:#fff}.bw-glass-action:active{transform:scale(.95)}.bw-glass-action:disabled{border:1px solid var(--bw-glass-border-color-disabled);background-color:var(--bw-glass-bg-color-disabled);cursor:not-allowed}.bw-glass-action:disabled:hover{background-color:var(--bw-glass-bg-color-disabled)}.bw-glass-action:disabled:active{transform:scale(1)}.bw-glass-action--
|
|
1
|
+
bw-window{--bw-font-family:system-ui;--bw-font-size:14px;--bw-drop-area-bg-color:#0000000d;--bw-glass-clearance:2px;--bw-glass-border-radius:2px;--bw-glass-border-color:#1a1a1a;--bw-glass-border-color-disabled:#ccc;--bw-glass-bg-color-disabled:#f7f7f7;--bw-glass-header-height:30px;--bw-glass-header-gap:4px;--bw-glass-header-bg-color:#f7f7f7;--bw-minimized-glass-highlight-color:#d9d9d9;--bw-detached-glass-shadow:0 2px 6px #0000001f, 0 4px 14px #00000038;--bw-detached-glass-shadow-active:0 4px 10px #00000038, 0 10px 30px #00000061;--bw-detached-glass-resize-handle-size:12px;--bw-sill-gap:6px}bw-window[theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bw-glass-border-color:#666;--bw-glass-border-color-disabled:#4d4d4d;--bw-glass-header-bg-color:#2e2e2e;--bw-glass-bg-color-disabled:#292929;--bw-drop-area-bg-color:#ffffff1a;--bw-detached-glass-shadow:0 2px 6px #0000008c, 0 4px 14px #000000a6;--bw-detached-glass-shadow-active:0 4px 10px #000000a6, 0 10px 30px #000c;--bw-minimized-glass-highlight-color:#a6a6a6cc}bw-window[theme=dark] bw-pane,bw-window[theme=dark] bw-muntin{background-color:#242424}bw-window[theme=dark] bw-glass{color:#e6e6e6;background-color:#292929}bw-window[theme=dark] .bw-glass-tab:hover,bw-window[theme=dark] .bw-glass-action:hover,bw-window[theme=dark] .bw-minimized-glass:hover{background-color:#424242}.body--bw-resize-x{-webkit-user-select:none;user-select:none;cursor:ew-resize}.body--bw-resize-y{-webkit-user-select:none;user-select:none;cursor:ns-resize}bw-window{box-sizing:border-box;display:block;position:absolute}bw-window:has(>bw-pane[maximized])>:is(bw-pane,bw-muntin):not([maximized]){display:none}bw-pane{isolation:isolate;box-sizing:border-box;background-color:#f2f2f2;position:absolute;overflow:auto}bw-pane[drop-area]:before{content:"";background-color:var(--bw-drop-area-bg-color);position:absolute}bw-pane[drop-area=top]:before{height:50%;top:0;left:0;right:0}bw-pane[drop-area=right]:before{width:50%;top:0;bottom:0;right:0}bw-pane[drop-area=bottom]:before{height:50%;bottom:0;left:0;right:0}bw-pane[drop-area=left]:before{width:50%;top:0;bottom:0;left:0}bw-pane[drop-area=center]:before{inset:0}bw-muntin{box-sizing:border-box;background-color:#fff;position:absolute}bw-muntin[horizontal]{cursor:ns-resize}bw-muntin[vertical]{cursor:ew-resize}bw-muntin[resizable=false]{cursor:auto}bw-window:has(bw-glass) bw-pane{background-color:#0000}bw-window:has(bw-glass) bw-pane[drop-area]:before{z-index:1}bw-window:has(bw-glass) bw-pane[drop-area=top]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=right]:before{top:var(--bw-glass-clearance);right:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=bottom]:before{bottom:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=left]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=center]:before{inset:var(--bw-glass-clearance)}bw-window:has(bw-glass) bw-muntin{background-color:#0000}bw-glass{inset:var(--bw-glass-clearance);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);font-family:var(--bw-font-family);font-size:var(--bw-font-size);box-sizing:border-box;background-color:#fff;flex-direction:column;display:flex;position:absolute}bw-glass[draggable=true]:active{cursor:move;opacity:.4}bw-glass-header{box-sizing:border-box;flex-basis:var(--bw-glass-header-height);-webkit-user-select:none;user-select:none;align-items:center;gap:var(--bw-glass-header-gap);padding-inline:var(--bw-glass-header-gap);border-bottom:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);background-color:var(--bw-glass-header-bg-color);flex-shrink:0;display:flex;overflow:hidden}bw-glass-title{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}bw-glass-tab-container{align-self:flex-end;gap:var(--bw-glass-header-gap);display:flex}.bw-glass-tab{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);cursor:pointer;border-bottom:none}.bw-glass-tab:hover{background-color:#fff}.bw-glass-tab:active{transform:translateY(1px)}bw-glass-action-container{flex-shrink:0;gap:2px;margin-left:auto;display:flex}.bw-glass-action{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer}.bw-glass-action:hover{background-color:#fff}.bw-glass-action:active{transform:scale(.95)}.bw-glass-action:disabled{border:1px solid var(--bw-glass-border-color-disabled);background-color:var(--bw-glass-bg-color-disabled);cursor:not-allowed}.bw-glass-action:disabled:hover{background-color:var(--bw-glass-bg-color-disabled)}.bw-glass-action:disabled:active{transform:scale(1)}.bw-glass-action--minimize:before{content:"−"}.bw-glass-action--detach:before{content:"☐"}.bw-glass-action--attach:before{content:"◱"}.bw-glass-action--maximize:before{content:"🡥"}bw-pane[maximized] .bw-glass-action--maximize:before{content:"🡧"}.bw-glass-action--close:before{content:"✕"}bw-glass-content{box-sizing:border-box;flex-grow:1;display:block;overflow:auto}bw-glass[detached]{box-shadow:var(--bw-detached-glass-shadow)}bw-glass[detached][active]{box-shadow:var(--bw-detached-glass-shadow-active)}bw-glass[detached]>bw-glass-header[can-drag=true]:active{cursor:move}bw-glass-resize-handle{z-index:2;touch-action:none;position:absolute}bw-glass-resize-handle[resize-dir=n]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);height:var(--bw-detached-glass-resize-handle-size);cursor:ns-resize;left:0;right:0}bw-glass-resize-handle[resize-dir=s]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);height:var(--bw-detached-glass-resize-handle-size);cursor:ns-resize;left:0;right:0}bw-glass-resize-handle[resize-dir=e]{top:0;bottom:0;right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);cursor:ew-resize}bw-glass-resize-handle[resize-dir=w]{top:0;bottom:0;left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);cursor:ew-resize}bw-glass-resize-handle[resize-dir=ne]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nesw-resize}bw-glass-resize-handle[resize-dir=nw]{top:calc(var(--bw-detached-glass-resize-handle-size) / -2);left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nwse-resize}bw-glass-resize-handle[resize-dir=se]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);right:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nwse-resize}bw-glass-resize-handle[resize-dir=sw]{bottom:calc(var(--bw-detached-glass-resize-handle-size) / -2);left:calc(var(--bw-detached-glass-resize-handle-size) / -2);width:var(--bw-detached-glass-resize-handle-size);height:var(--bw-detached-glass-resize-handle-size);cursor:nesw-resize}bw-sill{margin-top:calc(var(--bw-sill-gap) - var(--bw-glass-clearance));gap:var(--bw-sill-gap);box-sizing:border-box;width:100%;padding-inline:var(--bw-glass-clearance);display:flex;position:absolute;top:100%}.bw-minimized-glass,.bw-minimized-detached-glass{border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer;background-color:var(--bw-glass-header-bg-color);flex-basis:10%;height:10px;display:block}:is(.bw-minimized-glass,.bw-minimized-detached-glass):hover{background-color:#fff}:is(.bw-minimized-glass,.bw-minimized-detached-glass):active{transform:scale(.95)}.bw-minimized-glass,.bw-minimized-detached-glass{animation:2s ease-out bw-minimized-glass-highlight}@keyframes bw-minimized-glass-highlight{0%{background-color:var(--bw-glass-header-bg-color)}30%{background-color:var(--bw-minimized-glass-highlight-color)}to{background-color:var(--bw-glass-header-bg-color)}}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/bwin.js
CHANGED
|
@@ -69,6 +69,10 @@ function c(e) {
|
|
|
69
69
|
return e instanceof Node ? e : document.createTextNode(String(e));
|
|
70
70
|
}
|
|
71
71
|
function l(e) {
|
|
72
|
+
let t = document.createDocumentFragment();
|
|
73
|
+
return t.append(...e.childNodes), t;
|
|
74
|
+
}
|
|
75
|
+
function u(e) {
|
|
72
76
|
return {
|
|
73
77
|
left: parseFloat(e.style.left) || 0,
|
|
74
78
|
top: parseFloat(e.style.top) || 0,
|
|
@@ -78,7 +82,7 @@ function l(e) {
|
|
|
78
82
|
}
|
|
79
83
|
//#endregion
|
|
80
84
|
//#region src/position.js
|
|
81
|
-
var
|
|
85
|
+
var d = {
|
|
82
86
|
Top: "top",
|
|
83
87
|
Right: "right",
|
|
84
88
|
Bottom: "bottom",
|
|
@@ -88,22 +92,22 @@ var u = {
|
|
|
88
92
|
Unknown: "unknown",
|
|
89
93
|
Outside: "outside"
|
|
90
94
|
};
|
|
91
|
-
function
|
|
95
|
+
function f(e) {
|
|
92
96
|
switch (e) {
|
|
93
|
-
case
|
|
94
|
-
case
|
|
95
|
-
case
|
|
96
|
-
case
|
|
97
|
+
case d.Top: return d.Bottom;
|
|
98
|
+
case d.Right: return d.Left;
|
|
99
|
+
case d.Bottom: return d.Top;
|
|
100
|
+
case d.Left: return d.Right;
|
|
97
101
|
default: throw Error(`[bwin] Invalid position: ${e}`);
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
|
-
function
|
|
104
|
+
function p({ width: e, height: t, x: n }) {
|
|
101
105
|
return t / e * n;
|
|
102
106
|
}
|
|
103
|
-
function
|
|
107
|
+
function m({ width: e, height: t, y: n }) {
|
|
104
108
|
return e / t * n;
|
|
105
109
|
}
|
|
106
|
-
function
|
|
110
|
+
function ee({ width: e, height: t, x: n }) {
|
|
107
111
|
return t - t / e * n;
|
|
108
112
|
}
|
|
109
113
|
function h({ width: e, height: t, y: n }) {
|
|
@@ -111,25 +115,25 @@ function h({ width: e, height: t, y: n }) {
|
|
|
111
115
|
}
|
|
112
116
|
function g(e, { clientX: t, clientY: n }) {
|
|
113
117
|
let r = e.getBoundingClientRect(), { width: i, height: a } = r, o = t - r.left, s = n - r.top;
|
|
114
|
-
if (o < 0 || o > i || s < 0 || s > a) return
|
|
115
|
-
let c = .3, l =
|
|
118
|
+
if (o < 0 || o > i || s < 0 || s > a) return d.Outside;
|
|
119
|
+
let c = .3, l = p({
|
|
116
120
|
width: i,
|
|
117
121
|
height: a,
|
|
118
122
|
x: o
|
|
119
|
-
}),
|
|
123
|
+
}), u = ee({
|
|
120
124
|
width: i,
|
|
121
125
|
height: a,
|
|
122
126
|
x: o
|
|
123
|
-
}),
|
|
127
|
+
}), f = m({
|
|
124
128
|
width: i,
|
|
125
129
|
height: a,
|
|
126
130
|
y: s
|
|
127
|
-
}),
|
|
131
|
+
}), g = h({
|
|
128
132
|
width: i,
|
|
129
133
|
height: a,
|
|
130
134
|
y: s
|
|
131
135
|
});
|
|
132
|
-
return o < i * (.5 - c / 2) && s > l && s <
|
|
136
|
+
return o < i * (.5 - c / 2) && s > l && s < u ? d.Left : o > i * .65 && s < l && s > u ? d.Right : s < a * (.5 - c / 2) && o > f && o < g ? d.Top : s > a * .65 && o < f && o > g ? d.Bottom : o > i * (.5 - c / 2) && o < i * .65 && s > a * (.5 - c / 2) && s < a * .65 ? d.Center : d.Unknown;
|
|
133
137
|
}
|
|
134
138
|
var _ = {
|
|
135
139
|
left: 0,
|
|
@@ -154,26 +158,26 @@ var _ = {
|
|
|
154
158
|
return this.children.length > 0;
|
|
155
159
|
}
|
|
156
160
|
isLeftRightSplit() {
|
|
157
|
-
return this.children.some((e) => e.position ===
|
|
161
|
+
return this.children.some((e) => e.position === d.Left || e.position === d.Right);
|
|
158
162
|
}
|
|
159
163
|
isTopBottomSplit() {
|
|
160
|
-
return this.children.some((e) => e.position ===
|
|
164
|
+
return this.children.some((e) => e.position === d.Top || e.position === d.Bottom);
|
|
161
165
|
}
|
|
162
166
|
get leftChild() {
|
|
163
|
-
return this.children.find((e) => e.position ===
|
|
167
|
+
return this.children.find((e) => e.position === d.Left);
|
|
164
168
|
}
|
|
165
169
|
get rightChild() {
|
|
166
|
-
return this.children.find((e) => e.position ===
|
|
170
|
+
return this.children.find((e) => e.position === d.Right);
|
|
167
171
|
}
|
|
168
172
|
get topChild() {
|
|
169
|
-
return this.children.find((e) => e.position ===
|
|
173
|
+
return this.children.find((e) => e.position === d.Top);
|
|
170
174
|
}
|
|
171
175
|
get bottomChild() {
|
|
172
|
-
return this.children.find((e) => e.position ===
|
|
176
|
+
return this.children.find((e) => e.position === d.Bottom);
|
|
173
177
|
}
|
|
174
178
|
getChildren() {
|
|
175
179
|
let e = null, t = null, n = null, r = null;
|
|
176
|
-
for (let i of this.children) i.position ===
|
|
180
|
+
for (let i of this.children) i.position === d.Left ? e = i : i.position === d.Right ? t = i : i.position === d.Top ? n = i : i.position === d.Bottom && (r = i);
|
|
177
181
|
return [
|
|
178
182
|
n,
|
|
179
183
|
t,
|
|
@@ -232,7 +236,7 @@ var _ = {
|
|
|
232
236
|
}
|
|
233
237
|
addChild(e) {
|
|
234
238
|
if (this.children.length >= 2) throw Error("[bwin] Maximum 2 children allowed");
|
|
235
|
-
this.children.push(e);
|
|
239
|
+
e.parent = this, this.children.push(e);
|
|
236
240
|
}
|
|
237
241
|
getDescendantParentById(e) {
|
|
238
242
|
for (let t of this.children) {
|
|
@@ -245,6 +249,12 @@ var _ = {
|
|
|
245
249
|
getChildSiblingById(e) {
|
|
246
250
|
return this.children.find((t) => t.id !== e);
|
|
247
251
|
}
|
|
252
|
+
getLargestLeaf() {
|
|
253
|
+
return this.getAllLeafDescendants().reduce((e, t) => t.width * t.height > e.width * e.height ? t : e);
|
|
254
|
+
}
|
|
255
|
+
getRelativeSize() {
|
|
256
|
+
return this.parent ? this.position === d.Left || this.position === d.Right ? this.width / this.parent.width : this.height / this.parent.height : 1;
|
|
257
|
+
}
|
|
248
258
|
get top() {
|
|
249
259
|
return this._top;
|
|
250
260
|
}
|
|
@@ -272,7 +282,7 @@ var _ = {
|
|
|
272
282
|
let [n, r, i, a] = this.getChildren();
|
|
273
283
|
if (a && r) {
|
|
274
284
|
let e = a.width + r.width, n = t * (a.width / e), i = e + t, o, s, c;
|
|
275
|
-
if (this.resizeStrategy === "natural" && this.position ===
|
|
285
|
+
if (this.resizeStrategy === "natural" && this.position === d.Left ? (o = a.width, s = r.width + t, c = r.left) : this.resizeStrategy === "natural" && this.position === d.Right ? (o = a.width + t, s = r.width, c = a.left + o) : (o = a.width + n, s = i - o, c = r.left + n), t < 0) {
|
|
276
286
|
let e = a.calcMinWidth(), t = r.calcMinWidth();
|
|
277
287
|
o < e && s > t ? (o = a.width, s = i - o, c = a.left + o) : s < t && o > e && (s = r.width, o = i - s, c = a.left + o);
|
|
278
288
|
}
|
|
@@ -289,7 +299,7 @@ var _ = {
|
|
|
289
299
|
let [n, r, i, a] = this.getChildren();
|
|
290
300
|
if (n && i) {
|
|
291
301
|
let e = n.height + i.height, r = t * (n.height / e), a = e + t, o, s, c;
|
|
292
|
-
if (this.resizeStrategy === "natural" && this.position ===
|
|
302
|
+
if (this.resizeStrategy === "natural" && this.position === d.Top ? (o = n.height, s = i.height + t, c = i.top) : this.resizeStrategy === "natural" && this.position === d.Bottom ? (o = n.height + t, s = i.height, c = n.top + o) : (o = n.height + r, s = a - o, c = i.top + r), t < 0) {
|
|
293
303
|
let e = n.calcMinHeight(), t = i.calcMinHeight();
|
|
294
304
|
o < e && s > t ? (o = n.height, s = a - o, c = n.top + o) : s < t && o > e && (s = i.height, o = a - s, c = n.top + o);
|
|
295
305
|
}
|
|
@@ -299,8 +309,8 @@ var _ = {
|
|
|
299
309
|
}
|
|
300
310
|
}, y = {
|
|
301
311
|
size: "50%",
|
|
302
|
-
position:
|
|
303
|
-
},
|
|
312
|
+
position: d.Left
|
|
313
|
+
}, te = class e {
|
|
304
314
|
left;
|
|
305
315
|
top;
|
|
306
316
|
width;
|
|
@@ -310,7 +320,7 @@ var _ = {
|
|
|
310
320
|
}
|
|
311
321
|
getPosition(e) {
|
|
312
322
|
if (!this.siblingConfigNode) return e;
|
|
313
|
-
let t =
|
|
323
|
+
let t = f(this.siblingConfigNode.position);
|
|
314
324
|
if (!e) return t;
|
|
315
325
|
if (e !== t) throw Error("[bwin] Sibling position and current position are not opposite");
|
|
316
326
|
return e;
|
|
@@ -319,30 +329,30 @@ var _ = {
|
|
|
319
329
|
if (!this.siblingConfigNode) return i(e);
|
|
320
330
|
if (!e) {
|
|
321
331
|
if (this.siblingConfigNode.size < 1) return 1 - this.siblingConfigNode.size;
|
|
322
|
-
if (this.siblingConfigNode.position ===
|
|
323
|
-
if (this.siblingConfigNode.position ===
|
|
332
|
+
if (this.siblingConfigNode.position === d.Left || this.siblingConfigNode.position === d.Right) return this.parentRect.width - this.siblingConfigNode.width;
|
|
333
|
+
if (this.siblingConfigNode.position === d.Top || this.siblingConfigNode.position === d.Bottom) return this.parentRect.height - this.siblingConfigNode.height;
|
|
324
334
|
}
|
|
325
335
|
let t = i(e);
|
|
326
336
|
if (t < 1) {
|
|
327
337
|
if (t + this.siblingConfigNode.size !== 1) throw Error("[bwin] Sum of sibling sizes is not equal to 1");
|
|
328
338
|
} else {
|
|
329
|
-
if ((this.position ===
|
|
330
|
-
if ((this.position ===
|
|
339
|
+
if ((this.position === d.Left || this.position === d.Right) && t + this.siblingConfigNode.size !== this.parentRect.width) throw Error("[bwin] Sum of sibling sizes is not equal to parent width");
|
|
340
|
+
if ((this.position === d.Top || this.position === d.Bottom) && t + this.siblingConfigNode.size !== this.parentRect.height) throw Error("[bwin] Sum of sibling sizes is not equal to parent height");
|
|
331
341
|
}
|
|
332
342
|
return t;
|
|
333
343
|
}
|
|
334
344
|
setBounds() {
|
|
335
|
-
if (this.position ===
|
|
336
|
-
else if (this.position ===
|
|
345
|
+
if (this.position === d.Root) this.left = 0, this.top = 0, this.width = this.parentRect.width, this.height = this.parentRect.height;
|
|
346
|
+
else if (this.position === d.Left) {
|
|
337
347
|
let e = this.size < 1 ? this.parentRect.width * this.size : this.size;
|
|
338
348
|
this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = e, this.height = this.parentRect.height;
|
|
339
|
-
} else if (this.position ===
|
|
349
|
+
} else if (this.position === d.Right) {
|
|
340
350
|
let e = this.size < 1 ? this.parentRect.width * this.size : this.size;
|
|
341
351
|
this.left = this.parentRect.left + this.parentRect.width - e, this.top = this.parentRect.top, this.width = e, this.height = this.parentRect.height;
|
|
342
|
-
} else if (this.position ===
|
|
352
|
+
} else if (this.position === d.Top) {
|
|
343
353
|
let e = this.size < 1 ? this.parentRect.height * this.size : this.size;
|
|
344
354
|
this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = this.parentRect.width, this.height = e;
|
|
345
|
-
} else if (this.position ===
|
|
355
|
+
} else if (this.position === d.Bottom) {
|
|
346
356
|
let e = this.size < 1 ? this.parentRect.height * this.size : this.size;
|
|
347
357
|
this.left = this.parentRect.left, this.top = this.parentRect.top + this.parentRect.height - e, this.width = this.parentRect.width, this.height = e;
|
|
348
358
|
}
|
|
@@ -400,28 +410,28 @@ var _ = {
|
|
|
400
410
|
let t = this.createSash({ resizeStrategy: e });
|
|
401
411
|
if (!Array.isArray(this.children) || this.children.length === 0) return t;
|
|
402
412
|
let n = this.normConfig(this.children[0]), r = this.normConfig(this.children.at(1)), i, a;
|
|
403
|
-
if (!n.size && !n.position && r ? (r.position ||=
|
|
413
|
+
if (!n.size && !n.position && r ? (r.position ||= d.Right, i = this.createPrimaryConfigNode(r), a = this.createSecondaryConfigNode(n, i)) : (i = this.createPrimaryConfigNode(n), a = this.createSecondaryConfigNode(r, i)), i && a) {
|
|
404
414
|
let n = i.buildSashTree({ resizeStrategy: e }), r = a.buildSashTree({ resizeStrategy: e });
|
|
405
415
|
n.parent = t, r.parent = t, t.children.push(n), t.children.push(r);
|
|
406
416
|
}
|
|
407
417
|
return t;
|
|
408
418
|
}
|
|
409
|
-
},
|
|
419
|
+
}, b = {
|
|
410
420
|
width: 333,
|
|
411
421
|
height: 333
|
|
412
|
-
},
|
|
422
|
+
}, x = {
|
|
413
423
|
fitContainer: !1,
|
|
414
424
|
theme: ""
|
|
415
|
-
},
|
|
416
|
-
constructor({ id: e, children: t, width: n =
|
|
417
|
-
...
|
|
418
|
-
...
|
|
425
|
+
}, S = class extends te {
|
|
426
|
+
constructor({ id: e, children: t, width: n = b.width, height: r = b.height, fitContainer: i = x.fitContainer, theme: a = x.theme, ...o } = {
|
|
427
|
+
...b,
|
|
428
|
+
...x
|
|
419
429
|
}) {
|
|
420
430
|
super({
|
|
421
431
|
id: e,
|
|
422
432
|
children: t,
|
|
423
433
|
size: NaN,
|
|
424
|
-
position:
|
|
434
|
+
position: d.Root,
|
|
425
435
|
parentRect: {
|
|
426
436
|
width: n,
|
|
427
437
|
height: r
|
|
@@ -429,25 +439,25 @@ var _ = {
|
|
|
429
439
|
...o
|
|
430
440
|
}), this.fitContainer = i, this.theme = a;
|
|
431
441
|
}
|
|
432
|
-
},
|
|
442
|
+
}, C = class extends v {
|
|
433
443
|
constructor(e = _) {
|
|
434
444
|
super({
|
|
435
445
|
...e,
|
|
436
|
-
position:
|
|
437
|
-
}), Object.assign(this,
|
|
446
|
+
position: d.Root
|
|
447
|
+
}), Object.assign(this, x);
|
|
438
448
|
}
|
|
439
449
|
};
|
|
440
450
|
//#endregion
|
|
441
451
|
//#region src/frame/pane-utils.js
|
|
442
|
-
function
|
|
452
|
+
function ne(e) {
|
|
443
453
|
let t = document.createElement("bw-pane");
|
|
444
454
|
return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("sash-id", e.id), t.setAttribute("position", e.position), t;
|
|
445
455
|
}
|
|
446
|
-
function
|
|
456
|
+
function w(e) {
|
|
447
457
|
let t = e.domNode;
|
|
448
458
|
return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("position", e.position), t;
|
|
449
459
|
}
|
|
450
|
-
function
|
|
460
|
+
function T(e, { size: n, id: r }) {
|
|
451
461
|
let a = i(n), o = e.width / 2;
|
|
452
462
|
a && (o = a < 1 ? e.width * a : a);
|
|
453
463
|
let s = new v({
|
|
@@ -456,19 +466,19 @@ function D(e, { size: n, id: r }) {
|
|
|
456
466
|
left: e.left,
|
|
457
467
|
width: o,
|
|
458
468
|
height: e.height,
|
|
459
|
-
position:
|
|
469
|
+
position: d.Left
|
|
460
470
|
}), c = new v({
|
|
461
471
|
id: e.id,
|
|
462
472
|
top: e.top,
|
|
463
473
|
left: e.left + s.width,
|
|
464
474
|
width: e.width - o,
|
|
465
475
|
height: e.height,
|
|
466
|
-
position:
|
|
476
|
+
position: d.Right,
|
|
467
477
|
domNode: e.domNode
|
|
468
478
|
});
|
|
469
479
|
return e.addChild(s), e.addChild(c), e.domNode = null, e.id = t(), s;
|
|
470
480
|
}
|
|
471
|
-
function
|
|
481
|
+
function E(e, { size: n, id: r }) {
|
|
472
482
|
let a = i(n), o = e.width / 2;
|
|
473
483
|
a && (o = a < 1 ? e.width * a : a);
|
|
474
484
|
let s = new v({
|
|
@@ -477,7 +487,7 @@ function O(e, { size: n, id: r }) {
|
|
|
477
487
|
top: e.top,
|
|
478
488
|
width: e.width - o,
|
|
479
489
|
height: e.height,
|
|
480
|
-
position:
|
|
490
|
+
position: d.Left,
|
|
481
491
|
domNode: e.domNode
|
|
482
492
|
}), c = new v({
|
|
483
493
|
id: r,
|
|
@@ -485,11 +495,11 @@ function O(e, { size: n, id: r }) {
|
|
|
485
495
|
top: e.top,
|
|
486
496
|
width: o,
|
|
487
497
|
height: e.height,
|
|
488
|
-
position:
|
|
498
|
+
position: d.Right
|
|
489
499
|
});
|
|
490
500
|
return e.addChild(s), e.addChild(c), e.domNode = null, e.id = t(), c;
|
|
491
501
|
}
|
|
492
|
-
function
|
|
502
|
+
function D(e, { size: n, id: r }) {
|
|
493
503
|
let a = i(n), o = e.height / 2;
|
|
494
504
|
a && (o = a < 1 ? e.height * a : a);
|
|
495
505
|
let s = new v({
|
|
@@ -498,19 +508,19 @@ function k(e, { size: n, id: r }) {
|
|
|
498
508
|
top: e.top,
|
|
499
509
|
width: e.width,
|
|
500
510
|
height: o,
|
|
501
|
-
position:
|
|
511
|
+
position: d.Top
|
|
502
512
|
}), c = new v({
|
|
503
513
|
id: e.id,
|
|
504
514
|
left: e.left,
|
|
505
515
|
top: e.top + s.height,
|
|
506
516
|
width: e.width,
|
|
507
517
|
height: e.height - o,
|
|
508
|
-
position:
|
|
518
|
+
position: d.Bottom,
|
|
509
519
|
domNode: e.domNode
|
|
510
520
|
});
|
|
511
521
|
return e.addChild(s), e.addChild(c), e.domNode = null, e.id = t(), s;
|
|
512
522
|
}
|
|
513
|
-
function
|
|
523
|
+
function O(e, { size: n, id: r }) {
|
|
514
524
|
let a = i(n), o = e.height / 2;
|
|
515
525
|
a && (o = a < 1 ? e.height * a : a);
|
|
516
526
|
let s = new v({
|
|
@@ -519,7 +529,7 @@ function A(e, { size: n, id: r }) {
|
|
|
519
529
|
left: e.left,
|
|
520
530
|
width: e.width,
|
|
521
531
|
height: e.height - o,
|
|
522
|
-
position:
|
|
532
|
+
position: d.Top,
|
|
523
533
|
domNode: e.domNode
|
|
524
534
|
}), c = new v({
|
|
525
535
|
id: r,
|
|
@@ -527,31 +537,31 @@ function A(e, { size: n, id: r }) {
|
|
|
527
537
|
left: e.left,
|
|
528
538
|
width: e.width,
|
|
529
539
|
height: o,
|
|
530
|
-
position:
|
|
540
|
+
position: d.Bottom
|
|
531
541
|
});
|
|
532
542
|
return e.addChild(s), e.addChild(c), e.domNode = null, e.id = t(), c;
|
|
533
543
|
}
|
|
534
|
-
function
|
|
535
|
-
if (t ===
|
|
544
|
+
function k(e, { position: t, size: n, id: r, minWidth: i, minHeight: a }) {
|
|
545
|
+
if (t === d.Left) return T(e, {
|
|
536
546
|
size: n,
|
|
537
547
|
id: r
|
|
538
548
|
});
|
|
539
|
-
if (t ===
|
|
549
|
+
if (t === d.Right) return E(e, {
|
|
540
550
|
size: n,
|
|
541
551
|
id: r
|
|
542
552
|
});
|
|
543
|
-
if (t ===
|
|
553
|
+
if (t === d.Top) return D(e, {
|
|
544
554
|
size: n,
|
|
545
555
|
id: r
|
|
546
556
|
});
|
|
547
|
-
if (t ===
|
|
557
|
+
if (t === d.Bottom) return O(e, {
|
|
548
558
|
size: n,
|
|
549
559
|
id: r
|
|
550
560
|
});
|
|
551
561
|
}
|
|
552
562
|
//#endregion
|
|
553
563
|
//#region src/frame/frame-utils.js
|
|
554
|
-
function
|
|
564
|
+
function A(e) {
|
|
555
565
|
if (e.tagName === "BW-PANE") return e.getAttribute("sash-id");
|
|
556
566
|
let t = e.closest("bw-pane");
|
|
557
567
|
if (!t) throw Error("[bwin] Pane element not found");
|
|
@@ -559,25 +569,25 @@ function M(e) {
|
|
|
559
569
|
}
|
|
560
570
|
//#endregion
|
|
561
571
|
//#region src/frame/pane.js
|
|
562
|
-
var
|
|
572
|
+
var re = {
|
|
563
573
|
createPane(e) {
|
|
564
|
-
let t =
|
|
574
|
+
let t = ne(e);
|
|
565
575
|
return e.store.droppable === !1 && t.setAttribute("can-drop", "false"), t;
|
|
566
576
|
},
|
|
567
577
|
onPaneCreate(t, n) {
|
|
568
|
-
n.store.content && t.append(c(n.store.content)), this?.debug && (t.style.backgroundColor = e(), t.innerHTML = "", t.append(
|
|
578
|
+
n.store.content && t.append(c(n.store.content)), this?.debug && (t.style.backgroundColor = e(), t.innerHTML = "", t.append(j(t)));
|
|
569
579
|
},
|
|
570
580
|
updatePane(e) {
|
|
571
|
-
return
|
|
581
|
+
return w(e);
|
|
572
582
|
},
|
|
573
583
|
onPaneUpdate(e, t) {
|
|
574
|
-
this?.debug && (e.innerHTML = "", e.append(
|
|
584
|
+
this?.debug && (e.innerHTML = "", e.append(j(e)));
|
|
575
585
|
},
|
|
576
586
|
addPane(e, { position: t, size: n, id: r }) {
|
|
577
587
|
if (!t) throw Error("[bwin] Position is required when adding pane");
|
|
578
588
|
let i = this.rootSash.getById(e);
|
|
579
589
|
if (!i) throw Error("[bwin] Parent sash not found when adding pane");
|
|
580
|
-
let a =
|
|
590
|
+
let a = k(i, {
|
|
581
591
|
position: t,
|
|
582
592
|
size: n,
|
|
583
593
|
id: r
|
|
@@ -588,14 +598,14 @@ var N = {
|
|
|
588
598
|
let n = this.rootSash.getDescendantParentById(e);
|
|
589
599
|
if (!n) throw Error("[bwin] Parent sash not found when removing pane");
|
|
590
600
|
let r = n.getChildSiblingById(e);
|
|
591
|
-
r.children.length === 0 ? (n.id = r.id, n.domNode = r.domNode, n.domNode.setAttribute("sash-id", r.id), n.children = []) : (n.id = t(), n.children = r.children, r.position ===
|
|
601
|
+
r.children.length === 0 ? (n.id = r.id, n.domNode = r.domNode, n.domNode.setAttribute("sash-id", r.id), n.children = []) : (n.id = t(), n.children = r.children, n.children.forEach((e) => e.parent = n), r.position === d.Left ? r.width = n.width : r.position === d.Right ? (r.width = n.width, r.left = n.left) : r.position === d.Top ? r.height = n.height : r.position === d.Bottom && (r.height = n.height, r.top = n.top)), this.update();
|
|
592
602
|
},
|
|
593
603
|
swapPanes(e, t) {
|
|
594
|
-
let n =
|
|
604
|
+
let n = A(e), i = A(t), a = e.getAttribute("can-drop") !== "false", o = t.getAttribute("can-drop") !== "false";
|
|
595
605
|
this.rootSash.swapIds(n, i), r(e, this.activeDropPaneEl), e.setAttribute("sash-id", i), t.setAttribute("sash-id", n), e.setAttribute("can-drop", o), t.setAttribute("can-drop", a);
|
|
596
606
|
}
|
|
597
607
|
};
|
|
598
|
-
function
|
|
608
|
+
function j(e) {
|
|
599
609
|
let t = document.createElement("pre");
|
|
600
610
|
return t.style.fontSize = "10px", t.innerHTML = `
|
|
601
611
|
${e.getAttribute("sash-id")}
|
|
@@ -608,7 +618,7 @@ height: ${e.style.height}
|
|
|
608
618
|
}
|
|
609
619
|
//#endregion
|
|
610
620
|
//#region src/frame/main.js
|
|
611
|
-
var
|
|
621
|
+
var ie = {
|
|
612
622
|
createWindow({ theme: e } = {}) {
|
|
613
623
|
let t = document.createElement("bw-window");
|
|
614
624
|
return t.style.width = `${this.rootSash.width}px`, t.style.height = `${this.rootSash.height}px`, t.setAttribute("root-sash-id", this.rootSash.id), e && t.setAttribute("theme", e), t;
|
|
@@ -629,7 +639,7 @@ var F = {
|
|
|
629
639
|
e.children.length > 0 ? t.includes(e.id) ? (this.updateMuntin(e), this.onMuntinUpdate(e.domNode, e)) : (e.domNode = this.createMuntin(e), this.windowElement.append(e.domNode)) : t.includes(e.id) ? (this.updatePane(e), this.onPaneUpdate(e.domNode, e)) : (e.domNode ||= this.createPane(e), this.windowElement.prepend(e.domNode));
|
|
630
640
|
});
|
|
631
641
|
}
|
|
632
|
-
},
|
|
642
|
+
}, ae = {
|
|
633
643
|
muntinSize: 4,
|
|
634
644
|
createMuntin(e) {
|
|
635
645
|
let t = document.createElement("bw-muntin"), n = e.leftChild, r = e.topChild;
|
|
@@ -641,7 +651,7 @@ var F = {
|
|
|
641
651
|
n ? (t.style.height = `${e.height}px`, t.style.top = `${e.top}px`, t.style.left = `${e.left + n.width - this.muntinSize / 2}px`) : r && (t.style.width = `${e.width}px`, t.style.top = `${e.top + r.height - this.muntinSize / 2}px`, t.style.left = `${e.left}px`);
|
|
642
652
|
},
|
|
643
653
|
onMuntinUpdate(e, t) {}
|
|
644
|
-
},
|
|
654
|
+
}, oe = {
|
|
645
655
|
fitContainer: !1,
|
|
646
656
|
fit() {
|
|
647
657
|
this.rootSash.width = this.containerElement.clientWidth, this.rootSash.height = this.containerElement.clientHeight, this.update();
|
|
@@ -653,7 +663,7 @@ var F = {
|
|
|
653
663
|
});
|
|
654
664
|
}).observe(this.containerElement);
|
|
655
665
|
}
|
|
656
|
-
},
|
|
666
|
+
}, se = {
|
|
657
667
|
activeMuntinSash: null,
|
|
658
668
|
isResizeStarted: !1,
|
|
659
669
|
isDropStarted: !1,
|
|
@@ -686,7 +696,7 @@ var F = {
|
|
|
686
696
|
this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
|
|
687
697
|
});
|
|
688
698
|
}
|
|
689
|
-
},
|
|
699
|
+
}, ce = {
|
|
690
700
|
activeDropPaneEl: null,
|
|
691
701
|
onPaneDrop(e, t) {},
|
|
692
702
|
enableDrop() {
|
|
@@ -704,13 +714,13 @@ var F = {
|
|
|
704
714
|
this.onPaneDrop(e, n), typeof n.store.onDrop == "function" && n.store.onDrop(e, n), this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null;
|
|
705
715
|
});
|
|
706
716
|
}
|
|
707
|
-
},
|
|
717
|
+
}, le = !1, M = class {
|
|
708
718
|
windowElement = null;
|
|
709
719
|
containerElement = null;
|
|
710
|
-
debug =
|
|
720
|
+
debug = le;
|
|
711
721
|
constructor(e) {
|
|
712
722
|
let t = null;
|
|
713
|
-
e instanceof
|
|
723
|
+
e instanceof C ? (t = e, this.rootSash = e) : (t = new S(e), this.rootSash = t.buildSashTree({ resizeStrategy: t.resizeStrategy })), this.fitContainer = t.fitContainer;
|
|
714
724
|
}
|
|
715
725
|
frame(e) {
|
|
716
726
|
this.containerElement = e, this.windowElement = this.createWindow({ theme: this.theme }), this.glaze(), this.containerElement.append(this.windowElement);
|
|
@@ -727,38 +737,10 @@ var F = {
|
|
|
727
737
|
});
|
|
728
738
|
}
|
|
729
739
|
};
|
|
730
|
-
|
|
731
|
-
//#endregion
|
|
732
|
-
//#region src/binary-window/actions.close.js
|
|
733
|
-
var H = {
|
|
734
|
-
label: "",
|
|
735
|
-
className: "bw-glass-action--close",
|
|
736
|
-
onClick: (e, t) => {
|
|
737
|
-
let n = M(e.target);
|
|
738
|
-
t.removePane(n);
|
|
739
|
-
}
|
|
740
|
-
}, U = {
|
|
741
|
-
label: "",
|
|
742
|
-
className: "bw-glass-action--minimize",
|
|
743
|
-
onClick: (e, t) => {
|
|
744
|
-
let n = t.sillElement;
|
|
745
|
-
if (!n) throw Error("[bwin] Sill element not found when minimizing");
|
|
746
|
-
let r = c("<button class=\"bw-minimized-glass\" />");
|
|
747
|
-
n.append(r);
|
|
748
|
-
let i = e.target.closest("bw-pane"), a = e.target.closest("bw-glass"), o = i.getAttribute("sash-id"), s = i.getAttribute("position");
|
|
749
|
-
r.bwGlassElement = a, r.bwOriginalPosition = s, r.bwOriginalBoundingRect = l(i), r.bwOriginalSashId = o, t.removePane(o);
|
|
750
|
-
}
|
|
751
|
-
}, W = {
|
|
752
|
-
label: "",
|
|
753
|
-
className: "bw-glass-action--maximize",
|
|
754
|
-
onClick: (e) => {
|
|
755
|
-
let t = e.target.closest("bw-pane");
|
|
756
|
-
t.hasAttribute("maximized") ? (t.removeAttribute("maximized"), t.style.left = `${t.bwOriginalBoundingRect.left}px`, t.style.top = `${t.bwOriginalBoundingRect.top}px`, t.style.width = `${t.bwOriginalBoundingRect.width}px`, t.style.height = `${t.bwOriginalBoundingRect.height}px`) : (t.setAttribute("maximized", ""), t.bwOriginalBoundingRect = l(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
|
|
757
|
-
}
|
|
758
|
-
};
|
|
740
|
+
M.assemble(ie, ae, re, oe, ce, se);
|
|
759
741
|
//#endregion
|
|
760
742
|
//#region src/rect.js
|
|
761
|
-
function
|
|
743
|
+
function ue(e, t) {
|
|
762
744
|
let n = e.left + e.width, r = e.top + e.height, i = t.left + t.width, a = t.top + t.height;
|
|
763
745
|
if (e.left >= i || t.left >= n || e.top >= a || t.top >= r) return null;
|
|
764
746
|
let o = Math.max(e.left, t.left), s = Math.max(e.top, t.top), c = Math.min(n, i), l = Math.min(r, a);
|
|
@@ -770,27 +752,23 @@ function G(e, t) {
|
|
|
770
752
|
};
|
|
771
753
|
}
|
|
772
754
|
//#endregion
|
|
773
|
-
//#region src/binary-window/
|
|
774
|
-
var
|
|
775
|
-
|
|
776
|
-
W,
|
|
777
|
-
H
|
|
778
|
-
], q = {
|
|
779
|
-
enableActions() {
|
|
755
|
+
//#region src/binary-window/glass/action.js
|
|
756
|
+
var de = {
|
|
757
|
+
enableGlassActions() {
|
|
780
758
|
this.handleMinimizedGlassClick(), this.observeActionButtons();
|
|
781
759
|
},
|
|
782
760
|
restoreGlass(e) {
|
|
783
761
|
let t = e.bwOriginalBoundingRect, n = 0, r = null;
|
|
784
762
|
if (this.windowElement.querySelectorAll("bw-pane").forEach((e) => {
|
|
785
|
-
let i =
|
|
763
|
+
let i = ue(t, u(e));
|
|
786
764
|
if (i) {
|
|
787
765
|
let t = i.width * i.height;
|
|
788
766
|
t > n && (n = t, r = e);
|
|
789
767
|
}
|
|
790
768
|
}), r) {
|
|
791
|
-
let n = e.bwOriginalPosition, i =
|
|
792
|
-
if (n ===
|
|
793
|
-
else if (n ===
|
|
769
|
+
let n = e.bwOriginalPosition, i = u(r), a = r.getAttribute("sash-id"), o = this.rootSash.getById(a), s = 0;
|
|
770
|
+
if (n === d.Left || n === d.Right) s = i.width - t.width < o.minWidth ? i.width / 2 : t.width;
|
|
771
|
+
else if (n === d.Top || n === d.Bottom) s = i.height - t.height < o.minHeight ? i.height / 2 : t.height;
|
|
794
772
|
else throw Error("[bwin] Invalid position when restoring glass");
|
|
795
773
|
let c = e.bwOriginalSashId;
|
|
796
774
|
this.addPane(r.getAttribute("sash-id"), {
|
|
@@ -808,7 +786,7 @@ var K = [
|
|
|
808
786
|
});
|
|
809
787
|
},
|
|
810
788
|
updateDisabledStateOfActionButtons() {
|
|
811
|
-
this.updateDisabledState(".bw-glass-action--close"), this.updateDisabledState(".bw-glass-action--minimize"), this.updateDisabledState(".bw-glass-action--maximize");
|
|
789
|
+
this.updateDisabledState(".bw-glass-action--close"), this.updateDisabledState(".bw-glass-action--minimize"), this.updateDisabledState(".bw-glass-action--maximize"), this.updateDisabledState(".bw-glass-action--detach");
|
|
812
790
|
},
|
|
813
791
|
updateDisabledState(e) {
|
|
814
792
|
if (this.windowElement.querySelectorAll("bw-pane").length === 1) {
|
|
@@ -829,15 +807,91 @@ var K = [
|
|
|
829
807
|
});
|
|
830
808
|
}).observe(this.windowElement, { childList: !0 });
|
|
831
809
|
}
|
|
832
|
-
},
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
810
|
+
}, N = null, P = !1, F = {
|
|
811
|
+
onPaneDrop(e, t) {
|
|
812
|
+
if (!N) return;
|
|
813
|
+
let n = this.activeDropPaneEl.getAttribute("drop-area");
|
|
814
|
+
if (n === "center") {
|
|
815
|
+
let e = N.closest("bw-pane");
|
|
816
|
+
this.swapPanes(e, this.activeDropPaneEl);
|
|
817
|
+
return;
|
|
818
|
+
} else {
|
|
819
|
+
let e = A(N);
|
|
820
|
+
this.removePane(e), this.addPane(t.id, {
|
|
821
|
+
position: n,
|
|
822
|
+
id: e
|
|
823
|
+
}).domNode.append(N);
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
enableGlassDrag() {
|
|
827
|
+
document.addEventListener("mousedown", (e) => {
|
|
828
|
+
if (e.button !== 0 || !e.target.matches("bw-glass-header")) return;
|
|
829
|
+
if (e.target.getAttribute("can-drag") === "false") {
|
|
830
|
+
e.preventDefault();
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
let t = e.target.closest("bw-glass");
|
|
834
|
+
t.setAttribute("draggable", !0), N = t;
|
|
835
|
+
}), document.addEventListener("mouseup", () => {
|
|
836
|
+
N &&= (N.removeAttribute("draggable"), null);
|
|
837
|
+
}), this.windowElement.addEventListener("dragstart", (e) => {
|
|
838
|
+
if (!(e.target instanceof HTMLElement) || !e.target.matches("bw-glass") || !N) return;
|
|
839
|
+
e.dataTransfer.effectAllowed = "move";
|
|
840
|
+
let t = N.closest("bw-pane");
|
|
841
|
+
P = t.getAttribute("can-drop") !== "false", t.setAttribute("can-drop", !1);
|
|
842
|
+
}), this.windowElement.addEventListener("dragend", () => {
|
|
843
|
+
N &&= (N.removeAttribute("draggable"), N.closest("bw-pane").setAttribute("can-drop", P), null);
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
}, I = {
|
|
847
|
+
label: "",
|
|
848
|
+
className: "bw-glass-action--close",
|
|
849
|
+
onClick: (e, t) => {
|
|
850
|
+
let n = A(e.target);
|
|
851
|
+
t.removePane(n);
|
|
852
|
+
}
|
|
853
|
+
}, L = {
|
|
854
|
+
label: "",
|
|
855
|
+
className: "bw-glass-action--minimize",
|
|
856
|
+
onClick: (e, t) => {
|
|
857
|
+
let n = t.sillElement;
|
|
858
|
+
if (!n) throw Error("[bwin] Sill element not found when minimizing");
|
|
859
|
+
let r = c("<button class=\"bw-minimized-glass\" />");
|
|
860
|
+
n.append(r);
|
|
861
|
+
let i = e.target.closest("bw-pane"), a = e.target.closest("bw-glass"), o = i.getAttribute("sash-id"), s = i.getAttribute("position");
|
|
862
|
+
r.bwGlassElement = a, r.bwOriginalPosition = s, r.bwOriginalBoundingRect = u(i), r.bwOriginalSashId = o, t.removePane(o);
|
|
863
|
+
}
|
|
864
|
+
}, R = {
|
|
865
|
+
label: "",
|
|
866
|
+
className: "bw-glass-action--maximize",
|
|
867
|
+
onClick: (e) => {
|
|
868
|
+
let t = e.target.closest("bw-pane");
|
|
869
|
+
t.hasAttribute("maximized") ? (t.removeAttribute("maximized"), t.style.left = `${t.bwOriginalBoundingRect.left}px`, t.style.top = `${t.bwOriginalBoundingRect.top}px`, t.style.width = `${t.bwOriginalBoundingRect.width}px`, t.style.height = `${t.bwOriginalBoundingRect.height}px`) : (t.setAttribute("maximized", ""), t.bwOriginalBoundingRect = u(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
|
|
870
|
+
}
|
|
871
|
+
}, z = 15, B = {
|
|
872
|
+
label: "",
|
|
873
|
+
className: "bw-glass-action--detach",
|
|
874
|
+
onClick: (e, t) => {
|
|
875
|
+
if (!t.addDetachedGlass) throw Error("[bwin] Failed to detach glass from pane");
|
|
876
|
+
let n = e.target.closest("bw-pane"), r = n.querySelector("bw-glass-content"), i = n.querySelector("bw-glass-title"), a = t.windowElement.getBoundingClientRect(), o = a.width - z * 2, s = a.height - z * 2, c = t.addDetachedGlass({
|
|
877
|
+
position: "center",
|
|
878
|
+
width: o,
|
|
879
|
+
height: s
|
|
880
|
+
}), l = n.getAttribute("sash-id"), u = t.rootSash.getById(l), d = u.parent.getChildSiblingById(l).id;
|
|
881
|
+
if (c.domNode.bwOriginalSiblingSashId = d, c.domNode.bwOriginalPosition = n.getAttribute("position"), c.domNode.bwOriginalRelativeSize = u.getRelativeSize(), c.contentElement.replaceWith(r), c.titleElement) c.titleElement.replaceWith(i);
|
|
882
|
+
else {
|
|
883
|
+
let e = document.createElement("bw-glass-title");
|
|
884
|
+
c.headerElement.prepend(e), e.replaceWith(i);
|
|
885
|
+
}
|
|
886
|
+
t.removePane(l);
|
|
887
|
+
}
|
|
888
|
+
}, V = [
|
|
889
|
+
L,
|
|
890
|
+
B,
|
|
891
|
+
I
|
|
892
|
+
], H = class {
|
|
839
893
|
domNode;
|
|
840
|
-
constructor({ title: e =
|
|
894
|
+
constructor({ title: e = null, content: t = null, tabs: n = [], actions: r = V, draggable: i = !0, sash: a = null, binaryWindow: o }) {
|
|
841
895
|
this.title = e, this.content = t, this.tabs = n, this.actions = r, this.sash = a, this.draggable = i, this.binaryWindow = o, this.build();
|
|
842
896
|
}
|
|
843
897
|
build() {
|
|
@@ -860,7 +914,7 @@ var K = [
|
|
|
860
914
|
return e;
|
|
861
915
|
}
|
|
862
916
|
createActions() {
|
|
863
|
-
let e = document.createElement("bw-glass-action-container"), t =
|
|
917
|
+
let e = document.createElement("bw-glass-action-container"), t = Array.isArray(this.actions) ? this.actions : [];
|
|
864
918
|
for (let n of t) {
|
|
865
919
|
let t = n?.label ?? n, r = c(`<button class="${n.className ? `bw-glass-action ${n.className}` : "bw-glass-action"}">${t}</button>`);
|
|
866
920
|
typeof n.onClick == "function" && r.addEventListener("click", (e) => {
|
|
@@ -875,45 +929,21 @@ var K = [
|
|
|
875
929
|
get headerElement() {
|
|
876
930
|
return this.domNode.querySelector("bw-glass-header");
|
|
877
931
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
let e = M(this.activeDragGlassEl);
|
|
890
|
-
this.removePane(e), this.addPane(t.id, {
|
|
891
|
-
position: n,
|
|
892
|
-
id: e
|
|
893
|
-
}).domNode.append(this.activeDragGlassEl);
|
|
894
|
-
}
|
|
932
|
+
get titleElement() {
|
|
933
|
+
return this.domNode.querySelector("bw-glass-title");
|
|
934
|
+
}
|
|
935
|
+
}, fe = [
|
|
936
|
+
L,
|
|
937
|
+
R,
|
|
938
|
+
B,
|
|
939
|
+
I
|
|
940
|
+
], pe = {
|
|
941
|
+
enableGlassFeature() {
|
|
942
|
+
this.enableGlassActions(), this.enableGlassDrag();
|
|
895
943
|
},
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
if (e.target.getAttribute("can-drag") === "false") {
|
|
900
|
-
e.preventDefault();
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
let t = e.target.closest("bw-glass");
|
|
904
|
-
t.setAttribute("draggable", !0), this.activeDragGlassEl = t;
|
|
905
|
-
}), document.addEventListener("mouseup", () => {
|
|
906
|
-
this.activeDragGlassEl &&= (this.activeDragGlassEl.removeAttribute("draggable"), null);
|
|
907
|
-
}), this.windowElement.addEventListener("dragstart", (e) => {
|
|
908
|
-
if (!(e.target instanceof HTMLElement) || !e.target.matches("bw-glass") || !this.activeDragGlassEl) return;
|
|
909
|
-
e.dataTransfer.effectAllowed = "move";
|
|
910
|
-
let t = this.activeDragGlassEl.closest("bw-pane");
|
|
911
|
-
this.activeDragGlassPaneCanDrop = t.getAttribute("can-drop") !== "false", t.setAttribute("can-drop", !1);
|
|
912
|
-
}), this.windowElement.addEventListener("dragend", () => {
|
|
913
|
-
this.activeDragGlassEl &&= (this.activeDragGlassEl.removeAttribute("draggable"), this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop", this.activeDragGlassPaneCanDrop), null);
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
}, Z = {
|
|
944
|
+
...de,
|
|
945
|
+
...F
|
|
946
|
+
}, me = {
|
|
917
947
|
trimMuntin(e) {
|
|
918
948
|
e.hasAttribute("vertical") ? (e.style.top = `${parseFloat(e.style.top) + this.muntinSize / 2}px`, e.style.height = `${parseFloat(e.style.height) - this.muntinSize}px`) : e.hasAttribute("horizontal") && (e.style.left = `${parseFloat(e.style.left) + this.muntinSize / 2}px`, e.style.width = `${parseFloat(e.style.width) - this.muntinSize}px`);
|
|
919
949
|
},
|
|
@@ -923,23 +953,289 @@ var K = [
|
|
|
923
953
|
onMuntinUpdate(e) {
|
|
924
954
|
this.trimMuntin(e);
|
|
925
955
|
}
|
|
926
|
-
},
|
|
956
|
+
}, he = [
|
|
957
|
+
"n",
|
|
958
|
+
"s",
|
|
959
|
+
"e",
|
|
960
|
+
"w",
|
|
961
|
+
"ne",
|
|
962
|
+
"nw",
|
|
963
|
+
"se",
|
|
964
|
+
"sw"
|
|
965
|
+
];
|
|
966
|
+
function ge() {
|
|
967
|
+
return he.map((e) => {
|
|
968
|
+
let t = document.createElement("bw-glass-resize-handle");
|
|
969
|
+
return t.setAttribute("resize-dir", e), t;
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
function _e({ position: e, offset: t, offsetX: n, offsetY: r, width: i, height: a }) {
|
|
973
|
+
let o = n ?? t, s = r ?? t;
|
|
974
|
+
switch (e) {
|
|
975
|
+
case "top-left": return {
|
|
976
|
+
top: `${s}px`,
|
|
977
|
+
left: `${o}px`,
|
|
978
|
+
right: "auto",
|
|
979
|
+
bottom: "auto"
|
|
980
|
+
};
|
|
981
|
+
case "top-right": return {
|
|
982
|
+
top: `${s}px`,
|
|
983
|
+
right: `${o}px`,
|
|
984
|
+
left: "auto",
|
|
985
|
+
bottom: "auto"
|
|
986
|
+
};
|
|
987
|
+
case "bottom-left": return {
|
|
988
|
+
bottom: `${s}px`,
|
|
989
|
+
left: `${o}px`,
|
|
990
|
+
right: "auto",
|
|
991
|
+
top: "auto"
|
|
992
|
+
};
|
|
993
|
+
case "bottom-right": return {
|
|
994
|
+
bottom: `${s}px`,
|
|
995
|
+
right: `${o}px`,
|
|
996
|
+
left: "auto",
|
|
997
|
+
top: "auto"
|
|
998
|
+
};
|
|
999
|
+
case "center": return {
|
|
1000
|
+
top: `calc(50% - ${a / 2}px + ${s}px)`,
|
|
1001
|
+
left: `calc(50% - ${i / 2}px + ${o}px)`,
|
|
1002
|
+
right: "auto",
|
|
1003
|
+
bottom: "auto"
|
|
1004
|
+
};
|
|
1005
|
+
default: throw Error(`Position "${e}" is not supported for detached glass.`);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
var U = new class {
|
|
1009
|
+
constructor() {
|
|
1010
|
+
this.glasses = [], this.topZIndex = 1;
|
|
1011
|
+
}
|
|
1012
|
+
addGlassByElement(e) {
|
|
1013
|
+
this.glasses.push(e);
|
|
1014
|
+
}
|
|
1015
|
+
getActiveGlass() {
|
|
1016
|
+
return this.glasses.find((e) => e.hasAttribute("active")) ?? null;
|
|
1017
|
+
}
|
|
1018
|
+
bringToFront(e) {
|
|
1019
|
+
e.hasAttribute("active") || (this.topZIndex += 1, e.style.zIndex = this.topZIndex, e.parentElement?.querySelectorAll(":scope > bw-glass[detached][active]").forEach((t) => t !== e && t.removeAttribute("active")), e.setAttribute("active", ""));
|
|
1020
|
+
}
|
|
1021
|
+
removeGlassById(e) {
|
|
1022
|
+
let t = this.glasses.findIndex((t) => t.id === e);
|
|
1023
|
+
if (t !== -1) {
|
|
1024
|
+
let [e] = this.glasses.splice(t, 1);
|
|
1025
|
+
return e;
|
|
1026
|
+
}
|
|
1027
|
+
return null;
|
|
1028
|
+
}
|
|
1029
|
+
}(), W = [
|
|
1030
|
+
{
|
|
1031
|
+
label: "",
|
|
1032
|
+
className: "bw-glass-action--minimize",
|
|
1033
|
+
onClick: (e, t) => {
|
|
1034
|
+
let n = t.sillElement;
|
|
1035
|
+
if (!n) throw Error("[bwin] Sill element not found when minimizing");
|
|
1036
|
+
let r = c("<button class=\"bw-minimized-detached-glass\" />");
|
|
1037
|
+
n.append(r);
|
|
1038
|
+
let i = e.target.closest("bw-glass[detached]");
|
|
1039
|
+
if (!i) throw Error("[bwin] Detached Glass element not found when minimizing");
|
|
1040
|
+
r.bwDetachedGlassElement = i, i.style.display = "none";
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
label: "",
|
|
1045
|
+
className: "bw-glass-action--attach",
|
|
1046
|
+
onClick: (e, t) => {
|
|
1047
|
+
let n = e.target.closest("bw-glass[detached]"), r = n.bwOriginalPosition, i = n.bwOriginalSiblingSashId, a = n.bwOriginalRelativeSize, o = t.rootSash.getById(i), s = i, c = r, u = a;
|
|
1048
|
+
if (!o) {
|
|
1049
|
+
let e = t.rootSash.getLargestLeaf();
|
|
1050
|
+
s = e.id, c = e.width > e.height ? "right" : "bottom", u = .5;
|
|
1051
|
+
}
|
|
1052
|
+
let d = n.querySelector("bw-glass-content");
|
|
1053
|
+
t.addPane(s, {
|
|
1054
|
+
position: c,
|
|
1055
|
+
size: u,
|
|
1056
|
+
content: l(d),
|
|
1057
|
+
title: n.querySelector("bw-glass-title")?.textContent || ""
|
|
1058
|
+
}), t.removeDetachedGlass(n.id);
|
|
1059
|
+
}
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
label: "",
|
|
1063
|
+
className: "bw-glass-action--close",
|
|
1064
|
+
onClick: (e) => {
|
|
1065
|
+
let t = e.target.closest("bw-glass[detached]");
|
|
1066
|
+
t && (U.removeGlassById(t.id), t.remove());
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
], ve = class extends H {
|
|
1070
|
+
constructor(e) {
|
|
1071
|
+
let { position: n, width: r = 222, height: i = 222, offset: a = 0, offsetX: o, offsetY: s, id: c, actions: l = W, ...u } = e;
|
|
1072
|
+
super({
|
|
1073
|
+
...u,
|
|
1074
|
+
actions: l
|
|
1075
|
+
}), this.domNode.setAttribute("id", c || t() + "-F"), this.domNode.setAttribute("detached", ""), this.domNode.style.position = "absolute", this.domNode.style.width = `${r}px`, this.domNode.style.height = `${i}px`;
|
|
1076
|
+
let { top: d, left: f, right: p, bottom: m } = _e({
|
|
1077
|
+
position: n,
|
|
1078
|
+
offset: a,
|
|
1079
|
+
offsetX: o,
|
|
1080
|
+
offsetY: s,
|
|
1081
|
+
width: r,
|
|
1082
|
+
height: i
|
|
1083
|
+
});
|
|
1084
|
+
this.domNode.style.top = d, this.domNode.style.left = f, this.domNode.style.right = p, this.domNode.style.bottom = m;
|
|
1085
|
+
}
|
|
1086
|
+
}, ye = 200, be = 200, G = 25;
|
|
1087
|
+
function xe(e, { width: t, height: n }) {
|
|
1088
|
+
let r = U.getActiveGlass();
|
|
1089
|
+
if (!r) return { position: "center" };
|
|
1090
|
+
let i = e.getBoundingClientRect(), a = r.getBoundingClientRect(), o = a.left - i.left + G, s = a.top - i.top + G;
|
|
1091
|
+
return o + t > i.width && (o = G), s + n > i.height && (s = G), {
|
|
1092
|
+
position: "top-left",
|
|
1093
|
+
offsetX: o,
|
|
1094
|
+
offsetY: s
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
var Se = {
|
|
1098
|
+
addDetachedGlass(e = {}) {
|
|
1099
|
+
let t = e.width ?? ye, n = e.height ?? be, { position: r, offsetX: i, offsetY: a } = e.position ? {} : xe(this.windowElement, {
|
|
1100
|
+
width: t,
|
|
1101
|
+
height: n
|
|
1102
|
+
}), o = new ve({
|
|
1103
|
+
actions: this.actions[1],
|
|
1104
|
+
binaryWindow: this,
|
|
1105
|
+
position: r,
|
|
1106
|
+
offsetX: i,
|
|
1107
|
+
offsetY: a,
|
|
1108
|
+
...e,
|
|
1109
|
+
width: t,
|
|
1110
|
+
height: n
|
|
1111
|
+
});
|
|
1112
|
+
return this.windowElement.append(o.domNode), U.addGlassByElement(o.domNode), U.bringToFront(o.domNode), o;
|
|
1113
|
+
},
|
|
1114
|
+
removeDetachedGlass(e) {
|
|
1115
|
+
let t = U.removeGlassById(e);
|
|
1116
|
+
return t?.remove(), t;
|
|
1117
|
+
}
|
|
1118
|
+
}, Ce = { enableDetachedGlassActivate() {
|
|
1119
|
+
this.windowElement.addEventListener("pointerdown", (e) => {
|
|
1120
|
+
if (e.button !== 0) return;
|
|
1121
|
+
let t = e.target.closest?.("bw-glass[detached]");
|
|
1122
|
+
t && U.bringToFront(t);
|
|
1123
|
+
});
|
|
1124
|
+
} }, we = { enableDetachedGlassMove() {
|
|
1125
|
+
let e = null, t = 0, n = 0, r = 0, i = 0;
|
|
1126
|
+
this.windowElement.addEventListener("pointerdown", (a) => {
|
|
1127
|
+
if (a.button !== 0) return;
|
|
1128
|
+
let o = a.target.closest("bw-glass-header");
|
|
1129
|
+
if (!o || a.target.closest("button") || o.getAttribute("can-drag") === "false") return;
|
|
1130
|
+
let s = o.closest("bw-glass[detached]");
|
|
1131
|
+
if (!s) return;
|
|
1132
|
+
a.preventDefault(), o.setPointerCapture(a.pointerId), e = s, t = a.pageX, n = a.pageY;
|
|
1133
|
+
let c = this.windowElement.getBoundingClientRect(), l = s.getBoundingClientRect();
|
|
1134
|
+
r = l.left - c.left, i = l.top - c.top;
|
|
1135
|
+
}), this.windowElement.addEventListener("pointermove", (a) => {
|
|
1136
|
+
if (!e) return;
|
|
1137
|
+
let o = r + (a.pageX - t), s = i + (a.pageY - n);
|
|
1138
|
+
e.style.right = "auto", e.style.bottom = "auto", e.style.left = `${o}px`, e.style.top = `${s}px`;
|
|
1139
|
+
}), this.windowElement.addEventListener("pointerup", (t) => {
|
|
1140
|
+
e &&= (t.target.hasPointerCapture?.(t.pointerId) && t.target.releasePointerCapture(t.pointerId), null);
|
|
1141
|
+
});
|
|
1142
|
+
} }, K = null, q = 0, J = 0, Y = { enableDetachedGlassDrag() {
|
|
1143
|
+
document.addEventListener("mousedown", (e) => {
|
|
1144
|
+
if (e.button !== 0) return;
|
|
1145
|
+
let t = e.target.closest("bw-glass-header");
|
|
1146
|
+
if (!t || e.target.closest("button") || t.getAttribute("can-drag") === "false") return;
|
|
1147
|
+
let n = t.closest("bw-glass[detached]");
|
|
1148
|
+
n && (n.setAttribute("draggable", !0), K = n);
|
|
1149
|
+
}), document.addEventListener("mouseup", () => {
|
|
1150
|
+
K &&= (K.removeAttribute("draggable"), null);
|
|
1151
|
+
}), this.windowElement.addEventListener("dragstart", (e) => {
|
|
1152
|
+
if (!K) return;
|
|
1153
|
+
e.dataTransfer.effectAllowed = "move";
|
|
1154
|
+
let t = K.getBoundingClientRect();
|
|
1155
|
+
q = e.clientX - t.left, J = e.clientY - t.top;
|
|
1156
|
+
}), this.windowElement.addEventListener("dragend", (e) => {
|
|
1157
|
+
if (!K) return;
|
|
1158
|
+
let t = this.windowElement.getBoundingClientRect(), n = e.clientX - t.left - q, r = e.clientY - t.top - J;
|
|
1159
|
+
K.style.right = "auto", K.style.bottom = "auto", K.style.left = `${n}px`, K.style.top = `${r}px`, K.removeAttribute("draggable"), K = null;
|
|
1160
|
+
});
|
|
1161
|
+
} }, X = 100, Z = 60;
|
|
1162
|
+
function Te(e) {
|
|
1163
|
+
return !!e.querySelector(":scope > bw-glass-resize-handle");
|
|
1164
|
+
}
|
|
1165
|
+
function Ee(e) {
|
|
1166
|
+
Te(e) || e.append(...ge());
|
|
1167
|
+
}
|
|
1168
|
+
function Q(e) {
|
|
1169
|
+
e.querySelectorAll(":scope > bw-glass-resize-handle").forEach((e) => e.remove());
|
|
1170
|
+
}
|
|
1171
|
+
var De = { enableDetachedGlassResize() {
|
|
1172
|
+
let e = null, t = "", n = 0, r = 0, i = null;
|
|
1173
|
+
this.windowElement.addEventListener("pointerover", (e) => {
|
|
1174
|
+
let t = e.target.closest?.("bw-glass[detached]");
|
|
1175
|
+
t && Ee(t);
|
|
1176
|
+
}), this.windowElement.addEventListener("pointerout", (t) => {
|
|
1177
|
+
let n = t.target.closest?.("bw-glass[detached]");
|
|
1178
|
+
n && t.relatedTarget?.closest?.("bw-glass[detached]") !== n && n !== e && Q(n);
|
|
1179
|
+
}), this.windowElement.addEventListener("pointerdown", (a) => {
|
|
1180
|
+
if (a.button !== 0 || a.target.tagName !== "BW-GLASS-RESIZE-HANDLE") return;
|
|
1181
|
+
let o = a.target.closest("bw-glass[detached]");
|
|
1182
|
+
if (!o) return;
|
|
1183
|
+
a.preventDefault(), a.target.setPointerCapture(a.pointerId), e = o, t = a.target.getAttribute("resize-dir"), n = a.pageX, r = a.pageY;
|
|
1184
|
+
let s = this.windowElement.getBoundingClientRect(), c = o.getBoundingClientRect();
|
|
1185
|
+
i = {
|
|
1186
|
+
left: c.left - s.left,
|
|
1187
|
+
top: c.top - s.top,
|
|
1188
|
+
width: c.width,
|
|
1189
|
+
height: c.height
|
|
1190
|
+
};
|
|
1191
|
+
}), this.windowElement.addEventListener("pointermove", (a) => {
|
|
1192
|
+
if (!e) return;
|
|
1193
|
+
let o = t, s = a.pageX - n, c = a.pageY - r, l = i, { left: u, top: d, width: f, height: p } = l;
|
|
1194
|
+
o.includes("e") ? f = Math.max(X, l.width + s) : o.includes("w") && (f = Math.max(X, l.width - s), u = l.left + (l.width - f)), o.includes("s") ? p = Math.max(Z, l.height + c) : o.includes("n") && (p = Math.max(Z, l.height - c), d = l.top + (l.height - p)), e.style.right = "auto", e.style.bottom = "auto", e.style.left = `${u}px`, e.style.top = `${d}px`, e.style.width = `${f}px`, e.style.height = `${p}px`;
|
|
1195
|
+
}), this.windowElement.addEventListener("pointerup", (n) => {
|
|
1196
|
+
if (!e) return;
|
|
1197
|
+
n.target.hasPointerCapture?.(n.pointerId) && n.target.releasePointerCapture(n.pointerId);
|
|
1198
|
+
let r = e;
|
|
1199
|
+
e = null, t = "", i = null, r.matches(":hover") || Q(r);
|
|
1200
|
+
});
|
|
1201
|
+
} }, Oe = { handleMinimizedDetachedGlassClick() {
|
|
1202
|
+
this.sillElement.addEventListener("click", (e) => {
|
|
1203
|
+
let t = e.target;
|
|
1204
|
+
if (!t.matches(".bw-minimized-detached-glass")) return;
|
|
1205
|
+
let n = t.bwDetachedGlassElement;
|
|
1206
|
+
n && (n.style.display = "", t.remove(), U.bringToFront(n));
|
|
1207
|
+
});
|
|
1208
|
+
} }, ke = {
|
|
1209
|
+
enableDetachedGlassFeatures() {
|
|
1210
|
+
this.enableDetachedGlassActivate(), this.enableDetachedGlassResize(), this.enableDetachedGlassMove(), this.handleMinimizedDetachedGlassClick();
|
|
1211
|
+
},
|
|
1212
|
+
...Se,
|
|
1213
|
+
...Ce,
|
|
1214
|
+
...we,
|
|
1215
|
+
...Y,
|
|
1216
|
+
...De,
|
|
1217
|
+
...Oe
|
|
1218
|
+
}, $ = class e extends M {
|
|
927
1219
|
sillElement = null;
|
|
1220
|
+
constructor(t) {
|
|
1221
|
+
super(t), this.theme = t.theme || "", this.actions = e.normActions(t.actions);
|
|
1222
|
+
}
|
|
928
1223
|
frame() {
|
|
929
1224
|
super.frame(...arguments);
|
|
930
1225
|
let e = c("<bw-sill />");
|
|
931
1226
|
this.windowElement.append(e), this.sillElement = e;
|
|
932
1227
|
}
|
|
933
1228
|
enableFeatures() {
|
|
934
|
-
super.enableFeatures(), this.
|
|
1229
|
+
super.enableFeatures(), this.enableGlassFeature(), this.enableDetachedGlassFeatures();
|
|
935
1230
|
}
|
|
936
1231
|
onPaneCreate(e, t) {
|
|
937
|
-
let n = new
|
|
1232
|
+
let n = this.actions[0], r = new H({
|
|
1233
|
+
actions: n,
|
|
938
1234
|
...t.store,
|
|
939
1235
|
sash: t,
|
|
940
1236
|
binaryWindow: this
|
|
941
1237
|
});
|
|
942
|
-
e.innerHTML = "", e.append(
|
|
1238
|
+
e.innerHTML = "", e.append(r.domNode), this.debug && r.contentElement.prepend(`${t.id}`);
|
|
943
1239
|
}
|
|
944
1240
|
onPaneUpdate() {}
|
|
945
1241
|
addPane(e, t) {
|
|
@@ -947,7 +1243,7 @@ var K = [
|
|
|
947
1243
|
position: n,
|
|
948
1244
|
size: r,
|
|
949
1245
|
id: i
|
|
950
|
-
}), s = new
|
|
1246
|
+
}), s = new H({
|
|
951
1247
|
...a,
|
|
952
1248
|
sash: o,
|
|
953
1249
|
binaryWindow: this
|
|
@@ -969,7 +1265,17 @@ var K = [
|
|
|
969
1265
|
let t = this.getMinimizedGlassElementBySashId(e);
|
|
970
1266
|
t && t.remove();
|
|
971
1267
|
}
|
|
1268
|
+
static normActions(e) {
|
|
1269
|
+
if (e === void 0) return [V, W];
|
|
1270
|
+
if (!e || !Array.isArray(e) || e.length === 0) return [[], []];
|
|
1271
|
+
if (e.length === 1 && Array.isArray(e[0])) return [e[0], W];
|
|
1272
|
+
if (!e.some(Array.isArray)) return [e, W];
|
|
1273
|
+
if (e.length >= 2 && !Array.isArray(e[0]) && Array.isArray(e[1])) return [[], e[1]];
|
|
1274
|
+
if (e.length >= 2 && Array.isArray(e[0]) && !Array.isArray(e[1])) return [e[0], []];
|
|
1275
|
+
if (e.length >= 2 && Array.isArray(e[0]) && Array.isArray(e[1])) return e;
|
|
1276
|
+
throw Error("[bwin] Invalid actions format");
|
|
1277
|
+
}
|
|
972
1278
|
};
|
|
973
|
-
|
|
1279
|
+
$.assemble(pe, ke, me);
|
|
974
1280
|
//#endregion
|
|
975
|
-
export {
|
|
1281
|
+
export { fe as BUILTIN_ACTIONS, $ as BinaryWindow, S as ConfigRoot, W as DEFAULT_DETACHED_GLASS_ACTIONS, V as DEFAULT_GLASS_ACTIONS, M as Frame, d as Position, v as Sash, C as SashConfig };
|