bwin 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bwin.js +429 -416
- package/package.json +1 -1
package/dist/bwin.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
var
|
|
2
|
-
var $ = (
|
|
3
|
-
var f = (
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
return `rgba(${n}, ${
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var $ = (i, t, e) => t in i ? L(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var f = (i, t, e) => $(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
function I(i = 0.7, t = 128) {
|
|
5
|
+
const e = 256 - t, n = Math.floor(Math.random() * e + t), s = Math.floor(Math.random() * e + t), o = Math.floor(Math.random() * e + t), h = Math.max(0.5, Math.random() * i);
|
|
6
|
+
return `rgba(${n}, ${s}, ${o}, ${h})`;
|
|
7
7
|
}
|
|
8
|
-
function C(
|
|
9
|
-
if (
|
|
8
|
+
function C(i = 2, t = 3) {
|
|
9
|
+
if (i < 0 || t < 0)
|
|
10
10
|
throw new Error("Parameters must be non-negative numbers");
|
|
11
|
-
const
|
|
12
|
-
let
|
|
13
|
-
for (let
|
|
14
|
-
const h = Math.floor(Math.random() *
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
for (let
|
|
11
|
+
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = "0123456789";
|
|
12
|
+
let s = "";
|
|
13
|
+
for (let o = 0; o < i; o++) {
|
|
14
|
+
const h = Math.floor(Math.random() * e.length);
|
|
15
|
+
s += e[h];
|
|
16
|
+
}
|
|
17
|
+
s += "-";
|
|
18
|
+
for (let o = 0; o < t; o++) {
|
|
19
19
|
const h = Math.floor(Math.random() * n.length);
|
|
20
|
-
|
|
20
|
+
s += n[h];
|
|
21
21
|
}
|
|
22
|
-
return
|
|
22
|
+
return s;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function z(i, t) {
|
|
25
25
|
for (; t.firstChild; )
|
|
26
|
-
|
|
26
|
+
i.append(t.firstChild);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
|
|
28
|
+
function W(i, t) {
|
|
29
|
+
const e = document.createElement("div");
|
|
30
|
+
z(e, i), z(i, t), z(t, e);
|
|
31
31
|
}
|
|
32
|
-
function b(
|
|
33
|
-
if (typeof
|
|
34
|
-
return
|
|
35
|
-
if (typeof
|
|
36
|
-
const t =
|
|
32
|
+
function b(i) {
|
|
33
|
+
if (typeof i == "number" && !isNaN(i))
|
|
34
|
+
return i;
|
|
35
|
+
if (typeof i == "string") {
|
|
36
|
+
const t = i.trim();
|
|
37
37
|
if (t.endsWith("%")) {
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
-
const n = Number(
|
|
38
|
+
const e = t.slice(0, -1);
|
|
39
|
+
if (!e) return NaN;
|
|
40
|
+
const n = Number(e);
|
|
41
41
|
return isNaN(n) ? NaN : n / 100;
|
|
42
42
|
}
|
|
43
43
|
if (t.endsWith("px")) {
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
46
|
-
const n = Number(
|
|
44
|
+
const e = t.slice(0, -2);
|
|
45
|
+
if (!e) return NaN;
|
|
46
|
+
const n = Number(e);
|
|
47
47
|
return isNaN(n) ? NaN : n;
|
|
48
48
|
}
|
|
49
49
|
return Number(t);
|
|
50
50
|
}
|
|
51
51
|
return NaN;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
53
|
+
function H(i) {
|
|
54
|
+
return i !== null && typeof i == "object" && !Array.isArray(i) && Object.getPrototypeOf(i) === Object.prototype;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
for (const
|
|
58
|
-
if (Object.hasOwn(
|
|
59
|
-
throw new Error(`Key "${
|
|
60
|
-
e
|
|
56
|
+
function O(i, t) {
|
|
57
|
+
for (const e in t) {
|
|
58
|
+
if (Object.hasOwn(i, e))
|
|
59
|
+
throw new Error(`Key "${e}" already exists in target object`);
|
|
60
|
+
i[e] = t[e];
|
|
61
61
|
}
|
|
62
|
-
return
|
|
62
|
+
return i;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function P(i) {
|
|
65
65
|
const t = document.createElement("template");
|
|
66
|
-
return t.innerHTML =
|
|
66
|
+
return t.innerHTML = i.trim(), t.content;
|
|
67
67
|
}
|
|
68
|
-
function m(
|
|
69
|
-
if (
|
|
68
|
+
function m(i) {
|
|
69
|
+
if (i == null || i === "")
|
|
70
70
|
return null;
|
|
71
|
-
if (typeof
|
|
71
|
+
if (typeof i == "string")
|
|
72
72
|
try {
|
|
73
|
-
const t =
|
|
73
|
+
const t = P(i);
|
|
74
74
|
return t.childNodes.length === 1 ? t.firstChild : t;
|
|
75
75
|
} catch {
|
|
76
|
-
return document.createTextNode(
|
|
76
|
+
return document.createTextNode(i);
|
|
77
77
|
}
|
|
78
|
-
return
|
|
78
|
+
return i instanceof Node ? i : document.createTextNode(String(i));
|
|
79
79
|
}
|
|
80
|
-
function M(
|
|
81
|
-
const t = parseFloat(
|
|
82
|
-
return { left: t, top:
|
|
80
|
+
function M(i) {
|
|
81
|
+
const t = parseFloat(i.style.left) || 0, e = parseFloat(i.style.top) || 0, n = parseFloat(i.style.width) || 0, s = parseFloat(i.style.height) || 0;
|
|
82
|
+
return { left: t, top: e, width: n, height: s };
|
|
83
83
|
}
|
|
84
84
|
const r = {
|
|
85
85
|
Top: "top",
|
|
@@ -91,8 +91,8 @@ const r = {
|
|
|
91
91
|
Unknown: "unknown",
|
|
92
92
|
Outside: "outside"
|
|
93
93
|
};
|
|
94
|
-
function G(
|
|
95
|
-
switch (
|
|
94
|
+
function G(i) {
|
|
95
|
+
switch (i) {
|
|
96
96
|
case r.Top:
|
|
97
97
|
return r.Bottom;
|
|
98
98
|
case r.Right:
|
|
@@ -102,27 +102,27 @@ function G(e) {
|
|
|
102
102
|
case r.Left:
|
|
103
103
|
return r.Right;
|
|
104
104
|
default:
|
|
105
|
-
throw new Error(`[bwin] Invalid position: ${
|
|
105
|
+
throw new Error(`[bwin] Invalid position: ${i}`);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
function F({ width:
|
|
109
|
-
return t /
|
|
108
|
+
function F({ width: i, height: t, x: e }) {
|
|
109
|
+
return t / i * e;
|
|
110
110
|
}
|
|
111
|
-
function _({ width:
|
|
112
|
-
return
|
|
111
|
+
function _({ width: i, height: t, y: e }) {
|
|
112
|
+
return i / t * e;
|
|
113
113
|
}
|
|
114
|
-
function k({ width:
|
|
115
|
-
return t - t /
|
|
114
|
+
function k({ width: i, height: t, x: e }) {
|
|
115
|
+
return t - t / i * e;
|
|
116
116
|
}
|
|
117
|
-
function U({ width:
|
|
118
|
-
return
|
|
117
|
+
function U({ width: i, height: t, y: e }) {
|
|
118
|
+
return i - i / t * e;
|
|
119
119
|
}
|
|
120
|
-
function Y(
|
|
121
|
-
const n =
|
|
122
|
-
if (h < 0 || h >
|
|
120
|
+
function Y(i, { clientX: t, clientY: e }) {
|
|
121
|
+
const n = i.getBoundingClientRect(), { width: s, height: o } = n, h = t - n.left, l = e - n.top;
|
|
122
|
+
if (h < 0 || h > s || l < 0 || l > o)
|
|
123
123
|
return r.Outside;
|
|
124
|
-
const d = 0.3, a = F({ width:
|
|
125
|
-
return h <
|
|
124
|
+
const d = 0.3, a = F({ width: s, height: o, x: h }), c = k({ width: s, height: o, x: h }), p = _({ width: s, height: o, y: l }), u = U({ width: s, height: o, y: l });
|
|
125
|
+
return h < s * (0.5 - d / 2) && l > a && l < c ? r.Left : h > s * (0.5 + d / 2) && l < a && l > c ? r.Right : l < o * (0.5 - d / 2) && h > p && h < u ? r.Top : l > o * (0.5 + d / 2) && h < p && h > u ? r.Bottom : h > s * (0.5 - d / 2) && h < s * (0.5 + d / 2) && l > o * (0.5 - d / 2) && l < o * (0.5 + d / 2) ? r.Center : r.Unknown;
|
|
126
126
|
}
|
|
127
127
|
const X = 100, q = 100, w = {
|
|
128
128
|
left: 0,
|
|
@@ -136,10 +136,10 @@ const X = 100, q = 100, w = {
|
|
|
136
136
|
class g {
|
|
137
137
|
constructor({
|
|
138
138
|
left: t = w.left,
|
|
139
|
-
top:
|
|
139
|
+
top: e = w.top,
|
|
140
140
|
width: n = w.width,
|
|
141
|
-
height:
|
|
142
|
-
minWidth:
|
|
141
|
+
height: s = w.height,
|
|
142
|
+
minWidth: o = w.minWidth,
|
|
143
143
|
minHeight: h = w.minHeight,
|
|
144
144
|
domNode: l = null,
|
|
145
145
|
store: d = {},
|
|
@@ -148,10 +148,10 @@ class g {
|
|
|
148
148
|
} = w) {
|
|
149
149
|
if (this.id = c ?? C(), !a)
|
|
150
150
|
throw new Error("[bwin] Sash position is required");
|
|
151
|
-
this.position = a, this.domNode = l, this._top =
|
|
151
|
+
this.position = a, this.domNode = l, this._top = e, this._left = t, this._width = n, this._height = s, this.children = [], this.minWidth = o, this.minHeight = h, this.store = d;
|
|
152
152
|
}
|
|
153
153
|
walk(t) {
|
|
154
|
-
this.children.forEach((
|
|
154
|
+
this.children.forEach((e) => e.walk(t)), t(this);
|
|
155
155
|
}
|
|
156
156
|
isLeaf() {
|
|
157
157
|
return this.children.length === 0;
|
|
@@ -183,59 +183,66 @@ class g {
|
|
|
183
183
|
return this.children.find((t) => t.position === r.Bottom);
|
|
184
184
|
}
|
|
185
185
|
getChildren() {
|
|
186
|
-
let t = null,
|
|
187
|
-
for (const
|
|
188
|
-
|
|
189
|
-
return [n,
|
|
186
|
+
let t = null, e = null, n = null, s = null;
|
|
187
|
+
for (const o of this.children)
|
|
188
|
+
o.position === r.Left ? t = o : o.position === r.Right ? e = o : o.position === r.Top ? n = o : o.position === r.Bottom && (s = o);
|
|
189
|
+
return [n, e, s, t];
|
|
190
190
|
}
|
|
191
191
|
getAllLeafDescendants() {
|
|
192
192
|
const t = [];
|
|
193
|
-
return this.walk((
|
|
194
|
-
|
|
193
|
+
return this.walk((e) => {
|
|
194
|
+
e.children.length === 0 && t.push(e);
|
|
195
195
|
}), t;
|
|
196
196
|
}
|
|
197
197
|
calcMinWidth() {
|
|
198
198
|
if (this.isLeaf())
|
|
199
199
|
return this.minWidth;
|
|
200
|
-
const [t,
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
return Math.max(this.minWidth,
|
|
200
|
+
const [t, e, n, s] = this.getChildren();
|
|
201
|
+
if (s && e) {
|
|
202
|
+
const o = s.calcMinWidth() + e.calcMinWidth();
|
|
203
|
+
return Math.max(this.minWidth, o);
|
|
204
204
|
}
|
|
205
205
|
if (t && n) {
|
|
206
|
-
const
|
|
207
|
-
return Math.max(this.minWidth,
|
|
206
|
+
const o = Math.max(t.calcMinWidth(), n.calcMinWidth());
|
|
207
|
+
return Math.max(this.minWidth, o);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
calcMinHeight() {
|
|
211
211
|
if (this.isLeaf())
|
|
212
212
|
return this.minHeight;
|
|
213
|
-
const [t,
|
|
214
|
-
if (
|
|
215
|
-
const
|
|
216
|
-
return Math.max(this.minHeight,
|
|
213
|
+
const [t, e, n, s] = this.getChildren();
|
|
214
|
+
if (s && e) {
|
|
215
|
+
const o = Math.max(s.calcMinHeight(), e.calcMinHeight());
|
|
216
|
+
return Math.max(this.minHeight, o);
|
|
217
217
|
}
|
|
218
218
|
if (t && n) {
|
|
219
|
-
const
|
|
220
|
-
return Math.max(this.minHeight,
|
|
219
|
+
const o = t.calcMinHeight() + n.calcMinHeight();
|
|
220
|
+
return Math.max(this.minHeight, o);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
// Get self or descendant by id
|
|
224
224
|
getById(t) {
|
|
225
225
|
if (this.id === t)
|
|
226
226
|
return this;
|
|
227
|
-
for (const
|
|
228
|
-
const n =
|
|
227
|
+
for (const e of this.children) {
|
|
228
|
+
const n = e.getById(t);
|
|
229
229
|
if (n)
|
|
230
230
|
return n;
|
|
231
231
|
}
|
|
232
232
|
return null;
|
|
233
233
|
}
|
|
234
|
+
swapIds(t, e) {
|
|
235
|
+
const n = this.getById(t), s = this.getById(e);
|
|
236
|
+
if (!n || !s)
|
|
237
|
+
throw new Error("[bwin] Sash not found when swapping IDs");
|
|
238
|
+
const o = n.id;
|
|
239
|
+
n.id = s.id, s.id = o;
|
|
240
|
+
}
|
|
234
241
|
// Get all ids of self and descendants
|
|
235
242
|
getAllIds() {
|
|
236
243
|
const t = [this.id];
|
|
237
|
-
for (const
|
|
238
|
-
t.push(...
|
|
244
|
+
for (const e of this.children)
|
|
245
|
+
t.push(...e.getAllIds());
|
|
239
246
|
return t;
|
|
240
247
|
}
|
|
241
248
|
addChild(t) {
|
|
@@ -244,81 +251,81 @@ class g {
|
|
|
244
251
|
this.children.push(t);
|
|
245
252
|
}
|
|
246
253
|
getDescendantParentById(t) {
|
|
247
|
-
for (const
|
|
248
|
-
if (
|
|
254
|
+
for (const e of this.children) {
|
|
255
|
+
if (e.id === t)
|
|
249
256
|
return this;
|
|
250
|
-
const n =
|
|
257
|
+
const n = e.getDescendantParentById(t);
|
|
251
258
|
if (n)
|
|
252
259
|
return n;
|
|
253
260
|
}
|
|
254
261
|
return null;
|
|
255
262
|
}
|
|
256
263
|
getChildSiblingById(t) {
|
|
257
|
-
return this.children.find((
|
|
264
|
+
return this.children.find((e) => e.id !== t);
|
|
258
265
|
}
|
|
259
266
|
get top() {
|
|
260
267
|
return this._top;
|
|
261
268
|
}
|
|
262
269
|
set top(t) {
|
|
263
|
-
const
|
|
270
|
+
const e = t - this._top;
|
|
264
271
|
this._top = t;
|
|
265
|
-
const [n,
|
|
266
|
-
n &&
|
|
272
|
+
const [n, s, o, h] = this.getChildren();
|
|
273
|
+
n && o && (n.top += e, o.top += e), h && s && (h.top += e, s.top += e);
|
|
267
274
|
}
|
|
268
275
|
get left() {
|
|
269
276
|
return this._left;
|
|
270
277
|
}
|
|
271
278
|
set left(t) {
|
|
272
|
-
const
|
|
279
|
+
const e = t - this._left;
|
|
273
280
|
this._left = t;
|
|
274
|
-
const [n,
|
|
275
|
-
h &&
|
|
281
|
+
const [n, s, o, h] = this.getChildren();
|
|
282
|
+
h && s && (h.left += e, s.left += e), n && o && (n.left += e, o.left += e);
|
|
276
283
|
}
|
|
277
284
|
get width() {
|
|
278
285
|
return this._width;
|
|
279
286
|
}
|
|
280
287
|
set width(t) {
|
|
281
|
-
const
|
|
288
|
+
const e = t - this._width;
|
|
282
289
|
this._width = t;
|
|
283
|
-
const [n,
|
|
284
|
-
if (h &&
|
|
285
|
-
const l = h.width +
|
|
286
|
-
let c = h.width + d, p = a - c, u =
|
|
287
|
-
const
|
|
288
|
-
|
|
290
|
+
const [n, s, o, h] = this.getChildren();
|
|
291
|
+
if (h && s) {
|
|
292
|
+
const l = h.width + s.width, d = e * (h.width / l), a = l + e;
|
|
293
|
+
let c = h.width + d, p = a - c, u = s.left + d;
|
|
294
|
+
const y = h.calcMinWidth(), E = s.calcMinWidth();
|
|
295
|
+
e < 0 && (c < y && p > E ? (c = h.width, p = a - c, u = h.left + c) : p < E && c > y && (p = s.width, c = a - p, u = h.left + c)), h.width = c, s.width = p, s.left = u;
|
|
289
296
|
}
|
|
290
|
-
n &&
|
|
297
|
+
n && o && (n.width += e, o.width += e);
|
|
291
298
|
}
|
|
292
299
|
get height() {
|
|
293
300
|
return this._height;
|
|
294
301
|
}
|
|
295
302
|
set height(t) {
|
|
296
|
-
const
|
|
303
|
+
const e = t - this._height;
|
|
297
304
|
this._height = t;
|
|
298
|
-
const [n,
|
|
299
|
-
if (n &&
|
|
300
|
-
const l = n.height +
|
|
301
|
-
let c = n.height + d, p = a - c, u =
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
c <
|
|
305
|
+
const [n, s, o, h] = this.getChildren();
|
|
306
|
+
if (n && o) {
|
|
307
|
+
const l = n.height + o.height, d = e * (n.height / l), a = l + e;
|
|
308
|
+
let c = n.height + d, p = a - c, u = o.top + d;
|
|
309
|
+
if (e < 0) {
|
|
310
|
+
const y = n.calcMinHeight(), E = o.calcMinHeight();
|
|
311
|
+
c < y && p > E ? (c = n.height, p = a - c, u = n.top + c) : p < E && c > y && (p = o.height, c = a - p, u = n.top + c);
|
|
305
312
|
}
|
|
306
|
-
n.height = c,
|
|
313
|
+
n.height = c, o.height = p, o.top = u;
|
|
307
314
|
}
|
|
308
|
-
h &&
|
|
315
|
+
h && s && (h.height += e, s.height += e);
|
|
309
316
|
}
|
|
310
317
|
}
|
|
311
|
-
const
|
|
318
|
+
const v = {
|
|
312
319
|
size: "50%",
|
|
313
320
|
position: r.Left
|
|
314
321
|
};
|
|
315
322
|
class A {
|
|
316
323
|
constructor({
|
|
317
324
|
parentRect: t,
|
|
318
|
-
children:
|
|
325
|
+
children: e,
|
|
319
326
|
siblingConfigNode: n,
|
|
320
|
-
id:
|
|
321
|
-
minWidth:
|
|
327
|
+
id: s,
|
|
328
|
+
minWidth: o,
|
|
322
329
|
minHeight: h,
|
|
323
330
|
position: l,
|
|
324
331
|
size: d,
|
|
@@ -328,15 +335,15 @@ class A {
|
|
|
328
335
|
f(this, "top");
|
|
329
336
|
f(this, "width");
|
|
330
337
|
f(this, "height");
|
|
331
|
-
this.parentRect = t, this.children =
|
|
338
|
+
this.parentRect = t, this.children = e, this.siblingConfigNode = n, this.id = s, this.minWidth = o, this.minHeight = h, this.position = this.getPosition(l), this.size = this.getSize(d), this.nonCoreData = a, this.setBounds();
|
|
332
339
|
}
|
|
333
340
|
getPosition(t) {
|
|
334
341
|
if (!this.siblingConfigNode)
|
|
335
342
|
return t;
|
|
336
|
-
const
|
|
343
|
+
const e = G(this.siblingConfigNode.position);
|
|
337
344
|
if (!t)
|
|
338
|
-
return
|
|
339
|
-
if (t !==
|
|
345
|
+
return e;
|
|
346
|
+
if (t !== e)
|
|
340
347
|
throw new Error("[bwin] Sibling position and current position are not opposite");
|
|
341
348
|
return t;
|
|
342
349
|
}
|
|
@@ -351,17 +358,17 @@ class A {
|
|
|
351
358
|
if (this.siblingConfigNode.position === r.Top || this.siblingConfigNode.position === r.Bottom)
|
|
352
359
|
return this.parentRect.height - this.siblingConfigNode.height;
|
|
353
360
|
}
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
if (
|
|
361
|
+
const e = b(t);
|
|
362
|
+
if (e < 1) {
|
|
363
|
+
if (e + this.siblingConfigNode.size !== 1)
|
|
357
364
|
throw new Error("[bwin] Sum of sibling sizes is not equal to 1");
|
|
358
365
|
} else {
|
|
359
|
-
if ((this.position === r.Left || this.position === r.Right) &&
|
|
366
|
+
if ((this.position === r.Left || this.position === r.Right) && e + this.siblingConfigNode.size !== this.parentRect.width)
|
|
360
367
|
throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");
|
|
361
|
-
if ((this.position === r.Top || this.position === r.Bottom) &&
|
|
368
|
+
if ((this.position === r.Top || this.position === r.Bottom) && e + this.siblingConfigNode.size !== this.parentRect.height)
|
|
362
369
|
throw new Error("[bwin] Sum of sibling sizes is not equal to parent height");
|
|
363
370
|
}
|
|
364
|
-
return
|
|
371
|
+
return e;
|
|
365
372
|
}
|
|
366
373
|
setBounds() {
|
|
367
374
|
if (this.position === r.Root)
|
|
@@ -394,16 +401,16 @@ class A {
|
|
|
394
401
|
});
|
|
395
402
|
}
|
|
396
403
|
normConfig(t) {
|
|
397
|
-
if (
|
|
404
|
+
if (H(t))
|
|
398
405
|
return t;
|
|
399
406
|
if (Array.isArray(t))
|
|
400
407
|
return {
|
|
401
408
|
children: t
|
|
402
409
|
};
|
|
403
410
|
if (typeof t == "string" || typeof t == "number") {
|
|
404
|
-
const
|
|
405
|
-
if (isNaN(
|
|
406
|
-
throw new Error(`[bwin] Invalid size value: ${
|
|
411
|
+
const e = b(t);
|
|
412
|
+
if (isNaN(e))
|
|
413
|
+
throw new Error(`[bwin] Invalid size value: ${e}`);
|
|
407
414
|
return {
|
|
408
415
|
size: t
|
|
409
416
|
};
|
|
@@ -413,27 +420,27 @@ class A {
|
|
|
413
420
|
throw new Error(`[bwin] Invalid config value: ${t}`);
|
|
414
421
|
}
|
|
415
422
|
}
|
|
416
|
-
createPrimaryConfigNode({ size: t, position:
|
|
423
|
+
createPrimaryConfigNode({ size: t, position: e, children: n, id: s, minWidth: o, minHeight: h, ...l }) {
|
|
417
424
|
return new A({
|
|
418
425
|
parentRect: this,
|
|
419
|
-
size: t ??
|
|
420
|
-
position:
|
|
426
|
+
size: t ?? v.size,
|
|
427
|
+
position: e ?? v.position,
|
|
421
428
|
children: n,
|
|
422
|
-
id:
|
|
423
|
-
minWidth:
|
|
429
|
+
id: s,
|
|
430
|
+
minWidth: o,
|
|
424
431
|
minHeight: h,
|
|
425
432
|
...l
|
|
426
433
|
});
|
|
427
434
|
}
|
|
428
|
-
createSecondaryConfigNode({ size: t, position:
|
|
435
|
+
createSecondaryConfigNode({ size: t, position: e, children: n, id: s, minWidth: o, minHeight: h, ...l }, d) {
|
|
429
436
|
return new A({
|
|
430
437
|
parentRect: this,
|
|
431
438
|
size: t,
|
|
432
|
-
position:
|
|
439
|
+
position: e,
|
|
433
440
|
children: n,
|
|
434
441
|
siblingConfigNode: d,
|
|
435
|
-
id:
|
|
436
|
-
minWidth:
|
|
442
|
+
id: s,
|
|
443
|
+
minWidth: o,
|
|
437
444
|
minHeight: h,
|
|
438
445
|
...l
|
|
439
446
|
});
|
|
@@ -442,171 +449,179 @@ class A {
|
|
|
442
449
|
const t = this.createSash();
|
|
443
450
|
if (!Array.isArray(this.children) || this.children.length === 0)
|
|
444
451
|
return t;
|
|
445
|
-
const
|
|
446
|
-
let
|
|
447
|
-
return !
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
)) : (
|
|
452
|
+
const e = this.normConfig(this.children[0]), n = this.normConfig(this.children.at(1));
|
|
453
|
+
let s, o;
|
|
454
|
+
return !e.size && !e.position && n ? (n.position || (n.position = r.Right), s = this.createPrimaryConfigNode(n), o = this.createSecondaryConfigNode(
|
|
455
|
+
e,
|
|
456
|
+
s
|
|
457
|
+
)) : (s = this.createPrimaryConfigNode(e), o = this.createSecondaryConfigNode(
|
|
451
458
|
n,
|
|
452
|
-
|
|
453
|
-
)),
|
|
459
|
+
s
|
|
460
|
+
)), s && o && (t.children.push(s.buildSashTree()), t.children.push(o.buildSashTree())), t;
|
|
454
461
|
}
|
|
455
462
|
}
|
|
456
|
-
const
|
|
463
|
+
const D = {
|
|
457
464
|
width: 333,
|
|
458
465
|
height: 333
|
|
459
|
-
},
|
|
466
|
+
}, S = {
|
|
460
467
|
fitContainer: !1
|
|
461
468
|
};
|
|
462
469
|
class j extends A {
|
|
463
470
|
constructor({
|
|
464
471
|
id: t,
|
|
465
|
-
children:
|
|
466
|
-
width: n =
|
|
467
|
-
height:
|
|
468
|
-
fitContainer:
|
|
472
|
+
children: e,
|
|
473
|
+
width: n = D.width,
|
|
474
|
+
height: s = D.height,
|
|
475
|
+
fitContainer: o = S.fitContainer,
|
|
469
476
|
...h
|
|
470
477
|
} = {
|
|
471
|
-
...
|
|
472
|
-
...
|
|
478
|
+
...D,
|
|
479
|
+
...S
|
|
473
480
|
}) {
|
|
474
481
|
super({
|
|
475
482
|
id: t,
|
|
476
|
-
children:
|
|
483
|
+
children: e,
|
|
477
484
|
size: NaN,
|
|
478
485
|
position: r.Root,
|
|
479
|
-
parentRect: { width: n, height:
|
|
486
|
+
parentRect: { width: n, height: s },
|
|
480
487
|
...h
|
|
481
|
-
}), this.fitContainer =
|
|
488
|
+
}), this.fitContainer = o;
|
|
482
489
|
}
|
|
483
490
|
}
|
|
484
491
|
class K extends g {
|
|
485
492
|
constructor(t = w) {
|
|
486
|
-
super({ ...t, position: r.Root }), Object.assign(this,
|
|
493
|
+
super({ ...t, position: r.Root }), Object.assign(this, S);
|
|
487
494
|
}
|
|
488
495
|
}
|
|
489
|
-
function V(
|
|
496
|
+
function V(i) {
|
|
490
497
|
const t = document.createElement("bw-pane");
|
|
491
|
-
return t.style.top = `${
|
|
498
|
+
return t.style.top = `${i.top}px`, t.style.left = `${i.left}px`, t.style.width = `${i.width}px`, t.style.height = `${i.height}px`, t.setAttribute("sash-id", i.id), t.setAttribute("position", i.position), t;
|
|
492
499
|
}
|
|
493
|
-
function J(
|
|
494
|
-
const t =
|
|
495
|
-
return t.style.top = `${
|
|
500
|
+
function J(i) {
|
|
501
|
+
const t = i.domNode;
|
|
502
|
+
return t.style.top = `${i.top}px`, t.style.left = `${i.left}px`, t.style.width = `${i.width}px`, t.style.height = `${i.height}px`, t.setAttribute("position", i.position), t;
|
|
496
503
|
}
|
|
497
|
-
function Q(
|
|
504
|
+
function Q(i, { size: t, id: e }) {
|
|
498
505
|
const n = b(t);
|
|
499
|
-
let
|
|
500
|
-
n && (n < 1 ?
|
|
501
|
-
const
|
|
502
|
-
id:
|
|
503
|
-
top:
|
|
504
|
-
left:
|
|
505
|
-
width:
|
|
506
|
-
height:
|
|
506
|
+
let s = i.width / 2;
|
|
507
|
+
n && (n < 1 ? s = i.width * n : s = n);
|
|
508
|
+
const o = new g({
|
|
509
|
+
id: e,
|
|
510
|
+
top: i.top,
|
|
511
|
+
left: i.left,
|
|
512
|
+
width: s,
|
|
513
|
+
height: i.height,
|
|
507
514
|
position: r.Left
|
|
508
515
|
}), h = new g({
|
|
509
|
-
id:
|
|
510
|
-
top:
|
|
511
|
-
left:
|
|
512
|
-
width:
|
|
513
|
-
height:
|
|
516
|
+
id: i.id,
|
|
517
|
+
top: i.top,
|
|
518
|
+
left: i.left + o.width,
|
|
519
|
+
width: i.width - s,
|
|
520
|
+
height: i.height,
|
|
514
521
|
position: r.Right,
|
|
515
|
-
domNode:
|
|
522
|
+
domNode: i.domNode
|
|
516
523
|
});
|
|
517
|
-
return
|
|
524
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), o;
|
|
518
525
|
}
|
|
519
|
-
function Z(
|
|
526
|
+
function Z(i, { size: t, id: e }) {
|
|
520
527
|
const n = b(t);
|
|
521
|
-
let
|
|
522
|
-
n && (n < 1 ?
|
|
523
|
-
const
|
|
524
|
-
id:
|
|
525
|
-
left:
|
|
526
|
-
top:
|
|
527
|
-
width:
|
|
528
|
-
height:
|
|
528
|
+
let s = i.width / 2;
|
|
529
|
+
n && (n < 1 ? s = i.width * n : s = n);
|
|
530
|
+
const o = new g({
|
|
531
|
+
id: i.id,
|
|
532
|
+
left: i.left,
|
|
533
|
+
top: i.top,
|
|
534
|
+
width: i.width - s,
|
|
535
|
+
height: i.height,
|
|
529
536
|
position: r.Left,
|
|
530
|
-
domNode:
|
|
537
|
+
domNode: i.domNode
|
|
531
538
|
}), h = new g({
|
|
532
|
-
id:
|
|
533
|
-
left:
|
|
534
|
-
top:
|
|
535
|
-
width:
|
|
536
|
-
height:
|
|
539
|
+
id: e,
|
|
540
|
+
left: i.left + o.width,
|
|
541
|
+
top: i.top,
|
|
542
|
+
width: s,
|
|
543
|
+
height: i.height,
|
|
537
544
|
position: r.Right
|
|
538
545
|
});
|
|
539
|
-
return
|
|
546
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), h;
|
|
540
547
|
}
|
|
541
|
-
function tt(
|
|
548
|
+
function tt(i, { size: t, id: e }) {
|
|
542
549
|
const n = b(t);
|
|
543
|
-
let
|
|
544
|
-
n && (n < 1 ?
|
|
545
|
-
const
|
|
546
|
-
id:
|
|
547
|
-
left:
|
|
548
|
-
top:
|
|
549
|
-
width:
|
|
550
|
-
height:
|
|
550
|
+
let s = i.height / 2;
|
|
551
|
+
n && (n < 1 ? s = i.height * n : s = n);
|
|
552
|
+
const o = new g({
|
|
553
|
+
id: e,
|
|
554
|
+
left: i.left,
|
|
555
|
+
top: i.top,
|
|
556
|
+
width: i.width,
|
|
557
|
+
height: s,
|
|
551
558
|
position: r.Top
|
|
552
559
|
}), h = new g({
|
|
553
|
-
id:
|
|
554
|
-
left:
|
|
555
|
-
top:
|
|
556
|
-
width:
|
|
557
|
-
height:
|
|
560
|
+
id: i.id,
|
|
561
|
+
left: i.left,
|
|
562
|
+
top: i.top + o.height,
|
|
563
|
+
width: i.width,
|
|
564
|
+
height: i.height - s,
|
|
558
565
|
position: r.Bottom,
|
|
559
|
-
domNode:
|
|
566
|
+
domNode: i.domNode
|
|
560
567
|
});
|
|
561
|
-
return
|
|
568
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), o;
|
|
562
569
|
}
|
|
563
|
-
function
|
|
570
|
+
function it(i, { size: t, id: e }) {
|
|
564
571
|
const n = b(t);
|
|
565
|
-
let
|
|
566
|
-
n && (n < 1 ?
|
|
567
|
-
const
|
|
568
|
-
id:
|
|
569
|
-
top:
|
|
570
|
-
left:
|
|
571
|
-
width:
|
|
572
|
-
height:
|
|
572
|
+
let s = i.height / 2;
|
|
573
|
+
n && (n < 1 ? s = i.height * n : s = n);
|
|
574
|
+
const o = new g({
|
|
575
|
+
id: i.id,
|
|
576
|
+
top: i.top,
|
|
577
|
+
left: i.left,
|
|
578
|
+
width: i.width,
|
|
579
|
+
height: i.height - s,
|
|
573
580
|
position: r.Top,
|
|
574
|
-
domNode:
|
|
581
|
+
domNode: i.domNode
|
|
575
582
|
}), h = new g({
|
|
576
|
-
id:
|
|
577
|
-
top:
|
|
578
|
-
left:
|
|
579
|
-
width:
|
|
580
|
-
height:
|
|
583
|
+
id: e,
|
|
584
|
+
top: i.top + o.height,
|
|
585
|
+
left: i.left,
|
|
586
|
+
width: i.width,
|
|
587
|
+
height: s,
|
|
581
588
|
position: r.Bottom
|
|
582
589
|
});
|
|
583
|
-
return
|
|
590
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), h;
|
|
584
591
|
}
|
|
585
|
-
function
|
|
592
|
+
function et(i, { position: t, size: e, id: n, minWidth: s, minHeight: o }) {
|
|
586
593
|
if (t === r.Left)
|
|
587
|
-
return Q(
|
|
594
|
+
return Q(i, { size: e, id: n });
|
|
588
595
|
if (t === r.Right)
|
|
589
|
-
return Z(
|
|
596
|
+
return Z(i, { size: e, id: n });
|
|
590
597
|
if (t === r.Top)
|
|
591
|
-
return tt(
|
|
598
|
+
return tt(i, { size: e, id: n });
|
|
592
599
|
if (t === r.Bottom)
|
|
593
|
-
return
|
|
600
|
+
return it(i, { size: e, id: n });
|
|
601
|
+
}
|
|
602
|
+
function R(i) {
|
|
603
|
+
if (i.tagName === "BW-PANE")
|
|
604
|
+
return i.getAttribute("sash-id");
|
|
605
|
+
const t = i.closest("bw-pane");
|
|
606
|
+
if (!t)
|
|
607
|
+
throw new Error("[bwin] Pane element not found");
|
|
608
|
+
return t.getAttribute("sash-id");
|
|
594
609
|
}
|
|
595
610
|
const nt = {
|
|
596
|
-
createPane(
|
|
597
|
-
const t = V(
|
|
598
|
-
return
|
|
611
|
+
createPane(i) {
|
|
612
|
+
const t = V(i);
|
|
613
|
+
return i.store.droppable === !1 && t.setAttribute("can-drop", "false"), t;
|
|
599
614
|
},
|
|
600
615
|
// Intended to be overridden
|
|
601
|
-
onPaneCreate(
|
|
602
|
-
t.store.content &&
|
|
616
|
+
onPaneCreate(i, t) {
|
|
617
|
+
t.store.content && i.append(m(t.store.content)), this != null && this.debug && (i.style.backgroundColor = I(), i.innerHTML = "", i.append(x(i)));
|
|
603
618
|
},
|
|
604
|
-
updatePane(
|
|
605
|
-
return J(
|
|
619
|
+
updatePane(i) {
|
|
620
|
+
return J(i);
|
|
606
621
|
},
|
|
607
622
|
// Intended to be overridden
|
|
608
|
-
onPaneUpdate(
|
|
609
|
-
this != null && this.debug && (
|
|
623
|
+
onPaneUpdate(i, t) {
|
|
624
|
+
this != null && this.debug && (i.innerHTML = "", i.append(x(i)));
|
|
610
625
|
},
|
|
611
626
|
/**
|
|
612
627
|
* Add a pane into the target pane. The two panes become next to each other
|
|
@@ -615,72 +630,76 @@ const nt = {
|
|
|
615
630
|
* @param {'top'|'right'|'bottom'|'left'} position - The position of the new pane relative to the target pane
|
|
616
631
|
* @returns {Sash} - The newly created sash
|
|
617
632
|
*/
|
|
618
|
-
addPane(
|
|
633
|
+
addPane(i, { position: t, size: e, id: n }) {
|
|
619
634
|
if (!t) throw new Error("[bwin] Position is required when adding pane");
|
|
620
|
-
const
|
|
621
|
-
if (!
|
|
622
|
-
const
|
|
623
|
-
return this.update(),
|
|
635
|
+
const s = this.rootSash.getById(i);
|
|
636
|
+
if (!s) throw new Error("[bwin] Parent sash not found when adding pane");
|
|
637
|
+
const o = et(s, { position: t, size: e, id: n });
|
|
638
|
+
return this.update(), o;
|
|
624
639
|
},
|
|
625
640
|
/**
|
|
626
641
|
* Remove a pane
|
|
627
642
|
*
|
|
628
643
|
* @param {string} sashId - The Sash ID of the pane to be removed
|
|
629
644
|
*/
|
|
630
|
-
removePane(
|
|
631
|
-
const t = this.rootSash.getDescendantParentById(
|
|
645
|
+
removePane(i) {
|
|
646
|
+
const t = this.rootSash.getDescendantParentById(i);
|
|
632
647
|
if (!t) throw new Error("[bwin] Parent sash not found when removing pane");
|
|
633
|
-
const
|
|
634
|
-
|
|
648
|
+
const e = t.getChildSiblingById(i);
|
|
649
|
+
e.children.length === 0 ? (t.id = e.id, t.domNode = e.domNode, t.domNode.setAttribute("sash-id", e.id), t.children = []) : (t.id = C(), t.children = e.children, e.position === r.Left ? e.width = t.width : e.position === r.Right ? (e.width = t.width, e.left = t.left) : e.position === r.Top ? e.height = t.height : e.position === r.Bottom && (e.height = t.height, e.top = t.top)), this.update();
|
|
650
|
+
},
|
|
651
|
+
swapPanes(i, t) {
|
|
652
|
+
const e = R(i), n = R(t), s = i.getAttribute("can-drop") !== "false", o = t.getAttribute("can-drop") !== "false";
|
|
653
|
+
this.rootSash.swapIds(e, n), W(i, this.activeDropPaneEl), i.setAttribute("sash-id", n), t.setAttribute("sash-id", e), i.setAttribute("can-drop", o), t.setAttribute("can-drop", s);
|
|
635
654
|
}
|
|
636
655
|
};
|
|
637
|
-
function
|
|
656
|
+
function x(i) {
|
|
638
657
|
const t = document.createElement("pre");
|
|
639
658
|
t.style.fontSize = "10px";
|
|
640
|
-
const
|
|
641
|
-
${
|
|
642
|
-
${
|
|
643
|
-
top: ${
|
|
644
|
-
left: ${
|
|
645
|
-
width: ${
|
|
646
|
-
height: ${
|
|
659
|
+
const e = `
|
|
660
|
+
${i.getAttribute("sash-id")}
|
|
661
|
+
${i.getAttribute("position")}
|
|
662
|
+
top: ${i.style.top}
|
|
663
|
+
left: ${i.style.left}
|
|
664
|
+
width: ${i.style.width}
|
|
665
|
+
height: ${i.style.height}
|
|
647
666
|
`;
|
|
648
|
-
return t.innerHTML =
|
|
667
|
+
return t.innerHTML = e.trim(), t;
|
|
649
668
|
}
|
|
650
|
-
const
|
|
669
|
+
const st = {
|
|
651
670
|
createWindow() {
|
|
652
|
-
const
|
|
653
|
-
return
|
|
671
|
+
const i = document.createElement("bw-window");
|
|
672
|
+
return i.style.width = `${this.rootSash.width}px`, i.style.height = `${this.rootSash.height}px`, i.setAttribute("root-sash-id", this.rootSash.id), i;
|
|
654
673
|
},
|
|
655
674
|
glaze() {
|
|
656
|
-
this.rootSash.walk((
|
|
675
|
+
this.rootSash.walk((i) => {
|
|
657
676
|
let t = null;
|
|
658
|
-
|
|
677
|
+
i.children.length > 0 ? (t = this.createMuntin(i), this.onMuntinCreate(t, i), this.windowElement.append(t)) : (t = this.createPane(i), this.onPaneCreate(t, i), this.windowElement.prepend(t)), i.domNode = t;
|
|
659
678
|
});
|
|
660
679
|
},
|
|
661
680
|
update() {
|
|
662
681
|
this.windowElement.style.width = `${this.rootSash.width}px`, this.windowElement.style.height = `${this.rootSash.height}px`;
|
|
663
|
-
const
|
|
664
|
-
this.windowElement.querySelectorAll("[sash-id]").forEach((
|
|
665
|
-
const n =
|
|
666
|
-
t.push(n),
|
|
667
|
-
}), this.rootSash.walk((
|
|
668
|
-
|
|
682
|
+
const i = this.rootSash.getAllIds(), t = [];
|
|
683
|
+
this.windowElement.querySelectorAll("[sash-id]").forEach((e) => {
|
|
684
|
+
const n = e.getAttribute("sash-id");
|
|
685
|
+
t.push(n), i.includes(n) || e.remove();
|
|
686
|
+
}), this.rootSash.walk((e) => {
|
|
687
|
+
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 || (e.domNode = this.createPane(e)), this.windowElement.prepend(e.domNode));
|
|
669
688
|
});
|
|
670
689
|
}
|
|
671
|
-
},
|
|
690
|
+
}, ot = {
|
|
672
691
|
muntinSize: 4,
|
|
673
|
-
createMuntin(
|
|
674
|
-
const t = document.createElement("bw-muntin"),
|
|
675
|
-
return
|
|
692
|
+
createMuntin(i) {
|
|
693
|
+
const t = document.createElement("bw-muntin"), e = i.leftChild, n = i.topChild;
|
|
694
|
+
return e ? (t.style.width = `${this.muntinSize}px`, t.style.height = `${i.height}px`, t.style.top = `${i.top}px`, t.style.left = `${i.left + e.width - this.muntinSize / 2}px`, t.setAttribute("vertical", "")) : n && (t.style.width = `${i.width}px`, t.style.height = `${this.muntinSize}px`, t.style.top = `${i.top + n.height - this.muntinSize / 2}px`, t.style.left = `${i.left}px`, t.setAttribute("horizontal", "")), t.setAttribute("sash-id", i.id), i.store.resizable === !1 && t.setAttribute("resizable", "false"), t;
|
|
676
695
|
},
|
|
677
|
-
onMuntinCreate(
|
|
696
|
+
onMuntinCreate(i, t) {
|
|
678
697
|
},
|
|
679
|
-
updateMuntin(
|
|
680
|
-
const t =
|
|
681
|
-
|
|
698
|
+
updateMuntin(i) {
|
|
699
|
+
const t = i.domNode, e = i.leftChild, n = i.topChild;
|
|
700
|
+
e ? (t.style.height = `${i.height}px`, t.style.top = `${i.top}px`, t.style.left = `${i.left + e.width - this.muntinSize / 2}px`) : n && (t.style.width = `${i.width}px`, t.style.top = `${i.top + n.height - this.muntinSize / 2}px`, t.style.left = `${i.left}px`);
|
|
682
701
|
},
|
|
683
|
-
onMuntinUpdate(
|
|
702
|
+
onMuntinUpdate(i, t) {
|
|
684
703
|
}
|
|
685
704
|
}, ht = {
|
|
686
705
|
fitContainer: !1,
|
|
@@ -689,8 +708,8 @@ const ot = {
|
|
|
689
708
|
},
|
|
690
709
|
enableFitContainer() {
|
|
691
710
|
new ResizeObserver((t) => {
|
|
692
|
-
for (const
|
|
693
|
-
|
|
711
|
+
for (const e of t)
|
|
712
|
+
e.target === this.containerElement && this.fitContainer && this.fit();
|
|
694
713
|
}).observe(this.containerElement);
|
|
695
714
|
}
|
|
696
715
|
}, rt = {
|
|
@@ -706,21 +725,21 @@ const ot = {
|
|
|
706
725
|
document.body.classList.remove("body--bw-resize-x"), document.body.classList.remove("body--bw-resize-y");
|
|
707
726
|
},
|
|
708
727
|
enableResize() {
|
|
709
|
-
document.addEventListener("mousedown", (
|
|
710
|
-
if (
|
|
711
|
-
const t =
|
|
712
|
-
this.activeMuntinSash = this.rootSash.getById(t), this.activeMuntinSash && (this.isResizeStarted = !0, this.lastX =
|
|
713
|
-
}), document.addEventListener("mousemove", (
|
|
728
|
+
document.addEventListener("mousedown", (i) => {
|
|
729
|
+
if (i.target.tagName !== "BW-MUNTIN" || i.target.getAttribute("resizable") === "false") return;
|
|
730
|
+
const t = i.target.getAttribute("sash-id");
|
|
731
|
+
this.activeMuntinSash = this.rootSash.getById(t), this.activeMuntinSash && (this.isResizeStarted = !0, this.lastX = i.pageX, this.lastY = i.pageY, this.applyResizeStyles());
|
|
732
|
+
}), document.addEventListener("mousemove", (i) => {
|
|
714
733
|
if (!this.isResizeStarted || !this.activeMuntinSash) return;
|
|
715
|
-
const [t,
|
|
716
|
-
if (
|
|
717
|
-
const l =
|
|
718
|
-
if (l > 0 && a <=
|
|
719
|
-
|
|
734
|
+
const [t, e, n, s] = this.activeMuntinSash.getChildren(), o = this.activeMuntinSash.isLeftRightSplit(), h = this.activeMuntinSash.isTopBottomSplit();
|
|
735
|
+
if (o && s && e) {
|
|
736
|
+
const l = i.pageX - this.lastX, d = s.width + l, a = e.width - l;
|
|
737
|
+
if (l > 0 && a <= e.calcMinWidth() || l < 0 && d <= s.calcMinWidth()) return;
|
|
738
|
+
s.width = d, e.width = a, e.left = e.left + l, this.update(), this.lastX = i.pageX;
|
|
720
739
|
} else if (h && t && n) {
|
|
721
|
-
const l =
|
|
740
|
+
const l = i.pageY - this.lastY, d = t.height + l, a = n.height - l;
|
|
722
741
|
if (l > 0 && a <= n.calcMinHeight() || l < 0 && d <= t.calcMinHeight()) return;
|
|
723
|
-
t.height = d, n.height = a, n.top = n.top + l, this.update(), this.lastY =
|
|
742
|
+
t.height = d, n.height = a, n.top = n.top + l, this.update(), this.lastY = i.pageY;
|
|
724
743
|
}
|
|
725
744
|
}), document.addEventListener("mouseup", () => {
|
|
726
745
|
this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
|
|
@@ -729,31 +748,31 @@ const ot = {
|
|
|
729
748
|
}, lt = {
|
|
730
749
|
activeDropPaneEl: null,
|
|
731
750
|
// Intended to be overridden in `BinaryWindow` class
|
|
732
|
-
onPaneDrop(
|
|
751
|
+
onPaneDrop(i, t) {
|
|
733
752
|
},
|
|
734
753
|
enableDrop() {
|
|
735
|
-
this.windowElement.addEventListener("dragover", (
|
|
736
|
-
|
|
737
|
-
const t =
|
|
754
|
+
this.windowElement.addEventListener("dragover", (i) => {
|
|
755
|
+
i.preventDefault();
|
|
756
|
+
const t = i.target.matches("bw-pane") ? i.target : i.target.closest("bw-pane");
|
|
738
757
|
if (!t || (t !== this.activeDropPaneEl && (this.activeDropPaneEl && this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = t), t.getAttribute("can-drop") === "false")) return;
|
|
739
|
-
const
|
|
740
|
-
t.setAttribute("drop-area",
|
|
741
|
-
}), this.windowElement.addEventListener("dragleave", (
|
|
742
|
-
|
|
743
|
-
}), this.windowElement.addEventListener("drop", (
|
|
758
|
+
const e = Y(t, i);
|
|
759
|
+
t.setAttribute("drop-area", e);
|
|
760
|
+
}), this.windowElement.addEventListener("dragleave", (i) => {
|
|
761
|
+
i.currentTarget.contains(i.relatedTarget) && i.currentTarget !== i.relatedTarget || this.activeDropPaneEl && (this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null);
|
|
762
|
+
}), this.windowElement.addEventListener("drop", (i) => {
|
|
744
763
|
if (!this.activeDropPaneEl || this.activeDropPaneEl.getAttribute("can-drop") === "false") return;
|
|
745
|
-
const t = this.activeDropPaneEl.getAttribute("sash-id"),
|
|
746
|
-
this.onPaneDrop(
|
|
764
|
+
const t = this.activeDropPaneEl.getAttribute("sash-id"), e = this.rootSash.getById(t);
|
|
765
|
+
this.onPaneDrop(i, e), typeof e.store.onDrop == "function" && e.store.onDrop(i, e), this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null;
|
|
747
766
|
});
|
|
748
767
|
}
|
|
749
768
|
}, dt = !1;
|
|
750
|
-
class
|
|
769
|
+
class B {
|
|
751
770
|
constructor(t) {
|
|
752
771
|
f(this, "windowElement", null);
|
|
753
772
|
f(this, "containerElement", null);
|
|
754
773
|
f(this, "debug", dt);
|
|
755
|
-
let
|
|
756
|
-
t instanceof K ? (
|
|
774
|
+
let e = null;
|
|
775
|
+
t instanceof K ? (e = t, this.rootSash = t) : (e = new j(t), this.rootSash = e.buildSashTree()), this.fitContainer = e.fitContainer;
|
|
757
776
|
}
|
|
758
777
|
frame(t) {
|
|
759
778
|
this.containerElement = t, this.windowElement = this.createWindow(), this.glaze(), this.containerElement.append(this.windowElement);
|
|
@@ -766,58 +785,50 @@ class T {
|
|
|
766
785
|
this.frame(t), this.enableFeatures();
|
|
767
786
|
}
|
|
768
787
|
static assemble(...t) {
|
|
769
|
-
t.forEach((
|
|
770
|
-
|
|
788
|
+
t.forEach((e) => {
|
|
789
|
+
O(this.prototype, e);
|
|
771
790
|
});
|
|
772
791
|
}
|
|
773
792
|
}
|
|
774
|
-
|
|
775
|
-
ot,
|
|
793
|
+
B.assemble(
|
|
776
794
|
st,
|
|
795
|
+
ot,
|
|
777
796
|
nt,
|
|
778
797
|
ht,
|
|
779
798
|
lt,
|
|
780
799
|
rt
|
|
781
800
|
);
|
|
782
|
-
function L(e) {
|
|
783
|
-
if (e.tagName === "BW-PANE")
|
|
784
|
-
return e.getAttribute("sash-id");
|
|
785
|
-
const t = e.closest("bw-pane");
|
|
786
|
-
if (!t)
|
|
787
|
-
throw new Error("[bwin] Pane element not found");
|
|
788
|
-
return t.getAttribute("sash-id");
|
|
789
|
-
}
|
|
790
801
|
const at = {
|
|
791
802
|
label: "",
|
|
792
803
|
className: "bw-glass-action--close",
|
|
793
|
-
onClick: (
|
|
794
|
-
const
|
|
795
|
-
t.removePane(
|
|
804
|
+
onClick: (i, t) => {
|
|
805
|
+
const e = R(i.target);
|
|
806
|
+
t.removePane(e);
|
|
796
807
|
}
|
|
797
808
|
}, ct = {
|
|
798
809
|
label: "",
|
|
799
810
|
className: "bw-glass-action--minimize",
|
|
800
|
-
onClick: (
|
|
801
|
-
const
|
|
802
|
-
if (!
|
|
811
|
+
onClick: (i, t) => {
|
|
812
|
+
const e = t.sillElement;
|
|
813
|
+
if (!e) throw new Error("[bwin] Sill element not found when minimizing");
|
|
803
814
|
const n = m('<button class="bw-minimized-glass" />');
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
n.bwGlassElement =
|
|
815
|
+
e.append(n);
|
|
816
|
+
const s = i.target.closest("bw-pane"), o = i.target.closest("bw-glass"), h = s.getAttribute("sash-id"), l = s.getAttribute("position");
|
|
817
|
+
n.bwGlassElement = o, n.bwOriginalPosition = l, n.bwOriginalBoundingRect = M(s), n.bwOriginalSashId = h, t.removePane(h);
|
|
807
818
|
}
|
|
808
819
|
}, pt = {
|
|
809
820
|
label: "",
|
|
810
821
|
className: "bw-glass-action--maximize",
|
|
811
|
-
onClick: (
|
|
812
|
-
const t =
|
|
822
|
+
onClick: (i) => {
|
|
823
|
+
const t = i.target.closest("bw-pane");
|
|
813
824
|
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 = M(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
|
|
814
825
|
}
|
|
815
826
|
};
|
|
816
|
-
function ut(
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
827
|
+
function ut(i, t) {
|
|
828
|
+
const e = i.left + i.width, n = i.top + i.height, s = t.left + t.width, o = t.top + t.height;
|
|
829
|
+
if (i.left >= s || t.left >= e || i.top >= o || t.top >= n)
|
|
819
830
|
return null;
|
|
820
|
-
const h = Math.max(
|
|
831
|
+
const h = Math.max(i.left, t.left), l = Math.max(i.top, t.top), d = Math.min(e, s), a = Math.min(n, o);
|
|
821
832
|
return {
|
|
822
833
|
left: h,
|
|
823
834
|
top: l,
|
|
@@ -829,53 +840,55 @@ const ft = [ct, pt, at], gt = {
|
|
|
829
840
|
enableActions() {
|
|
830
841
|
this.handleMinimizedGlassClick(), this.observeActionButtons();
|
|
831
842
|
},
|
|
832
|
-
restoreGlass(
|
|
833
|
-
const t =
|
|
834
|
-
let
|
|
835
|
-
if (this.windowElement.querySelectorAll("bw-pane").forEach((
|
|
836
|
-
const
|
|
843
|
+
restoreGlass(i) {
|
|
844
|
+
const t = i.bwOriginalBoundingRect;
|
|
845
|
+
let e = 0, n = null;
|
|
846
|
+
if (this.windowElement.querySelectorAll("bw-pane").forEach((s) => {
|
|
847
|
+
const o = M(s), h = ut(t, o);
|
|
837
848
|
if (h) {
|
|
838
849
|
const l = h.width * h.height;
|
|
839
|
-
l >
|
|
850
|
+
l > e && (e = l, n = s);
|
|
840
851
|
}
|
|
841
852
|
}), n) {
|
|
842
|
-
const
|
|
853
|
+
const s = i.bwOriginalPosition, o = M(n), h = n.getAttribute("sash-id"), l = this.rootSash.getById(h);
|
|
843
854
|
let d = 0;
|
|
844
|
-
if (
|
|
845
|
-
d =
|
|
846
|
-
else if (
|
|
847
|
-
d =
|
|
855
|
+
if (s === r.Left || s === r.Right)
|
|
856
|
+
d = o.width - t.width < l.minWidth ? o.width / 2 : t.width;
|
|
857
|
+
else if (s === r.Top || s === r.Bottom)
|
|
858
|
+
d = o.height - t.height < l.minHeight ? o.height / 2 : t.height;
|
|
848
859
|
else
|
|
849
860
|
throw new Error("[bwin] Invalid position when restoring glass");
|
|
861
|
+
const a = i.bwOriginalSashId;
|
|
850
862
|
this.addPane(n.getAttribute("sash-id"), {
|
|
851
|
-
|
|
863
|
+
id: a,
|
|
864
|
+
position: s,
|
|
852
865
|
size: d
|
|
853
|
-
}).domNode.append(
|
|
866
|
+
}).domNode.append(i.bwGlassElement);
|
|
854
867
|
}
|
|
855
868
|
},
|
|
856
869
|
handleMinimizedGlassClick() {
|
|
857
|
-
this.sillElement.addEventListener("click", (
|
|
858
|
-
if (!
|
|
859
|
-
const t =
|
|
870
|
+
this.sillElement.addEventListener("click", (i) => {
|
|
871
|
+
if (!i.target.matches(".bw-minimized-glass")) return;
|
|
872
|
+
const t = i.target;
|
|
860
873
|
this.restoreGlass(t), t.remove();
|
|
861
874
|
});
|
|
862
875
|
},
|
|
863
876
|
updateDisabledStateOfActionButtons() {
|
|
864
877
|
this.updateDisabledState(".bw-glass-action--close"), this.updateDisabledState(".bw-glass-action--minimize"), this.updateDisabledState(".bw-glass-action--maximize");
|
|
865
878
|
},
|
|
866
|
-
updateDisabledState(
|
|
879
|
+
updateDisabledState(i) {
|
|
867
880
|
if (this.windowElement.querySelectorAll("bw-pane").length === 1) {
|
|
868
|
-
const
|
|
869
|
-
|
|
881
|
+
const e = this.windowElement.querySelector(i);
|
|
882
|
+
e && e.setAttribute("disabled", "");
|
|
870
883
|
} else
|
|
871
|
-
this.windowElement.querySelectorAll(
|
|
872
|
-
|
|
884
|
+
this.windowElement.querySelectorAll(i).forEach((e) => {
|
|
885
|
+
e.removeAttribute("disabled");
|
|
873
886
|
});
|
|
874
887
|
},
|
|
875
888
|
observeActionButtons() {
|
|
876
889
|
this.updateDisabledStateOfActionButtons(), new MutationObserver((t) => {
|
|
877
|
-
t.forEach((
|
|
878
|
-
|
|
890
|
+
t.forEach((e) => {
|
|
891
|
+
e.type === "childList" && this.updateDisabledStateOfActionButtons();
|
|
879
892
|
});
|
|
880
893
|
}).observe(this.windowElement, {
|
|
881
894
|
childList: !0
|
|
@@ -888,43 +901,43 @@ const ft = [ct, pt, at], gt = {
|
|
|
888
901
|
actions: void 0,
|
|
889
902
|
draggable: !0
|
|
890
903
|
};
|
|
891
|
-
class
|
|
904
|
+
class T {
|
|
892
905
|
constructor({
|
|
893
906
|
title: t = N.title,
|
|
894
|
-
content:
|
|
907
|
+
content: e = N.content,
|
|
895
908
|
tabs: n = N.tabs,
|
|
896
|
-
actions:
|
|
897
|
-
draggable:
|
|
909
|
+
actions: s = N.actions,
|
|
910
|
+
draggable: o = N.draggable,
|
|
898
911
|
sash: h,
|
|
899
912
|
binaryWindow: l
|
|
900
913
|
}) {
|
|
901
914
|
f(this, "domNode");
|
|
902
|
-
this.title = t, this.content =
|
|
915
|
+
this.title = t, this.content = e, this.tabs = n, this.actions = s, this.sash = h, this.draggable = o, this.binaryWindow = l, this.build();
|
|
903
916
|
}
|
|
904
917
|
build() {
|
|
905
918
|
const t = document.createElement("bw-glass-header");
|
|
906
919
|
if (Array.isArray(this.tabs) && this.tabs.length > 0)
|
|
907
920
|
t.append(this.createTabs());
|
|
908
921
|
else if (this.title) {
|
|
909
|
-
const
|
|
910
|
-
|
|
922
|
+
const s = document.createElement("bw-glass-title");
|
|
923
|
+
s.append(m(this.title)), t.append(s);
|
|
911
924
|
}
|
|
912
925
|
t.setAttribute("can-drag", this.draggable), t.append(this.createActions());
|
|
913
|
-
const
|
|
914
|
-
n &&
|
|
926
|
+
const e = document.createElement("bw-glass-content"), n = m(this.content);
|
|
927
|
+
n && e.append(n), this.domNode = document.createElement("bw-glass"), this.domNode.append(t, e);
|
|
915
928
|
}
|
|
916
929
|
createTabs() {
|
|
917
930
|
const t = document.createElement("bw-glass-tab-container");
|
|
918
|
-
for (const
|
|
919
|
-
const n = (
|
|
920
|
-
t.append(
|
|
931
|
+
for (const e of this.tabs) {
|
|
932
|
+
const n = (e == null ? void 0 : e.label) ?? e, s = m(`<button class="bw-glass-tab">${n}</button>`);
|
|
933
|
+
t.append(s);
|
|
921
934
|
}
|
|
922
935
|
return t;
|
|
923
936
|
}
|
|
924
937
|
createActions() {
|
|
925
|
-
const t = document.createElement("bw-glass-action-container"),
|
|
926
|
-
for (const n of
|
|
927
|
-
const
|
|
938
|
+
const t = document.createElement("bw-glass-action-container"), e = this.actions === void 0 ? ft : Array.isArray(this.actions) ? this.actions : [];
|
|
939
|
+
for (const n of e) {
|
|
940
|
+
const s = (n == null ? void 0 : n.label) ?? n, o = n.className ? `bw-glass-action ${n.className}` : "bw-glass-action", h = m(`<button class="${o}">${s}</button>`);
|
|
928
941
|
typeof n.onClick == "function" && h.addEventListener("click", (l) => {
|
|
929
942
|
n.onClick(l, this.binaryWindow);
|
|
930
943
|
}), t.append(h);
|
|
@@ -941,33 +954,33 @@ class x {
|
|
|
941
954
|
const wt = {
|
|
942
955
|
activeDragGlassEl: null,
|
|
943
956
|
activeDragGlassPaneCanDrop: !1,
|
|
944
|
-
onPaneDrop(
|
|
957
|
+
onPaneDrop(i, t) {
|
|
945
958
|
if (!this.activeDragGlassEl) return;
|
|
946
|
-
const
|
|
947
|
-
if (
|
|
948
|
-
const n = this.activeDragGlassEl.closest("bw-pane")
|
|
949
|
-
|
|
959
|
+
const e = this.activeDropPaneEl.getAttribute("drop-area");
|
|
960
|
+
if (e === "center") {
|
|
961
|
+
const n = this.activeDragGlassEl.closest("bw-pane");
|
|
962
|
+
this.swapPanes(n, this.activeDropPaneEl);
|
|
950
963
|
return;
|
|
951
964
|
} else {
|
|
952
|
-
const n =
|
|
953
|
-
this.addPane(t.id, { position:
|
|
965
|
+
const n = R(this.activeDragGlassEl);
|
|
966
|
+
this.removePane(n), this.addPane(t.id, { position: e, id: n }).domNode.append(this.activeDragGlassEl);
|
|
954
967
|
}
|
|
955
968
|
},
|
|
956
969
|
enableDrag() {
|
|
957
|
-
document.addEventListener("mousedown", (
|
|
958
|
-
if (
|
|
959
|
-
if (
|
|
960
|
-
|
|
970
|
+
document.addEventListener("mousedown", (i) => {
|
|
971
|
+
if (i.button !== 0 || !i.target.matches("bw-glass-header")) return;
|
|
972
|
+
if (i.target.getAttribute("can-drag") === "false") {
|
|
973
|
+
i.preventDefault();
|
|
961
974
|
return;
|
|
962
975
|
}
|
|
963
|
-
const
|
|
964
|
-
|
|
976
|
+
const e = i.target.closest("bw-glass");
|
|
977
|
+
e.setAttribute("draggable", !0), this.activeDragGlassEl = e;
|
|
965
978
|
}), document.addEventListener("mouseup", () => {
|
|
966
979
|
this.activeDragGlassEl && (this.activeDragGlassEl.removeAttribute("draggable"), this.activeDragGlassEl = null);
|
|
967
|
-
}), this.windowElement.addEventListener("dragstart", (
|
|
968
|
-
if (!(
|
|
980
|
+
}), this.windowElement.addEventListener("dragstart", (i) => {
|
|
981
|
+
if (!(i.target instanceof HTMLElement) || !i.target.matches("bw-glass") || !this.activeDragGlassEl)
|
|
969
982
|
return;
|
|
970
|
-
|
|
983
|
+
i.dataTransfer.effectAllowed = "move";
|
|
971
984
|
const t = this.activeDragGlassEl.closest("bw-pane");
|
|
972
985
|
this.activeDragGlassPaneCanDrop = t.getAttribute("can-drop") !== "false", t.setAttribute("can-drop", !1);
|
|
973
986
|
}), this.windowElement.addEventListener("dragend", () => {
|
|
@@ -975,32 +988,32 @@ const wt = {
|
|
|
975
988
|
});
|
|
976
989
|
}
|
|
977
990
|
}, mt = {
|
|
978
|
-
trimMuntin(
|
|
979
|
-
|
|
991
|
+
trimMuntin(i) {
|
|
992
|
+
i.hasAttribute("vertical") ? (i.style.top = `${parseFloat(i.style.top) + this.muntinSize / 2}px`, i.style.height = `${parseFloat(i.style.height) - this.muntinSize}px`) : i.hasAttribute("horizontal") && (i.style.left = `${parseFloat(i.style.left) + this.muntinSize / 2}px`, i.style.width = `${parseFloat(i.style.width) - this.muntinSize}px`);
|
|
980
993
|
},
|
|
981
|
-
onMuntinCreate(
|
|
982
|
-
this.trimMuntin(
|
|
994
|
+
onMuntinCreate(i) {
|
|
995
|
+
this.trimMuntin(i);
|
|
983
996
|
},
|
|
984
|
-
onMuntinUpdate(
|
|
985
|
-
this.trimMuntin(
|
|
997
|
+
onMuntinUpdate(i) {
|
|
998
|
+
this.trimMuntin(i);
|
|
986
999
|
}
|
|
987
1000
|
};
|
|
988
|
-
class bt extends
|
|
1001
|
+
class bt extends B {
|
|
989
1002
|
constructor() {
|
|
990
1003
|
super(...arguments);
|
|
991
1004
|
f(this, "sillElement", null);
|
|
992
1005
|
}
|
|
993
1006
|
frame() {
|
|
994
1007
|
super.frame(...arguments);
|
|
995
|
-
const
|
|
996
|
-
this.windowElement.append(
|
|
1008
|
+
const e = m("<bw-sill />");
|
|
1009
|
+
this.windowElement.append(e), this.sillElement = e;
|
|
997
1010
|
}
|
|
998
1011
|
enableFeatures() {
|
|
999
1012
|
super.enableFeatures(), this.enableDrag(), this.enableActions();
|
|
1000
1013
|
}
|
|
1001
|
-
onPaneCreate(
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1014
|
+
onPaneCreate(e, n) {
|
|
1015
|
+
const s = new T({ ...n.store, sash: n, binaryWindow: this });
|
|
1016
|
+
e.innerHTML = "", e.append(s.domNode), this.debug && s.contentElement.prepend(`${n.id}`);
|
|
1004
1017
|
}
|
|
1005
1018
|
onPaneUpdate() {
|
|
1006
1019
|
}
|
|
@@ -1011,8 +1024,8 @@ class bt extends T {
|
|
|
1011
1024
|
* @param {Object} props - The pane and glass properties grouped together
|
|
1012
1025
|
* @returns {Sash} - The newly created Sash
|
|
1013
1026
|
*/
|
|
1014
|
-
addPane(
|
|
1015
|
-
const { position:
|
|
1027
|
+
addPane(e, n) {
|
|
1028
|
+
const { position: s, size: o, id: h, ...l } = n, d = super.addPane(e, { position: s, size: o, id: h }), a = new T({ ...l, sash: d, binaryWindow: this });
|
|
1016
1029
|
return d.domNode.append(a.domNode), d;
|
|
1017
1030
|
}
|
|
1018
1031
|
}
|
|
@@ -1021,7 +1034,7 @@ export {
|
|
|
1021
1034
|
ft as BUILTIN_ACTIONS,
|
|
1022
1035
|
bt as BinaryWindow,
|
|
1023
1036
|
j as ConfigRoot,
|
|
1024
|
-
|
|
1037
|
+
B as Frame,
|
|
1025
1038
|
r as Position,
|
|
1026
1039
|
g as Sash,
|
|
1027
1040
|
K as SashConfig
|