react-bwin 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-bwin.d.ts +11 -2
- package/dist/react-bwin.js +327 -290
- package/dist/react-bwin.umd.js +2 -2
- package/package.json +2 -2
package/dist/react-bwin.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import t, { forwardRef as n, useContext as r, useEffect as i, useImperativeHandle as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
3
|
+
import { createPortal as l } from "react-dom";
|
|
4
|
+
//#region node_modules/.pnpm/bwin@0.4.3/node_modules/bwin/dist/bwin.js
|
|
5
|
+
function u(e = .7, t = 128) {
|
|
5
6
|
let n = 256 - t;
|
|
6
7
|
return `rgba(${Math.floor(Math.random() * n + t)}, ${Math.floor(Math.random() * n + t)}, ${Math.floor(Math.random() * n + t)}, ${Math.max(.5, Math.random() * e)})`;
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
+
function d(e = 2, t = 3) {
|
|
9
10
|
if (e < 0 || t < 0) throw Error("Parameters must be non-negative numbers");
|
|
10
11
|
let n = "";
|
|
11
12
|
for (let t = 0; t < e; t++) {
|
|
@@ -19,14 +20,14 @@ function l(e = 2, t = 3) {
|
|
|
19
20
|
}
|
|
20
21
|
return n;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function f(e, t) {
|
|
23
24
|
for (; t.firstChild;) e.append(t.firstChild);
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function p(e, t) {
|
|
26
27
|
let n = document.createElement("div");
|
|
27
|
-
|
|
28
|
+
f(n, e), f(e, t), f(t, n);
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
+
function m(e) {
|
|
30
31
|
if (typeof e == "number" && !isNaN(e)) return e;
|
|
31
32
|
if (typeof e == "string") {
|
|
32
33
|
let t = e.trim();
|
|
@@ -46,35 +47,35 @@ function f(e) {
|
|
|
46
47
|
}
|
|
47
48
|
return NaN;
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function h(e) {
|
|
50
51
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.getPrototypeOf(e) === Object.prototype;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function g(e, t) {
|
|
53
54
|
for (let n in t) {
|
|
54
55
|
if (Object.hasOwn(e, n)) throw Error(`Key "${n}" already exists in target object`);
|
|
55
56
|
e[n] = t[n];
|
|
56
57
|
}
|
|
57
58
|
return e;
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function _(e) {
|
|
60
61
|
let t = document.createElement("template");
|
|
61
62
|
return t.innerHTML = e.trim(), t.content;
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
+
function v(e) {
|
|
64
65
|
if (e == null || e === "") return null;
|
|
65
66
|
if (typeof e == "string") try {
|
|
66
|
-
let t =
|
|
67
|
+
let t = _(e);
|
|
67
68
|
return t.childNodes.length === 1 ? t.firstChild : t;
|
|
68
69
|
} catch {
|
|
69
70
|
return document.createTextNode(e);
|
|
70
71
|
}
|
|
71
72
|
return e instanceof Node ? e : document.createTextNode(String(e));
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
+
function y(e) {
|
|
74
75
|
let t = document.createDocumentFragment();
|
|
75
76
|
return t.append(...e.childNodes), t;
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
+
function b(e) {
|
|
78
79
|
return {
|
|
79
80
|
left: parseFloat(e.style.left) || 0,
|
|
80
81
|
top: parseFloat(e.style.top) || 0,
|
|
@@ -82,7 +83,7 @@ function v(e) {
|
|
|
82
83
|
height: parseFloat(e.style.height) || 0
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
|
-
var
|
|
86
|
+
var x = {
|
|
86
87
|
Top: "top",
|
|
87
88
|
Right: "right",
|
|
88
89
|
Bottom: "bottom",
|
|
@@ -92,48 +93,48 @@ var y = {
|
|
|
92
93
|
Unknown: "unknown",
|
|
93
94
|
Outside: "outside"
|
|
94
95
|
};
|
|
95
|
-
function
|
|
96
|
+
function S(e) {
|
|
96
97
|
switch (e) {
|
|
97
|
-
case
|
|
98
|
-
case
|
|
99
|
-
case
|
|
100
|
-
case
|
|
98
|
+
case x.Top: return x.Bottom;
|
|
99
|
+
case x.Right: return x.Left;
|
|
100
|
+
case x.Bottom: return x.Top;
|
|
101
|
+
case x.Left: return x.Right;
|
|
101
102
|
default: throw Error(`[bwin] Invalid position: ${e}`);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
|
-
function
|
|
105
|
+
function ee({ width: e, height: t, x: n }) {
|
|
105
106
|
return t / e * n;
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function te({ width: e, height: t, y: n }) {
|
|
108
109
|
return e / t * n;
|
|
109
110
|
}
|
|
110
|
-
function
|
|
111
|
+
function ne({ width: e, height: t, x: n }) {
|
|
111
112
|
return t - t / e * n;
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
+
function re({ width: e, height: t, y: n }) {
|
|
114
115
|
return e - e / t * n;
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function ie(e, { clientX: t, clientY: n }) {
|
|
117
118
|
let r = e.getBoundingClientRect(), { width: i, height: a } = r, o = t - r.left, s = n - r.top;
|
|
118
|
-
if (o < 0 || o > i || s < 0 || s > a) return
|
|
119
|
-
let c = .3, l =
|
|
119
|
+
if (o < 0 || o > i || s < 0 || s > a) return x.Outside;
|
|
120
|
+
let c = .3, l = ee({
|
|
120
121
|
width: i,
|
|
121
122
|
height: a,
|
|
122
123
|
x: o
|
|
123
|
-
}), u =
|
|
124
|
+
}), u = ne({
|
|
124
125
|
width: i,
|
|
125
126
|
height: a,
|
|
126
127
|
x: o
|
|
127
|
-
}), d =
|
|
128
|
+
}), d = te({
|
|
128
129
|
width: i,
|
|
129
130
|
height: a,
|
|
130
131
|
y: s
|
|
131
|
-
}), f =
|
|
132
|
+
}), f = re({
|
|
132
133
|
width: i,
|
|
133
134
|
height: a,
|
|
134
135
|
y: s
|
|
135
136
|
});
|
|
136
|
-
return o < i * (.5 - c / 2) && s > l && s < u ?
|
|
137
|
+
return o < i * (.5 - c / 2) && s > l && s < u ? x.Left : o > i * .65 && s < l && s > u ? x.Right : s < a * (.5 - c / 2) && o > d && o < f ? x.Top : s > a * .65 && o < d && o > f ? x.Bottom : o > i * (.5 - c / 2) && o < i * .65 && s > a * (.5 - c / 2) && s < a * .65 ? x.Center : x.Unknown;
|
|
137
138
|
}
|
|
138
139
|
var C = {
|
|
139
140
|
left: 0,
|
|
@@ -144,9 +145,9 @@ var C = {
|
|
|
144
145
|
minHeight: 100,
|
|
145
146
|
resizeStrategy: "classic"
|
|
146
147
|
}, w = class {
|
|
147
|
-
constructor({ left: e = C.left, top: t = C.top, width: n = C.width, height: r = C.height, minWidth: i = C.minWidth, minHeight: a = C.minHeight, resizeStrategy: o = C.resizeStrategy, parent: s = null, domNode: c = null, store:
|
|
148
|
-
if (this.id = f ??
|
|
149
|
-
this.position =
|
|
148
|
+
constructor({ left: e = C.left, top: t = C.top, width: n = C.width, height: r = C.height, minWidth: i = C.minWidth, minHeight: a = C.minHeight, resizeStrategy: o = C.resizeStrategy, parent: s = null, domNode: c = null, store: l = {}, position: u, id: f } = C) {
|
|
149
|
+
if (this.id = f ?? d(), !u) throw Error("[bwin] Sash position is required");
|
|
150
|
+
this.position = u, this.domNode = c, this.parent = s, this._top = t, this._left = e, this._width = n, this._height = r, this.children = [], this.minWidth = i, this.minHeight = a, this.resizeStrategy = o, this.store = l;
|
|
150
151
|
}
|
|
151
152
|
walk(e) {
|
|
152
153
|
this.children.forEach((t) => t.walk(e)), e(this);
|
|
@@ -158,26 +159,26 @@ var C = {
|
|
|
158
159
|
return this.children.length > 0;
|
|
159
160
|
}
|
|
160
161
|
isLeftRightSplit() {
|
|
161
|
-
return this.children.some((e) => e.position ===
|
|
162
|
+
return this.children.some((e) => e.position === x.Left || e.position === x.Right);
|
|
162
163
|
}
|
|
163
164
|
isTopBottomSplit() {
|
|
164
|
-
return this.children.some((e) => e.position ===
|
|
165
|
+
return this.children.some((e) => e.position === x.Top || e.position === x.Bottom);
|
|
165
166
|
}
|
|
166
167
|
get leftChild() {
|
|
167
|
-
return this.children.find((e) => e.position ===
|
|
168
|
+
return this.children.find((e) => e.position === x.Left);
|
|
168
169
|
}
|
|
169
170
|
get rightChild() {
|
|
170
|
-
return this.children.find((e) => e.position ===
|
|
171
|
+
return this.children.find((e) => e.position === x.Right);
|
|
171
172
|
}
|
|
172
173
|
get topChild() {
|
|
173
|
-
return this.children.find((e) => e.position ===
|
|
174
|
+
return this.children.find((e) => e.position === x.Top);
|
|
174
175
|
}
|
|
175
176
|
get bottomChild() {
|
|
176
|
-
return this.children.find((e) => e.position ===
|
|
177
|
+
return this.children.find((e) => e.position === x.Bottom);
|
|
177
178
|
}
|
|
178
179
|
getChildren() {
|
|
179
180
|
let e = null, t = null, n = null, r = null;
|
|
180
|
-
for (let i of this.children) i.position ===
|
|
181
|
+
for (let i of this.children) i.position === x.Left ? e = i : i.position === x.Right ? t = i : i.position === x.Top ? n = i : i.position === x.Bottom && (r = i);
|
|
181
182
|
return [
|
|
182
183
|
n,
|
|
183
184
|
t,
|
|
@@ -253,7 +254,7 @@ var C = {
|
|
|
253
254
|
return this.getAllLeafDescendants().reduce((e, t) => t.width * t.height > e.width * e.height ? t : e);
|
|
254
255
|
}
|
|
255
256
|
getRelativeSize() {
|
|
256
|
-
return this.parent ? this.position ===
|
|
257
|
+
return this.parent ? this.position === x.Left || this.position === x.Right ? this.width / this.parent.width : this.height / this.parent.height : 1;
|
|
257
258
|
}
|
|
258
259
|
get top() {
|
|
259
260
|
return this._top;
|
|
@@ -282,7 +283,7 @@ var C = {
|
|
|
282
283
|
let [n, r, i, a] = this.getChildren();
|
|
283
284
|
if (a && r) {
|
|
284
285
|
let e = a.width + r.width, n = t * (a.width / e), i = e + t, o, s, c;
|
|
285
|
-
if (this.resizeStrategy === "natural" && this.position ===
|
|
286
|
+
if (this.resizeStrategy === "natural" && this.position === x.Left ? (o = a.width, s = r.width + t, c = r.left) : this.resizeStrategy === "natural" && this.position === x.Right ? (o = a.width + t, s = r.width, c = a.left + o) : (o = a.width + n, s = i - o, c = r.left + n), t < 0) {
|
|
286
287
|
let e = a.calcMinWidth(), t = r.calcMinWidth();
|
|
287
288
|
o < e && s > t ? (o = a.width, s = i - o, c = a.left + o) : s < t && o > e && (s = r.width, o = i - s, c = a.left + o);
|
|
288
289
|
}
|
|
@@ -299,7 +300,7 @@ var C = {
|
|
|
299
300
|
let [n, r, i, a] = this.getChildren();
|
|
300
301
|
if (n && i) {
|
|
301
302
|
let e = n.height + i.height, r = t * (n.height / e), a = e + t, o, s, c;
|
|
302
|
-
if (this.resizeStrategy === "natural" && this.position ===
|
|
303
|
+
if (this.resizeStrategy === "natural" && this.position === x.Top ? (o = n.height, s = i.height + t, c = i.top) : this.resizeStrategy === "natural" && this.position === x.Bottom ? (o = n.height + t, s = i.height, c = n.top + o) : (o = n.height + r, s = a - o, c = i.top + r), t < 0) {
|
|
303
304
|
let e = n.calcMinHeight(), t = i.calcMinHeight();
|
|
304
305
|
o < e && s > t ? (o = n.height, s = a - o, c = n.top + o) : s < t && o > e && (s = i.height, o = a - s, c = n.top + o);
|
|
305
306
|
}
|
|
@@ -309,8 +310,8 @@ var C = {
|
|
|
309
310
|
}
|
|
310
311
|
}, T = {
|
|
311
312
|
size: "50%",
|
|
312
|
-
position:
|
|
313
|
-
},
|
|
313
|
+
position: x.Left
|
|
314
|
+
}, ae = class e {
|
|
314
315
|
left;
|
|
315
316
|
top;
|
|
316
317
|
width;
|
|
@@ -320,39 +321,39 @@ var C = {
|
|
|
320
321
|
}
|
|
321
322
|
getPosition(e) {
|
|
322
323
|
if (!this.siblingConfigNode) return e;
|
|
323
|
-
let t =
|
|
324
|
+
let t = S(this.siblingConfigNode.position);
|
|
324
325
|
if (!e) return t;
|
|
325
326
|
if (e !== t) throw Error("[bwin] Sibling position and current position are not opposite");
|
|
326
327
|
return e;
|
|
327
328
|
}
|
|
328
329
|
getSize(e) {
|
|
329
|
-
if (!this.siblingConfigNode) return
|
|
330
|
+
if (!this.siblingConfigNode) return m(e);
|
|
330
331
|
if (!e) {
|
|
331
332
|
if (this.siblingConfigNode.size < 1) return 1 - this.siblingConfigNode.size;
|
|
332
|
-
if (this.siblingConfigNode.position ===
|
|
333
|
-
if (this.siblingConfigNode.position ===
|
|
333
|
+
if (this.siblingConfigNode.position === x.Left || this.siblingConfigNode.position === x.Right) return this.parentRect.width - this.siblingConfigNode.width;
|
|
334
|
+
if (this.siblingConfigNode.position === x.Top || this.siblingConfigNode.position === x.Bottom) return this.parentRect.height - this.siblingConfigNode.height;
|
|
334
335
|
}
|
|
335
|
-
let t =
|
|
336
|
+
let t = m(e);
|
|
336
337
|
if (t < 1) {
|
|
337
338
|
if (t + this.siblingConfigNode.size !== 1) throw Error("[bwin] Sum of sibling sizes is not equal to 1");
|
|
338
339
|
} else {
|
|
339
|
-
if ((this.position ===
|
|
340
|
-
if ((this.position ===
|
|
340
|
+
if ((this.position === x.Left || this.position === x.Right) && t + this.siblingConfigNode.size !== this.parentRect.width) throw Error("[bwin] Sum of sibling sizes is not equal to parent width");
|
|
341
|
+
if ((this.position === x.Top || this.position === x.Bottom) && t + this.siblingConfigNode.size !== this.parentRect.height) throw Error("[bwin] Sum of sibling sizes is not equal to parent height");
|
|
341
342
|
}
|
|
342
343
|
return t;
|
|
343
344
|
}
|
|
344
345
|
setBounds() {
|
|
345
|
-
if (this.position ===
|
|
346
|
-
else if (this.position ===
|
|
346
|
+
if (this.position === x.Root) this.left = 0, this.top = 0, this.width = this.parentRect.width, this.height = this.parentRect.height;
|
|
347
|
+
else if (this.position === x.Left) {
|
|
347
348
|
let e = this.size < 1 ? this.parentRect.width * this.size : this.size;
|
|
348
349
|
this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = e, this.height = this.parentRect.height;
|
|
349
|
-
} else if (this.position ===
|
|
350
|
+
} else if (this.position === x.Right) {
|
|
350
351
|
let e = this.size < 1 ? this.parentRect.width * this.size : this.size;
|
|
351
352
|
this.left = this.parentRect.left + this.parentRect.width - e, this.top = this.parentRect.top, this.width = e, this.height = this.parentRect.height;
|
|
352
|
-
} else if (this.position ===
|
|
353
|
+
} else if (this.position === x.Top) {
|
|
353
354
|
let e = this.size < 1 ? this.parentRect.height * this.size : this.size;
|
|
354
355
|
this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = this.parentRect.width, this.height = e;
|
|
355
|
-
} else if (this.position ===
|
|
356
|
+
} else if (this.position === x.Bottom) {
|
|
356
357
|
let e = this.size < 1 ? this.parentRect.height * this.size : this.size;
|
|
357
358
|
this.left = this.parentRect.left, this.top = this.parentRect.top + this.parentRect.height - e, this.width = this.parentRect.width, this.height = e;
|
|
358
359
|
}
|
|
@@ -372,10 +373,10 @@ var C = {
|
|
|
372
373
|
});
|
|
373
374
|
}
|
|
374
375
|
normConfig(e) {
|
|
375
|
-
if (
|
|
376
|
+
if (h(e)) return e;
|
|
376
377
|
if (Array.isArray(e)) return { children: e };
|
|
377
378
|
if (typeof e == "string" || typeof e == "number") {
|
|
378
|
-
let t =
|
|
379
|
+
let t = m(e);
|
|
379
380
|
if (isNaN(t)) throw Error(`[bwin] Invalid size value: ${t}`);
|
|
380
381
|
return { size: e };
|
|
381
382
|
} else if (e == null) return {};
|
|
@@ -410,7 +411,7 @@ var C = {
|
|
|
410
411
|
let t = this.createSash({ resizeStrategy: e });
|
|
411
412
|
if (!Array.isArray(this.children) || this.children.length === 0) return t;
|
|
412
413
|
let n = this.normConfig(this.children[0]), r = this.normConfig(this.children.at(1)), i, a;
|
|
413
|
-
if (!n.size && !n.position && r ? (r.position ||=
|
|
414
|
+
if (!n.size && !n.position && r ? (r.position ||= x.Right, i = this.createPrimaryConfigNode(r), a = this.createSecondaryConfigNode(n, i)) : (i = this.createPrimaryConfigNode(n), a = this.createSecondaryConfigNode(r, i)), i && a) {
|
|
414
415
|
let n = i.buildSashTree({ resizeStrategy: e }), r = a.buildSashTree({ resizeStrategy: e });
|
|
415
416
|
n.parent = t, r.parent = t, t.children.push(n), t.children.push(r);
|
|
416
417
|
}
|
|
@@ -422,7 +423,7 @@ var C = {
|
|
|
422
423
|
}, D = {
|
|
423
424
|
fitContainer: !1,
|
|
424
425
|
theme: ""
|
|
425
|
-
},
|
|
426
|
+
}, oe = class extends ae {
|
|
426
427
|
constructor({ id: e, children: t, width: n = E.width, height: r = E.height, fitContainer: i = D.fitContainer, theme: a = D.theme, ...o } = {
|
|
427
428
|
...E,
|
|
428
429
|
...D
|
|
@@ -431,7 +432,7 @@ var C = {
|
|
|
431
432
|
id: e,
|
|
432
433
|
children: t,
|
|
433
434
|
size: NaN,
|
|
434
|
-
position:
|
|
435
|
+
position: x.Root,
|
|
435
436
|
parentRect: {
|
|
436
437
|
width: n,
|
|
437
438
|
height: r
|
|
@@ -439,24 +440,24 @@ var C = {
|
|
|
439
440
|
...o
|
|
440
441
|
}), this.fitContainer = i, this.theme = a;
|
|
441
442
|
}
|
|
442
|
-
},
|
|
443
|
+
}, se = class extends w {
|
|
443
444
|
constructor(e = C) {
|
|
444
445
|
super({
|
|
445
446
|
...e,
|
|
446
|
-
position:
|
|
447
|
+
position: x.Root
|
|
447
448
|
}), Object.assign(this, D);
|
|
448
449
|
}
|
|
449
450
|
};
|
|
450
|
-
function
|
|
451
|
+
function ce(e) {
|
|
451
452
|
let t = document.createElement("bw-pane");
|
|
452
453
|
return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("sash-id", e.id), t.setAttribute("position", e.position), t;
|
|
453
454
|
}
|
|
454
|
-
function
|
|
455
|
+
function le(e) {
|
|
455
456
|
let t = e.domNode;
|
|
456
457
|
return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("position", e.position), t;
|
|
457
458
|
}
|
|
458
|
-
function
|
|
459
|
-
let r =
|
|
459
|
+
function ue(e, { size: t, id: n }) {
|
|
460
|
+
let r = m(t), i = e.width / 2;
|
|
460
461
|
r && (i = r < 1 ? e.width * r : r);
|
|
461
462
|
let a = new w({
|
|
462
463
|
id: n,
|
|
@@ -464,20 +465,20 @@ function ce(e, { size: t, id: n }) {
|
|
|
464
465
|
left: e.left,
|
|
465
466
|
width: i,
|
|
466
467
|
height: e.height,
|
|
467
|
-
position:
|
|
468
|
+
position: x.Left
|
|
468
469
|
}), o = new w({
|
|
469
470
|
id: e.id,
|
|
470
471
|
top: e.top,
|
|
471
472
|
left: e.left + a.width,
|
|
472
473
|
width: e.width - i,
|
|
473
474
|
height: e.height,
|
|
474
|
-
position:
|
|
475
|
+
position: x.Right,
|
|
475
476
|
domNode: e.domNode
|
|
476
477
|
});
|
|
477
|
-
return e.addChild(a), e.addChild(o), e.domNode = null, e.id =
|
|
478
|
+
return e.addChild(a), e.addChild(o), e.domNode = null, e.id = d(), a;
|
|
478
479
|
}
|
|
479
|
-
function
|
|
480
|
-
let r =
|
|
480
|
+
function de(e, { size: t, id: n }) {
|
|
481
|
+
let r = m(t), i = e.width / 2;
|
|
481
482
|
r && (i = r < 1 ? e.width * r : r);
|
|
482
483
|
let a = new w({
|
|
483
484
|
id: e.id,
|
|
@@ -485,7 +486,7 @@ function O(e, { size: t, id: n }) {
|
|
|
485
486
|
top: e.top,
|
|
486
487
|
width: e.width - i,
|
|
487
488
|
height: e.height,
|
|
488
|
-
position:
|
|
489
|
+
position: x.Left,
|
|
489
490
|
domNode: e.domNode
|
|
490
491
|
}), o = new w({
|
|
491
492
|
id: n,
|
|
@@ -493,12 +494,12 @@ function O(e, { size: t, id: n }) {
|
|
|
493
494
|
top: e.top,
|
|
494
495
|
width: i,
|
|
495
496
|
height: e.height,
|
|
496
|
-
position:
|
|
497
|
+
position: x.Right
|
|
497
498
|
});
|
|
498
|
-
return e.addChild(a), e.addChild(o), e.domNode = null, e.id =
|
|
499
|
+
return e.addChild(a), e.addChild(o), e.domNode = null, e.id = d(), o;
|
|
499
500
|
}
|
|
500
|
-
function
|
|
501
|
-
let r =
|
|
501
|
+
function fe(e, { size: t, id: n }) {
|
|
502
|
+
let r = m(t), i = e.height / 2;
|
|
502
503
|
r && (i = r < 1 ? e.height * r : r);
|
|
503
504
|
let a = new w({
|
|
504
505
|
id: n,
|
|
@@ -506,20 +507,20 @@ function k(e, { size: t, id: n }) {
|
|
|
506
507
|
top: e.top,
|
|
507
508
|
width: e.width,
|
|
508
509
|
height: i,
|
|
509
|
-
position:
|
|
510
|
+
position: x.Top
|
|
510
511
|
}), o = new w({
|
|
511
512
|
id: e.id,
|
|
512
513
|
left: e.left,
|
|
513
514
|
top: e.top + a.height,
|
|
514
515
|
width: e.width,
|
|
515
516
|
height: e.height - i,
|
|
516
|
-
position:
|
|
517
|
+
position: x.Bottom,
|
|
517
518
|
domNode: e.domNode
|
|
518
519
|
});
|
|
519
|
-
return e.addChild(a), e.addChild(o), e.domNode = null, e.id =
|
|
520
|
+
return e.addChild(a), e.addChild(o), e.domNode = null, e.id = d(), a;
|
|
520
521
|
}
|
|
521
|
-
function
|
|
522
|
-
let r =
|
|
522
|
+
function pe(e, { size: t, id: n }) {
|
|
523
|
+
let r = m(t), i = e.height / 2;
|
|
523
524
|
r && (i = r < 1 ? e.height * r : r);
|
|
524
525
|
let a = new w({
|
|
525
526
|
id: e.id,
|
|
@@ -527,7 +528,7 @@ function le(e, { size: t, id: n }) {
|
|
|
527
528
|
left: e.left,
|
|
528
529
|
width: e.width,
|
|
529
530
|
height: e.height - i,
|
|
530
|
-
position:
|
|
531
|
+
position: x.Top,
|
|
531
532
|
domNode: e.domNode
|
|
532
533
|
}), o = new w({
|
|
533
534
|
id: n,
|
|
@@ -535,53 +536,53 @@ function le(e, { size: t, id: n }) {
|
|
|
535
536
|
left: e.left,
|
|
536
537
|
width: e.width,
|
|
537
538
|
height: i,
|
|
538
|
-
position:
|
|
539
|
+
position: x.Bottom
|
|
539
540
|
});
|
|
540
|
-
return e.addChild(a), e.addChild(o), e.domNode = null, e.id =
|
|
541
|
+
return e.addChild(a), e.addChild(o), e.domNode = null, e.id = d(), o;
|
|
541
542
|
}
|
|
542
|
-
function
|
|
543
|
-
if (t ===
|
|
543
|
+
function me(e, { position: t, size: n, id: r, minWidth: i, minHeight: a }) {
|
|
544
|
+
if (t === x.Left) return ue(e, {
|
|
544
545
|
size: n,
|
|
545
546
|
id: r
|
|
546
547
|
});
|
|
547
|
-
if (t ===
|
|
548
|
+
if (t === x.Right) return de(e, {
|
|
548
549
|
size: n,
|
|
549
550
|
id: r
|
|
550
551
|
});
|
|
551
|
-
if (t ===
|
|
552
|
+
if (t === x.Top) return fe(e, {
|
|
552
553
|
size: n,
|
|
553
554
|
id: r
|
|
554
555
|
});
|
|
555
|
-
if (t ===
|
|
556
|
+
if (t === x.Bottom) return pe(e, {
|
|
556
557
|
size: n,
|
|
557
558
|
id: r
|
|
558
559
|
});
|
|
559
560
|
}
|
|
560
|
-
function
|
|
561
|
+
function O(e) {
|
|
561
562
|
if (e.tagName === "BW-PANE") return e.getAttribute("sash-id");
|
|
562
563
|
let t = e.closest("bw-pane");
|
|
563
564
|
if (!t) throw Error("[bwin] Pane element not found");
|
|
564
565
|
return t.getAttribute("sash-id");
|
|
565
566
|
}
|
|
566
|
-
var
|
|
567
|
+
var he = {
|
|
567
568
|
createPane(e) {
|
|
568
|
-
let t =
|
|
569
|
+
let t = ce(e);
|
|
569
570
|
return e.store.droppable === !1 && t.setAttribute("can-drop", "false"), t;
|
|
570
571
|
},
|
|
571
572
|
onPaneCreate(e, t) {
|
|
572
|
-
t.store.content && e.append(
|
|
573
|
+
t.store.content && e.append(v(t.store.content)), this?.debug && (e.style.backgroundColor = u(), e.innerHTML = "", e.append(k(e)));
|
|
573
574
|
},
|
|
574
575
|
updatePane(e) {
|
|
575
|
-
return
|
|
576
|
+
return le(e);
|
|
576
577
|
},
|
|
577
578
|
onPaneUpdate(e, t) {
|
|
578
|
-
this?.debug && (e.innerHTML = "", e.append(
|
|
579
|
+
this?.debug && (e.innerHTML = "", e.append(k(e)));
|
|
579
580
|
},
|
|
580
581
|
addPane(e, { position: t, size: n, id: r }) {
|
|
581
582
|
if (!t) throw Error("[bwin] Position is required when adding pane");
|
|
582
583
|
let i = this.rootSash.getById(e);
|
|
583
584
|
if (!i) throw Error("[bwin] Parent sash not found when adding pane");
|
|
584
|
-
let a =
|
|
585
|
+
let a = me(i, {
|
|
585
586
|
position: t,
|
|
586
587
|
size: n,
|
|
587
588
|
id: r
|
|
@@ -592,14 +593,14 @@ var de = {
|
|
|
592
593
|
let t = this.rootSash.getDescendantParentById(e);
|
|
593
594
|
if (!t) throw Error("[bwin] Parent sash not found when removing pane");
|
|
594
595
|
let n = t.getChildSiblingById(e);
|
|
595
|
-
n.children.length === 0 ? (t.id = n.id, t.domNode = n.domNode, t.domNode.setAttribute("sash-id", n.id), t.children = []) : (t.id =
|
|
596
|
+
n.children.length === 0 ? (t.id = n.id, t.domNode = n.domNode, t.domNode.setAttribute("sash-id", n.id), t.children = []) : (t.id = d(), t.children = n.children, t.children.forEach((e) => e.parent = t), n.position === x.Left ? n.width = t.width : n.position === x.Right ? (n.width = t.width, n.left = t.left) : n.position === x.Top ? n.height = t.height : n.position === x.Bottom && (n.height = t.height, n.top = t.top)), this.update();
|
|
596
597
|
},
|
|
597
598
|
swapPanes(e, t) {
|
|
598
|
-
let n =
|
|
599
|
-
this.rootSash.swapIds(n, r),
|
|
599
|
+
let n = O(e), r = O(t), i = e.getAttribute("can-drop") !== "false", a = t.getAttribute("can-drop") !== "false";
|
|
600
|
+
this.rootSash.swapIds(n, r), p(e, this.activeDropPaneEl), e.setAttribute("sash-id", r), t.setAttribute("sash-id", n), e.setAttribute("can-drop", a), t.setAttribute("can-drop", i);
|
|
600
601
|
}
|
|
601
602
|
};
|
|
602
|
-
function
|
|
603
|
+
function k(e) {
|
|
603
604
|
let t = document.createElement("pre");
|
|
604
605
|
return t.style.fontSize = "10px", t.innerHTML = `
|
|
605
606
|
${e.getAttribute("sash-id")}
|
|
@@ -610,7 +611,7 @@ width: ${e.style.width}
|
|
|
610
611
|
height: ${e.style.height}
|
|
611
612
|
`.trim(), t;
|
|
612
613
|
}
|
|
613
|
-
var
|
|
614
|
+
var ge = {
|
|
614
615
|
createWindow({ theme: e } = {}) {
|
|
615
616
|
let t = document.createElement("bw-window");
|
|
616
617
|
return t.style.width = `${this.rootSash.width}px`, t.style.height = `${this.rootSash.height}px`, t.setAttribute("root-sash-id", this.rootSash.id), e && t.setAttribute("theme", e), t;
|
|
@@ -631,7 +632,7 @@ var fe = {
|
|
|
631
632
|
e.children.length > 0 ? t.includes(e.id) ? (this.updateMuntin(e), this.onMuntinUpdate(e.domNode, e)) : (e.domNode = this.createMuntin(e), this.windowElement.append(e.domNode)) : t.includes(e.id) ? (this.updatePane(e), this.onPaneUpdate(e.domNode, e)) : (e.domNode ||= this.createPane(e), this.windowElement.prepend(e.domNode));
|
|
632
633
|
});
|
|
633
634
|
}
|
|
634
|
-
},
|
|
635
|
+
}, _e = {
|
|
635
636
|
muntinSize: 4,
|
|
636
637
|
createMuntin(e) {
|
|
637
638
|
let t = document.createElement("bw-muntin"), n = e.leftChild, r = e.topChild;
|
|
@@ -643,7 +644,7 @@ var fe = {
|
|
|
643
644
|
n ? (t.style.height = `${e.height}px`, t.style.top = `${e.top}px`, t.style.left = `${e.left + n.width - this.muntinSize / 2}px`) : r && (t.style.width = `${e.width}px`, t.style.top = `${e.top + r.height - this.muntinSize / 2}px`, t.style.left = `${e.left}px`);
|
|
644
645
|
},
|
|
645
646
|
onMuntinUpdate(e, t) {}
|
|
646
|
-
},
|
|
647
|
+
}, ve = {
|
|
647
648
|
fitContainer: !1,
|
|
648
649
|
fit() {
|
|
649
650
|
this.rootSash.width = this.containerElement.clientWidth, this.rootSash.height = this.containerElement.clientHeight, this.update();
|
|
@@ -655,7 +656,7 @@ var fe = {
|
|
|
655
656
|
});
|
|
656
657
|
}).observe(this.containerElement);
|
|
657
658
|
}
|
|
658
|
-
},
|
|
659
|
+
}, ye = {
|
|
659
660
|
activeMuntinSash: null,
|
|
660
661
|
isResizeStarted: !1,
|
|
661
662
|
isDropStarted: !1,
|
|
@@ -688,7 +689,7 @@ var fe = {
|
|
|
688
689
|
this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
|
|
689
690
|
});
|
|
690
691
|
}
|
|
691
|
-
},
|
|
692
|
+
}, be = {
|
|
692
693
|
activeDropPaneEl: null,
|
|
693
694
|
onPaneDrop(e, t) {},
|
|
694
695
|
enableDrop() {
|
|
@@ -696,7 +697,7 @@ var fe = {
|
|
|
696
697
|
e.preventDefault();
|
|
697
698
|
let t = e.target.matches("bw-pane") ? e.target : e.target.closest("bw-pane");
|
|
698
699
|
if (!t || (t !== this.activeDropPaneEl && (this.activeDropPaneEl && this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = t), t.getAttribute("can-drop") === "false")) return;
|
|
699
|
-
let n =
|
|
700
|
+
let n = ie(t, e);
|
|
700
701
|
t.setAttribute("drop-area", n);
|
|
701
702
|
}), this.windowElement.addEventListener("dragleave", (e) => {
|
|
702
703
|
e.currentTarget.contains(e.relatedTarget) && e.currentTarget !== e.relatedTarget || (this.activeDropPaneEl &&= (this.activeDropPaneEl.removeAttribute("drop-area"), null));
|
|
@@ -706,13 +707,13 @@ var fe = {
|
|
|
706
707
|
this.onPaneDrop(e, n), typeof n.store.onDrop == "function" && n.store.onDrop(e, n), this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null;
|
|
707
708
|
});
|
|
708
709
|
}
|
|
709
|
-
},
|
|
710
|
+
}, xe = !1, A = class {
|
|
710
711
|
windowElement = null;
|
|
711
712
|
containerElement = null;
|
|
712
|
-
debug =
|
|
713
|
+
debug = xe;
|
|
713
714
|
constructor(e) {
|
|
714
715
|
let t = null;
|
|
715
|
-
e instanceof
|
|
716
|
+
e instanceof se ? (t = e, this.rootSash = e) : (t = new oe(e), this.rootSash = t.buildSashTree({ resizeStrategy: t.resizeStrategy })), this.fitContainer = t.fitContainer;
|
|
716
717
|
}
|
|
717
718
|
frame(e) {
|
|
718
719
|
this.containerElement = e, this.windowElement = this.createWindow({ theme: this.theme }), this.glaze(), this.containerElement.append(this.windowElement);
|
|
@@ -725,12 +726,12 @@ var fe = {
|
|
|
725
726
|
}
|
|
726
727
|
static assemble(...e) {
|
|
727
728
|
e.forEach((e) => {
|
|
728
|
-
|
|
729
|
+
g(this.prototype, e);
|
|
729
730
|
});
|
|
730
731
|
}
|
|
731
732
|
};
|
|
732
|
-
|
|
733
|
-
function
|
|
733
|
+
A.assemble(ge, _e, he, ve, be, ye);
|
|
734
|
+
function j(e, t) {
|
|
734
735
|
let n = e.left + e.width, r = e.top + e.height, i = t.left + t.width, a = t.top + t.height;
|
|
735
736
|
if (e.left >= i || t.left >= n || e.top >= a || t.top >= r) return null;
|
|
736
737
|
let o = Math.max(e.left, t.left), s = Math.max(e.top, t.top), c = Math.min(n, i), l = Math.min(r, a);
|
|
@@ -741,28 +742,29 @@ function N(e, t) {
|
|
|
741
742
|
height: l - s
|
|
742
743
|
};
|
|
743
744
|
}
|
|
744
|
-
var
|
|
745
|
+
var M = {
|
|
745
746
|
enableGlassActions() {
|
|
746
747
|
this.handleMinimizedGlassClick(), this.observeActionButtons();
|
|
747
748
|
},
|
|
748
749
|
restoreGlass(e) {
|
|
749
750
|
let t = e.bwOriginalBoundingRect, n = 0, r = null;
|
|
750
751
|
if (this.windowElement.querySelectorAll("bw-pane").forEach((e) => {
|
|
751
|
-
let i =
|
|
752
|
+
let i = j(t, b(e));
|
|
752
753
|
if (i) {
|
|
753
754
|
let t = i.width * i.height;
|
|
754
755
|
t > n && (n = t, r = e);
|
|
755
756
|
}
|
|
756
757
|
}), r) {
|
|
757
|
-
let n = e.bwOriginalPosition, i =
|
|
758
|
-
if (n ===
|
|
759
|
-
else if (n ===
|
|
758
|
+
let n = e.bwOriginalPosition, i = b(r), a = r.getAttribute("sash-id"), o = this.rootSash.getById(a), s = 0;
|
|
759
|
+
if (n === x.Left || n === x.Right) s = i.width - t.width < o.minWidth ? i.width / 2 : t.width;
|
|
760
|
+
else if (n === x.Top || n === x.Bottom) s = i.height - t.height < o.minHeight ? i.height / 2 : t.height;
|
|
760
761
|
else throw Error("[bwin] Invalid position when restoring glass");
|
|
761
762
|
let c = e.bwOriginalSashId;
|
|
762
763
|
this.addPane(r.getAttribute("sash-id"), {
|
|
763
764
|
id: c,
|
|
764
765
|
position: n,
|
|
765
|
-
size: s
|
|
766
|
+
size: s,
|
|
767
|
+
withGlass: !1
|
|
766
768
|
}).domNode.append(e.bwGlassElement);
|
|
767
769
|
}
|
|
768
770
|
},
|
|
@@ -795,20 +797,21 @@ var P = {
|
|
|
795
797
|
});
|
|
796
798
|
}).observe(this.windowElement, { childList: !0 });
|
|
797
799
|
}
|
|
798
|
-
},
|
|
800
|
+
}, N = null, P = !1, Se = {
|
|
799
801
|
onPaneDrop(e, t) {
|
|
800
|
-
if (!
|
|
802
|
+
if (!N) return;
|
|
801
803
|
let n = this.activeDropPaneEl.getAttribute("drop-area");
|
|
802
804
|
if (n === "center") {
|
|
803
|
-
let e =
|
|
805
|
+
let e = N.closest("bw-pane");
|
|
804
806
|
this.swapPanes(e, this.activeDropPaneEl);
|
|
805
807
|
return;
|
|
806
808
|
} else {
|
|
807
|
-
let e =
|
|
809
|
+
let e = O(N);
|
|
808
810
|
this.removePane(e), this.addPane(t.id, {
|
|
809
811
|
position: n,
|
|
810
|
-
id: e
|
|
811
|
-
|
|
812
|
+
id: e,
|
|
813
|
+
withGlass: !1
|
|
814
|
+
}).domNode.append(N);
|
|
812
815
|
}
|
|
813
816
|
},
|
|
814
817
|
enableGlassDrag() {
|
|
@@ -819,62 +822,62 @@ var P = {
|
|
|
819
822
|
return;
|
|
820
823
|
}
|
|
821
824
|
let t = e.target.closest("bw-glass");
|
|
822
|
-
t.setAttribute("draggable", !0),
|
|
825
|
+
t.setAttribute("draggable", !0), N = t;
|
|
823
826
|
}), document.addEventListener("mouseup", () => {
|
|
824
|
-
|
|
827
|
+
N &&= (N.removeAttribute("draggable"), null);
|
|
825
828
|
}), this.windowElement.addEventListener("dragstart", (e) => {
|
|
826
|
-
if (!(e.target instanceof HTMLElement) || !e.target.matches("bw-glass") || !
|
|
829
|
+
if (!(e.target instanceof HTMLElement) || !e.target.matches("bw-glass") || !N) return;
|
|
827
830
|
e.dataTransfer.effectAllowed = "move";
|
|
828
|
-
let t =
|
|
829
|
-
|
|
831
|
+
let t = N.closest("bw-pane");
|
|
832
|
+
P = t.getAttribute("can-drop") !== "false", t.setAttribute("can-drop", !1);
|
|
830
833
|
}), this.windowElement.addEventListener("dragend", () => {
|
|
831
|
-
|
|
834
|
+
N &&= (N.removeAttribute("draggable"), N.closest("bw-pane").setAttribute("can-drop", P), null);
|
|
832
835
|
});
|
|
833
836
|
}
|
|
834
|
-
},
|
|
837
|
+
}, F = {
|
|
835
838
|
label: "",
|
|
836
839
|
className: "bw-glass-action--close",
|
|
837
840
|
onClick: (e, t) => {
|
|
838
|
-
let n =
|
|
841
|
+
let n = O(e.target);
|
|
839
842
|
t.removePane(n);
|
|
840
843
|
}
|
|
841
|
-
},
|
|
844
|
+
}, I = {
|
|
842
845
|
label: "",
|
|
843
846
|
className: "bw-glass-action--minimize",
|
|
844
847
|
onClick: (e, t) => {
|
|
845
848
|
let n = t.sillElement;
|
|
846
849
|
if (!n) throw Error("[bwin] Sill element not found when minimizing");
|
|
847
|
-
let r =
|
|
850
|
+
let r = v("<button class=\"bw-minimized-glass\" />");
|
|
848
851
|
n.append(r);
|
|
849
852
|
let i = e.target.closest("bw-pane"), a = e.target.closest("bw-glass"), o = i.getAttribute("sash-id"), s = i.getAttribute("position");
|
|
850
|
-
r.bwGlassElement = a, r.bwOriginalPosition = s, r.bwOriginalBoundingRect =
|
|
853
|
+
r.bwGlassElement = a, r.bwOriginalPosition = s, r.bwOriginalBoundingRect = b(i), r.bwOriginalSashId = o, t.removePane(o);
|
|
851
854
|
}
|
|
852
|
-
},
|
|
855
|
+
}, Ce = {
|
|
853
856
|
label: "",
|
|
854
857
|
className: "bw-glass-action--maximize",
|
|
855
858
|
onClick: (e) => {
|
|
856
859
|
let t = e.target.closest("bw-pane");
|
|
857
|
-
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 =
|
|
860
|
+
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 = b(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
|
|
858
861
|
}
|
|
859
|
-
},
|
|
862
|
+
}, L = 15, R = {
|
|
860
863
|
label: "",
|
|
861
864
|
className: "bw-glass-action--detach",
|
|
862
865
|
onClick: (e, t) => {
|
|
863
866
|
if (!t.addDetachedGlass) throw Error("[bwin] Failed to detach glass from pane");
|
|
864
|
-
let n = e.target.closest("bw-pane"), r = n.querySelector("bw-glass-content"), i = n.querySelector("bw-glass-title"), a = t.windowElement.getBoundingClientRect(), o = a.width -
|
|
867
|
+
let n = e.target.closest("bw-pane"), r = n.querySelector("bw-glass-content"), i = n.querySelector("bw-glass-title"), a = t.windowElement.getBoundingClientRect(), o = a.width - L * 2, s = a.height - L * 2, c = t.addDetachedGlass({
|
|
865
868
|
position: "center",
|
|
866
869
|
width: o,
|
|
867
870
|
height: s
|
|
868
871
|
}), l = n.getAttribute("sash-id"), u = t.rootSash.getById(l), d = u.parent.getChildSiblingById(l).id;
|
|
869
872
|
c.domNode.bwOriginalSiblingSashId = d, c.domNode.bwOriginalPosition = n.getAttribute("position"), c.domNode.bwOriginalRelativeSize = u.getRelativeSize(), c.contentElement.replaceWith(r), i && c.titleElement.replaceWith(i), t.removePane(l);
|
|
870
873
|
}
|
|
871
|
-
},
|
|
874
|
+
}, z = [
|
|
875
|
+
I,
|
|
872
876
|
R,
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
], H = class {
|
|
877
|
+
F
|
|
878
|
+
], B = class {
|
|
876
879
|
domNode;
|
|
877
|
-
constructor({ title: e = null, content: t = null, tabs: n = [], actions: r =
|
|
880
|
+
constructor({ title: e = null, content: t = null, tabs: n = [], actions: r = z, draggable: i = !0, sash: a = null, binaryWindow: o }) {
|
|
878
881
|
this.title = e, this.content = t, this.tabs = n, this.actions = r, this.sash = a, this.draggable = i, this.binaryWindow = o, this.build();
|
|
879
882
|
}
|
|
880
883
|
build() {
|
|
@@ -882,16 +885,16 @@ var P = {
|
|
|
882
885
|
if (Array.isArray(this.tabs) && this.tabs.length > 0) e.append(this.createTabs());
|
|
883
886
|
else {
|
|
884
887
|
let t = document.createElement("bw-glass-title");
|
|
885
|
-
this.title && t.append(
|
|
888
|
+
this.title && t.append(v(this.title)), e.append(t);
|
|
886
889
|
}
|
|
887
890
|
e.setAttribute("can-drag", this.draggable), e.append(this.createActions());
|
|
888
|
-
let t = document.createElement("bw-glass-content"), n =
|
|
891
|
+
let t = document.createElement("bw-glass-content"), n = v(this.content);
|
|
889
892
|
n && t.append(n), this.domNode = document.createElement("bw-glass"), this.domNode.append(e, t);
|
|
890
893
|
}
|
|
891
894
|
createTabs() {
|
|
892
895
|
let e = document.createElement("bw-glass-tab-container");
|
|
893
896
|
for (let t of this.tabs) {
|
|
894
|
-
let n =
|
|
897
|
+
let n = v(`<button class="bw-glass-tab">${t?.label ?? t}</button>`);
|
|
895
898
|
e.append(n);
|
|
896
899
|
}
|
|
897
900
|
return e;
|
|
@@ -899,7 +902,7 @@ var P = {
|
|
|
899
902
|
createActions() {
|
|
900
903
|
let e = document.createElement("bw-glass-action-container"), t = Array.isArray(this.actions) ? this.actions : [];
|
|
901
904
|
for (let n of t) {
|
|
902
|
-
let t = n?.label ?? n, r =
|
|
905
|
+
let t = n?.label ?? n, r = v(`<button class="${n.className ? `bw-glass-action ${n.className}` : "bw-glass-action"}">${t}</button>`);
|
|
903
906
|
typeof n.onClick == "function" && r.addEventListener("click", (e) => {
|
|
904
907
|
n.onClick(e, this.binaryWindow);
|
|
905
908
|
}), e.append(r);
|
|
@@ -915,18 +918,18 @@ var P = {
|
|
|
915
918
|
get titleElement() {
|
|
916
919
|
return this.domNode.querySelector("bw-glass-title");
|
|
917
920
|
}
|
|
918
|
-
},
|
|
921
|
+
}, we = [
|
|
922
|
+
I,
|
|
923
|
+
Ce,
|
|
919
924
|
R,
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
L
|
|
923
|
-
], xe = {
|
|
925
|
+
F
|
|
926
|
+
], Te = {
|
|
924
927
|
enableGlassFeature() {
|
|
925
928
|
this.enableGlassActions(), this.enableGlassDrag();
|
|
926
929
|
},
|
|
927
|
-
...
|
|
928
|
-
...
|
|
929
|
-
},
|
|
930
|
+
...M,
|
|
931
|
+
...Se
|
|
932
|
+
}, Ee = {
|
|
930
933
|
trimMuntin(e) {
|
|
931
934
|
e.hasAttribute("vertical") ? (e.style.top = `${parseFloat(e.style.top) + this.muntinSize / 2}px`, e.style.height = `${parseFloat(e.style.height) - this.muntinSize}px`) : e.hasAttribute("horizontal") && (e.style.left = `${parseFloat(e.style.left) + this.muntinSize / 2}px`, e.style.width = `${parseFloat(e.style.width) - this.muntinSize}px`);
|
|
932
935
|
},
|
|
@@ -936,7 +939,7 @@ var P = {
|
|
|
936
939
|
onMuntinUpdate(e) {
|
|
937
940
|
this.trimMuntin(e);
|
|
938
941
|
}
|
|
939
|
-
},
|
|
942
|
+
}, De = [
|
|
940
943
|
"n",
|
|
941
944
|
"s",
|
|
942
945
|
"e",
|
|
@@ -946,13 +949,13 @@ var P = {
|
|
|
946
949
|
"se",
|
|
947
950
|
"sw"
|
|
948
951
|
];
|
|
949
|
-
function
|
|
950
|
-
return
|
|
952
|
+
function Oe() {
|
|
953
|
+
return De.map((e) => {
|
|
951
954
|
let t = document.createElement("bw-glass-resize-handle");
|
|
952
955
|
return t.setAttribute("resize-dir", e), t;
|
|
953
956
|
});
|
|
954
957
|
}
|
|
955
|
-
function
|
|
958
|
+
function ke({ position: e, offset: t, offsetX: n, offsetY: r, width: i, height: a }) {
|
|
956
959
|
let o = n ?? t, s = r ?? t;
|
|
957
960
|
switch (e) {
|
|
958
961
|
case "top-left": return {
|
|
@@ -988,7 +991,7 @@ function Te({ position: e, offset: t, offsetX: n, offsetY: r, width: i, height:
|
|
|
988
991
|
default: throw Error(`Position "${e}" is not supported for detached glass.`);
|
|
989
992
|
}
|
|
990
993
|
}
|
|
991
|
-
var
|
|
994
|
+
var V = new class {
|
|
992
995
|
constructor() {
|
|
993
996
|
this.glasses = [], this.topZIndex = 1;
|
|
994
997
|
}
|
|
@@ -1009,14 +1012,14 @@ var U = new class {
|
|
|
1009
1012
|
}
|
|
1010
1013
|
return null;
|
|
1011
1014
|
}
|
|
1012
|
-
}(),
|
|
1015
|
+
}(), H = [
|
|
1013
1016
|
{
|
|
1014
1017
|
label: "",
|
|
1015
1018
|
className: "bw-glass-action--minimize",
|
|
1016
1019
|
onClick: (e, t) => {
|
|
1017
1020
|
let n = t.sillElement;
|
|
1018
1021
|
if (!n) throw Error("[bwin] Sill element not found when minimizing");
|
|
1019
|
-
let r =
|
|
1022
|
+
let r = v("<button class=\"bw-minimized-detached-glass\" />");
|
|
1020
1023
|
n.append(r);
|
|
1021
1024
|
let i = e.target.closest("bw-glass[detached]");
|
|
1022
1025
|
if (!i) throw Error("[bwin] Detached Glass element not found when minimizing");
|
|
@@ -1036,7 +1039,7 @@ var U = new class {
|
|
|
1036
1039
|
t.addPane(s, {
|
|
1037
1040
|
position: c,
|
|
1038
1041
|
size: l,
|
|
1039
|
-
content:
|
|
1042
|
+
content: y(u),
|
|
1040
1043
|
title: n.querySelector("bw-glass-title")?.textContent || ""
|
|
1041
1044
|
}), t.removeDetachedGlass(n.id);
|
|
1042
1045
|
}
|
|
@@ -1046,17 +1049,17 @@ var U = new class {
|
|
|
1046
1049
|
className: "bw-glass-action--close",
|
|
1047
1050
|
onClick: (e) => {
|
|
1048
1051
|
let t = e.target.closest("bw-glass[detached]");
|
|
1049
|
-
t && (
|
|
1052
|
+
t && (V.removeGlassById(t.id), t.remove());
|
|
1050
1053
|
}
|
|
1051
1054
|
}
|
|
1052
|
-
],
|
|
1055
|
+
], U = class extends B {
|
|
1053
1056
|
constructor(e) {
|
|
1054
|
-
let { position: t, width: n = 222, height: r = 222, offset: i = 0, offsetX: a, offsetY: o, id: s, actions: c =
|
|
1057
|
+
let { position: t, width: n = 222, height: r = 222, offset: i = 0, offsetX: a, offsetY: o, id: s, actions: c = H, ...l } = e;
|
|
1055
1058
|
super({
|
|
1056
|
-
...
|
|
1059
|
+
...l,
|
|
1057
1060
|
actions: c
|
|
1058
|
-
}), this.domNode.setAttribute("id", s ||
|
|
1059
|
-
let { top:
|
|
1061
|
+
}), this.domNode.setAttribute("id", s || d() + "-F"), this.domNode.setAttribute("detached", ""), this.domNode.style.position = "absolute", this.domNode.style.width = `${n}px`, this.domNode.style.height = `${r}px`;
|
|
1062
|
+
let { top: u, left: f, right: p, bottom: m } = ke({
|
|
1060
1063
|
position: t,
|
|
1061
1064
|
offset: i,
|
|
1062
1065
|
offsetX: a,
|
|
@@ -1064,25 +1067,25 @@ var U = new class {
|
|
|
1064
1067
|
width: n,
|
|
1065
1068
|
height: r
|
|
1066
1069
|
});
|
|
1067
|
-
this.domNode.style.top =
|
|
1070
|
+
this.domNode.style.top = u, this.domNode.style.left = f, this.domNode.style.right = p, this.domNode.style.bottom = m;
|
|
1068
1071
|
}
|
|
1069
|
-
},
|
|
1070
|
-
function
|
|
1071
|
-
let r =
|
|
1072
|
+
}, Ae = 200, je = 200, W = 25;
|
|
1073
|
+
function Me(e, { width: t, height: n }) {
|
|
1074
|
+
let r = V.getActiveGlass();
|
|
1072
1075
|
if (!r) return { position: "center" };
|
|
1073
|
-
let i = e.getBoundingClientRect(), a = r.getBoundingClientRect(), o = a.left - i.left +
|
|
1074
|
-
return o + t > i.width && (o =
|
|
1076
|
+
let i = e.getBoundingClientRect(), a = r.getBoundingClientRect(), o = a.left - i.left + W, s = a.top - i.top + W;
|
|
1077
|
+
return o + t > i.width && (o = W), s + n > i.height && (s = W), {
|
|
1075
1078
|
position: "top-left",
|
|
1076
1079
|
offsetX: o,
|
|
1077
1080
|
offsetY: s
|
|
1078
1081
|
};
|
|
1079
1082
|
}
|
|
1080
|
-
var
|
|
1083
|
+
var Ne = {
|
|
1081
1084
|
addDetachedGlass(e = {}) {
|
|
1082
|
-
let t = e.width ??
|
|
1085
|
+
let t = e.width ?? Ae, n = e.height ?? je, { position: r, offsetX: i, offsetY: a } = e.position ? {} : Me(this.windowElement, {
|
|
1083
1086
|
width: t,
|
|
1084
1087
|
height: n
|
|
1085
|
-
}), o = new
|
|
1088
|
+
}), o = new U({
|
|
1086
1089
|
actions: this.actions[1],
|
|
1087
1090
|
binaryWindow: this,
|
|
1088
1091
|
position: r,
|
|
@@ -1092,19 +1095,19 @@ var Ae = {
|
|
|
1092
1095
|
width: t,
|
|
1093
1096
|
height: n
|
|
1094
1097
|
});
|
|
1095
|
-
return this.windowElement.append(o.domNode),
|
|
1098
|
+
return this.windowElement.append(o.domNode), V.addGlassByElement(o.domNode), V.bringToFront(o.domNode), o;
|
|
1096
1099
|
},
|
|
1097
1100
|
removeDetachedGlass(e) {
|
|
1098
|
-
let t =
|
|
1101
|
+
let t = V.removeGlassById(e);
|
|
1099
1102
|
return t?.remove(), t;
|
|
1100
1103
|
}
|
|
1101
|
-
},
|
|
1104
|
+
}, Pe = { enableDetachedGlassActivate() {
|
|
1102
1105
|
this.windowElement.addEventListener("pointerdown", (e) => {
|
|
1103
1106
|
if (e.button !== 0) return;
|
|
1104
1107
|
let t = e.target.closest?.("bw-glass[detached]");
|
|
1105
|
-
t &&
|
|
1108
|
+
t && V.bringToFront(t);
|
|
1106
1109
|
});
|
|
1107
|
-
} },
|
|
1110
|
+
} }, Fe = { enableDetachedGlassMove() {
|
|
1108
1111
|
let e = null, t = 0, n = 0, r = 0, i = 0;
|
|
1109
1112
|
this.windowElement.addEventListener("pointerdown", (a) => {
|
|
1110
1113
|
if (a.button !== 0) return;
|
|
@@ -1122,43 +1125,43 @@ var Ae = {
|
|
|
1122
1125
|
}), this.windowElement.addEventListener("pointerup", (t) => {
|
|
1123
1126
|
e &&= (t.target.hasPointerCapture?.(t.pointerId) && t.target.releasePointerCapture(t.pointerId), null);
|
|
1124
1127
|
});
|
|
1125
|
-
} },
|
|
1128
|
+
} }, G = null, K = 0, q = 0, Ie = { enableDetachedGlassDrag() {
|
|
1126
1129
|
document.addEventListener("mousedown", (e) => {
|
|
1127
1130
|
if (e.button !== 0) return;
|
|
1128
1131
|
let t = e.target.closest("bw-glass-header");
|
|
1129
1132
|
if (!t || e.target.closest("button") || t.getAttribute("can-drag") === "false") return;
|
|
1130
1133
|
let n = t.closest("bw-glass[detached]");
|
|
1131
|
-
n && (n.setAttribute("draggable", !0),
|
|
1134
|
+
n && (n.setAttribute("draggable", !0), G = n);
|
|
1132
1135
|
}), document.addEventListener("mouseup", () => {
|
|
1133
|
-
|
|
1136
|
+
G &&= (G.removeAttribute("draggable"), null);
|
|
1134
1137
|
}), this.windowElement.addEventListener("dragstart", (e) => {
|
|
1135
|
-
if (!
|
|
1138
|
+
if (!G) return;
|
|
1136
1139
|
e.dataTransfer.effectAllowed = "move";
|
|
1137
|
-
let t =
|
|
1138
|
-
|
|
1140
|
+
let t = G.getBoundingClientRect();
|
|
1141
|
+
K = e.clientX - t.left, q = e.clientY - t.top;
|
|
1139
1142
|
}), this.windowElement.addEventListener("dragend", (e) => {
|
|
1140
|
-
if (!
|
|
1141
|
-
let t = this.windowElement.getBoundingClientRect(), n = e.clientX - t.left -
|
|
1142
|
-
|
|
1143
|
+
if (!G) return;
|
|
1144
|
+
let t = this.windowElement.getBoundingClientRect(), n = e.clientX - t.left - K, r = e.clientY - t.top - q;
|
|
1145
|
+
G.style.right = "auto", G.style.bottom = "auto", G.style.left = `${n}px`, G.style.top = `${r}px`, G.removeAttribute("draggable"), G = null;
|
|
1143
1146
|
});
|
|
1144
|
-
} },
|
|
1145
|
-
function
|
|
1147
|
+
} }, J = 100, Y = 60;
|
|
1148
|
+
function Le(e) {
|
|
1146
1149
|
return !!e.querySelector(":scope > bw-glass-resize-handle");
|
|
1147
1150
|
}
|
|
1148
|
-
function
|
|
1149
|
-
|
|
1151
|
+
function Re(e) {
|
|
1152
|
+
Le(e) || e.append(...Oe());
|
|
1150
1153
|
}
|
|
1151
|
-
function
|
|
1154
|
+
function X(e) {
|
|
1152
1155
|
e.querySelectorAll(":scope > bw-glass-resize-handle").forEach((e) => e.remove());
|
|
1153
1156
|
}
|
|
1154
|
-
var
|
|
1157
|
+
var ze = { enableDetachedGlassResize() {
|
|
1155
1158
|
let e = null, t = "", n = 0, r = 0, i = null;
|
|
1156
1159
|
this.windowElement.addEventListener("pointerover", (e) => {
|
|
1157
1160
|
let t = e.target.closest?.("bw-glass[detached]");
|
|
1158
|
-
t &&
|
|
1161
|
+
t && Re(t);
|
|
1159
1162
|
}), this.windowElement.addEventListener("pointerout", (t) => {
|
|
1160
1163
|
let n = t.target.closest?.("bw-glass[detached]");
|
|
1161
|
-
n && t.relatedTarget?.closest?.("bw-glass[detached]") !== n && n !== e &&
|
|
1164
|
+
n && t.relatedTarget?.closest?.("bw-glass[detached]") !== n && n !== e && X(n);
|
|
1162
1165
|
}), this.windowElement.addEventListener("pointerdown", (a) => {
|
|
1163
1166
|
if (a.button !== 0 || a.target.tagName !== "BW-GLASS-RESIZE-HANDLE") return;
|
|
1164
1167
|
let o = a.target.closest("bw-glass[detached]");
|
|
@@ -1174,45 +1177,45 @@ var Ie = { enableDetachedGlassResize() {
|
|
|
1174
1177
|
}), this.windowElement.addEventListener("pointermove", (a) => {
|
|
1175
1178
|
if (!e) return;
|
|
1176
1179
|
let o = t, s = a.pageX - n, c = a.pageY - r, l = i, { left: u, top: d, width: f, height: p } = l;
|
|
1177
|
-
o.includes("e") ? f = Math.max(
|
|
1180
|
+
o.includes("e") ? f = Math.max(J, l.width + s) : o.includes("w") && (f = Math.max(J, l.width - s), u = l.left + (l.width - f)), o.includes("s") ? p = Math.max(Y, l.height + c) : o.includes("n") && (p = Math.max(Y, l.height - c), d = l.top + (l.height - p)), e.style.right = "auto", e.style.bottom = "auto", e.style.left = `${u}px`, e.style.top = `${d}px`, e.style.width = `${f}px`, e.style.height = `${p}px`;
|
|
1178
1181
|
}), this.windowElement.addEventListener("pointerup", (n) => {
|
|
1179
1182
|
if (!e) return;
|
|
1180
1183
|
n.target.hasPointerCapture?.(n.pointerId) && n.target.releasePointerCapture(n.pointerId);
|
|
1181
1184
|
let r = e;
|
|
1182
|
-
e = null, t = "", i = null, r.matches(":hover") ||
|
|
1185
|
+
e = null, t = "", i = null, r.matches(":hover") || X(r);
|
|
1183
1186
|
});
|
|
1184
|
-
} },
|
|
1187
|
+
} }, Be = { handleMinimizedDetachedGlassClick() {
|
|
1185
1188
|
this.sillElement.addEventListener("click", (e) => {
|
|
1186
1189
|
let t = e.target;
|
|
1187
1190
|
if (!t.matches(".bw-minimized-detached-glass")) return;
|
|
1188
1191
|
let n = t.bwDetachedGlassElement;
|
|
1189
|
-
n && (n.style.display = "", t.remove(),
|
|
1192
|
+
n && (n.style.display = "", t.remove(), V.bringToFront(n));
|
|
1190
1193
|
});
|
|
1191
|
-
} },
|
|
1194
|
+
} }, Ve = {
|
|
1192
1195
|
enableDetachedGlassFeatures() {
|
|
1193
1196
|
this.enableDetachedGlassActivate(), this.enableDetachedGlassResize(), this.enableDetachedGlassMove(), this.handleMinimizedDetachedGlassClick();
|
|
1194
1197
|
},
|
|
1195
|
-
...Ae,
|
|
1196
|
-
...je,
|
|
1197
|
-
...Me,
|
|
1198
1198
|
...Ne,
|
|
1199
|
+
...Pe,
|
|
1200
|
+
...Fe,
|
|
1199
1201
|
...Ie,
|
|
1200
|
-
...
|
|
1201
|
-
|
|
1202
|
+
...ze,
|
|
1203
|
+
...Be
|
|
1204
|
+
}, Z = class e extends A {
|
|
1202
1205
|
sillElement = null;
|
|
1203
1206
|
constructor(t) {
|
|
1204
1207
|
super(t), this.theme = t.theme || "", this.actions = e.normActions(t.actions);
|
|
1205
1208
|
}
|
|
1206
1209
|
frame() {
|
|
1207
1210
|
super.frame(...arguments);
|
|
1208
|
-
let e =
|
|
1211
|
+
let e = v("<bw-sill />");
|
|
1209
1212
|
this.windowElement.append(e), this.sillElement = e;
|
|
1210
1213
|
}
|
|
1211
1214
|
enableFeatures() {
|
|
1212
1215
|
super.enableFeatures(), this.enableGlassFeature(), this.enableDetachedGlassFeatures();
|
|
1213
1216
|
}
|
|
1214
1217
|
onPaneCreate(e, t) {
|
|
1215
|
-
let n = this.actions[0], r = new
|
|
1218
|
+
let n = this.actions[0], r = new B({
|
|
1216
1219
|
actions: n,
|
|
1217
1220
|
...t.store,
|
|
1218
1221
|
sash: t,
|
|
@@ -1222,16 +1225,20 @@ var Ie = { enableDetachedGlassResize() {
|
|
|
1222
1225
|
}
|
|
1223
1226
|
onPaneUpdate() {}
|
|
1224
1227
|
addPane(e, t) {
|
|
1225
|
-
let { position: n, size: r, id: i,
|
|
1228
|
+
let { position: n, size: r, id: i, withGlass: a = !0, ...o } = t, s = super.addPane(e, {
|
|
1226
1229
|
position: n,
|
|
1227
1230
|
size: r,
|
|
1228
1231
|
id: i
|
|
1229
|
-
}), s = new H({
|
|
1230
|
-
...a,
|
|
1231
|
-
sash: o,
|
|
1232
|
-
binaryWindow: this
|
|
1233
1232
|
});
|
|
1234
|
-
|
|
1233
|
+
if (a) {
|
|
1234
|
+
let e = new B({
|
|
1235
|
+
...o,
|
|
1236
|
+
sash: s,
|
|
1237
|
+
binaryWindow: this
|
|
1238
|
+
});
|
|
1239
|
+
s.domNode.append(e.domNode);
|
|
1240
|
+
}
|
|
1241
|
+
return s;
|
|
1235
1242
|
}
|
|
1236
1243
|
setTheme(e) {
|
|
1237
1244
|
if (!e) {
|
|
@@ -1249,108 +1256,138 @@ var Ie = { enableDetachedGlassResize() {
|
|
|
1249
1256
|
t && t.remove();
|
|
1250
1257
|
}
|
|
1251
1258
|
static normActions(e) {
|
|
1252
|
-
if (e === void 0) return [
|
|
1259
|
+
if (e === void 0) return [z, H];
|
|
1253
1260
|
if (!e || !Array.isArray(e) || e.length === 0) return [[], []];
|
|
1254
|
-
if (e.length === 1 && Array.isArray(e[0])) return [e[0],
|
|
1255
|
-
if (!e.some(Array.isArray)) return [e,
|
|
1261
|
+
if (e.length === 1 && Array.isArray(e[0])) return [e[0], H];
|
|
1262
|
+
if (!e.some(Array.isArray)) return [e, H];
|
|
1256
1263
|
if (e.length >= 2 && !Array.isArray(e[0]) && Array.isArray(e[1])) return [[], e[1]];
|
|
1257
1264
|
if (e.length >= 2 && Array.isArray(e[0]) && !Array.isArray(e[1])) return [e[0], []];
|
|
1258
1265
|
if (e.length >= 2 && Array.isArray(e[0]) && Array.isArray(e[1])) return e;
|
|
1259
1266
|
throw Error("[bwin] Invalid actions format");
|
|
1260
1267
|
}
|
|
1261
1268
|
};
|
|
1262
|
-
|
|
1269
|
+
Z.assemble(Te, Ve, Ee);
|
|
1263
1270
|
//#endregion
|
|
1264
1271
|
//#region src/Muntin.tsx
|
|
1265
|
-
var
|
|
1266
|
-
function
|
|
1267
|
-
let
|
|
1268
|
-
return
|
|
1269
|
-
|
|
1270
|
-
}, []), /* @__PURE__ */
|
|
1271
|
-
"sash-id":
|
|
1272
|
+
var Q = 4;
|
|
1273
|
+
function He({ sash: e }) {
|
|
1274
|
+
let n = s(), r = e.leftChild, a = e.topChild, o, c, l, u, d, f;
|
|
1275
|
+
return r ? (o = Q, c = e.height - Q, l = e.top + Q / 2, u = e.left + r.width - Q / 2, d = !0) : a && (o = e.width - Q, c = Q, l = e.top + a.height - Q / 2, u = e.left + Q / 2, f = !0), i(() => {
|
|
1276
|
+
e.domNode = n.current;
|
|
1277
|
+
}, []), /* @__PURE__ */ t.createElement("bw-muntin", {
|
|
1278
|
+
"sash-id": e.id,
|
|
1272
1279
|
style: {
|
|
1273
|
-
width:
|
|
1280
|
+
width: o,
|
|
1274
1281
|
height: c,
|
|
1275
1282
|
top: l,
|
|
1276
1283
|
left: u
|
|
1277
1284
|
},
|
|
1278
1285
|
vertical: d,
|
|
1279
1286
|
horizontal: f,
|
|
1280
|
-
resizable:
|
|
1281
|
-
ref:
|
|
1287
|
+
resizable: e.store?.resizable === !1 ? "false" : "true",
|
|
1288
|
+
ref: n
|
|
1282
1289
|
});
|
|
1283
1290
|
}
|
|
1284
1291
|
//#endregion
|
|
1285
1292
|
//#region src/Pane.tsx
|
|
1286
|
-
function
|
|
1287
|
-
let
|
|
1288
|
-
|
|
1289
|
-
|
|
1293
|
+
function Ue({ sash: e, bwin: n }) {
|
|
1294
|
+
let r = s(), { left: a, top: o, width: c, height: l, id: u, position: d } = e;
|
|
1295
|
+
i(() => {
|
|
1296
|
+
e.domNode = r.current;
|
|
1290
1297
|
}, []);
|
|
1291
|
-
let f =
|
|
1292
|
-
return /* @__PURE__ */
|
|
1298
|
+
let f = e.store?.actions === void 0 ? n.actions[0] : Array.isArray(e.store.actions) ? e.store.actions : [];
|
|
1299
|
+
return /* @__PURE__ */ t.createElement("bw-pane", {
|
|
1293
1300
|
"sash-id": u,
|
|
1294
1301
|
position: d,
|
|
1295
1302
|
style: {
|
|
1296
|
-
left:
|
|
1297
|
-
top:
|
|
1303
|
+
left: a,
|
|
1304
|
+
top: o,
|
|
1298
1305
|
width: c,
|
|
1299
1306
|
height: l
|
|
1300
1307
|
},
|
|
1301
|
-
"can-drop":
|
|
1302
|
-
ref:
|
|
1303
|
-
}, /* @__PURE__ */
|
|
1304
|
-
let i =
|
|
1305
|
-
return /* @__PURE__ */
|
|
1308
|
+
"can-drop": e.store?.droppable === !1 ? "false" : "true",
|
|
1309
|
+
ref: r
|
|
1310
|
+
}, /* @__PURE__ */ t.createElement("bw-glass", null, /* @__PURE__ */ t.createElement("bw-glass-header", { "can-drag": e.store?.draggable === !1 ? "false" : "true" }, /* @__PURE__ */ t.createElement("bw-glass-title", null, e.store?.title), f.length > 0 && /* @__PURE__ */ t.createElement("bw-glass-action-container", null, f.map((e, r) => {
|
|
1311
|
+
let i = e.className ? `bw-glass-action ${e.className}` : "bw-glass-action";
|
|
1312
|
+
return /* @__PURE__ */ t.createElement("button", {
|
|
1306
1313
|
className: i,
|
|
1307
|
-
key:
|
|
1308
|
-
onClick: (
|
|
1309
|
-
},
|
|
1310
|
-
}))), /* @__PURE__ */
|
|
1314
|
+
key: r,
|
|
1315
|
+
onClick: (t) => e.onClick(t, n)
|
|
1316
|
+
}, e.label);
|
|
1317
|
+
}))), /* @__PURE__ */ t.createElement("bw-glass-content", null, e.store?.content)));
|
|
1318
|
+
}
|
|
1319
|
+
//#endregion
|
|
1320
|
+
//#region src/WindowProvider.tsx
|
|
1321
|
+
var $ = e.createContext(null);
|
|
1322
|
+
function We({ children: t }) {
|
|
1323
|
+
let n = e.useRef(null);
|
|
1324
|
+
return /* @__PURE__ */ e.createElement($.Provider, { value: { api: n } }, t);
|
|
1325
|
+
}
|
|
1326
|
+
function Ge() {
|
|
1327
|
+
let t = e.useContext($);
|
|
1328
|
+
if (!t) throw Error("useWindow must be used within a WindowProvider");
|
|
1329
|
+
let { api: n } = t, r = e.useRef();
|
|
1330
|
+
return r.current ||= new Proxy({}, { get(e, t) {
|
|
1331
|
+
return (...e) => {
|
|
1332
|
+
if (!n.current) throw Error("[react-bwin] Window API is not ready yet. Render a <Window> inside the <WindowProvider> before calling its methods.");
|
|
1333
|
+
let r = n.current[t];
|
|
1334
|
+
return r(...e);
|
|
1335
|
+
};
|
|
1336
|
+
} }), r.current;
|
|
1311
1337
|
}
|
|
1312
1338
|
//#endregion
|
|
1313
1339
|
//#region src/Window.tsx
|
|
1314
|
-
var
|
|
1315
|
-
let
|
|
1316
|
-
...
|
|
1317
|
-
children:
|
|
1318
|
-
}),
|
|
1319
|
-
|
|
1320
|
-
e.children.length > 0 ?
|
|
1321
|
-
}),
|
|
1322
|
-
let e =
|
|
1323
|
-
e?.parentElement && (
|
|
1324
|
-
}, []),
|
|
1325
|
-
fit:
|
|
1326
|
-
removePane:
|
|
1327
|
-
setTheme:
|
|
1328
|
-
addPane:
|
|
1340
|
+
var Ke = n((e, n) => {
|
|
1341
|
+
let u = s(), d = s(), [f, p] = c(), { panes: m, ...h } = e, g = new Z({
|
|
1342
|
+
...h,
|
|
1343
|
+
children: m
|
|
1344
|
+
}), _ = [], v = [];
|
|
1345
|
+
g.rootSash.walk((e) => {
|
|
1346
|
+
e.children.length > 0 ? _.push(e) : v.push(e);
|
|
1347
|
+
}), i(() => {
|
|
1348
|
+
let e = u.current;
|
|
1349
|
+
e?.parentElement && (g.windowElement = e, g.containerElement = e.parentElement, g.sillElement = d.current, g.enableFeatures());
|
|
1350
|
+
}, []), a(n, () => ({
|
|
1351
|
+
fit: g.fit.bind(g),
|
|
1352
|
+
removePane: g.removePane.bind(g),
|
|
1353
|
+
setTheme: g.setTheme.bind(g),
|
|
1354
|
+
addPane: S
|
|
1329
1355
|
}), []);
|
|
1330
|
-
let
|
|
1331
|
-
|
|
1332
|
-
|
|
1356
|
+
let y = r($);
|
|
1357
|
+
i(() => {
|
|
1358
|
+
if (y) return y.api.current = {
|
|
1359
|
+
fit: g.fit.bind(g),
|
|
1360
|
+
removePane: g.removePane.bind(g),
|
|
1361
|
+
setTheme: g.setTheme.bind(g),
|
|
1362
|
+
addPane: S
|
|
1363
|
+
}, () => {
|
|
1364
|
+
y.api.current = null;
|
|
1365
|
+
};
|
|
1366
|
+
}, []);
|
|
1367
|
+
let b = /* @__PURE__ */ t.createElement("bw-window", {
|
|
1368
|
+
"root-sash-id": g.rootSash.id,
|
|
1369
|
+
theme: g.theme || void 0,
|
|
1333
1370
|
style: {
|
|
1334
|
-
width:
|
|
1335
|
-
height:
|
|
1371
|
+
width: g.rootSash.width,
|
|
1372
|
+
height: g.rootSash.height
|
|
1336
1373
|
},
|
|
1337
|
-
ref:
|
|
1338
|
-
},
|
|
1339
|
-
key:
|
|
1340
|
-
sash:
|
|
1341
|
-
bwin:
|
|
1342
|
-
})),
|
|
1343
|
-
key:
|
|
1344
|
-
sash:
|
|
1345
|
-
})), /* @__PURE__ */
|
|
1346
|
-
function
|
|
1347
|
-
let { content: n, ...r } = t, i =
|
|
1348
|
-
|
|
1374
|
+
ref: u
|
|
1375
|
+
}, v.map((e) => /* @__PURE__ */ t.createElement(Ue, {
|
|
1376
|
+
key: e.id,
|
|
1377
|
+
sash: e,
|
|
1378
|
+
bwin: g
|
|
1379
|
+
})), _.map((e) => /* @__PURE__ */ t.createElement(He, {
|
|
1380
|
+
key: e.id,
|
|
1381
|
+
sash: e
|
|
1382
|
+
})), /* @__PURE__ */ t.createElement("bw-sill", { ref: d })), x = o(() => b, []);
|
|
1383
|
+
function S(e, t) {
|
|
1384
|
+
let { content: n, ...r } = t, i = g.addPane(e, r), a = document.querySelector(`bw-pane[sash-id="${i.id}"] bw-glass-content`);
|
|
1385
|
+
p((e) => [...e || [], {
|
|
1349
1386
|
node: n,
|
|
1350
1387
|
container: a
|
|
1351
1388
|
}]);
|
|
1352
1389
|
}
|
|
1353
|
-
return /* @__PURE__ */
|
|
1354
|
-
}),
|
|
1390
|
+
return /* @__PURE__ */ t.createElement(t.Fragment, null, x, f?.map((e) => l(e.node, e.container)));
|
|
1391
|
+
}), qe = "0.5.0";
|
|
1355
1392
|
//#endregion
|
|
1356
|
-
export {
|
|
1393
|
+
export { we as BUILTIN_ACTIONS, H as DEFAULT_DETACHED_GLASS_ACTIONS, z as DEFAULT_GLASS_ACTIONS, Ke as Window, We as WindowProvider, Ge as useWindow, qe as version };
|