bwin 0.2.3 → 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 +406 -381
- package/package.json +1 -1
package/dist/bwin.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var f = (
|
|
4
|
-
function
|
|
5
|
-
const
|
|
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
6
|
return `rgba(${n}, ${s}, ${o}, ${h})`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
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
|
|
11
|
+
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = "0123456789";
|
|
12
12
|
let s = "";
|
|
13
|
-
for (let o = 0; o <
|
|
14
|
-
const h = Math.floor(Math.random() *
|
|
15
|
-
s +=
|
|
13
|
+
for (let o = 0; o < i; o++) {
|
|
14
|
+
const h = Math.floor(Math.random() * e.length);
|
|
15
|
+
s += e[h];
|
|
16
16
|
}
|
|
17
17
|
s += "-";
|
|
18
18
|
for (let o = 0; o < t; o++) {
|
|
@@ -21,65 +21,65 @@ function z(e = 2, t = 3) {
|
|
|
21
21
|
}
|
|
22
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
|
|
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 O(
|
|
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
|
|
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
|
|
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,41 +102,41 @@ function F(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
|
|
109
|
-
return t /
|
|
108
|
+
function F({ width: i, height: t, x: e }) {
|
|
109
|
+
return t / i * e;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
111
|
+
function _({ width: i, height: t, y: e }) {
|
|
112
|
+
return i / t * e;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
return t - t /
|
|
114
|
+
function k({ width: i, height: t, x: e }) {
|
|
115
|
+
return t - t / i * e;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
return
|
|
117
|
+
function U({ width: i, height: t, y: e }) {
|
|
118
|
+
return i - i / t * e;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
const n =
|
|
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
122
|
if (h < 0 || h > s || l < 0 || l > o)
|
|
123
123
|
return r.Outside;
|
|
124
|
-
const d = 0.3, a =
|
|
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
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
|
-
const
|
|
127
|
+
const X = 100, q = 100, w = {
|
|
128
128
|
left: 0,
|
|
129
129
|
top: 0,
|
|
130
130
|
width: 150,
|
|
131
131
|
height: 150,
|
|
132
132
|
// Initial min values, real min width/height is calculated based on children
|
|
133
|
-
minWidth:
|
|
134
|
-
minHeight:
|
|
133
|
+
minWidth: X,
|
|
134
|
+
minHeight: q
|
|
135
135
|
};
|
|
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
141
|
height: s = w.height,
|
|
142
142
|
minWidth: o = w.minWidth,
|
|
@@ -146,12 +146,12 @@ class g {
|
|
|
146
146
|
position: a,
|
|
147
147
|
id: c
|
|
148
148
|
} = w) {
|
|
149
|
-
if (this.id = c ??
|
|
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,23 +183,23 @@ class g {
|
|
|
183
183
|
return this.children.find((t) => t.position === r.Bottom);
|
|
184
184
|
}
|
|
185
185
|
getChildren() {
|
|
186
|
-
let t = null,
|
|
186
|
+
let t = null, e = null, n = null, s = null;
|
|
187
187
|
for (const o of this.children)
|
|
188
|
-
o.position === r.Left ? t = o : o.position === r.Right ?
|
|
189
|
-
return [n,
|
|
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 (s &&
|
|
202
|
-
const o = s.calcMinWidth() +
|
|
200
|
+
const [t, e, n, s] = this.getChildren();
|
|
201
|
+
if (s && e) {
|
|
202
|
+
const o = s.calcMinWidth() + e.calcMinWidth();
|
|
203
203
|
return Math.max(this.minWidth, o);
|
|
204
204
|
}
|
|
205
205
|
if (t && n) {
|
|
@@ -210,9 +210,9 @@ class g {
|
|
|
210
210
|
calcMinHeight() {
|
|
211
211
|
if (this.isLeaf())
|
|
212
212
|
return this.minHeight;
|
|
213
|
-
const [t,
|
|
214
|
-
if (s &&
|
|
215
|
-
const o = Math.max(s.calcMinHeight(),
|
|
213
|
+
const [t, e, n, s] = this.getChildren();
|
|
214
|
+
if (s && e) {
|
|
215
|
+
const o = Math.max(s.calcMinHeight(), e.calcMinHeight());
|
|
216
216
|
return Math.max(this.minHeight, o);
|
|
217
217
|
}
|
|
218
218
|
if (t && n) {
|
|
@@ -224,18 +224,25 @@ class g {
|
|
|
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,78 +251,78 @@ 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
272
|
const [n, s, o, h] = this.getChildren();
|
|
266
|
-
n && o && (n.top +=
|
|
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
281
|
const [n, s, o, h] = this.getChildren();
|
|
275
|
-
h && s && (h.left +=
|
|
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
290
|
const [n, s, o, h] = this.getChildren();
|
|
284
291
|
if (h && s) {
|
|
285
|
-
const l = h.width + s.width, d =
|
|
292
|
+
const l = h.width + s.width, d = e * (h.width / l), a = l + e;
|
|
286
293
|
let c = h.width + d, p = a - c, u = s.left + d;
|
|
287
|
-
const
|
|
288
|
-
|
|
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 && o && (n.width +=
|
|
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
305
|
const [n, s, o, h] = this.getChildren();
|
|
299
306
|
if (n && o) {
|
|
300
|
-
const l = n.height + o.height, d =
|
|
307
|
+
const l = n.height + o.height, d = e * (n.height / l), a = l + e;
|
|
301
308
|
let c = n.height + d, p = a - c, u = o.top + d;
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
c <
|
|
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
313
|
n.height = c, o.height = p, o.top = u;
|
|
307
314
|
}
|
|
308
|
-
h && s && (h.height +=
|
|
315
|
+
h && s && (h.height += e, s.height += e);
|
|
309
316
|
}
|
|
310
317
|
}
|
|
311
318
|
const v = {
|
|
312
319
|
size: "50%",
|
|
313
320
|
position: r.Left
|
|
314
321
|
};
|
|
315
|
-
class
|
|
322
|
+
class A {
|
|
316
323
|
constructor({
|
|
317
324
|
parentRect: t,
|
|
318
|
-
children:
|
|
325
|
+
children: e,
|
|
319
326
|
siblingConfigNode: n,
|
|
320
327
|
id: s,
|
|
321
328
|
minWidth: o,
|
|
@@ -328,21 +335,21 @@ class R {
|
|
|
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
|
}
|
|
343
350
|
getSize(t) {
|
|
344
351
|
if (!this.siblingConfigNode)
|
|
345
|
-
return
|
|
352
|
+
return b(t);
|
|
346
353
|
if (!t) {
|
|
347
354
|
if (this.siblingConfigNode.size < 1)
|
|
348
355
|
return 1 - this.siblingConfigNode.size;
|
|
@@ -351,17 +358,17 @@ class R {
|
|
|
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 R {
|
|
|
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,11 +420,11 @@ class R {
|
|
|
413
420
|
throw new Error(`[bwin] Invalid config value: ${t}`);
|
|
414
421
|
}
|
|
415
422
|
}
|
|
416
|
-
createPrimaryConfigNode({ size: t, position:
|
|
417
|
-
return new
|
|
423
|
+
createPrimaryConfigNode({ size: t, position: e, children: n, id: s, minWidth: o, minHeight: h, ...l }) {
|
|
424
|
+
return new A({
|
|
418
425
|
parentRect: this,
|
|
419
426
|
size: t ?? v.size,
|
|
420
|
-
position:
|
|
427
|
+
position: e ?? v.position,
|
|
421
428
|
children: n,
|
|
422
429
|
id: s,
|
|
423
430
|
minWidth: o,
|
|
@@ -425,11 +432,11 @@ class R {
|
|
|
425
432
|
...l
|
|
426
433
|
});
|
|
427
434
|
}
|
|
428
|
-
createSecondaryConfigNode({ size: t, position:
|
|
429
|
-
return new
|
|
435
|
+
createSecondaryConfigNode({ size: t, position: e, children: n, id: s, minWidth: o, minHeight: h, ...l }, d) {
|
|
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
442
|
id: s,
|
|
@@ -442,38 +449,38 @@ class R {
|
|
|
442
449
|
const t = this.createSash();
|
|
443
450
|
if (!Array.isArray(this.children) || this.children.length === 0)
|
|
444
451
|
return t;
|
|
445
|
-
const
|
|
452
|
+
const e = this.normConfig(this.children[0]), n = this.normConfig(this.children.at(1));
|
|
446
453
|
let s, o;
|
|
447
|
-
return !
|
|
448
|
-
|
|
454
|
+
return !e.size && !e.position && n ? (n.position || (n.position = r.Right), s = this.createPrimaryConfigNode(n), o = this.createSecondaryConfigNode(
|
|
455
|
+
e,
|
|
449
456
|
s
|
|
450
|
-
)) : (s = this.createPrimaryConfigNode(
|
|
457
|
+
)) : (s = this.createPrimaryConfigNode(e), o = this.createSecondaryConfigNode(
|
|
451
458
|
n,
|
|
452
459
|
s
|
|
453
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
|
-
class
|
|
469
|
+
class j extends A {
|
|
463
470
|
constructor({
|
|
464
471
|
id: t,
|
|
465
|
-
children:
|
|
466
|
-
width: n =
|
|
467
|
-
height: s =
|
|
468
|
-
fitContainer: o =
|
|
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
486
|
parentRect: { width: n, height: s },
|
|
@@ -481,120 +488,140 @@ class K extends R {
|
|
|
481
488
|
}), this.fitContainer = o;
|
|
482
489
|
}
|
|
483
490
|
}
|
|
484
|
-
class
|
|
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
|
|
496
|
+
function V(i) {
|
|
490
497
|
const t = document.createElement("bw-pane");
|
|
491
|
-
return t.style.top = `${
|
|
492
|
-
}
|
|
493
|
-
function J(
|
|
494
|
-
const t =
|
|
495
|
-
return t.style.top = `${
|
|
496
|
-
}
|
|
497
|
-
function Q(
|
|
498
|
-
const
|
|
499
|
-
let
|
|
500
|
-
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}), o = new g({
|
|
508
|
-
top: e.top,
|
|
509
|
-
left: e.left + s.width,
|
|
510
|
-
width: e.width - n,
|
|
511
|
-
height: e.height,
|
|
512
|
-
position: r.Right
|
|
513
|
-
}), h = M(o);
|
|
514
|
-
return o.domNode = h, b(h, e.domNode), e.addChild(s), e.addChild(o), s;
|
|
515
|
-
}
|
|
516
|
-
function Z(e, { size: t }) {
|
|
517
|
-
const i = C(t);
|
|
518
|
-
let n = e.width / 2;
|
|
519
|
-
i && (i < 1 ? n = e.width * i : n = i);
|
|
520
|
-
const s = new g({
|
|
521
|
-
left: e.left,
|
|
522
|
-
top: e.top,
|
|
523
|
-
width: e.width - n,
|
|
524
|
-
height: e.height,
|
|
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;
|
|
499
|
+
}
|
|
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;
|
|
503
|
+
}
|
|
504
|
+
function Q(i, { size: t, id: e }) {
|
|
505
|
+
const n = b(t);
|
|
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,
|
|
525
514
|
position: r.Left
|
|
526
|
-
}),
|
|
527
|
-
|
|
528
|
-
top:
|
|
529
|
-
|
|
530
|
-
|
|
515
|
+
}), h = new g({
|
|
516
|
+
id: i.id,
|
|
517
|
+
top: i.top,
|
|
518
|
+
left: i.left + o.width,
|
|
519
|
+
width: i.width - s,
|
|
520
|
+
height: i.height,
|
|
521
|
+
position: r.Right,
|
|
522
|
+
domNode: i.domNode
|
|
523
|
+
});
|
|
524
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), o;
|
|
525
|
+
}
|
|
526
|
+
function Z(i, { size: t, id: e }) {
|
|
527
|
+
const n = b(t);
|
|
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,
|
|
536
|
+
position: r.Left,
|
|
537
|
+
domNode: i.domNode
|
|
538
|
+
}), h = new g({
|
|
539
|
+
id: e,
|
|
540
|
+
left: i.left + o.width,
|
|
541
|
+
top: i.top,
|
|
542
|
+
width: s,
|
|
543
|
+
height: i.height,
|
|
531
544
|
position: r.Right
|
|
532
|
-
})
|
|
533
|
-
return
|
|
534
|
-
}
|
|
535
|
-
function tt(
|
|
536
|
-
const
|
|
537
|
-
let
|
|
538
|
-
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}), o = new g({
|
|
546
|
-
left: e.left,
|
|
547
|
-
top: e.top + s.height,
|
|
548
|
-
width: e.width,
|
|
549
|
-
height: e.height - n,
|
|
550
|
-
position: r.Bottom
|
|
551
|
-
}), h = M(o);
|
|
552
|
-
return o.domNode = h, b(h, e.domNode), e.addChild(s), e.addChild(o), s;
|
|
553
|
-
}
|
|
554
|
-
function et(e, { size: t }) {
|
|
555
|
-
const i = C(t);
|
|
556
|
-
let n = e.height / 2;
|
|
557
|
-
i && (i < 1 ? n = e.height * i : n = i);
|
|
558
|
-
const s = new g({
|
|
559
|
-
top: e.top,
|
|
560
|
-
left: e.left,
|
|
561
|
-
width: e.width,
|
|
562
|
-
height: e.height - n,
|
|
545
|
+
});
|
|
546
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), h;
|
|
547
|
+
}
|
|
548
|
+
function tt(i, { size: t, id: e }) {
|
|
549
|
+
const n = b(t);
|
|
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,
|
|
563
558
|
position: r.Top
|
|
564
|
-
}),
|
|
565
|
-
|
|
566
|
-
left:
|
|
567
|
-
|
|
568
|
-
|
|
559
|
+
}), h = new g({
|
|
560
|
+
id: i.id,
|
|
561
|
+
left: i.left,
|
|
562
|
+
top: i.top + o.height,
|
|
563
|
+
width: i.width,
|
|
564
|
+
height: i.height - s,
|
|
565
|
+
position: r.Bottom,
|
|
566
|
+
domNode: i.domNode
|
|
567
|
+
});
|
|
568
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), o;
|
|
569
|
+
}
|
|
570
|
+
function it(i, { size: t, id: e }) {
|
|
571
|
+
const n = b(t);
|
|
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,
|
|
580
|
+
position: r.Top,
|
|
581
|
+
domNode: i.domNode
|
|
582
|
+
}), h = new g({
|
|
583
|
+
id: e,
|
|
584
|
+
top: i.top + o.height,
|
|
585
|
+
left: i.left,
|
|
586
|
+
width: i.width,
|
|
587
|
+
height: s,
|
|
569
588
|
position: r.Bottom
|
|
570
|
-
})
|
|
571
|
-
return
|
|
589
|
+
});
|
|
590
|
+
return i.addChild(o), i.addChild(h), i.domNode = null, i.id = C(), h;
|
|
572
591
|
}
|
|
573
|
-
function
|
|
592
|
+
function et(i, { position: t, size: e, id: n, minWidth: s, minHeight: o }) {
|
|
574
593
|
if (t === r.Left)
|
|
575
|
-
return Q(
|
|
594
|
+
return Q(i, { size: e, id: n });
|
|
576
595
|
if (t === r.Right)
|
|
577
|
-
return Z(
|
|
596
|
+
return Z(i, { size: e, id: n });
|
|
578
597
|
if (t === r.Top)
|
|
579
|
-
return tt(
|
|
598
|
+
return tt(i, { size: e, id: n });
|
|
580
599
|
if (t === r.Bottom)
|
|
581
|
-
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");
|
|
582
609
|
}
|
|
583
610
|
const nt = {
|
|
584
|
-
createPane(
|
|
585
|
-
const t =
|
|
586
|
-
return
|
|
611
|
+
createPane(i) {
|
|
612
|
+
const t = V(i);
|
|
613
|
+
return i.store.droppable === !1 && t.setAttribute("can-drop", "false"), t;
|
|
587
614
|
},
|
|
588
615
|
// Intended to be overridden
|
|
589
|
-
onPaneCreate(
|
|
590
|
-
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)));
|
|
591
618
|
},
|
|
592
|
-
updatePane(
|
|
593
|
-
return J(
|
|
619
|
+
updatePane(i) {
|
|
620
|
+
return J(i);
|
|
594
621
|
},
|
|
595
622
|
// Intended to be overridden
|
|
596
|
-
onPaneUpdate(
|
|
597
|
-
this != null && this.debug && (
|
|
623
|
+
onPaneUpdate(i, t) {
|
|
624
|
+
this != null && this.debug && (i.innerHTML = "", i.append(x(i)));
|
|
598
625
|
},
|
|
599
626
|
/**
|
|
600
627
|
* Add a pane into the target pane. The two panes become next to each other
|
|
@@ -603,72 +630,76 @@ const nt = {
|
|
|
603
630
|
* @param {'top'|'right'|'bottom'|'left'} position - The position of the new pane relative to the target pane
|
|
604
631
|
* @returns {Sash} - The newly created sash
|
|
605
632
|
*/
|
|
606
|
-
addPane(
|
|
633
|
+
addPane(i, { position: t, size: e, id: n }) {
|
|
607
634
|
if (!t) throw new Error("[bwin] Position is required when adding pane");
|
|
608
|
-
const
|
|
609
|
-
if (!
|
|
610
|
-
const
|
|
611
|
-
return
|
|
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;
|
|
612
639
|
},
|
|
613
640
|
/**
|
|
614
641
|
* Remove a pane
|
|
615
642
|
*
|
|
616
643
|
* @param {string} sashId - The Sash ID of the pane to be removed
|
|
617
644
|
*/
|
|
618
|
-
removePane(
|
|
619
|
-
const t = this.rootSash.getDescendantParentById(
|
|
645
|
+
removePane(i) {
|
|
646
|
+
const t = this.rootSash.getDescendantParentById(i);
|
|
620
647
|
if (!t) throw new Error("[bwin] Parent sash not found when removing pane");
|
|
621
|
-
const
|
|
622
|
-
|
|
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);
|
|
623
654
|
}
|
|
624
655
|
};
|
|
625
|
-
function x(
|
|
656
|
+
function x(i) {
|
|
626
657
|
const t = document.createElement("pre");
|
|
627
658
|
t.style.fontSize = "10px";
|
|
628
|
-
const
|
|
629
|
-
${
|
|
630
|
-
${
|
|
631
|
-
top: ${
|
|
632
|
-
left: ${
|
|
633
|
-
width: ${
|
|
634
|
-
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}
|
|
635
666
|
`;
|
|
636
|
-
return t.innerHTML =
|
|
667
|
+
return t.innerHTML = e.trim(), t;
|
|
637
668
|
}
|
|
638
669
|
const st = {
|
|
639
670
|
createWindow() {
|
|
640
|
-
const
|
|
641
|
-
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;
|
|
642
673
|
},
|
|
643
674
|
glaze() {
|
|
644
|
-
this.rootSash.walk((
|
|
675
|
+
this.rootSash.walk((i) => {
|
|
645
676
|
let t = null;
|
|
646
|
-
|
|
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;
|
|
647
678
|
});
|
|
648
679
|
},
|
|
649
680
|
update() {
|
|
650
681
|
this.windowElement.style.width = `${this.rootSash.width}px`, this.windowElement.style.height = `${this.rootSash.height}px`;
|
|
651
|
-
const
|
|
652
|
-
this.windowElement.querySelectorAll("[sash-id]").forEach((
|
|
653
|
-
const n =
|
|
654
|
-
t.push(n),
|
|
655
|
-
}), this.rootSash.walk((
|
|
656
|
-
|
|
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));
|
|
657
688
|
});
|
|
658
689
|
}
|
|
659
690
|
}, ot = {
|
|
660
691
|
muntinSize: 4,
|
|
661
|
-
createMuntin(
|
|
662
|
-
const t = document.createElement("bw-muntin"),
|
|
663
|
-
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;
|
|
664
695
|
},
|
|
665
|
-
onMuntinCreate(
|
|
696
|
+
onMuntinCreate(i, t) {
|
|
666
697
|
},
|
|
667
|
-
updateMuntin(
|
|
668
|
-
const t =
|
|
669
|
-
|
|
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`);
|
|
670
701
|
},
|
|
671
|
-
onMuntinUpdate(
|
|
702
|
+
onMuntinUpdate(i, t) {
|
|
672
703
|
}
|
|
673
704
|
}, ht = {
|
|
674
705
|
fitContainer: !1,
|
|
@@ -677,8 +708,8 @@ const st = {
|
|
|
677
708
|
},
|
|
678
709
|
enableFitContainer() {
|
|
679
710
|
new ResizeObserver((t) => {
|
|
680
|
-
for (const
|
|
681
|
-
|
|
711
|
+
for (const e of t)
|
|
712
|
+
e.target === this.containerElement && this.fitContainer && this.fit();
|
|
682
713
|
}).observe(this.containerElement);
|
|
683
714
|
}
|
|
684
715
|
}, rt = {
|
|
@@ -694,21 +725,21 @@ const st = {
|
|
|
694
725
|
document.body.classList.remove("body--bw-resize-x"), document.body.classList.remove("body--bw-resize-y");
|
|
695
726
|
},
|
|
696
727
|
enableResize() {
|
|
697
|
-
document.addEventListener("mousedown", (
|
|
698
|
-
if (
|
|
699
|
-
const t =
|
|
700
|
-
this.activeMuntinSash = this.rootSash.getById(t), this.activeMuntinSash && (this.isResizeStarted = !0, this.lastX =
|
|
701
|
-
}), 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) => {
|
|
702
733
|
if (!this.isResizeStarted || !this.activeMuntinSash) return;
|
|
703
|
-
const [t,
|
|
704
|
-
if (o && s &&
|
|
705
|
-
const l =
|
|
706
|
-
if (l > 0 && a <=
|
|
707
|
-
s.width = d,
|
|
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;
|
|
708
739
|
} else if (h && t && n) {
|
|
709
|
-
const l =
|
|
740
|
+
const l = i.pageY - this.lastY, d = t.height + l, a = n.height - l;
|
|
710
741
|
if (l > 0 && a <= n.calcMinHeight() || l < 0 && d <= t.calcMinHeight()) return;
|
|
711
|
-
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;
|
|
712
743
|
}
|
|
713
744
|
}), document.addEventListener("mouseup", () => {
|
|
714
745
|
this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
|
|
@@ -717,31 +748,31 @@ const st = {
|
|
|
717
748
|
}, lt = {
|
|
718
749
|
activeDropPaneEl: null,
|
|
719
750
|
// Intended to be overridden in `BinaryWindow` class
|
|
720
|
-
onPaneDrop(
|
|
751
|
+
onPaneDrop(i, t) {
|
|
721
752
|
},
|
|
722
753
|
enableDrop() {
|
|
723
|
-
this.windowElement.addEventListener("dragover", (
|
|
724
|
-
|
|
725
|
-
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");
|
|
726
757
|
if (!t || (t !== this.activeDropPaneEl && (this.activeDropPaneEl && this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = t), t.getAttribute("can-drop") === "false")) return;
|
|
727
|
-
const
|
|
728
|
-
t.setAttribute("drop-area",
|
|
729
|
-
}), this.windowElement.addEventListener("dragleave", (
|
|
730
|
-
|
|
731
|
-
}), 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) => {
|
|
732
763
|
if (!this.activeDropPaneEl || this.activeDropPaneEl.getAttribute("can-drop") === "false") return;
|
|
733
|
-
const t = this.activeDropPaneEl.getAttribute("sash-id"),
|
|
734
|
-
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;
|
|
735
766
|
});
|
|
736
767
|
}
|
|
737
768
|
}, dt = !1;
|
|
738
|
-
class
|
|
769
|
+
class B {
|
|
739
770
|
constructor(t) {
|
|
740
771
|
f(this, "windowElement", null);
|
|
741
772
|
f(this, "containerElement", null);
|
|
742
773
|
f(this, "debug", dt);
|
|
743
|
-
let
|
|
744
|
-
t instanceof
|
|
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;
|
|
745
776
|
}
|
|
746
777
|
frame(t) {
|
|
747
778
|
this.containerElement = t, this.windowElement = this.createWindow(), this.glaze(), this.containerElement.append(this.windowElement);
|
|
@@ -754,12 +785,12 @@ class L {
|
|
|
754
785
|
this.frame(t), this.enableFeatures();
|
|
755
786
|
}
|
|
756
787
|
static assemble(...t) {
|
|
757
|
-
t.forEach((
|
|
758
|
-
O(this.prototype,
|
|
788
|
+
t.forEach((e) => {
|
|
789
|
+
O(this.prototype, e);
|
|
759
790
|
});
|
|
760
791
|
}
|
|
761
792
|
}
|
|
762
|
-
|
|
793
|
+
B.assemble(
|
|
763
794
|
st,
|
|
764
795
|
ot,
|
|
765
796
|
nt,
|
|
@@ -767,45 +798,37 @@ L.assemble(
|
|
|
767
798
|
lt,
|
|
768
799
|
rt
|
|
769
800
|
);
|
|
770
|
-
function B(e) {
|
|
771
|
-
if (e.tagName === "BW-PANE")
|
|
772
|
-
return e.getAttribute("sash-id");
|
|
773
|
-
const t = e.closest("bw-pane");
|
|
774
|
-
if (!t)
|
|
775
|
-
throw new Error("[bwin] Pane element not found");
|
|
776
|
-
return t.getAttribute("sash-id");
|
|
777
|
-
}
|
|
778
801
|
const at = {
|
|
779
802
|
label: "",
|
|
780
803
|
className: "bw-glass-action--close",
|
|
781
|
-
onClick: (
|
|
782
|
-
const
|
|
783
|
-
t.removePane(
|
|
804
|
+
onClick: (i, t) => {
|
|
805
|
+
const e = R(i.target);
|
|
806
|
+
t.removePane(e);
|
|
784
807
|
}
|
|
785
808
|
}, ct = {
|
|
786
809
|
label: "",
|
|
787
810
|
className: "bw-glass-action--minimize",
|
|
788
|
-
onClick: (
|
|
789
|
-
const
|
|
790
|
-
if (!
|
|
811
|
+
onClick: (i, t) => {
|
|
812
|
+
const e = t.sillElement;
|
|
813
|
+
if (!e) throw new Error("[bwin] Sill element not found when minimizing");
|
|
791
814
|
const n = m('<button class="bw-minimized-glass" />');
|
|
792
|
-
|
|
793
|
-
const s =
|
|
794
|
-
n.bwGlassElement = o, n.bwOriginalPosition = l, n.bwOriginalBoundingRect =
|
|
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);
|
|
795
818
|
}
|
|
796
819
|
}, pt = {
|
|
797
820
|
label: "",
|
|
798
821
|
className: "bw-glass-action--maximize",
|
|
799
|
-
onClick: (
|
|
800
|
-
const t =
|
|
801
|
-
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 =
|
|
822
|
+
onClick: (i) => {
|
|
823
|
+
const t = i.target.closest("bw-pane");
|
|
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%");
|
|
802
825
|
}
|
|
803
826
|
};
|
|
804
|
-
function ut(
|
|
805
|
-
const
|
|
806
|
-
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)
|
|
807
830
|
return null;
|
|
808
|
-
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);
|
|
809
832
|
return {
|
|
810
833
|
left: h,
|
|
811
834
|
top: l,
|
|
@@ -817,17 +840,17 @@ const ft = [ct, pt, at], gt = {
|
|
|
817
840
|
enableActions() {
|
|
818
841
|
this.handleMinimizedGlassClick(), this.observeActionButtons();
|
|
819
842
|
},
|
|
820
|
-
restoreGlass(
|
|
821
|
-
const t =
|
|
822
|
-
let
|
|
843
|
+
restoreGlass(i) {
|
|
844
|
+
const t = i.bwOriginalBoundingRect;
|
|
845
|
+
let e = 0, n = null;
|
|
823
846
|
if (this.windowElement.querySelectorAll("bw-pane").forEach((s) => {
|
|
824
|
-
const o =
|
|
847
|
+
const o = M(s), h = ut(t, o);
|
|
825
848
|
if (h) {
|
|
826
849
|
const l = h.width * h.height;
|
|
827
|
-
l >
|
|
850
|
+
l > e && (e = l, n = s);
|
|
828
851
|
}
|
|
829
852
|
}), n) {
|
|
830
|
-
const s =
|
|
853
|
+
const s = i.bwOriginalPosition, o = M(n), h = n.getAttribute("sash-id"), l = this.rootSash.getById(h);
|
|
831
854
|
let d = 0;
|
|
832
855
|
if (s === r.Left || s === r.Right)
|
|
833
856
|
d = o.width - t.width < l.minWidth ? o.width / 2 : t.width;
|
|
@@ -835,35 +858,37 @@ const ft = [ct, pt, at], gt = {
|
|
|
835
858
|
d = o.height - t.height < l.minHeight ? o.height / 2 : t.height;
|
|
836
859
|
else
|
|
837
860
|
throw new Error("[bwin] Invalid position when restoring glass");
|
|
861
|
+
const a = i.bwOriginalSashId;
|
|
838
862
|
this.addPane(n.getAttribute("sash-id"), {
|
|
863
|
+
id: a,
|
|
839
864
|
position: s,
|
|
840
865
|
size: d
|
|
841
|
-
}).domNode.append(
|
|
866
|
+
}).domNode.append(i.bwGlassElement);
|
|
842
867
|
}
|
|
843
868
|
},
|
|
844
869
|
handleMinimizedGlassClick() {
|
|
845
|
-
this.sillElement.addEventListener("click", (
|
|
846
|
-
if (!
|
|
847
|
-
const t =
|
|
870
|
+
this.sillElement.addEventListener("click", (i) => {
|
|
871
|
+
if (!i.target.matches(".bw-minimized-glass")) return;
|
|
872
|
+
const t = i.target;
|
|
848
873
|
this.restoreGlass(t), t.remove();
|
|
849
874
|
});
|
|
850
875
|
},
|
|
851
876
|
updateDisabledStateOfActionButtons() {
|
|
852
877
|
this.updateDisabledState(".bw-glass-action--close"), this.updateDisabledState(".bw-glass-action--minimize"), this.updateDisabledState(".bw-glass-action--maximize");
|
|
853
878
|
},
|
|
854
|
-
updateDisabledState(
|
|
879
|
+
updateDisabledState(i) {
|
|
855
880
|
if (this.windowElement.querySelectorAll("bw-pane").length === 1) {
|
|
856
|
-
const
|
|
857
|
-
|
|
881
|
+
const e = this.windowElement.querySelector(i);
|
|
882
|
+
e && e.setAttribute("disabled", "");
|
|
858
883
|
} else
|
|
859
|
-
this.windowElement.querySelectorAll(
|
|
860
|
-
|
|
884
|
+
this.windowElement.querySelectorAll(i).forEach((e) => {
|
|
885
|
+
e.removeAttribute("disabled");
|
|
861
886
|
});
|
|
862
887
|
},
|
|
863
888
|
observeActionButtons() {
|
|
864
889
|
this.updateDisabledStateOfActionButtons(), new MutationObserver((t) => {
|
|
865
|
-
t.forEach((
|
|
866
|
-
|
|
890
|
+
t.forEach((e) => {
|
|
891
|
+
e.type === "childList" && this.updateDisabledStateOfActionButtons();
|
|
867
892
|
});
|
|
868
893
|
}).observe(this.windowElement, {
|
|
869
894
|
childList: !0
|
|
@@ -879,7 +904,7 @@ const ft = [ct, pt, at], gt = {
|
|
|
879
904
|
class T {
|
|
880
905
|
constructor({
|
|
881
906
|
title: t = N.title,
|
|
882
|
-
content:
|
|
907
|
+
content: e = N.content,
|
|
883
908
|
tabs: n = N.tabs,
|
|
884
909
|
actions: s = N.actions,
|
|
885
910
|
draggable: o = N.draggable,
|
|
@@ -887,7 +912,7 @@ class T {
|
|
|
887
912
|
binaryWindow: l
|
|
888
913
|
}) {
|
|
889
914
|
f(this, "domNode");
|
|
890
|
-
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();
|
|
891
916
|
}
|
|
892
917
|
build() {
|
|
893
918
|
const t = document.createElement("bw-glass-header");
|
|
@@ -898,20 +923,20 @@ class T {
|
|
|
898
923
|
s.append(m(this.title)), t.append(s);
|
|
899
924
|
}
|
|
900
925
|
t.setAttribute("can-drag", this.draggable), t.append(this.createActions());
|
|
901
|
-
const
|
|
902
|
-
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);
|
|
903
928
|
}
|
|
904
929
|
createTabs() {
|
|
905
930
|
const t = document.createElement("bw-glass-tab-container");
|
|
906
|
-
for (const
|
|
907
|
-
const n = (
|
|
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>`);
|
|
908
933
|
t.append(s);
|
|
909
934
|
}
|
|
910
935
|
return t;
|
|
911
936
|
}
|
|
912
937
|
createActions() {
|
|
913
|
-
const t = document.createElement("bw-glass-action-container"),
|
|
914
|
-
for (const n of
|
|
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) {
|
|
915
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>`);
|
|
916
941
|
typeof n.onClick == "function" && h.addEventListener("click", (l) => {
|
|
917
942
|
n.onClick(l, this.binaryWindow);
|
|
@@ -929,33 +954,33 @@ class T {
|
|
|
929
954
|
const wt = {
|
|
930
955
|
activeDragGlassEl: null,
|
|
931
956
|
activeDragGlassPaneCanDrop: !1,
|
|
932
|
-
onPaneDrop(
|
|
957
|
+
onPaneDrop(i, t) {
|
|
933
958
|
if (!this.activeDragGlassEl) return;
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
936
|
-
const n = this.activeDragGlassEl.closest("bw-pane")
|
|
937
|
-
|
|
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);
|
|
938
963
|
return;
|
|
939
964
|
} else {
|
|
940
|
-
const n =
|
|
941
|
-
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);
|
|
942
967
|
}
|
|
943
968
|
},
|
|
944
969
|
enableDrag() {
|
|
945
|
-
document.addEventListener("mousedown", (
|
|
946
|
-
if (
|
|
947
|
-
if (
|
|
948
|
-
|
|
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();
|
|
949
974
|
return;
|
|
950
975
|
}
|
|
951
|
-
const
|
|
952
|
-
|
|
976
|
+
const e = i.target.closest("bw-glass");
|
|
977
|
+
e.setAttribute("draggable", !0), this.activeDragGlassEl = e;
|
|
953
978
|
}), document.addEventListener("mouseup", () => {
|
|
954
979
|
this.activeDragGlassEl && (this.activeDragGlassEl.removeAttribute("draggable"), this.activeDragGlassEl = null);
|
|
955
|
-
}), this.windowElement.addEventListener("dragstart", (
|
|
956
|
-
if (!(
|
|
980
|
+
}), this.windowElement.addEventListener("dragstart", (i) => {
|
|
981
|
+
if (!(i.target instanceof HTMLElement) || !i.target.matches("bw-glass") || !this.activeDragGlassEl)
|
|
957
982
|
return;
|
|
958
|
-
|
|
983
|
+
i.dataTransfer.effectAllowed = "move";
|
|
959
984
|
const t = this.activeDragGlassEl.closest("bw-pane");
|
|
960
985
|
this.activeDragGlassPaneCanDrop = t.getAttribute("can-drop") !== "false", t.setAttribute("can-drop", !1);
|
|
961
986
|
}), this.windowElement.addEventListener("dragend", () => {
|
|
@@ -963,32 +988,32 @@ const wt = {
|
|
|
963
988
|
});
|
|
964
989
|
}
|
|
965
990
|
}, mt = {
|
|
966
|
-
trimMuntin(
|
|
967
|
-
|
|
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`);
|
|
968
993
|
},
|
|
969
|
-
onMuntinCreate(
|
|
970
|
-
this.trimMuntin(
|
|
994
|
+
onMuntinCreate(i) {
|
|
995
|
+
this.trimMuntin(i);
|
|
971
996
|
},
|
|
972
|
-
onMuntinUpdate(
|
|
973
|
-
this.trimMuntin(
|
|
997
|
+
onMuntinUpdate(i) {
|
|
998
|
+
this.trimMuntin(i);
|
|
974
999
|
}
|
|
975
1000
|
};
|
|
976
|
-
class bt extends
|
|
1001
|
+
class bt extends B {
|
|
977
1002
|
constructor() {
|
|
978
1003
|
super(...arguments);
|
|
979
1004
|
f(this, "sillElement", null);
|
|
980
1005
|
}
|
|
981
1006
|
frame() {
|
|
982
1007
|
super.frame(...arguments);
|
|
983
|
-
const
|
|
984
|
-
this.windowElement.append(
|
|
1008
|
+
const e = m("<bw-sill />");
|
|
1009
|
+
this.windowElement.append(e), this.sillElement = e;
|
|
985
1010
|
}
|
|
986
1011
|
enableFeatures() {
|
|
987
1012
|
super.enableFeatures(), this.enableDrag(), this.enableActions();
|
|
988
1013
|
}
|
|
989
|
-
onPaneCreate(
|
|
1014
|
+
onPaneCreate(e, n) {
|
|
990
1015
|
const s = new T({ ...n.store, sash: n, binaryWindow: this });
|
|
991
|
-
|
|
1016
|
+
e.innerHTML = "", e.append(s.domNode), this.debug && s.contentElement.prepend(`${n.id}`);
|
|
992
1017
|
}
|
|
993
1018
|
onPaneUpdate() {
|
|
994
1019
|
}
|
|
@@ -999,18 +1024,18 @@ class bt extends L {
|
|
|
999
1024
|
* @param {Object} props - The pane and glass properties grouped together
|
|
1000
1025
|
* @returns {Sash} - The newly created Sash
|
|
1001
1026
|
*/
|
|
1002
|
-
addPane(
|
|
1003
|
-
const { position: s, size: o,
|
|
1004
|
-
return
|
|
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 });
|
|
1029
|
+
return d.domNode.append(a.domNode), d;
|
|
1005
1030
|
}
|
|
1006
1031
|
}
|
|
1007
1032
|
bt.assemble(wt, mt, gt);
|
|
1008
1033
|
export {
|
|
1009
1034
|
ft as BUILTIN_ACTIONS,
|
|
1010
1035
|
bt as BinaryWindow,
|
|
1011
|
-
|
|
1012
|
-
|
|
1036
|
+
j as ConfigRoot,
|
|
1037
|
+
B as Frame,
|
|
1013
1038
|
r as Position,
|
|
1014
1039
|
g as Sash,
|
|
1015
|
-
|
|
1040
|
+
K as SashConfig
|
|
1016
1041
|
};
|