react-bwin 0.2.5 → 0.3.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.css +1 -1
- package/dist/react-bwin.d.ts +16 -2
- package/dist/react-bwin.js +231 -234
- package/dist/react-bwin.umd.js +2 -2
- package/package.json +55 -54
package/dist/react-bwin.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--bw-font-family: system-ui;--bw-font-size: 14px;--bw-drop-area-bg-color: hsl(0, 0%, 0%, .05);--bw-glass-clearance: 2px;--bw-glass-border-radius: 2px;--bw-glass-border-color: hsl(0, 0%, 10%);--bw-glass-border-color-disabled: hsl(0, 0%, 80%);--bw-glass-bg-color-disabled: hsl(0, 0%, 97%);--bw-glass-header-height: 30px;--bw-glass-header-gap: 4px;--bw-glass-header-bg-color: hsl(0, 0%, 97%);--bw-sill-gap: 6px}.body--bw-resize-x{-webkit-user-select:none;user-select:none;cursor:ew-resize}.body--bw-resize-y{-webkit-user-select:none;user-select:none;cursor:ns-resize}bw-window{position:absolute;display:block;box-sizing:border-box}bw-window:has(>bw-pane[maximized])>:is(bw-pane,bw-muntin):not([maximized]){display:none}bw-pane{position:absolute;overflow:auto;box-sizing:border-box;background-color:#f2f2f2}bw-pane[drop-area]:before{content:"";position:absolute;background-color:var(--bw-drop-area-bg-color)}bw-pane[drop-area=top]:before{top:0;left:0;right:0;height:50%}bw-pane[drop-area=right]:before{top:0;right:0;bottom:0;width:50%}bw-pane[drop-area=bottom]:before{bottom:0;left:0;right:0;height:50%}bw-pane[drop-area=left]:before{top:0;left:0;bottom:0;width:50%}bw-pane[drop-area=center]:before{top:0;left:0;right:0;bottom:0}bw-muntin{box-sizing:border-box;position:absolute;background-color:#fff}bw-muntin[horizontal]{cursor:ns-resize}bw-muntin[vertical]{cursor:ew-resize}bw-muntin[resizable=false]{cursor:auto}bw-window:has(bw-glass) bw-pane{background-color:transparent}bw-window:has(bw-glass) bw-pane[drop-area]:before{z-index:1}bw-window:has(bw-glass) bw-pane[drop-area=top]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=right]:before{top:var(--bw-glass-clearance);right:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=bottom]:before{bottom:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=left]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=center]:before{inset:var(--bw-glass-clearance)}bw-window:has(bw-glass) bw-muntin{background-color:transparent}bw-glass{position:absolute;inset:var(--bw-glass-clearance);display:flex;flex-direction:column;border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);background-color:#fff;font-family:var(--bw-font-family);font-size:var(--bw-font-size);box-sizing:border-box}bw-glass[draggable=true]:active{cursor:move;opacity:.4}bw-glass-header{box-sizing:border-box;
|
|
1
|
+
:root{--bw-font-family: system-ui;--bw-font-size: 14px;--bw-drop-area-bg-color: hsl(0, 0%, 0%, .05);--bw-glass-clearance: 2px;--bw-glass-border-radius: 2px;--bw-glass-border-color: hsl(0, 0%, 10%);--bw-glass-border-color-disabled: hsl(0, 0%, 80%);--bw-glass-bg-color-disabled: hsl(0, 0%, 97%);--bw-glass-header-height: 30px;--bw-glass-header-gap: 4px;--bw-glass-header-bg-color: hsl(0, 0%, 97%);--bw-sill-gap: 6px}.body--bw-resize-x{-webkit-user-select:none;user-select:none;cursor:ew-resize}.body--bw-resize-y{-webkit-user-select:none;user-select:none;cursor:ns-resize}bw-window{position:absolute;display:block;box-sizing:border-box}bw-window:has(>bw-pane[maximized])>:is(bw-pane,bw-muntin):not([maximized]){display:none}bw-pane{position:absolute;overflow:auto;box-sizing:border-box;background-color:#f2f2f2}bw-pane[drop-area]:before{content:"";position:absolute;background-color:var(--bw-drop-area-bg-color)}bw-pane[drop-area=top]:before{top:0;left:0;right:0;height:50%}bw-pane[drop-area=right]:before{top:0;right:0;bottom:0;width:50%}bw-pane[drop-area=bottom]:before{bottom:0;left:0;right:0;height:50%}bw-pane[drop-area=left]:before{top:0;left:0;bottom:0;width:50%}bw-pane[drop-area=center]:before{top:0;left:0;right:0;bottom:0}bw-muntin{box-sizing:border-box;position:absolute;background-color:#fff}bw-muntin[horizontal]{cursor:ns-resize}bw-muntin[vertical]{cursor:ew-resize}bw-muntin[resizable=false]{cursor:auto}bw-window:has(bw-glass) bw-pane{background-color:transparent}bw-window:has(bw-glass) bw-pane[drop-area]:before{z-index:1}bw-window:has(bw-glass) bw-pane[drop-area=top]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=right]:before{top:var(--bw-glass-clearance);right:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=bottom]:before{bottom:var(--bw-glass-clearance);left:var(--bw-glass-clearance);right:var(--bw-glass-clearance);height:50%}bw-window:has(bw-glass) bw-pane[drop-area=left]:before{top:var(--bw-glass-clearance);left:var(--bw-glass-clearance);bottom:var(--bw-glass-clearance);width:50%}bw-window:has(bw-glass) bw-pane[drop-area=center]:before{inset:var(--bw-glass-clearance)}bw-window:has(bw-glass) bw-muntin{background-color:transparent}bw-glass{position:absolute;inset:var(--bw-glass-clearance);display:flex;flex-direction:column;border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);background-color:#fff;font-family:var(--bw-font-family);font-size:var(--bw-font-size);box-sizing:border-box}bw-glass[draggable=true]:active{cursor:move;opacity:.4}bw-glass-header{box-sizing:border-box;flex-basis:var(--bw-glass-header-height);flex-shrink:0;display:flex;align-items:center;gap:var(--bw-glass-header-gap);overflow:hidden;padding-inline:var(--bw-glass-header-gap);border-bottom:1px solid var(--bw-glass-border-color);border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);background-color:var(--bw-glass-header-bg-color)}bw-glass-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}bw-glass-tab-container{align-self:flex-end;display:flex;gap:var(--bw-glass-header-gap)}.bw-glass-tab{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-bottom:none;border-top-left-radius:var(--bw-glass-border-radius);border-top-right-radius:var(--bw-glass-border-radius);cursor:pointer}.bw-glass-tab:hover{background-color:#fff}.bw-glass-tab:active{transform:translateY(1px)}bw-glass-action-container{margin-left:auto;display:flex;flex-shrink:0;gap:2px}.bw-glass-action{font-family:var(--bw-font-family);border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer}.bw-glass-action:hover{background-color:#fff}.bw-glass-action:active{transform:scale(.95)}.bw-glass-action:disabled{border:1px solid var(--bw-glass-border-color-disabled);background-color:var(--bw-glass-bg-color-disabled);cursor:not-allowed}.bw-glass-action:disabled:hover{background-color:var(--bw-glass-bg-color-disabled)}.bw-glass-action:disabled:active{transform:scale(1)}.bw-glass-action--close:before{content:"✕"}.bw-glass-action--maximize:before{content:"☐"}bw-pane[maximized] .bw-glass-action--maximize:before{content:"□"}.bw-glass-action--minimize:before{content:"−"}bw-glass-content{display:block;box-sizing:border-box;overflow:auto;flex-grow:1}bw-sill{position:absolute;top:100%;margin-top:calc(var(--bw-sill-gap) - var(--bw-glass-clearance));width:100%;display:flex;gap:var(--bw-sill-gap);box-sizing:border-box;padding-inline:var(--bw-glass-clearance)}.bw-minimized-glass{display:block;flex-basis:10%;height:10px;border:1px solid var(--bw-glass-border-color);border-radius:var(--bw-glass-border-radius);cursor:pointer;background-color:var(--bw-glass-header-bg-color)}.bw-minimized-glass:hover{background-color:#fff}.bw-minimized-glass:active{transform:scale(.95)}
|
package/dist/react-bwin.d.ts
CHANGED
|
@@ -74,15 +74,29 @@ declare global {
|
|
|
74
74
|
mount(container: HTMLElement): void
|
|
75
75
|
enableFeatures(): void
|
|
76
76
|
fit(): void
|
|
77
|
+
addPane(targetPaneId: string, fields: PaneFields): Sash
|
|
78
|
+
removePane(targetPaneId: string): void
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
type
|
|
80
|
-
|
|
81
|
+
type WindowHandle = {
|
|
82
|
+
addPane: (targetPaneId: string, fields: PaneFields) => void
|
|
83
|
+
removePane: (targetPaneId: string) => void
|
|
84
|
+
fit: () => void
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
type WindowProps = Omit<ConfigRoot, 'children'> & {
|
|
84
88
|
panes?: ConfigNode[]
|
|
85
89
|
}
|
|
90
|
+
|
|
91
|
+
type PaneFields = {
|
|
92
|
+
size?: number | string
|
|
93
|
+
position?: Position
|
|
94
|
+
title?: React.ReactNode
|
|
95
|
+
content?: React.ReactNode
|
|
96
|
+
actions?: Actions
|
|
97
|
+
draggable?: boolean
|
|
98
|
+
droppable?: boolean
|
|
99
|
+
}
|
|
86
100
|
}
|
|
87
101
|
|
|
88
102
|
export {
|
package/dist/react-bwin.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import f, { useRef as A, useEffect as W, forwardRef as Y, useState as j, useImperativeHandle as K, useMemo as V } from "react";
|
|
2
|
+
import { createPortal as Z } from "react-dom";
|
|
3
|
+
var J = Object.defineProperty, Q = (e, t, i) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, E = (e, t, i) => Q(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
function tt(e = 0.7, t = 128) {
|
|
4
5
|
const i = 256 - t, n = Math.floor(Math.random() * i + t), s = Math.floor(Math.random() * i + t), o = Math.floor(Math.random() * i + t), h = Math.max(0.5, Math.random() * e);
|
|
5
6
|
return `rgba(${n}, ${s}, ${o}, ${h})`;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
+
function B(e = 2, t = 3) {
|
|
8
9
|
if (e < 0 || t < 0)
|
|
9
10
|
throw new Error("Parameters must be non-negative numbers");
|
|
10
11
|
const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = "0123456789";
|
|
@@ -20,15 +21,15 @@ function D(e = 2, t = 3) {
|
|
|
20
21
|
}
|
|
21
22
|
return s;
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function z(e, t) {
|
|
24
25
|
for (; t.firstChild; )
|
|
25
26
|
e.append(t.firstChild);
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function et(e, t) {
|
|
28
29
|
const i = document.createElement("div");
|
|
29
|
-
|
|
30
|
+
z(i, e), z(e, t), z(t, i);
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function C(e) {
|
|
32
33
|
if (typeof e == "number" && !isNaN(e))
|
|
33
34
|
return e;
|
|
34
35
|
if (typeof e == "string") {
|
|
@@ -49,10 +50,10 @@ function z(e) {
|
|
|
49
50
|
}
|
|
50
51
|
return NaN;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function it(e) {
|
|
53
54
|
return e !== null && typeof e == "object" && !Array.isArray(e) && Object.getPrototypeOf(e) === Object.prototype;
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function nt(e, t) {
|
|
56
57
|
for (const i in t) {
|
|
57
58
|
if (Object.hasOwn(e, i))
|
|
58
59
|
throw new Error(`Key "${i}" already exists in target object`);
|
|
@@ -60,16 +61,16 @@ function Z(e, t) {
|
|
|
60
61
|
}
|
|
61
62
|
return e;
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
+
function st(e) {
|
|
64
65
|
const t = document.createElement("template");
|
|
65
66
|
return t.innerHTML = e.trim(), t.content;
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
+
function N(e) {
|
|
68
69
|
if (e == null || e === "")
|
|
69
70
|
return null;
|
|
70
71
|
if (typeof e == "string")
|
|
71
72
|
try {
|
|
72
|
-
const t =
|
|
73
|
+
const t = st(e);
|
|
73
74
|
return t.childNodes.length === 1 ? t.firstChild : t;
|
|
74
75
|
} catch {
|
|
75
76
|
return document.createTextNode(e);
|
|
@@ -90,7 +91,7 @@ const r = {
|
|
|
90
91
|
Unknown: "unknown",
|
|
91
92
|
Outside: "outside"
|
|
92
93
|
};
|
|
93
|
-
function
|
|
94
|
+
function ot(e) {
|
|
94
95
|
switch (e) {
|
|
95
96
|
case r.Top:
|
|
96
97
|
return r.Bottom;
|
|
@@ -104,50 +105,50 @@ function Q(e) {
|
|
|
104
105
|
throw new Error(`[bwin] Invalid position: ${e}`);
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function ht({ width: e, height: t, x: i }) {
|
|
108
109
|
return t / e * i;
|
|
109
110
|
}
|
|
110
|
-
function
|
|
111
|
+
function rt({ width: e, height: t, y: i }) {
|
|
111
112
|
return e / t * i;
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
+
function at({ width: e, height: t, x: i }) {
|
|
114
115
|
return t - t / e * i;
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function lt({ width: e, height: t, y: i }) {
|
|
117
118
|
return e - e / t * i;
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
+
function dt(e, { clientX: t, clientY: i }) {
|
|
120
121
|
const n = e.getBoundingClientRect(), { width: s, height: o } = n, h = t - n.left, a = i - n.top;
|
|
121
122
|
if (h < 0 || h > s || a < 0 || a > o)
|
|
122
123
|
return r.Outside;
|
|
123
|
-
const d = 0.3,
|
|
124
|
-
return h < s * (0.5 - d / 2) && a >
|
|
124
|
+
const d = 0.3, l = ht({ width: s, height: o, x: h }), c = at({ width: s, height: o, x: h }), u = rt({ width: s, height: o, y: a }), g = lt({ width: s, height: o, y: a });
|
|
125
|
+
return h < s * (0.5 - d / 2) && a > l && a < c ? r.Left : h > s * (0.5 + d / 2) && a < l && a > c ? r.Right : a < o * (0.5 - d / 2) && h > u && h < g ? r.Top : a > o * (0.5 + d / 2) && h < u && h > g ? r.Bottom : h > s * (0.5 - d / 2) && h < s * (0.5 + d / 2) && a > o * (0.5 - d / 2) && a < o * (0.5 + d / 2) ? r.Center : r.Unknown;
|
|
125
126
|
}
|
|
126
|
-
const
|
|
127
|
+
const ct = 100, pt = 100, v = {
|
|
127
128
|
left: 0,
|
|
128
129
|
top: 0,
|
|
129
130
|
width: 150,
|
|
130
131
|
height: 150,
|
|
131
132
|
// Initial min values, real min width/height is calculated based on children
|
|
132
|
-
minWidth:
|
|
133
|
-
minHeight:
|
|
133
|
+
minWidth: ct,
|
|
134
|
+
minHeight: pt
|
|
134
135
|
};
|
|
135
|
-
class
|
|
136
|
+
class b {
|
|
136
137
|
constructor({
|
|
137
|
-
left: t =
|
|
138
|
-
top: i =
|
|
139
|
-
width: n =
|
|
140
|
-
height: s =
|
|
141
|
-
minWidth: o =
|
|
142
|
-
minHeight: h =
|
|
138
|
+
left: t = v.left,
|
|
139
|
+
top: i = v.top,
|
|
140
|
+
width: n = v.width,
|
|
141
|
+
height: s = v.height,
|
|
142
|
+
minWidth: o = v.minWidth,
|
|
143
|
+
minHeight: h = v.minHeight,
|
|
143
144
|
domNode: a = null,
|
|
144
145
|
store: d = {},
|
|
145
|
-
position:
|
|
146
|
-
id:
|
|
147
|
-
} =
|
|
148
|
-
if (this.id =
|
|
146
|
+
position: l,
|
|
147
|
+
id: c
|
|
148
|
+
} = v) {
|
|
149
|
+
if (this.id = c ?? B(), !l)
|
|
149
150
|
throw new Error("[bwin] Sash position is required");
|
|
150
|
-
this.position =
|
|
151
|
+
this.position = l, this.domNode = a, this._top = i, this._left = t, this._width = n, this._height = s, this.children = [], this.minWidth = o, this.minHeight = h, this.store = d;
|
|
151
152
|
}
|
|
152
153
|
walk(t) {
|
|
153
154
|
this.children.forEach((i) => i.walk(t)), t(this);
|
|
@@ -281,10 +282,10 @@ class m {
|
|
|
281
282
|
this._width = t;
|
|
282
283
|
const [n, s, o, h] = this.getChildren();
|
|
283
284
|
if (h && s) {
|
|
284
|
-
const a = h.width + s.width, d = i * (h.width / a),
|
|
285
|
-
let
|
|
286
|
-
const
|
|
287
|
-
|
|
285
|
+
const a = h.width + s.width, d = i * (h.width / a), l = a + i;
|
|
286
|
+
let c = h.width + d, u = l - c, g = s.left + d;
|
|
287
|
+
const m = h.calcMinWidth(), w = s.calcMinWidth();
|
|
288
|
+
c < m && u > w ? (c = m, u = l - c, g = h.left + c) : u < w && c > m && (u = w, c = l - u, g = h.left + c), h.width = c, s.width = u, s.left = g;
|
|
288
289
|
}
|
|
289
290
|
n && o && (n.width += i, o.width += i);
|
|
290
291
|
}
|
|
@@ -296,15 +297,15 @@ class m {
|
|
|
296
297
|
this._height = t;
|
|
297
298
|
const [n, s, o, h] = this.getChildren();
|
|
298
299
|
if (n && o) {
|
|
299
|
-
const a = n.height + o.height, d = i * (n.height / a),
|
|
300
|
-
let
|
|
301
|
-
const
|
|
302
|
-
|
|
300
|
+
const a = n.height + o.height, d = i * (n.height / a), l = a + i;
|
|
301
|
+
let c = n.height + d, u = l - c, g = o.top + d;
|
|
302
|
+
const m = n.calcMinHeight(), w = o.calcMinHeight();
|
|
303
|
+
c < m && u > w ? (c = m, u = l - c, g = n.top + c) : u < w && c > m && (u = w, c = l - u, g = n.top + c), n.height = c, o.height = u, o.top = g;
|
|
303
304
|
}
|
|
304
305
|
h && s && (h.height += i, s.height += i);
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
|
-
const
|
|
308
|
+
const H = {
|
|
308
309
|
size: "50%",
|
|
309
310
|
position: r.Left
|
|
310
311
|
};
|
|
@@ -318,14 +319,14 @@ class P {
|
|
|
318
319
|
minHeight: h,
|
|
319
320
|
position: a,
|
|
320
321
|
size: d,
|
|
321
|
-
...
|
|
322
|
+
...l
|
|
322
323
|
}) {
|
|
323
|
-
|
|
324
|
+
E(this, "left"), E(this, "top"), E(this, "width"), E(this, "height"), this.parentRect = t, this.children = i, this.siblingConfigNode = n, this.id = s, this.minWidth = o, this.minHeight = h, this.position = this.getPosition(a), this.size = this.getSize(d), this.nonCoreData = l, this.setBounds();
|
|
324
325
|
}
|
|
325
326
|
getPosition(t) {
|
|
326
327
|
if (!this.siblingConfigNode)
|
|
327
328
|
return t;
|
|
328
|
-
const i =
|
|
329
|
+
const i = ot(this.siblingConfigNode.position);
|
|
329
330
|
if (!t)
|
|
330
331
|
return i;
|
|
331
332
|
if (t !== i)
|
|
@@ -334,7 +335,7 @@ class P {
|
|
|
334
335
|
}
|
|
335
336
|
getSize(t) {
|
|
336
337
|
if (!this.siblingConfigNode)
|
|
337
|
-
return
|
|
338
|
+
return C(t);
|
|
338
339
|
if (!t) {
|
|
339
340
|
if (this.siblingConfigNode.size < 1)
|
|
340
341
|
return 1 - this.siblingConfigNode.size;
|
|
@@ -343,7 +344,7 @@ class P {
|
|
|
343
344
|
if (this.siblingConfigNode.position === r.Top || this.siblingConfigNode.position === r.Bottom)
|
|
344
345
|
return this.parentRect.height - this.siblingConfigNode.height;
|
|
345
346
|
}
|
|
346
|
-
const i =
|
|
347
|
+
const i = C(t);
|
|
347
348
|
if (i < 1) {
|
|
348
349
|
if (i + this.siblingConfigNode.size !== 1)
|
|
349
350
|
throw new Error("[bwin] Sum of sibling sizes is not equal to 1");
|
|
@@ -373,7 +374,7 @@ class P {
|
|
|
373
374
|
}
|
|
374
375
|
}
|
|
375
376
|
createSash() {
|
|
376
|
-
return new
|
|
377
|
+
return new b({
|
|
377
378
|
left: this.left,
|
|
378
379
|
top: this.top,
|
|
379
380
|
width: this.width,
|
|
@@ -386,14 +387,14 @@ class P {
|
|
|
386
387
|
});
|
|
387
388
|
}
|
|
388
389
|
normConfig(t) {
|
|
389
|
-
if (
|
|
390
|
+
if (it(t))
|
|
390
391
|
return t;
|
|
391
392
|
if (Array.isArray(t))
|
|
392
393
|
return {
|
|
393
394
|
children: t
|
|
394
395
|
};
|
|
395
396
|
if (typeof t == "string" || typeof t == "number") {
|
|
396
|
-
const i =
|
|
397
|
+
const i = C(t);
|
|
397
398
|
if (isNaN(i))
|
|
398
399
|
throw new Error(`[bwin] Invalid size value: ${i}`);
|
|
399
400
|
return {
|
|
@@ -408,8 +409,8 @@ class P {
|
|
|
408
409
|
createPrimaryConfigNode({ size: t, position: i, children: n, id: s, minWidth: o, minHeight: h, ...a }) {
|
|
409
410
|
return new P({
|
|
410
411
|
parentRect: this,
|
|
411
|
-
size: t ??
|
|
412
|
-
position: i ??
|
|
412
|
+
size: t ?? H.size,
|
|
413
|
+
position: i ?? H.position,
|
|
413
414
|
children: n,
|
|
414
415
|
id: s,
|
|
415
416
|
minWidth: o,
|
|
@@ -445,23 +446,23 @@ class P {
|
|
|
445
446
|
)), s && o && (t.children.push(s.buildSashTree()), t.children.push(o.buildSashTree())), t;
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
|
-
const
|
|
449
|
+
const L = {
|
|
449
450
|
width: 333,
|
|
450
451
|
height: 333
|
|
451
|
-
},
|
|
452
|
+
}, T = {
|
|
452
453
|
fitContainer: !1
|
|
453
454
|
};
|
|
454
|
-
class
|
|
455
|
+
class ut extends P {
|
|
455
456
|
constructor({
|
|
456
457
|
id: t,
|
|
457
458
|
children: i,
|
|
458
|
-
width: n =
|
|
459
|
-
height: s =
|
|
460
|
-
fitContainer: o =
|
|
459
|
+
width: n = L.width,
|
|
460
|
+
height: s = L.height,
|
|
461
|
+
fitContainer: o = T.fitContainer,
|
|
461
462
|
...h
|
|
462
463
|
} = {
|
|
463
|
-
...
|
|
464
|
-
|
|
464
|
+
...L,
|
|
465
|
+
...T
|
|
465
466
|
}) {
|
|
466
467
|
super({
|
|
467
468
|
id: t,
|
|
@@ -473,120 +474,120 @@ class rt extends P {
|
|
|
473
474
|
}), this.fitContainer = o;
|
|
474
475
|
}
|
|
475
476
|
}
|
|
476
|
-
class
|
|
477
|
-
constructor(t =
|
|
478
|
-
super({ ...t, position: r.Root }), Object.assign(this,
|
|
477
|
+
class gt extends b {
|
|
478
|
+
constructor(t = v) {
|
|
479
|
+
super({ ...t, position: r.Root }), Object.assign(this, T);
|
|
479
480
|
}
|
|
480
481
|
}
|
|
481
|
-
function
|
|
482
|
+
function M(e) {
|
|
482
483
|
const t = document.createElement("bw-pane");
|
|
483
484
|
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;
|
|
484
485
|
}
|
|
485
|
-
function
|
|
486
|
+
function ft(e) {
|
|
486
487
|
const t = e.domNode;
|
|
487
488
|
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;
|
|
488
489
|
}
|
|
489
|
-
function
|
|
490
|
-
const i =
|
|
490
|
+
function mt(e, { size: t }) {
|
|
491
|
+
const i = C(t);
|
|
491
492
|
let n = e.width / 2;
|
|
492
493
|
i && (i < 1 ? n = e.width * i : n = i);
|
|
493
|
-
const s = new
|
|
494
|
+
const s = new b({
|
|
494
495
|
top: e.top,
|
|
495
496
|
left: e.left,
|
|
496
497
|
width: n,
|
|
497
498
|
height: e.height,
|
|
498
499
|
position: r.Left
|
|
499
|
-
}), o = new
|
|
500
|
+
}), o = new b({
|
|
500
501
|
top: e.top,
|
|
501
502
|
left: e.left + s.width,
|
|
502
503
|
width: e.width - n,
|
|
503
504
|
height: e.height,
|
|
504
505
|
position: r.Right
|
|
505
|
-
}), h =
|
|
506
|
-
return o.domNode = h,
|
|
506
|
+
}), h = M(o);
|
|
507
|
+
return o.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), s;
|
|
507
508
|
}
|
|
508
|
-
function
|
|
509
|
-
const i =
|
|
509
|
+
function wt(e, { size: t }) {
|
|
510
|
+
const i = C(t);
|
|
510
511
|
let n = e.width / 2;
|
|
511
512
|
i && (i < 1 ? n = e.width * i : n = i);
|
|
512
|
-
const s = new
|
|
513
|
+
const s = new b({
|
|
513
514
|
left: e.left,
|
|
514
515
|
top: e.top,
|
|
515
516
|
width: e.width - n,
|
|
516
517
|
height: e.height,
|
|
517
518
|
position: r.Left
|
|
518
|
-
}), o = new
|
|
519
|
+
}), o = new b({
|
|
519
520
|
left: e.left + s.width,
|
|
520
521
|
top: e.top,
|
|
521
522
|
width: n,
|
|
522
523
|
height: e.height,
|
|
523
524
|
position: r.Right
|
|
524
|
-
}), h =
|
|
525
|
-
return s.domNode = h,
|
|
525
|
+
}), h = M(s);
|
|
526
|
+
return s.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), o;
|
|
526
527
|
}
|
|
527
|
-
function
|
|
528
|
-
const i =
|
|
528
|
+
function bt(e, { size: t }) {
|
|
529
|
+
const i = C(t);
|
|
529
530
|
let n = e.height / 2;
|
|
530
531
|
i && (i < 1 ? n = e.height * i : n = i);
|
|
531
|
-
const s = new
|
|
532
|
+
const s = new b({
|
|
532
533
|
left: e.left,
|
|
533
534
|
top: e.top,
|
|
534
535
|
width: e.width,
|
|
535
536
|
height: n,
|
|
536
537
|
position: r.Top
|
|
537
|
-
}), o = new
|
|
538
|
+
}), o = new b({
|
|
538
539
|
left: e.left,
|
|
539
540
|
top: e.top + s.height,
|
|
540
541
|
width: e.width,
|
|
541
542
|
height: e.height - n,
|
|
542
543
|
position: r.Bottom
|
|
543
|
-
}), h =
|
|
544
|
-
return o.domNode = h,
|
|
544
|
+
}), h = M(o);
|
|
545
|
+
return o.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), s;
|
|
545
546
|
}
|
|
546
|
-
function
|
|
547
|
-
const i =
|
|
547
|
+
function Et(e, { size: t }) {
|
|
548
|
+
const i = C(t);
|
|
548
549
|
let n = e.height / 2;
|
|
549
550
|
i && (i < 1 ? n = e.height * i : n = i);
|
|
550
|
-
const s = new
|
|
551
|
+
const s = new b({
|
|
551
552
|
top: e.top,
|
|
552
553
|
left: e.left,
|
|
553
554
|
width: e.width,
|
|
554
555
|
height: e.height - n,
|
|
555
556
|
position: r.Top
|
|
556
|
-
}), o = new
|
|
557
|
+
}), o = new b({
|
|
557
558
|
top: e.top + s.height,
|
|
558
559
|
left: e.left,
|
|
559
560
|
width: e.width,
|
|
560
561
|
height: n,
|
|
561
562
|
position: r.Bottom
|
|
562
|
-
}), h =
|
|
563
|
-
return s.domNode = h,
|
|
563
|
+
}), h = M(s);
|
|
564
|
+
return s.domNode = h, z(h, e.domNode), e.addChild(s), e.addChild(o), o;
|
|
564
565
|
}
|
|
565
|
-
function
|
|
566
|
+
function yt(e, { position: t, size: i, minWidth: n, minHeight: s }) {
|
|
566
567
|
if (t === r.Left)
|
|
567
|
-
return
|
|
568
|
+
return mt(e, { size: i });
|
|
568
569
|
if (t === r.Right)
|
|
569
|
-
return
|
|
570
|
+
return wt(e, { size: i });
|
|
570
571
|
if (t === r.Top)
|
|
571
|
-
return
|
|
572
|
+
return bt(e, { size: i });
|
|
572
573
|
if (t === r.Bottom)
|
|
573
|
-
return
|
|
574
|
+
return Et(e, { size: i });
|
|
574
575
|
}
|
|
575
|
-
const
|
|
576
|
+
const vt = {
|
|
576
577
|
createPane(e) {
|
|
577
|
-
const t =
|
|
578
|
+
const t = M(e);
|
|
578
579
|
return e.store.droppable === !1 && t.setAttribute("can-drop", "false"), t;
|
|
579
580
|
},
|
|
580
581
|
// Intended to be overridden
|
|
581
582
|
onPaneCreate(e, t) {
|
|
582
|
-
t.store.content && e.append(
|
|
583
|
+
t.store.content && e.append(N(t.store.content)), this != null && this.debug && (e.style.backgroundColor = tt(), e.innerHTML = "", e.append(G(e)));
|
|
583
584
|
},
|
|
584
585
|
updatePane(e) {
|
|
585
|
-
return
|
|
586
|
+
return ft(e);
|
|
586
587
|
},
|
|
587
588
|
// Intended to be overridden
|
|
588
589
|
onPaneUpdate(e, t) {
|
|
589
|
-
this != null && this.debug && (e.innerHTML = "", e.append(
|
|
590
|
+
this != null && this.debug && (e.innerHTML = "", e.append(G(e)));
|
|
590
591
|
},
|
|
591
592
|
/**
|
|
592
593
|
* Add a pane into the target pane. The two panes become next to each other
|
|
@@ -599,8 +600,8 @@ const ft = {
|
|
|
599
600
|
if (!t) throw new Error("[bwin] Position is required when adding pane");
|
|
600
601
|
const n = this.rootSash.getById(e);
|
|
601
602
|
if (!n) throw new Error("[bwin] Parent sash not found when adding pane");
|
|
602
|
-
const s =
|
|
603
|
-
return n.id =
|
|
603
|
+
const s = yt(n, { position: t, size: i });
|
|
604
|
+
return n.id = B(), this.update(), s;
|
|
604
605
|
},
|
|
605
606
|
/**
|
|
606
607
|
* Remove a pane
|
|
@@ -611,10 +612,10 @@ const ft = {
|
|
|
611
612
|
const t = this.rootSash.getDescendantParentById(e);
|
|
612
613
|
if (!t) throw new Error("[bwin] Parent sash not found when removing pane");
|
|
613
614
|
const i = t.getChildSiblingById(e);
|
|
614
|
-
t.id =
|
|
615
|
+
t.id = B(), i.children.length === 0 ? (t.domNode = i.domNode, t.domNode.setAttribute("sash-id", t.id), t.children = []) : (t.children = i.children, i.position === r.Left ? i.width = t.width : i.position === r.Right ? (i.width = t.width, i.left = t.left) : i.position === r.Top ? i.height = t.height : i.position === r.Bottom && (i.height = t.height, i.top = t.top)), this.update();
|
|
615
616
|
}
|
|
616
617
|
};
|
|
617
|
-
function
|
|
618
|
+
function G(e) {
|
|
618
619
|
const t = document.createElement("pre");
|
|
619
620
|
t.style.fontSize = "10px";
|
|
620
621
|
const i = `
|
|
@@ -627,10 +628,10 @@ height: ${e.style.height}
|
|
|
627
628
|
`;
|
|
628
629
|
return t.innerHTML = i.trim(), t;
|
|
629
630
|
}
|
|
630
|
-
const
|
|
631
|
+
const Nt = {
|
|
631
632
|
createWindow() {
|
|
632
633
|
const e = document.createElement("bw-window");
|
|
633
|
-
return e.style.width = `${this.rootSash.width}px`, e.style.height = `${this.rootSash.height}px`, e.setAttribute("sash-id", this.rootSash.id), e;
|
|
634
|
+
return e.style.width = `${this.rootSash.width}px`, e.style.height = `${this.rootSash.height}px`, e.setAttribute("root-sash-id", this.rootSash.id), e;
|
|
634
635
|
},
|
|
635
636
|
glaze() {
|
|
636
637
|
this.rootSash.walk((e) => {
|
|
@@ -648,7 +649,7 @@ const wt = {
|
|
|
648
649
|
i.children.length > 0 ? t.includes(i.id) ? (this.updateMuntin(i), this.onMuntinUpdate(i.domNode, i)) : (i.domNode = this.createMuntin(i), this.windowElement.append(i.domNode)) : t.includes(i.id) ? (this.updatePane(i), this.onPaneUpdate(i.domNode, i)) : (i.domNode || (i.domNode = this.createPane(i)), this.windowElement.prepend(i.domNode));
|
|
649
650
|
});
|
|
650
651
|
}
|
|
651
|
-
},
|
|
652
|
+
}, zt = {
|
|
652
653
|
muntinSize: 4,
|
|
653
654
|
createMuntin(e) {
|
|
654
655
|
const t = document.createElement("bw-muntin"), i = e.leftChild, n = e.topChild;
|
|
@@ -662,7 +663,7 @@ const wt = {
|
|
|
662
663
|
},
|
|
663
664
|
onMuntinUpdate(e, t) {
|
|
664
665
|
}
|
|
665
|
-
},
|
|
666
|
+
}, Ct = {
|
|
666
667
|
fitContainer: !1,
|
|
667
668
|
fit() {
|
|
668
669
|
this.rootSash.width = this.containerElement.clientWidth, this.rootSash.height = this.containerElement.clientHeight, this.update();
|
|
@@ -673,7 +674,7 @@ const wt = {
|
|
|
673
674
|
t.target === this.containerElement && this.fitContainer && this.fit();
|
|
674
675
|
}).observe(this.containerElement);
|
|
675
676
|
}
|
|
676
|
-
},
|
|
677
|
+
}, St = {
|
|
677
678
|
activeMuntinSash: null,
|
|
678
679
|
isResizeStarted: !1,
|
|
679
680
|
isDropStarted: !1,
|
|
@@ -694,21 +695,21 @@ const wt = {
|
|
|
694
695
|
if (!this.isResizeStarted || !this.activeMuntinSash) return;
|
|
695
696
|
const [t, i, n, s] = this.activeMuntinSash.getChildren(), o = this.activeMuntinSash.isLeftRightSplit(), h = this.activeMuntinSash.isTopBottomSplit();
|
|
696
697
|
if (o && s && i) {
|
|
697
|
-
const a = e.pageX - this.lastX, d = s.width + a,
|
|
698
|
-
if (d <= s.calcMinWidth() ||
|
|
698
|
+
const a = e.pageX - this.lastX, d = s.width + a, l = i.width - a;
|
|
699
|
+
if (d <= s.calcMinWidth() || l <= i.calcMinWidth())
|
|
699
700
|
return;
|
|
700
|
-
s.width = d, i.width =
|
|
701
|
+
s.width = d, i.width = l, i.left = i.left + a, this.update(), this.lastX = e.pageX;
|
|
701
702
|
} else if (h && t && n) {
|
|
702
|
-
const a = e.pageY - this.lastY, d = t.height + a,
|
|
703
|
-
if (d <= t.calcMinHeight() ||
|
|
703
|
+
const a = e.pageY - this.lastY, d = t.height + a, l = n.height - a;
|
|
704
|
+
if (d <= t.calcMinHeight() || l <= n.calcMinHeight())
|
|
704
705
|
return;
|
|
705
|
-
t.height = d, n.height =
|
|
706
|
+
t.height = d, n.height = l, n.top = n.top + a, this.update(), this.lastY = e.pageY;
|
|
706
707
|
}
|
|
707
708
|
}), document.addEventListener("mouseup", () => {
|
|
708
709
|
this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
|
|
709
710
|
});
|
|
710
711
|
}
|
|
711
|
-
},
|
|
712
|
+
}, Mt = {
|
|
712
713
|
activeDropPaneEl: null,
|
|
713
714
|
// Intended to be overridden in `BinaryWindow` class
|
|
714
715
|
onPaneDrop(e, t) {
|
|
@@ -718,7 +719,7 @@ const wt = {
|
|
|
718
719
|
e.preventDefault();
|
|
719
720
|
const t = e.target.matches("bw-pane") ? e.target : e.target.closest("bw-pane");
|
|
720
721
|
if (!t || (t !== this.activeDropPaneEl && (this.activeDropPaneEl && this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = t), t.getAttribute("can-drop") === "false")) return;
|
|
721
|
-
const i =
|
|
722
|
+
const i = dt(t, e);
|
|
722
723
|
t.setAttribute("drop-area", i);
|
|
723
724
|
}), this.windowElement.addEventListener("dragleave", (e) => {
|
|
724
725
|
e.currentTarget.contains(e.relatedTarget) && e.currentTarget !== e.relatedTarget || this.activeDropPaneEl && (this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null);
|
|
@@ -728,12 +729,12 @@ const wt = {
|
|
|
728
729
|
this.onPaneDrop(e, i), typeof i.store.onDrop == "function" && i.store.onDrop(e, i), this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null;
|
|
729
730
|
});
|
|
730
731
|
}
|
|
731
|
-
},
|
|
732
|
-
class
|
|
732
|
+
}, At = !1;
|
|
733
|
+
class O {
|
|
733
734
|
constructor(t) {
|
|
734
|
-
|
|
735
|
+
E(this, "windowElement", null), E(this, "containerElement", null), E(this, "debug", At);
|
|
735
736
|
let i = null;
|
|
736
|
-
t instanceof
|
|
737
|
+
t instanceof gt ? (i = t, this.rootSash = t) : (i = new ut(t), this.rootSash = i.buildSashTree()), this.fitContainer = i.fitContainer;
|
|
737
738
|
}
|
|
738
739
|
frame(t) {
|
|
739
740
|
this.containerElement = t, this.windowElement = this.createWindow(), this.glaze(), this.containerElement.append(this.windowElement);
|
|
@@ -747,19 +748,19 @@ class H {
|
|
|
747
748
|
}
|
|
748
749
|
static assemble(...t) {
|
|
749
750
|
t.forEach((i) => {
|
|
750
|
-
|
|
751
|
+
nt(this.prototype, i);
|
|
751
752
|
});
|
|
752
753
|
}
|
|
753
754
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
755
|
+
O.assemble(
|
|
756
|
+
Nt,
|
|
757
|
+
zt,
|
|
758
|
+
vt,
|
|
759
|
+
Ct,
|
|
760
|
+
Mt,
|
|
761
|
+
St
|
|
761
762
|
);
|
|
762
|
-
function
|
|
763
|
+
function k(e) {
|
|
763
764
|
if (e.tagName === "BW-PANE")
|
|
764
765
|
return e.getAttribute("sash-id");
|
|
765
766
|
const t = e.closest("bw-pane");
|
|
@@ -767,25 +768,25 @@ function G(e) {
|
|
|
767
768
|
throw new Error("[bwin] Pane element not found");
|
|
768
769
|
return t.getAttribute("sash-id");
|
|
769
770
|
}
|
|
770
|
-
const
|
|
771
|
+
const Rt = {
|
|
771
772
|
label: "",
|
|
772
773
|
className: "bw-glass-action--close",
|
|
773
774
|
onClick: (e, t) => {
|
|
774
|
-
const i =
|
|
775
|
+
const i = k(e.target);
|
|
775
776
|
t.removePane(i);
|
|
776
777
|
}
|
|
777
|
-
},
|
|
778
|
+
}, Pt = {
|
|
778
779
|
label: "",
|
|
779
780
|
className: "bw-glass-action--minimize",
|
|
780
781
|
onClick: (e, t) => {
|
|
781
782
|
const i = t.sillElement;
|
|
782
783
|
if (!i) throw new Error("[bwin] Sill element not found when minimizing");
|
|
783
|
-
const n =
|
|
784
|
+
const n = N('<button class="bw-minimized-glass" />');
|
|
784
785
|
i.append(n);
|
|
785
786
|
const s = e.target.closest("bw-pane"), o = e.target.closest("bw-glass"), h = s.getAttribute("sash-id"), a = s.getAttribute("position");
|
|
786
787
|
n.bwGlassElement = o, n.bwOriginalPosition = a, n.bwOriginalBoundingRect = R(s), t.removePane(h);
|
|
787
788
|
}
|
|
788
|
-
},
|
|
789
|
+
}, xt = {
|
|
789
790
|
label: "",
|
|
790
791
|
className: "bw-glass-action--maximize",
|
|
791
792
|
onClick: (e) => {
|
|
@@ -793,19 +794,19 @@ const Nt = {
|
|
|
793
794
|
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 = R(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
|
|
794
795
|
}
|
|
795
796
|
};
|
|
796
|
-
function
|
|
797
|
+
function Dt(e, t) {
|
|
797
798
|
const i = e.left + e.width, n = e.top + e.height, s = t.left + t.width, o = t.top + t.height;
|
|
798
799
|
if (e.left >= s || t.left >= i || e.top >= o || t.top >= n)
|
|
799
800
|
return null;
|
|
800
|
-
const h = Math.max(e.left, t.left), a = Math.max(e.top, t.top), d = Math.min(i, s),
|
|
801
|
+
const h = Math.max(e.left, t.left), a = Math.max(e.top, t.top), d = Math.min(i, s), l = Math.min(n, o);
|
|
801
802
|
return {
|
|
802
803
|
left: h,
|
|
803
804
|
top: a,
|
|
804
805
|
width: d - h,
|
|
805
|
-
height:
|
|
806
|
+
height: l - a
|
|
806
807
|
};
|
|
807
808
|
}
|
|
808
|
-
const
|
|
809
|
+
const F = [Pt, xt, Rt], $t = {
|
|
809
810
|
enableActions() {
|
|
810
811
|
this.handleMinimizedGlassClick(), this.observeActionButtons();
|
|
811
812
|
},
|
|
@@ -813,7 +814,7 @@ const I = [zt, Ct, Nt], At = {
|
|
|
813
814
|
const t = e.bwOriginalBoundingRect;
|
|
814
815
|
let i = 0, n = null;
|
|
815
816
|
if (this.windowElement.querySelectorAll("bw-pane").forEach((s) => {
|
|
816
|
-
const o = R(s), h =
|
|
817
|
+
const o = R(s), h = Dt(t, o);
|
|
817
818
|
if (h) {
|
|
818
819
|
const a = h.width * h.height;
|
|
819
820
|
a > i && (i = a, n = s);
|
|
@@ -861,24 +862,24 @@ const I = [zt, Ct, Nt], At = {
|
|
|
861
862
|
childList: !0
|
|
862
863
|
});
|
|
863
864
|
}
|
|
864
|
-
},
|
|
865
|
+
}, S = {
|
|
865
866
|
title: null,
|
|
866
867
|
content: null,
|
|
867
868
|
tabs: [],
|
|
868
869
|
actions: void 0,
|
|
869
870
|
draggable: !0
|
|
870
871
|
};
|
|
871
|
-
class
|
|
872
|
+
class I {
|
|
872
873
|
constructor({
|
|
873
|
-
title: t =
|
|
874
|
-
content: i =
|
|
875
|
-
tabs: n =
|
|
876
|
-
actions: s =
|
|
877
|
-
draggable: o =
|
|
874
|
+
title: t = S.title,
|
|
875
|
+
content: i = S.content,
|
|
876
|
+
tabs: n = S.tabs,
|
|
877
|
+
actions: s = S.actions,
|
|
878
|
+
draggable: o = S.draggable,
|
|
878
879
|
sash: h,
|
|
879
880
|
binaryWindow: a
|
|
880
881
|
}) {
|
|
881
|
-
|
|
882
|
+
E(this, "domNode"), this.title = t, this.content = i, this.tabs = n, this.actions = s, this.sash = h, this.draggable = o, this.binaryWindow = a, this.build();
|
|
882
883
|
}
|
|
883
884
|
build() {
|
|
884
885
|
const t = document.createElement("bw-glass-header");
|
|
@@ -886,24 +887,24 @@ class W {
|
|
|
886
887
|
t.append(this.createTabs());
|
|
887
888
|
else if (this.title) {
|
|
888
889
|
const s = document.createElement("bw-glass-title");
|
|
889
|
-
s.append(
|
|
890
|
+
s.append(N(this.title)), t.append(s);
|
|
890
891
|
}
|
|
891
892
|
t.setAttribute("can-drag", this.draggable), t.append(this.createActions());
|
|
892
|
-
const i = document.createElement("bw-glass-content"), n =
|
|
893
|
+
const i = document.createElement("bw-glass-content"), n = N(this.content);
|
|
893
894
|
n && i.append(n), this.domNode = document.createElement("bw-glass"), this.domNode.append(t, i);
|
|
894
895
|
}
|
|
895
896
|
createTabs() {
|
|
896
897
|
const t = document.createElement("bw-glass-tab-container");
|
|
897
898
|
for (const i of this.tabs) {
|
|
898
|
-
const n = (i == null ? void 0 : i.label) ?? i, s =
|
|
899
|
+
const n = (i == null ? void 0 : i.label) ?? i, s = N(`<button class="bw-glass-tab">${n}</button>`);
|
|
899
900
|
t.append(s);
|
|
900
901
|
}
|
|
901
902
|
return t;
|
|
902
903
|
}
|
|
903
904
|
createActions() {
|
|
904
|
-
const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ?
|
|
905
|
+
const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ? F : Array.isArray(this.actions) ? this.actions : [];
|
|
905
906
|
for (const n of i) {
|
|
906
|
-
const s = (n == null ? void 0 : n.label) ?? n, o = n.className ? `bw-glass-action ${n.className}` : "bw-glass-action", h =
|
|
907
|
+
const s = (n == null ? void 0 : n.label) ?? n, o = n.className ? `bw-glass-action ${n.className}` : "bw-glass-action", h = N(`<button class="${o}">${s}</button>`);
|
|
907
908
|
typeof n.onClick == "function" && h.addEventListener("click", (a) => {
|
|
908
909
|
n.onClick(a, this.binaryWindow);
|
|
909
910
|
}), t.append(h);
|
|
@@ -917,7 +918,7 @@ class W {
|
|
|
917
918
|
return this.domNode.querySelector("bw-glass-header");
|
|
918
919
|
}
|
|
919
920
|
}
|
|
920
|
-
const
|
|
921
|
+
const Lt = {
|
|
921
922
|
activeDragGlassEl: null,
|
|
922
923
|
activeDragGlassPaneCanDrop: !1,
|
|
923
924
|
onPaneDrop(e, t) {
|
|
@@ -925,10 +926,10 @@ const Mt = {
|
|
|
925
926
|
const i = this.activeDropPaneEl.getAttribute("drop-area");
|
|
926
927
|
if (i === "center") {
|
|
927
928
|
const n = this.activeDragGlassEl.closest("bw-pane"), s = this.activeDropPaneEl.getAttribute("can-drop") !== "false";
|
|
928
|
-
|
|
929
|
+
et(n, this.activeDropPaneEl), n.setAttribute("can-drop", s);
|
|
929
930
|
return;
|
|
930
931
|
} else {
|
|
931
|
-
const n =
|
|
932
|
+
const n = k(this.activeDragGlassEl);
|
|
932
933
|
this.addPane(t.id, { position: i }).domNode.append(this.activeDragGlassEl), this.removePane(n);
|
|
933
934
|
}
|
|
934
935
|
},
|
|
@@ -953,7 +954,7 @@ const Mt = {
|
|
|
953
954
|
this.activeDragGlassEl && (this.activeDragGlassEl.removeAttribute("draggable"), this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop", this.activeDragGlassPaneCanDrop), this.activeDragGlassEl = null);
|
|
954
955
|
});
|
|
955
956
|
}
|
|
956
|
-
},
|
|
957
|
+
}, Bt = {
|
|
957
958
|
trimMuntin(e) {
|
|
958
959
|
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`);
|
|
959
960
|
},
|
|
@@ -964,62 +965,45 @@ const Mt = {
|
|
|
964
965
|
this.trimMuntin(e);
|
|
965
966
|
}
|
|
966
967
|
};
|
|
967
|
-
class
|
|
968
|
+
class _ extends O {
|
|
968
969
|
constructor() {
|
|
969
|
-
super(...arguments),
|
|
970
|
+
super(...arguments), E(this, "sillElement", null);
|
|
970
971
|
}
|
|
971
972
|
frame() {
|
|
972
973
|
super.frame(...arguments);
|
|
973
|
-
const t =
|
|
974
|
+
const t = N("<bw-sill />");
|
|
974
975
|
this.windowElement.append(t), this.sillElement = t;
|
|
975
976
|
}
|
|
976
977
|
enableFeatures() {
|
|
977
978
|
super.enableFeatures(), this.enableDrag(), this.enableActions();
|
|
978
979
|
}
|
|
979
980
|
onPaneCreate(t, i) {
|
|
980
|
-
const n = new
|
|
981
|
+
const n = new I({ ...i.store, sash: i, binaryWindow: this });
|
|
981
982
|
t.innerHTML = "", t.append(n.domNode), this.debug && n.contentElement.prepend(`${i.id}`);
|
|
982
983
|
}
|
|
983
984
|
onPaneUpdate() {
|
|
984
985
|
}
|
|
985
986
|
/**
|
|
986
|
-
* Add glass into the target pane.
|
|
987
|
-
*
|
|
988
|
-
* @param {string} paneSashId - The Sash ID of the pane that the glass moves into
|
|
989
|
-
* @param {'top'|'right'|'bottom'|'left'} position - The position of the glass relative to the target pane
|
|
990
|
-
* @param {Object} glassProps - The glass properties
|
|
991
|
-
*
|
|
992
|
-
*/
|
|
993
|
-
addGlass(t, i, n) {
|
|
994
|
-
const s = this.addPane(t, { position: i }), o = new W({ ...n, sash: s, binaryWindow: this });
|
|
995
|
-
s.domNode.append(o.domNode);
|
|
996
|
-
}
|
|
997
|
-
/**
|
|
998
|
-
* Remove glass from or together with the pane
|
|
987
|
+
* Add a pane with glass into the target pane.
|
|
999
988
|
*
|
|
1000
|
-
* @param {string}
|
|
1001
|
-
* @param {
|
|
989
|
+
* @param {string} targetPaneId - The Sash ID of the target pane
|
|
990
|
+
* @param {Object} props - The pane and glass properties grouped together
|
|
991
|
+
* @returns {Sash} - The newly created Sash
|
|
1002
992
|
*/
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
else {
|
|
1007
|
-
const n = this.rootSash.getById(t);
|
|
1008
|
-
if (!n) throw new Error("[bwin] Pane not found when removing glass");
|
|
1009
|
-
const s = n.domNode.querySelector("bw-glass");
|
|
1010
|
-
s && s.remove();
|
|
1011
|
-
}
|
|
993
|
+
addPane(t, i) {
|
|
994
|
+
const { position: n, size: s, ...o } = i, h = super.addPane(t, { position: n, size: s }), a = new I({ ...o, sash: h, binaryWindow: this });
|
|
995
|
+
return h.domNode.append(a.domNode), h;
|
|
1012
996
|
}
|
|
1013
997
|
}
|
|
1014
|
-
|
|
998
|
+
_.assemble(Lt, Bt, $t);
|
|
1015
999
|
const y = 4;
|
|
1016
|
-
function
|
|
1017
|
-
var
|
|
1018
|
-
const t =
|
|
1019
|
-
let s, o, h, a, d,
|
|
1020
|
-
return i ? (s = y, o = e.height - y, h = e.top + y / 2, a = e.left + i.width - y / 2, d = !0) : n && (s = e.width - y, o = y, h = e.top + n.height - y / 2, a = e.left + y / 2,
|
|
1000
|
+
function Tt({ sash: e }) {
|
|
1001
|
+
var c;
|
|
1002
|
+
const t = A(), i = e.leftChild, n = e.topChild;
|
|
1003
|
+
let s, o, h, a, d, l;
|
|
1004
|
+
return i ? (s = y, o = e.height - y, h = e.top + y / 2, a = e.left + i.width - y / 2, d = !0) : n && (s = e.width - y, o = y, h = e.top + n.height - y / 2, a = e.left + y / 2, l = !0), W(() => {
|
|
1021
1005
|
e.domNode = t.current;
|
|
1022
|
-
}, []), /* @__PURE__ */
|
|
1006
|
+
}, []), /* @__PURE__ */ f.createElement(
|
|
1023
1007
|
"bw-muntin",
|
|
1024
1008
|
{
|
|
1025
1009
|
"sash-id": e.id,
|
|
@@ -1030,79 +1014,92 @@ function Pt({ sash: e }) {
|
|
|
1030
1014
|
left: a
|
|
1031
1015
|
},
|
|
1032
1016
|
vertical: d,
|
|
1033
|
-
horizontal:
|
|
1034
|
-
resizable: ((
|
|
1017
|
+
horizontal: l,
|
|
1018
|
+
resizable: ((c = e.store) == null ? void 0 : c.resizable) === !1 ? "false" : "true",
|
|
1035
1019
|
ref: t
|
|
1036
1020
|
}
|
|
1037
1021
|
);
|
|
1038
1022
|
}
|
|
1039
|
-
function
|
|
1023
|
+
function Wt({
|
|
1040
1024
|
sash: e,
|
|
1041
1025
|
bwin: t
|
|
1042
1026
|
}) {
|
|
1043
|
-
var
|
|
1044
|
-
const i =
|
|
1045
|
-
|
|
1027
|
+
var c, u, g, m, w;
|
|
1028
|
+
const i = A(), { left: n, top: s, width: o, height: h, id: a, position: d } = e;
|
|
1029
|
+
W(() => {
|
|
1046
1030
|
e.domNode = i.current;
|
|
1047
1031
|
}, []);
|
|
1048
|
-
const
|
|
1049
|
-
return /* @__PURE__ */
|
|
1032
|
+
const l = ((c = e.store) == null ? void 0 : c.actions) === void 0 ? F : Array.isArray(e.store.actions) ? e.store.actions : [];
|
|
1033
|
+
return /* @__PURE__ */ f.createElement(
|
|
1050
1034
|
"bw-pane",
|
|
1051
1035
|
{
|
|
1052
1036
|
"sash-id": a,
|
|
1053
1037
|
position: d,
|
|
1054
1038
|
style: { left: n, top: s, width: o, height: h },
|
|
1055
|
-
"can-drop": ((
|
|
1039
|
+
"can-drop": ((u = e.store) == null ? void 0 : u.droppable) === !1 ? "false" : "true",
|
|
1056
1040
|
ref: i
|
|
1057
1041
|
},
|
|
1058
|
-
/* @__PURE__ */
|
|
1042
|
+
/* @__PURE__ */ f.createElement("bw-glass", null, /* @__PURE__ */ f.createElement(
|
|
1059
1043
|
"bw-glass-header",
|
|
1060
1044
|
{
|
|
1061
|
-
"can-drag": ((
|
|
1045
|
+
"can-drag": ((g = e.store) == null ? void 0 : g.draggable) === !1 ? "false" : "true"
|
|
1062
1046
|
},
|
|
1063
|
-
((
|
|
1064
|
-
|
|
1065
|
-
const
|
|
1066
|
-
return /* @__PURE__ */
|
|
1047
|
+
((m = e.store) == null ? void 0 : m.title) && /* @__PURE__ */ f.createElement("bw-glass-title", null, e.store.title),
|
|
1048
|
+
l.length > 0 && /* @__PURE__ */ f.createElement("bw-glass-action-container", null, l.map((p, x) => {
|
|
1049
|
+
const D = p.className ? `bw-glass-action ${p.className}` : "bw-glass-action";
|
|
1050
|
+
return /* @__PURE__ */ f.createElement(
|
|
1067
1051
|
"button",
|
|
1068
1052
|
{
|
|
1069
|
-
className:
|
|
1070
|
-
key:
|
|
1071
|
-
onClick: (
|
|
1053
|
+
className: D,
|
|
1054
|
+
key: x,
|
|
1055
|
+
onClick: ($) => p.onClick($, t)
|
|
1072
1056
|
},
|
|
1073
|
-
|
|
1057
|
+
p.label
|
|
1074
1058
|
);
|
|
1075
1059
|
}))
|
|
1076
|
-
), /* @__PURE__ */
|
|
1060
|
+
), /* @__PURE__ */ f.createElement("bw-glass-content", null, (w = e.store) == null ? void 0 : w.content))
|
|
1077
1061
|
);
|
|
1078
1062
|
}
|
|
1079
|
-
const
|
|
1080
|
-
const i =
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
}),
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1086
|
-
}, []),
|
|
1063
|
+
const It = Y((e, t) => {
|
|
1064
|
+
const i = A(), n = A(), [s, o] = j(), { panes: h, ...a } = e, d = { ...a, children: h }, l = new _(d), c = [], u = [];
|
|
1065
|
+
l.rootSash.walk((p) => {
|
|
1066
|
+
p.children.length > 0 ? c.push(p) : u.push(p);
|
|
1067
|
+
}), W(() => {
|
|
1068
|
+
const p = i.current;
|
|
1069
|
+
p != null && p.parentElement && (l.windowElement = p, l.containerElement = p.parentElement, l.sillElement = n.current, l.enableFeatures());
|
|
1070
|
+
}, []), K(
|
|
1087
1071
|
t,
|
|
1088
1072
|
() => ({
|
|
1089
|
-
|
|
1073
|
+
fit: l.fit.bind(l),
|
|
1074
|
+
removePane: l.removePane.bind(l),
|
|
1075
|
+
addPane: w
|
|
1090
1076
|
}),
|
|
1091
1077
|
[]
|
|
1092
|
-
)
|
|
1078
|
+
);
|
|
1079
|
+
const g = /* @__PURE__ */ f.createElement(
|
|
1093
1080
|
"bw-window",
|
|
1094
1081
|
{
|
|
1095
|
-
"sash-id":
|
|
1096
|
-
style: { width:
|
|
1082
|
+
"root-sash-id": l.rootSash.id,
|
|
1083
|
+
style: { width: l.rootSash.width, height: l.rootSash.height },
|
|
1097
1084
|
ref: i
|
|
1098
1085
|
},
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
/* @__PURE__ */
|
|
1102
|
-
);
|
|
1103
|
-
|
|
1086
|
+
u.map((p) => /* @__PURE__ */ f.createElement(Wt, { key: p.id, sash: p, bwin: l })),
|
|
1087
|
+
c.map((p) => /* @__PURE__ */ f.createElement(Tt, { key: p.id, sash: p })),
|
|
1088
|
+
/* @__PURE__ */ f.createElement("bw-sill", { ref: n })
|
|
1089
|
+
), m = V(() => g, []);
|
|
1090
|
+
function w(p, x) {
|
|
1091
|
+
const { content: D, ...$ } = x, q = l.addPane(p, $), U = document.querySelector(
|
|
1092
|
+
`bw-pane[sash-id="${q.id}"] bw-glass-content`
|
|
1093
|
+
);
|
|
1094
|
+
o((X) => [
|
|
1095
|
+
...X || [],
|
|
1096
|
+
{ node: D, container: U }
|
|
1097
|
+
]);
|
|
1098
|
+
}
|
|
1099
|
+
return /* @__PURE__ */ f.createElement(f.Fragment, null, m, s == null ? void 0 : s.map((p) => Z(p.node, p.container)));
|
|
1100
|
+
}), Ot = "0.3.0";
|
|
1104
1101
|
export {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1102
|
+
F as BUILTIN_ACTIONS,
|
|
1103
|
+
It as Window,
|
|
1104
|
+
Ot as version
|
|
1108
1105
|
};
|
package/dist/react-bwin.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(b,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],p):(b=typeof globalThis<"u"?globalThis:b||self,p(b.ReactBinaryWindow={},b.React))})(this,function(b,p){"use strict";var O=Object.defineProperty,k=(e,t,i)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,y=(e,t,i)=>k(e,typeof t!="symbol"?t+"":t,i);function F(e=.7,t=128){const i=256-t,n=Math.floor(Math.random()*i+t),s=Math.floor(Math.random()*i+t),o=Math.floor(Math.random()*i+t),h=Math.max(.5,Math.random()*e);return`rgba(${n}, ${s}, ${o}, ${h})`}function D(e=2,t=3){if(e<0||t<0)throw new Error("Parameters must be non-negative numbers");const i="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="0123456789";let s="";for(let o=0;o<e;o++){const h=Math.floor(Math.random()*i.length);s+=i[h]}s+="-";for(let o=0;o<t;o++){const h=Math.floor(Math.random()*n.length);s+=n[h]}return s}function N(e,t){for(;t.firstChild;)e.append(t.firstChild)}function _(e,t){const i=document.createElement("div");N(i,e),N(e,t),N(t,i)}function z(e){if(typeof e=="number"&&!isNaN(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("%")){const i=t.slice(0,-1);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n/100}if(t.endsWith("px")){const i=t.slice(0,-2);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n}return Number(t)}return NaN}function q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function U(e,t){for(const i in t){if(Object.hasOwn(e,i))throw new Error(`Key "${i}" already exists in target object`);e[i]=t[i]}return e}function j(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content}function C(e){if(e==null||e==="")return null;if(typeof e=="string")try{const t=j(e);return t.childNodes.length===1?t.firstChild:t}catch{return document.createTextNode(e)}return e instanceof Node?e:document.createTextNode(String(e))}function A(e){const t=parseFloat(e.style.left)||0,i=parseFloat(e.style.top)||0,n=parseFloat(e.style.width)||0,s=parseFloat(e.style.height)||0;return{left:t,top:i,width:n,height:s}}const r={Top:"top",Right:"right",Bottom:"bottom",Left:"left",Center:"center",Root:"root",Unknown:"unknown",Outside:"outside"};function X(e){switch(e){case r.Top:return r.Bottom;case r.Right:return r.Left;case r.Bottom:return r.Top;case r.Left:return r.Right;default:throw new Error(`[bwin] Invalid position: ${e}`)}}function Y({width:e,height:t,x:i}){return t/e*i}function K({width:e,height:t,y:i}){return e/t*i}function V({width:e,height:t,x:i}){return t-t/e*i}function Z({width:e,height:t,y:i}){return e-e/t*i}function J(e,{clientX:t,clientY:i}){const n=e.getBoundingClientRect(),{width:s,height:o}=n,h=t-n.left,a=i-n.top;if(h<0||h>s||a<0||a>o)return r.Outside;const d=.3,c=Y({width:s,height:o,x:h}),l=V({width:s,height:o,x:h}),u=K({width:s,height:o,y:a}),g=Z({width:s,height:o,y:a});return h<s*(.5-d/2)&&a>c&&a<l?r.Left:h>s*(.5+d/2)&&a<c&&a>l?r.Right:a<o*(.5-d/2)&&h>u&&h<g?r.Top:a>o*(.5+d/2)&&h<u&&h>g?r.Bottom:h>s*(.5-d/2)&&h<s*(.5+d/2)&&a>o*(.5-d/2)&&a<o*(.5+d/2)?r.Center:r.Unknown}const Q=100,tt=100,E={left:0,top:0,width:150,height:150,minWidth:Q,minHeight:tt};class f{constructor({left:t=E.left,top:i=E.top,width:n=E.width,height:s=E.height,minWidth:o=E.minWidth,minHeight:h=E.minHeight,domNode:a=null,store:d={},position:c,id:l}=E){if(this.id=l??D(),!c)throw new Error("[bwin] Sash position is required");this.position=c,this.domNode=a,this._top=i,this._left=t,this._width=n,this._height=s,this.children=[],this.minWidth=o,this.minHeight=h,this.store=d}walk(t){this.children.forEach(i=>i.walk(t)),t(this)}isLeaf(){return this.children.length===0}isSplit(){return this.children.length>0}isLeftRightSplit(){return this.children.some(t=>t.position===r.Left||t.position===r.Right)}isTopBottomSplit(){return this.children.some(t=>t.position===r.Top||t.position===r.Bottom)}get leftChild(){return this.children.find(t=>t.position===r.Left)}get rightChild(){return this.children.find(t=>t.position===r.Right)}get topChild(){return this.children.find(t=>t.position===r.Top)}get bottomChild(){return this.children.find(t=>t.position===r.Bottom)}getChildren(){let t=null,i=null,n=null,s=null;for(const o of this.children)o.position===r.Left?t=o:o.position===r.Right?i=o:o.position===r.Top?n=o:o.position===r.Bottom&&(s=o);return[n,i,s,t]}getAllLeafDescendants(){const t=[];return this.walk(i=>{i.children.length===0&&t.push(i)}),t}calcMinWidth(){if(this.isLeaf())return this.minWidth;const[t,i,n,s]=this.getChildren();if(s&&i){const o=s.calcMinWidth()+i.calcMinWidth();return Math.max(this.minWidth,o)}if(t&&n){const o=Math.max(t.calcMinWidth(),n.calcMinWidth());return Math.max(this.minWidth,o)}}calcMinHeight(){if(this.isLeaf())return this.minHeight;const[t,i,n,s]=this.getChildren();if(s&&i){const o=Math.max(s.calcMinHeight(),i.calcMinHeight());return Math.max(this.minHeight,o)}if(t&&n){const o=t.calcMinHeight()+n.calcMinHeight();return Math.max(this.minHeight,o)}}getById(t){if(this.id===t)return this;for(const i of this.children){const n=i.getById(t);if(n)return n}return null}getAllIds(){const t=[this.id];for(const i of this.children)t.push(...i.getAllIds());return t}addChild(t){if(this.children.length>=2)throw new Error("[bwin] Maximum 2 children allowed");this.children.push(t)}getDescendantParentById(t){for(const i of this.children){if(i.id===t)return this;const n=i.getDescendantParentById(t);if(n)return n}return null}getChildSiblingById(t){return this.children.find(i=>i.id!==t)}get top(){return this._top}set top(t){const i=t-this._top;this._top=t;const[n,s,o,h]=this.getChildren();n&&o&&(n.top+=i,o.top+=i),h&&s&&(h.top+=i,s.top+=i)}get left(){return this._left}set left(t){const i=t-this._left;this._left=t;const[n,s,o,h]=this.getChildren();h&&s&&(h.left+=i,s.left+=i),n&&o&&(n.left+=i,o.left+=i)}get width(){return this._width}set width(t){const i=t-this._width;this._width=t;const[n,s,o,h]=this.getChildren();if(h&&s){const a=h.width+s.width,d=i*(h.width/a),c=a+i;let l=h.width+d,u=c-l,g=s.left+d;const w=h.calcMinWidth(),m=s.calcMinWidth();l<w&&u>m?(l=w,u=c-l,g=h.left+l):u<m&&l>w&&(u=m,l=c-u,g=h.left+l),h.width=l,s.width=u,s.left=g}n&&o&&(n.width+=i,o.width+=i)}get height(){return this._height}set height(t){const i=t-this._height;this._height=t;const[n,s,o,h]=this.getChildren();if(n&&o){const a=n.height+o.height,d=i*(n.height/a),c=a+i;let l=n.height+d,u=c-l,g=o.top+d;const w=n.calcMinHeight(),m=o.calcMinHeight();l<w&&u>m?(l=w,u=c-l,g=n.top+l):u<m&&l>w&&(u=m,l=c-u,g=n.top+l),n.height=l,o.height=u,o.top=g}h&&s&&(h.height+=i,s.height+=i)}}const L={size:"50%",position:r.Left};class P{constructor({parentRect:t,children:i,siblingConfigNode:n,id:s,minWidth:o,minHeight:h,position:a,size:d,...c}){y(this,"left"),y(this,"top"),y(this,"width"),y(this,"height"),this.parentRect=t,this.children=i,this.siblingConfigNode=n,this.id=s,this.minWidth=o,this.minHeight=h,this.position=this.getPosition(a),this.size=this.getSize(d),this.nonCoreData=c,this.setBounds()}getPosition(t){if(!this.siblingConfigNode)return t;const i=X(this.siblingConfigNode.position);if(!t)return i;if(t!==i)throw new Error("[bwin] Sibling position and current position are not opposite");return t}getSize(t){if(!this.siblingConfigNode)return z(t);if(!t){if(this.siblingConfigNode.size<1)return 1-this.siblingConfigNode.size;if(this.siblingConfigNode.position===r.Left||this.siblingConfigNode.position===r.Right)return this.parentRect.width-this.siblingConfigNode.width;if(this.siblingConfigNode.position===r.Top||this.siblingConfigNode.position===r.Bottom)return this.parentRect.height-this.siblingConfigNode.height}const i=z(t);if(i<1){if(i+this.siblingConfigNode.size!==1)throw new Error("[bwin] Sum of sibling sizes is not equal to 1")}else{if((this.position===r.Left||this.position===r.Right)&&i+this.siblingConfigNode.size!==this.parentRect.width)throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");if((this.position===r.Top||this.position===r.Bottom)&&i+this.siblingConfigNode.size!==this.parentRect.height)throw new Error("[bwin] Sum of sibling sizes is not equal to parent height")}return i}setBounds(){if(this.position===r.Root)this.left=0,this.top=0,this.width=this.parentRect.width,this.height=this.parentRect.height;else if(this.position===r.Left){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===r.Right){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left+this.parentRect.width-t,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===r.Top){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=this.parentRect.width,this.height=t}else if(this.position===r.Bottom){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top+this.parentRect.height-t,this.width=this.parentRect.width,this.height=t}}createSash(){return new f({left:this.left,top:this.top,width:this.width,height:this.height,position:this.position,id:this.id,minWidth:this.minWidth,minHeight:this.minHeight,store:this.nonCoreData})}normConfig(t){if(q(t))return t;if(Array.isArray(t))return{children:t};if(typeof t=="string"||typeof t=="number"){const i=z(t);if(isNaN(i))throw new Error(`[bwin] Invalid size value: ${i}`);return{size:t}}else{if(t==null)return{};throw new Error(`[bwin] Invalid config value: ${t}`)}}createPrimaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...a}){return new P({parentRect:this,size:t??L.size,position:i??L.position,children:n,id:s,minWidth:o,minHeight:h,...a})}createSecondaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...a},d){return new P({parentRect:this,size:t,position:i,children:n,siblingConfigNode:d,id:s,minWidth:o,minHeight:h,...a})}buildSashTree(){const t=this.createSash();if(!Array.isArray(this.children)||this.children.length===0)return t;const i=this.normConfig(this.children[0]),n=this.normConfig(this.children.at(1));let s,o;return!i.size&&!i.position&&n?(n.position||(n.position=r.Right),s=this.createPrimaryConfigNode(n),o=this.createSecondaryConfigNode(i,s)):(s=this.createPrimaryConfigNode(i),o=this.createSecondaryConfigNode(n,s)),s&&o&&(t.children.push(s.buildSashTree()),t.children.push(o.buildSashTree())),t}}const R={width:333,height:333},$={fitContainer:!1};class et extends P{constructor({id:t,children:i,width:n=R.width,height:s=R.height,fitContainer:o=$.fitContainer,...h}={...R,...$}){super({id:t,children:i,size:NaN,position:r.Root,parentRect:{width:n,height:s},...h}),this.fitContainer=o}}class it extends f{constructor(t=E){super({...t,position:r.Root}),Object.assign(this,$)}}function S(e){const t=document.createElement("bw-pane");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}function nt(e){const t=e.domNode;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}function st(e,{size:t}){const i=z(t);let n=e.width/2;i&&(i<1?n=e.width*i:n=i);const s=new f({top:e.top,left:e.left,width:n,height:e.height,position:r.Left}),o=new f({top:e.top,left:e.left+s.width,width:e.width-n,height:e.height,position:r.Right}),h=S(o);return o.domNode=h,N(h,e.domNode),e.addChild(s),e.addChild(o),s}function ot(e,{size:t}){const i=z(t);let n=e.width/2;i&&(i<1?n=e.width*i:n=i);const s=new f({left:e.left,top:e.top,width:e.width-n,height:e.height,position:r.Left}),o=new f({left:e.left+s.width,top:e.top,width:n,height:e.height,position:r.Right}),h=S(s);return s.domNode=h,N(h,e.domNode),e.addChild(s),e.addChild(o),o}function ht(e,{size:t}){const i=z(t);let n=e.height/2;i&&(i<1?n=e.height*i:n=i);const s=new f({left:e.left,top:e.top,width:e.width,height:n,position:r.Top}),o=new f({left:e.left,top:e.top+s.height,width:e.width,height:e.height-n,position:r.Bottom}),h=S(o);return o.domNode=h,N(h,e.domNode),e.addChild(s),e.addChild(o),s}function rt(e,{size:t}){const i=z(t);let n=e.height/2;i&&(i<1?n=e.height*i:n=i);const s=new f({top:e.top,left:e.left,width:e.width,height:e.height-n,position:r.Top}),o=new f({top:e.top+s.height,left:e.left,width:e.width,height:n,position:r.Bottom}),h=S(s);return s.domNode=h,N(h,e.domNode),e.addChild(s),e.addChild(o),o}function at(e,{position:t,size:i,minWidth:n,minHeight:s}){if(t===r.Left)return st(e,{size:i});if(t===r.Right)return ot(e,{size:i});if(t===r.Top)return ht(e,{size:i});if(t===r.Bottom)return rt(e,{size:i})}const lt={createPane(e){const t=S(e);return e.store.droppable===!1&&t.setAttribute("can-drop","false"),t},onPaneCreate(e,t){t.store.content&&e.append(C(t.store.content)),this!=null&&this.debug&&(e.style.backgroundColor=F(),e.innerHTML="",e.append(T(e)))},updatePane(e){return nt(e)},onPaneUpdate(e,t){this!=null&&this.debug&&(e.innerHTML="",e.append(T(e)))},addPane(e,{position:t,size:i}){if(!t)throw new Error("[bwin] Position is required when adding pane");const n=this.rootSash.getById(e);if(!n)throw new Error("[bwin] Parent sash not found when adding pane");const s=at(n,{position:t,size:i});return n.id=D(),this.update(),s},removePane(e){const t=this.rootSash.getDescendantParentById(e);if(!t)throw new Error("[bwin] Parent sash not found when removing pane");const i=t.getChildSiblingById(e);t.id=D(),i.children.length===0?(t.domNode=i.domNode,t.domNode.setAttribute("sash-id",t.id),t.children=[]):(t.children=i.children,i.position===r.Left?i.width=t.width:i.position===r.Right?(i.width=t.width,i.left=t.left):i.position===r.Top?i.height=t.height:i.position===r.Bottom&&(i.height=t.height,i.top=t.top)),this.update()}};function T(e){const t=document.createElement("pre");t.style.fontSize="10px";const i=`
|
|
1
|
+
(function(b,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],u):(b=typeof globalThis<"u"?globalThis:b||self,u(b.ReactBinaryWindow={},b.React,b.ReactDOM))})(this,function(b,u,_){"use strict";var q=Object.defineProperty,U=(e,t,i)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,E=(e,t,i)=>U(e,typeof t!="symbol"?t+"":t,i);function j(e=.7,t=128){const i=256-t,n=Math.floor(Math.random()*i+t),s=Math.floor(Math.random()*i+t),o=Math.floor(Math.random()*i+t),h=Math.max(.5,Math.random()*e);return`rgba(${n}, ${s}, ${o}, ${h})`}function x(e=2,t=3){if(e<0||t<0)throw new Error("Parameters must be non-negative numbers");const i="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="0123456789";let s="";for(let o=0;o<e;o++){const h=Math.floor(Math.random()*i.length);s+=i[h]}s+="-";for(let o=0;o<t;o++){const h=Math.floor(Math.random()*n.length);s+=n[h]}return s}function z(e,t){for(;t.firstChild;)e.append(t.firstChild)}function X(e,t){const i=document.createElement("div");z(i,e),z(e,t),z(t,i)}function C(e){if(typeof e=="number"&&!isNaN(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("%")){const i=t.slice(0,-1);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n/100}if(t.endsWith("px")){const i=t.slice(0,-2);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n}return Number(t)}return NaN}function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function K(e,t){for(const i in t){if(Object.hasOwn(e,i))throw new Error(`Key "${i}" already exists in target object`);e[i]=t[i]}return e}function V(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content}function S(e){if(e==null||e==="")return null;if(typeof e=="string")try{const t=V(e);return t.childNodes.length===1?t.firstChild:t}catch{return document.createTextNode(e)}return e instanceof Node?e:document.createTextNode(String(e))}function P(e){const t=parseFloat(e.style.left)||0,i=parseFloat(e.style.top)||0,n=parseFloat(e.style.width)||0,s=parseFloat(e.style.height)||0;return{left:t,top:i,width:n,height:s}}const r={Top:"top",Right:"right",Bottom:"bottom",Left:"left",Center:"center",Root:"root",Unknown:"unknown",Outside:"outside"};function Z(e){switch(e){case r.Top:return r.Bottom;case r.Right:return r.Left;case r.Bottom:return r.Top;case r.Left:return r.Right;default:throw new Error(`[bwin] Invalid position: ${e}`)}}function J({width:e,height:t,x:i}){return t/e*i}function Q({width:e,height:t,y:i}){return e/t*i}function tt({width:e,height:t,x:i}){return t-t/e*i}function et({width:e,height:t,y:i}){return e-e/t*i}function it(e,{clientX:t,clientY:i}){const n=e.getBoundingClientRect(),{width:s,height:o}=n,h=t-n.left,a=i-n.top;if(h<0||h>s||a<0||a>o)return r.Outside;const d=.3,l=J({width:s,height:o,x:h}),c=tt({width:s,height:o,x:h}),g=Q({width:s,height:o,y:a}),f=et({width:s,height:o,y:a});return h<s*(.5-d/2)&&a>l&&a<c?r.Left:h>s*(.5+d/2)&&a<l&&a>c?r.Right:a<o*(.5-d/2)&&h>g&&h<f?r.Top:a>o*(.5+d/2)&&h<g&&h>f?r.Bottom:h>s*(.5-d/2)&&h<s*(.5+d/2)&&a>o*(.5-d/2)&&a<o*(.5+d/2)?r.Center:r.Unknown}const nt=100,st=100,v={left:0,top:0,width:150,height:150,minWidth:nt,minHeight:st};class y{constructor({left:t=v.left,top:i=v.top,width:n=v.width,height:s=v.height,minWidth:o=v.minWidth,minHeight:h=v.minHeight,domNode:a=null,store:d={},position:l,id:c}=v){if(this.id=c??x(),!l)throw new Error("[bwin] Sash position is required");this.position=l,this.domNode=a,this._top=i,this._left=t,this._width=n,this._height=s,this.children=[],this.minWidth=o,this.minHeight=h,this.store=d}walk(t){this.children.forEach(i=>i.walk(t)),t(this)}isLeaf(){return this.children.length===0}isSplit(){return this.children.length>0}isLeftRightSplit(){return this.children.some(t=>t.position===r.Left||t.position===r.Right)}isTopBottomSplit(){return this.children.some(t=>t.position===r.Top||t.position===r.Bottom)}get leftChild(){return this.children.find(t=>t.position===r.Left)}get rightChild(){return this.children.find(t=>t.position===r.Right)}get topChild(){return this.children.find(t=>t.position===r.Top)}get bottomChild(){return this.children.find(t=>t.position===r.Bottom)}getChildren(){let t=null,i=null,n=null,s=null;for(const o of this.children)o.position===r.Left?t=o:o.position===r.Right?i=o:o.position===r.Top?n=o:o.position===r.Bottom&&(s=o);return[n,i,s,t]}getAllLeafDescendants(){const t=[];return this.walk(i=>{i.children.length===0&&t.push(i)}),t}calcMinWidth(){if(this.isLeaf())return this.minWidth;const[t,i,n,s]=this.getChildren();if(s&&i){const o=s.calcMinWidth()+i.calcMinWidth();return Math.max(this.minWidth,o)}if(t&&n){const o=Math.max(t.calcMinWidth(),n.calcMinWidth());return Math.max(this.minWidth,o)}}calcMinHeight(){if(this.isLeaf())return this.minHeight;const[t,i,n,s]=this.getChildren();if(s&&i){const o=Math.max(s.calcMinHeight(),i.calcMinHeight());return Math.max(this.minHeight,o)}if(t&&n){const o=t.calcMinHeight()+n.calcMinHeight();return Math.max(this.minHeight,o)}}getById(t){if(this.id===t)return this;for(const i of this.children){const n=i.getById(t);if(n)return n}return null}getAllIds(){const t=[this.id];for(const i of this.children)t.push(...i.getAllIds());return t}addChild(t){if(this.children.length>=2)throw new Error("[bwin] Maximum 2 children allowed");this.children.push(t)}getDescendantParentById(t){for(const i of this.children){if(i.id===t)return this;const n=i.getDescendantParentById(t);if(n)return n}return null}getChildSiblingById(t){return this.children.find(i=>i.id!==t)}get top(){return this._top}set top(t){const i=t-this._top;this._top=t;const[n,s,o,h]=this.getChildren();n&&o&&(n.top+=i,o.top+=i),h&&s&&(h.top+=i,s.top+=i)}get left(){return this._left}set left(t){const i=t-this._left;this._left=t;const[n,s,o,h]=this.getChildren();h&&s&&(h.left+=i,s.left+=i),n&&o&&(n.left+=i,o.left+=i)}get width(){return this._width}set width(t){const i=t-this._width;this._width=t;const[n,s,o,h]=this.getChildren();if(h&&s){const a=h.width+s.width,d=i*(h.width/a),l=a+i;let c=h.width+d,g=l-c,f=s.left+d;const m=h.calcMinWidth(),w=s.calcMinWidth();c<m&&g>w?(c=m,g=l-c,f=h.left+c):g<w&&c>m&&(g=w,c=l-g,f=h.left+c),h.width=c,s.width=g,s.left=f}n&&o&&(n.width+=i,o.width+=i)}get height(){return this._height}set height(t){const i=t-this._height;this._height=t;const[n,s,o,h]=this.getChildren();if(n&&o){const a=n.height+o.height,d=i*(n.height/a),l=a+i;let c=n.height+d,g=l-c,f=o.top+d;const m=n.calcMinHeight(),w=o.calcMinHeight();c<m&&g>w?(c=m,g=l-c,f=n.top+c):g<w&&c>m&&(g=w,c=l-g,f=n.top+c),n.height=c,o.height=g,o.top=f}h&&s&&(h.height+=i,s.height+=i)}}const H={size:"50%",position:r.Left};class D{constructor({parentRect:t,children:i,siblingConfigNode:n,id:s,minWidth:o,minHeight:h,position:a,size:d,...l}){E(this,"left"),E(this,"top"),E(this,"width"),E(this,"height"),this.parentRect=t,this.children=i,this.siblingConfigNode=n,this.id=s,this.minWidth=o,this.minHeight=h,this.position=this.getPosition(a),this.size=this.getSize(d),this.nonCoreData=l,this.setBounds()}getPosition(t){if(!this.siblingConfigNode)return t;const i=Z(this.siblingConfigNode.position);if(!t)return i;if(t!==i)throw new Error("[bwin] Sibling position and current position are not opposite");return t}getSize(t){if(!this.siblingConfigNode)return C(t);if(!t){if(this.siblingConfigNode.size<1)return 1-this.siblingConfigNode.size;if(this.siblingConfigNode.position===r.Left||this.siblingConfigNode.position===r.Right)return this.parentRect.width-this.siblingConfigNode.width;if(this.siblingConfigNode.position===r.Top||this.siblingConfigNode.position===r.Bottom)return this.parentRect.height-this.siblingConfigNode.height}const i=C(t);if(i<1){if(i+this.siblingConfigNode.size!==1)throw new Error("[bwin] Sum of sibling sizes is not equal to 1")}else{if((this.position===r.Left||this.position===r.Right)&&i+this.siblingConfigNode.size!==this.parentRect.width)throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");if((this.position===r.Top||this.position===r.Bottom)&&i+this.siblingConfigNode.size!==this.parentRect.height)throw new Error("[bwin] Sum of sibling sizes is not equal to parent height")}return i}setBounds(){if(this.position===r.Root)this.left=0,this.top=0,this.width=this.parentRect.width,this.height=this.parentRect.height;else if(this.position===r.Left){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===r.Right){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left+this.parentRect.width-t,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===r.Top){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=this.parentRect.width,this.height=t}else if(this.position===r.Bottom){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top+this.parentRect.height-t,this.width=this.parentRect.width,this.height=t}}createSash(){return new y({left:this.left,top:this.top,width:this.width,height:this.height,position:this.position,id:this.id,minWidth:this.minWidth,minHeight:this.minHeight,store:this.nonCoreData})}normConfig(t){if(Y(t))return t;if(Array.isArray(t))return{children:t};if(typeof t=="string"||typeof t=="number"){const i=C(t);if(isNaN(i))throw new Error(`[bwin] Invalid size value: ${i}`);return{size:t}}else{if(t==null)return{};throw new Error(`[bwin] Invalid config value: ${t}`)}}createPrimaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...a}){return new D({parentRect:this,size:t??H.size,position:i??H.position,children:n,id:s,minWidth:o,minHeight:h,...a})}createSecondaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...a},d){return new D({parentRect:this,size:t,position:i,children:n,siblingConfigNode:d,id:s,minWidth:o,minHeight:h,...a})}buildSashTree(){const t=this.createSash();if(!Array.isArray(this.children)||this.children.length===0)return t;const i=this.normConfig(this.children[0]),n=this.normConfig(this.children.at(1));let s,o;return!i.size&&!i.position&&n?(n.position||(n.position=r.Right),s=this.createPrimaryConfigNode(n),o=this.createSecondaryConfigNode(i,s)):(s=this.createPrimaryConfigNode(i),o=this.createSecondaryConfigNode(n,s)),s&&o&&(t.children.push(s.buildSashTree()),t.children.push(o.buildSashTree())),t}}const R={width:333,height:333},$={fitContainer:!1};class ot extends D{constructor({id:t,children:i,width:n=R.width,height:s=R.height,fitContainer:o=$.fitContainer,...h}={...R,...$}){super({id:t,children:i,size:NaN,position:r.Root,parentRect:{width:n,height:s},...h}),this.fitContainer=o}}class ht extends y{constructor(t=v){super({...t,position:r.Root}),Object.assign(this,$)}}function M(e){const t=document.createElement("bw-pane");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}function rt(e){const t=e.domNode;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}function at(e,{size:t}){const i=C(t);let n=e.width/2;i&&(i<1?n=e.width*i:n=i);const s=new y({top:e.top,left:e.left,width:n,height:e.height,position:r.Left}),o=new y({top:e.top,left:e.left+s.width,width:e.width-n,height:e.height,position:r.Right}),h=M(o);return o.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),s}function lt(e,{size:t}){const i=C(t);let n=e.width/2;i&&(i<1?n=e.width*i:n=i);const s=new y({left:e.left,top:e.top,width:e.width-n,height:e.height,position:r.Left}),o=new y({left:e.left+s.width,top:e.top,width:n,height:e.height,position:r.Right}),h=M(s);return s.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),o}function dt(e,{size:t}){const i=C(t);let n=e.height/2;i&&(i<1?n=e.height*i:n=i);const s=new y({left:e.left,top:e.top,width:e.width,height:n,position:r.Top}),o=new y({left:e.left,top:e.top+s.height,width:e.width,height:e.height-n,position:r.Bottom}),h=M(o);return o.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),s}function ct(e,{size:t}){const i=C(t);let n=e.height/2;i&&(i<1?n=e.height*i:n=i);const s=new y({top:e.top,left:e.left,width:e.width,height:e.height-n,position:r.Top}),o=new y({top:e.top+s.height,left:e.left,width:e.width,height:n,position:r.Bottom}),h=M(s);return s.domNode=h,z(h,e.domNode),e.addChild(s),e.addChild(o),o}function ut(e,{position:t,size:i,minWidth:n,minHeight:s}){if(t===r.Left)return at(e,{size:i});if(t===r.Right)return lt(e,{size:i});if(t===r.Top)return dt(e,{size:i});if(t===r.Bottom)return ct(e,{size:i})}const pt={createPane(e){const t=M(e);return e.store.droppable===!1&&t.setAttribute("can-drop","false"),t},onPaneCreate(e,t){t.store.content&&e.append(S(t.store.content)),this!=null&&this.debug&&(e.style.backgroundColor=j(),e.innerHTML="",e.append(O(e)))},updatePane(e){return rt(e)},onPaneUpdate(e,t){this!=null&&this.debug&&(e.innerHTML="",e.append(O(e)))},addPane(e,{position:t,size:i}){if(!t)throw new Error("[bwin] Position is required when adding pane");const n=this.rootSash.getById(e);if(!n)throw new Error("[bwin] Parent sash not found when adding pane");const s=ut(n,{position:t,size:i});return n.id=x(),this.update(),s},removePane(e){const t=this.rootSash.getDescendantParentById(e);if(!t)throw new Error("[bwin] Parent sash not found when removing pane");const i=t.getChildSiblingById(e);t.id=x(),i.children.length===0?(t.domNode=i.domNode,t.domNode.setAttribute("sash-id",t.id),t.children=[]):(t.children=i.children,i.position===r.Left?i.width=t.width:i.position===r.Right?(i.width=t.width,i.left=t.left):i.position===r.Top?i.height=t.height:i.position===r.Bottom&&(i.height=t.height,i.top=t.top)),this.update()}};function O(e){const t=document.createElement("pre");t.style.fontSize="10px";const i=`
|
|
2
2
|
${e.getAttribute("sash-id")}
|
|
3
3
|
${e.getAttribute("position")}
|
|
4
4
|
top: ${e.style.top}
|
|
5
5
|
left: ${e.style.left}
|
|
6
6
|
width: ${e.style.width}
|
|
7
7
|
height: ${e.style.height}
|
|
8
|
-
`;return t.innerHTML=i.trim(),t}const dt={createWindow(){const e=document.createElement("bw-window");return e.style.width=`${this.rootSash.width}px`,e.style.height=`${this.rootSash.height}px`,e.setAttribute("sash-id",this.rootSash.id),e},glaze(){this.rootSash.walk(e=>{let t=null;e.children.length>0?(t=this.createMuntin(e),this.onMuntinCreate(t,e),this.windowElement.append(t)):(t=this.createPane(e),this.onPaneCreate(t,e),this.windowElement.prepend(t)),e.domNode=t})},update(){this.windowElement.style.width=`${this.rootSash.width}px`,this.windowElement.style.height=`${this.rootSash.height}px`;const e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll("[sash-id]").forEach(i=>{const n=i.getAttribute("sash-id");t.push(n),e.includes(n)||i.remove()}),this.rootSash.walk(i=>{i.children.length>0?t.includes(i.id)?(this.updateMuntin(i),this.onMuntinUpdate(i.domNode,i)):(i.domNode=this.createMuntin(i),this.windowElement.append(i.domNode)):t.includes(i.id)?(this.updatePane(i),this.onPaneUpdate(i.domNode,i)):(i.domNode||(i.domNode=this.createPane(i)),this.windowElement.prepend(i.domNode))})}},ct={muntinSize:4,createMuntin(e){const t=document.createElement("bw-muntin"),i=e.leftChild,n=e.topChild;return i?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`,t.setAttribute("vertical","")):n&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`,t.setAttribute("horizontal","")),t.setAttribute("sash-id",e.id),e.store.resizable===!1&&t.setAttribute("resizable","false"),t},onMuntinCreate(e,t){},updateMuntin(e){const t=e.domNode,i=e.leftChild,n=e.topChild;i?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`):n&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},pt={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{for(const t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()}).observe(this.containerElement)}},ut={activeMuntinSash:null,isResizeStarted:!1,isDropStarted:!1,lastX:0,lastY:0,applyResizeStyles(){this.activeMuntinSash.domNode.hasAttribute("vertical")?document.body.classList.add("body--bw-resize-x"):this.activeMuntinSash.domNode.hasAttribute("horizontal")&&document.body.classList.add("body--bw-resize-y")},revertResizeStyles(){document.body.classList.remove("body--bw-resize-x"),document.body.classList.remove("body--bw-resize-y")},enableResize(){document.addEventListener("mousedown",e=>{if(e.target.tagName!=="BW-MUNTIN"||e.target.getAttribute("resizable")==="false")return;const t=e.target.getAttribute("sash-id");this.activeMuntinSash=this.rootSash.getById(t),this.activeMuntinSash&&(this.isResizeStarted=!0,this.lastX=e.pageX,this.lastY=e.pageY,this.applyResizeStyles())}),document.addEventListener("mousemove",e=>{if(!this.isResizeStarted||!this.activeMuntinSash)return;const[t,i,n,s]=this.activeMuntinSash.getChildren(),o=this.activeMuntinSash.isLeftRightSplit(),h=this.activeMuntinSash.isTopBottomSplit();if(o&&s&&i){const a=e.pageX-this.lastX,d=s.width+a,c=i.width-a;if(d<=s.calcMinWidth()||c<=i.calcMinWidth())return;s.width=d,i.width=c,i.left=i.left+a,this.update(),this.lastX=e.pageX}else if(h&&t&&n){const a=e.pageY-this.lastY,d=t.height+a,c=n.height-a;if(d<=t.calcMinHeight()||c<=n.calcMinHeight())return;t.height=d,n.height=c,n.top=n.top+a,this.update(),this.lastY=e.pageY}}),document.addEventListener("mouseup",()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},gt={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener("dragover",e=>{e.preventDefault();const t=e.target.matches("bw-pane")?e.target:e.target.closest("bw-pane");if(!t||(t!==this.activeDropPaneEl&&(this.activeDropPaneEl&&this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=t),t.getAttribute("can-drop")==="false"))return;const i=J(t,e);t.setAttribute("drop-area",i)}),this.windowElement.addEventListener("dragleave",e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||this.activeDropPaneEl&&(this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null)}),this.windowElement.addEventListener("drop",e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute("can-drop")==="false")return;const t=this.activeDropPaneEl.getAttribute("sash-id"),i=this.rootSash.getById(t);this.onPaneDrop(e,i),typeof i.store.onDrop=="function"&&i.store.onDrop(e,i),this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null})}},ft=!0;class W{constructor(t){y(this,"windowElement",null),y(this,"containerElement",null),y(this,"debug",ft);let i=null;t instanceof it?(i=t,this.rootSash=t):(i=new et(t),this.rootSash=i.buildSashTree()),this.fitContainer=i.fitContainer}frame(t){this.containerElement=t,this.windowElement=this.createWindow(),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(t){this.frame(t),this.enableFeatures()}static assemble(...t){t.forEach(i=>{U(this.prototype,i)})}}W.assemble(dt,ct,lt,pt,gt,ut);function H(e){if(e.tagName==="BW-PANE")return e.getAttribute("sash-id");const t=e.closest("bw-pane");if(!t)throw new Error("[bwin] Pane element not found");return t.getAttribute("sash-id")}const wt={label:"",className:"bw-glass-action--close",onClick:(e,t)=>{const i=H(e.target);t.removePane(i)}},mt={label:"",className:"bw-glass-action--minimize",onClick:(e,t)=>{const i=t.sillElement;if(!i)throw new Error("[bwin] Sill element not found when minimizing");const n=C('<button class="bw-minimized-glass" />');i.append(n);const s=e.target.closest("bw-pane"),o=e.target.closest("bw-glass"),h=s.getAttribute("sash-id"),a=s.getAttribute("position");n.bwGlassElement=o,n.bwOriginalPosition=a,n.bwOriginalBoundingRect=A(s),t.removePane(h)}},bt={label:"",className:"bw-glass-action--maximize",onClick:e=>{const t=e.target.closest("bw-pane");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=A(t),t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%")}};function yt(e,t){const i=e.left+e.width,n=e.top+e.height,s=t.left+t.width,o=t.top+t.height;if(e.left>=s||t.left>=i||e.top>=o||t.top>=n)return null;const h=Math.max(e.left,t.left),a=Math.max(e.top,t.top),d=Math.min(i,s),c=Math.min(n,o);return{left:h,top:a,width:d-h,height:c-a}}const B=[mt,bt,wt],Et={enableActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){const t=e.bwOriginalBoundingRect;let i=0,n=null;if(this.windowElement.querySelectorAll("bw-pane").forEach(s=>{const o=A(s),h=yt(t,o);if(h){const a=h.width*h.height;a>i&&(i=a,n=s)}}),n){const s=e.bwOriginalPosition,o=A(n);let h=0;if(s===r.Left||s===r.Right)h=t.width>=o.width?o.width/2:t.width;else if(s===r.Top||s===r.Bottom)h=t.height>=o.height?o.height/2:t.height;else throw new Error("[bwin] Invalid position when restoring glass");this.addPane(n.getAttribute("sash-id"),{position:s,size:h}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener("click",e=>{if(!e.target.matches(".bw-minimized-glass"))return;const t=e.target;this.restoreGlass(t),t.remove()})},updateDisabledStateOfActionButtons(){this.updateDisabledState(".bw-glass-action--close"),this.updateDisabledState(".bw-glass-action--minimize"),this.updateDisabledState(".bw-glass-action--maximize")},updateDisabledState(e){if(this.windowElement.querySelectorAll("bw-pane").length===1){const t=this.windowElement.querySelector(e);t&&t.setAttribute("disabled","")}else this.windowElement.querySelectorAll(e).forEach(t=>{t.removeAttribute("disabled")})},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(t=>{t.type==="childList"&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},M={title:null,content:null,tabs:[],actions:void 0,draggable:!0};class G{constructor({title:t=M.title,content:i=M.content,tabs:n=M.tabs,actions:s=M.actions,draggable:o=M.draggable,sash:h,binaryWindow:a}){y(this,"domNode"),this.title=t,this.content=i,this.tabs=n,this.actions=s,this.sash=h,this.draggable=o,this.binaryWindow=a,this.build()}build(){const t=document.createElement("bw-glass-header");if(Array.isArray(this.tabs)&&this.tabs.length>0)t.append(this.createTabs());else if(this.title){const s=document.createElement("bw-glass-title");s.append(C(this.title)),t.append(s)}t.setAttribute("can-drag",this.draggable),t.append(this.createActions());const i=document.createElement("bw-glass-content"),n=C(this.content);n&&i.append(n),this.domNode=document.createElement("bw-glass"),this.domNode.append(t,i)}createTabs(){const t=document.createElement("bw-glass-tab-container");for(const i of this.tabs){const n=(i==null?void 0:i.label)??i,s=C(`<button class="bw-glass-tab">${n}</button>`);t.append(s)}return t}createActions(){const t=document.createElement("bw-glass-action-container"),i=this.actions===void 0?B:Array.isArray(this.actions)?this.actions:[];for(const n of i){const s=(n==null?void 0:n.label)??n,o=n.className?`bw-glass-action ${n.className}`:"bw-glass-action",h=C(`<button class="${o}">${s}</button>`);typeof n.onClick=="function"&&h.addEventListener("click",a=>{n.onClick(a,this.binaryWindow)}),t.append(h)}return t}get contentElement(){return this.domNode.querySelector("bw-glass-content")}get headerElement(){return this.domNode.querySelector("bw-glass-header")}}const vt={activeDragGlassEl:null,activeDragGlassPaneCanDrop:!1,onPaneDrop(e,t){if(!this.activeDragGlassEl)return;const i=this.activeDropPaneEl.getAttribute("drop-area");if(i==="center"){const n=this.activeDragGlassEl.closest("bw-pane"),s=this.activeDropPaneEl.getAttribute("can-drop")!=="false";_(n,this.activeDropPaneEl),n.setAttribute("can-drop",s);return}else{const n=H(this.activeDragGlassEl);this.addPane(t.id,{position:i}).domNode.append(this.activeDragGlassEl),this.removePane(n)}},enableDrag(){document.addEventListener("mousedown",e=>{if(e.button!==0||!e.target.matches("bw-glass-header"))return;if(e.target.getAttribute("can-drag")==="false"){e.preventDefault();return}const t=e.target.closest("bw-glass");t.setAttribute("draggable",!0),this.activeDragGlassEl=t}),document.addEventListener("mouseup",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl=null)}),this.windowElement.addEventListener("dragstart",e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches("bw-glass")||!this.activeDragGlassEl)return;e.dataTransfer.effectAllowed="move";const t=this.activeDragGlassEl.closest("bw-pane");this.activeDragGlassPaneCanDrop=t.getAttribute("can-drop")!=="false",t.setAttribute("can-drop",!1)}),this.windowElement.addEventListener("dragend",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop",this.activeDragGlassPaneCanDrop),this.activeDragGlassEl=null)})}},Nt={trimMuntin(e){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`)},onMuntinCreate(e){this.trimMuntin(e)},onMuntinUpdate(e){this.trimMuntin(e)}};class I extends W{constructor(){super(...arguments),y(this,"sillElement",null)}frame(){super.frame(...arguments);const t=C("<bw-sill />");this.windowElement.append(t),this.sillElement=t}enableFeatures(){super.enableFeatures(),this.enableDrag(),this.enableActions()}onPaneCreate(t,i){const n=new G({...i.store,sash:i,binaryWindow:this});t.innerHTML="",t.append(n.domNode),this.debug&&n.contentElement.prepend(`${i.id}`)}onPaneUpdate(){}addGlass(t,i,n){const s=this.addPane(t,{position:i}),o=new G({...n,sash:s,binaryWindow:this});s.domNode.append(o.domNode)}removeGlass(t,i){if(i)this.removePane(t);else{const n=this.rootSash.getById(t);if(!n)throw new Error("[bwin] Pane not found when removing glass");const s=n.domNode.querySelector("bw-glass");s&&s.remove()}}}I.assemble(vt,Nt,Et);const v=4;function zt({sash:e}){var l;const t=p.useRef(),i=e.leftChild,n=e.topChild;let s,o,h,a,d,c;return i?(s=v,o=e.height-v,h=e.top+v/2,a=e.left+i.width-v/2,d=!0):n&&(s=e.width-v,o=v,h=e.top+n.height-v/2,a=e.left+v/2,c=!0),p.useEffect(()=>{e.domNode=t.current},[]),p.createElement("bw-muntin",{"sash-id":e.id,style:{width:s,height:o,top:h,left:a},vertical:d,horizontal:c,resizable:((l=e.store)==null?void 0:l.resizable)===!1?"false":"true",ref:t})}function Ct({sash:e,bwin:t}){var l,u,g,w,m;const i=p.useRef(),{left:n,top:s,width:o,height:h,id:a,position:d}=e;p.useEffect(()=>{e.domNode=i.current},[]);const c=((l=e.store)==null?void 0:l.actions)===void 0?B:Array.isArray(e.store.actions)?e.store.actions:[];return p.createElement("bw-pane",{"sash-id":a,position:d,style:{left:n,top:s,width:o,height:h},"can-drop":((u=e.store)==null?void 0:u.droppable)===!1?"false":"true",ref:i},p.createElement("bw-glass",null,p.createElement("bw-glass-header",{"can-drag":((g=e.store)==null?void 0:g.draggable)===!1?"false":"true"},((w=e.store)==null?void 0:w.title)&&p.createElement("bw-glass-title",null,e.store.title),c.length>0&&p.createElement("bw-glass-action-container",null,c.map((x,At)=>{const Pt=x.className?`bw-glass-action ${x.className}`:"bw-glass-action";return p.createElement("button",{className:Pt,key:At,onClick:xt=>x.onClick(xt,t)},x.label)}))),p.createElement("bw-glass-content",null,(m=e.store)==null?void 0:m.content)))}const St=p.forwardRef((e,t)=>{const i=p.useRef(),n=p.useRef(),{panes:s,...o}=e,h={...o,children:s},a=new I(h),d=[],c=[];return a.rootSash.walk(l=>{l.children.length>0?d.push(l):c.push(l)}),p.useEffect(()=>{const l=i.current;l!=null&&l.parentElement&&(a.windowElement=l,a.containerElement=l.parentElement,a.sillElement=n.current,a.enableFeatures())},[]),p.useImperativeHandle(t,()=>({binaryWindow:a}),[]),p.createElement("bw-window",{"sash-id":a.rootSash.id,style:{width:a.rootSash.width,height:a.rootSash.height},ref:i},c.map(l=>p.createElement(Ct,{key:l.id,sash:l,bwin:a})),d.map(l=>p.createElement(zt,{key:l.id,sash:l})),p.createElement("bw-sill",{ref:n}))}),Mt="0.2.5";b.BUILTIN_ACTIONS=B,b.Window=St,b.version=Mt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
|
8
|
+
`;return t.innerHTML=i.trim(),t}const gt={createWindow(){const e=document.createElement("bw-window");return e.style.width=`${this.rootSash.width}px`,e.style.height=`${this.rootSash.height}px`,e.setAttribute("root-sash-id",this.rootSash.id),e},glaze(){this.rootSash.walk(e=>{let t=null;e.children.length>0?(t=this.createMuntin(e),this.onMuntinCreate(t,e),this.windowElement.append(t)):(t=this.createPane(e),this.onPaneCreate(t,e),this.windowElement.prepend(t)),e.domNode=t})},update(){this.windowElement.style.width=`${this.rootSash.width}px`,this.windowElement.style.height=`${this.rootSash.height}px`;const e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll("[sash-id]").forEach(i=>{const n=i.getAttribute("sash-id");t.push(n),e.includes(n)||i.remove()}),this.rootSash.walk(i=>{i.children.length>0?t.includes(i.id)?(this.updateMuntin(i),this.onMuntinUpdate(i.domNode,i)):(i.domNode=this.createMuntin(i),this.windowElement.append(i.domNode)):t.includes(i.id)?(this.updatePane(i),this.onPaneUpdate(i.domNode,i)):(i.domNode||(i.domNode=this.createPane(i)),this.windowElement.prepend(i.domNode))})}},ft={muntinSize:4,createMuntin(e){const t=document.createElement("bw-muntin"),i=e.leftChild,n=e.topChild;return i?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`,t.setAttribute("vertical","")):n&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`,t.setAttribute("horizontal","")),t.setAttribute("sash-id",e.id),e.store.resizable===!1&&t.setAttribute("resizable","false"),t},onMuntinCreate(e,t){},updateMuntin(e){const t=e.domNode,i=e.leftChild,n=e.topChild;i?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`):n&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},mt={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{for(const t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()}).observe(this.containerElement)}},wt={activeMuntinSash:null,isResizeStarted:!1,isDropStarted:!1,lastX:0,lastY:0,applyResizeStyles(){this.activeMuntinSash.domNode.hasAttribute("vertical")?document.body.classList.add("body--bw-resize-x"):this.activeMuntinSash.domNode.hasAttribute("horizontal")&&document.body.classList.add("body--bw-resize-y")},revertResizeStyles(){document.body.classList.remove("body--bw-resize-x"),document.body.classList.remove("body--bw-resize-y")},enableResize(){document.addEventListener("mousedown",e=>{if(e.target.tagName!=="BW-MUNTIN"||e.target.getAttribute("resizable")==="false")return;const t=e.target.getAttribute("sash-id");this.activeMuntinSash=this.rootSash.getById(t),this.activeMuntinSash&&(this.isResizeStarted=!0,this.lastX=e.pageX,this.lastY=e.pageY,this.applyResizeStyles())}),document.addEventListener("mousemove",e=>{if(!this.isResizeStarted||!this.activeMuntinSash)return;const[t,i,n,s]=this.activeMuntinSash.getChildren(),o=this.activeMuntinSash.isLeftRightSplit(),h=this.activeMuntinSash.isTopBottomSplit();if(o&&s&&i){const a=e.pageX-this.lastX,d=s.width+a,l=i.width-a;if(d<=s.calcMinWidth()||l<=i.calcMinWidth())return;s.width=d,i.width=l,i.left=i.left+a,this.update(),this.lastX=e.pageX}else if(h&&t&&n){const a=e.pageY-this.lastY,d=t.height+a,l=n.height-a;if(d<=t.calcMinHeight()||l<=n.calcMinHeight())return;t.height=d,n.height=l,n.top=n.top+a,this.update(),this.lastY=e.pageY}}),document.addEventListener("mouseup",()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},bt={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener("dragover",e=>{e.preventDefault();const t=e.target.matches("bw-pane")?e.target:e.target.closest("bw-pane");if(!t||(t!==this.activeDropPaneEl&&(this.activeDropPaneEl&&this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=t),t.getAttribute("can-drop")==="false"))return;const i=it(t,e);t.setAttribute("drop-area",i)}),this.windowElement.addEventListener("dragleave",e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||this.activeDropPaneEl&&(this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null)}),this.windowElement.addEventListener("drop",e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute("can-drop")==="false")return;const t=this.activeDropPaneEl.getAttribute("sash-id"),i=this.rootSash.getById(t);this.onPaneDrop(e,i),typeof i.store.onDrop=="function"&&i.store.onDrop(e,i),this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null})}},yt=!1;class G{constructor(t){E(this,"windowElement",null),E(this,"containerElement",null),E(this,"debug",yt);let i=null;t instanceof ht?(i=t,this.rootSash=t):(i=new ot(t),this.rootSash=i.buildSashTree()),this.fitContainer=i.fitContainer}frame(t){this.containerElement=t,this.windowElement=this.createWindow(),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(t){this.frame(t),this.enableFeatures()}static assemble(...t){t.forEach(i=>{K(this.prototype,i)})}}G.assemble(gt,ft,pt,mt,bt,wt);function I(e){if(e.tagName==="BW-PANE")return e.getAttribute("sash-id");const t=e.closest("bw-pane");if(!t)throw new Error("[bwin] Pane element not found");return t.getAttribute("sash-id")}const Et={label:"",className:"bw-glass-action--close",onClick:(e,t)=>{const i=I(e.target);t.removePane(i)}},vt={label:"",className:"bw-glass-action--minimize",onClick:(e,t)=>{const i=t.sillElement;if(!i)throw new Error("[bwin] Sill element not found when minimizing");const n=S('<button class="bw-minimized-glass" />');i.append(n);const s=e.target.closest("bw-pane"),o=e.target.closest("bw-glass"),h=s.getAttribute("sash-id"),a=s.getAttribute("position");n.bwGlassElement=o,n.bwOriginalPosition=a,n.bwOriginalBoundingRect=P(s),t.removePane(h)}},Nt={label:"",className:"bw-glass-action--maximize",onClick:e=>{const t=e.target.closest("bw-pane");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=P(t),t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%")}};function zt(e,t){const i=e.left+e.width,n=e.top+e.height,s=t.left+t.width,o=t.top+t.height;if(e.left>=s||t.left>=i||e.top>=o||t.top>=n)return null;const h=Math.max(e.left,t.left),a=Math.max(e.top,t.top),d=Math.min(i,s),l=Math.min(n,o);return{left:h,top:a,width:d-h,height:l-a}}const L=[vt,Nt,Et],Ct={enableActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){const t=e.bwOriginalBoundingRect;let i=0,n=null;if(this.windowElement.querySelectorAll("bw-pane").forEach(s=>{const o=P(s),h=zt(t,o);if(h){const a=h.width*h.height;a>i&&(i=a,n=s)}}),n){const s=e.bwOriginalPosition,o=P(n);let h=0;if(s===r.Left||s===r.Right)h=t.width>=o.width?o.width/2:t.width;else if(s===r.Top||s===r.Bottom)h=t.height>=o.height?o.height/2:t.height;else throw new Error("[bwin] Invalid position when restoring glass");this.addPane(n.getAttribute("sash-id"),{position:s,size:h}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener("click",e=>{if(!e.target.matches(".bw-minimized-glass"))return;const t=e.target;this.restoreGlass(t),t.remove()})},updateDisabledStateOfActionButtons(){this.updateDisabledState(".bw-glass-action--close"),this.updateDisabledState(".bw-glass-action--minimize"),this.updateDisabledState(".bw-glass-action--maximize")},updateDisabledState(e){if(this.windowElement.querySelectorAll("bw-pane").length===1){const t=this.windowElement.querySelector(e);t&&t.setAttribute("disabled","")}else this.windowElement.querySelectorAll(e).forEach(t=>{t.removeAttribute("disabled")})},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(t=>{t.type==="childList"&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},A={title:null,content:null,tabs:[],actions:void 0,draggable:!0};class k{constructor({title:t=A.title,content:i=A.content,tabs:n=A.tabs,actions:s=A.actions,draggable:o=A.draggable,sash:h,binaryWindow:a}){E(this,"domNode"),this.title=t,this.content=i,this.tabs=n,this.actions=s,this.sash=h,this.draggable=o,this.binaryWindow=a,this.build()}build(){const t=document.createElement("bw-glass-header");if(Array.isArray(this.tabs)&&this.tabs.length>0)t.append(this.createTabs());else if(this.title){const s=document.createElement("bw-glass-title");s.append(S(this.title)),t.append(s)}t.setAttribute("can-drag",this.draggable),t.append(this.createActions());const i=document.createElement("bw-glass-content"),n=S(this.content);n&&i.append(n),this.domNode=document.createElement("bw-glass"),this.domNode.append(t,i)}createTabs(){const t=document.createElement("bw-glass-tab-container");for(const i of this.tabs){const n=(i==null?void 0:i.label)??i,s=S(`<button class="bw-glass-tab">${n}</button>`);t.append(s)}return t}createActions(){const t=document.createElement("bw-glass-action-container"),i=this.actions===void 0?L:Array.isArray(this.actions)?this.actions:[];for(const n of i){const s=(n==null?void 0:n.label)??n,o=n.className?`bw-glass-action ${n.className}`:"bw-glass-action",h=S(`<button class="${o}">${s}</button>`);typeof n.onClick=="function"&&h.addEventListener("click",a=>{n.onClick(a,this.binaryWindow)}),t.append(h)}return t}get contentElement(){return this.domNode.querySelector("bw-glass-content")}get headerElement(){return this.domNode.querySelector("bw-glass-header")}}const St={activeDragGlassEl:null,activeDragGlassPaneCanDrop:!1,onPaneDrop(e,t){if(!this.activeDragGlassEl)return;const i=this.activeDropPaneEl.getAttribute("drop-area");if(i==="center"){const n=this.activeDragGlassEl.closest("bw-pane"),s=this.activeDropPaneEl.getAttribute("can-drop")!=="false";X(n,this.activeDropPaneEl),n.setAttribute("can-drop",s);return}else{const n=I(this.activeDragGlassEl);this.addPane(t.id,{position:i}).domNode.append(this.activeDragGlassEl),this.removePane(n)}},enableDrag(){document.addEventListener("mousedown",e=>{if(e.button!==0||!e.target.matches("bw-glass-header"))return;if(e.target.getAttribute("can-drag")==="false"){e.preventDefault();return}const t=e.target.closest("bw-glass");t.setAttribute("draggable",!0),this.activeDragGlassEl=t}),document.addEventListener("mouseup",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl=null)}),this.windowElement.addEventListener("dragstart",e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches("bw-glass")||!this.activeDragGlassEl)return;e.dataTransfer.effectAllowed="move";const t=this.activeDragGlassEl.closest("bw-pane");this.activeDragGlassPaneCanDrop=t.getAttribute("can-drop")!=="false",t.setAttribute("can-drop",!1)}),this.windowElement.addEventListener("dragend",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop",this.activeDragGlassPaneCanDrop),this.activeDragGlassEl=null)})}},Mt={trimMuntin(e){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`)},onMuntinCreate(e){this.trimMuntin(e)},onMuntinUpdate(e){this.trimMuntin(e)}};class F extends G{constructor(){super(...arguments),E(this,"sillElement",null)}frame(){super.frame(...arguments);const t=S("<bw-sill />");this.windowElement.append(t),this.sillElement=t}enableFeatures(){super.enableFeatures(),this.enableDrag(),this.enableActions()}onPaneCreate(t,i){const n=new k({...i.store,sash:i,binaryWindow:this});t.innerHTML="",t.append(n.domNode),this.debug&&n.contentElement.prepend(`${i.id}`)}onPaneUpdate(){}addPane(t,i){const{position:n,size:s,...o}=i,h=super.addPane(t,{position:n,size:s}),a=new k({...o,sash:h,binaryWindow:this});return h.domNode.append(a.domNode),h}}F.assemble(St,Mt,Ct);const N=4;function At({sash:e}){var c;const t=u.useRef(),i=e.leftChild,n=e.topChild;let s,o,h,a,d,l;return i?(s=N,o=e.height-N,h=e.top+N/2,a=e.left+i.width-N/2,d=!0):n&&(s=e.width-N,o=N,h=e.top+n.height-N/2,a=e.left+N/2,l=!0),u.useEffect(()=>{e.domNode=t.current},[]),u.createElement("bw-muntin",{"sash-id":e.id,style:{width:s,height:o,top:h,left:a},vertical:d,horizontal:l,resizable:((c=e.store)==null?void 0:c.resizable)===!1?"false":"true",ref:t})}function Pt({sash:e,bwin:t}){var c,g,f,m,w;const i=u.useRef(),{left:n,top:s,width:o,height:h,id:a,position:d}=e;u.useEffect(()=>{e.domNode=i.current},[]);const l=((c=e.store)==null?void 0:c.actions)===void 0?L:Array.isArray(e.store.actions)?e.store.actions:[];return u.createElement("bw-pane",{"sash-id":a,position:d,style:{left:n,top:s,width:o,height:h},"can-drop":((g=e.store)==null?void 0:g.droppable)===!1?"false":"true",ref:i},u.createElement("bw-glass",null,u.createElement("bw-glass-header",{"can-drag":((f=e.store)==null?void 0:f.draggable)===!1?"false":"true"},((m=e.store)==null?void 0:m.title)&&u.createElement("bw-glass-title",null,e.store.title),l.length>0&&u.createElement("bw-glass-action-container",null,l.map((p,B)=>{const T=p.className?`bw-glass-action ${p.className}`:"bw-glass-action";return u.createElement("button",{className:T,key:B,onClick:W=>p.onClick(W,t)},p.label)}))),u.createElement("bw-glass-content",null,(w=e.store)==null?void 0:w.content)))}const Dt=u.forwardRef((e,t)=>{const i=u.useRef(),n=u.useRef(),[s,o]=u.useState(),{panes:h,...a}=e,d={...a,children:h},l=new F(d),c=[],g=[];l.rootSash.walk(p=>{p.children.length>0?c.push(p):g.push(p)}),u.useEffect(()=>{const p=i.current;p!=null&&p.parentElement&&(l.windowElement=p,l.containerElement=p.parentElement,l.sillElement=n.current,l.enableFeatures())},[]),u.useImperativeHandle(t,()=>({fit:l.fit.bind(l),removePane:l.removePane.bind(l),addPane:w}),[]);const f=u.createElement("bw-window",{"root-sash-id":l.rootSash.id,style:{width:l.rootSash.width,height:l.rootSash.height},ref:i},g.map(p=>u.createElement(Pt,{key:p.id,sash:p,bwin:l})),c.map(p=>u.createElement(At,{key:p.id,sash:p})),u.createElement("bw-sill",{ref:n})),m=u.useMemo(()=>f,[]);function w(p,B){const{content:T,...W}=B,Rt=l.addPane(p,W),$t=document.querySelector(`bw-pane[sash-id="${Rt.id}"] bw-glass-content`);o(Lt=>[...Lt||[],{node:T,container:$t}])}return u.createElement(u.Fragment,null,m,s==null?void 0:s.map(p=>_.createPortal(p.node,p.container)))}),xt="0.3.0";b.BUILTIN_ACTIONS=L,b.Window=Dt,b.version=xt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
2
|
+
"name": "react-bwin",
|
|
3
|
+
"description": "A tiling window manager in React based on Binary Window library",
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/bhjsdev/react-bwin.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"react",
|
|
12
|
+
"drag",
|
|
13
|
+
"drop",
|
|
14
|
+
"resize",
|
|
15
|
+
"window-manager",
|
|
16
|
+
"tiling-window-manager"
|
|
17
|
+
],
|
|
18
|
+
"author": "Bhjs Dev <bhjsdev@gmail.com>",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bugs": "https://github.com/bhjsdev/react-bwin/issues",
|
|
21
|
+
"homepage": "https://github.com/bhjsdev/react-bwin#readme",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"main": "./dist/react-bwin.js",
|
|
26
|
+
"module": "./dist/react-bwin.js",
|
|
27
|
+
"types": "./dist/react-bwin.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/react-bwin.d.ts",
|
|
31
|
+
"import": "./dist/react-bwin.js"
|
|
32
|
+
},
|
|
33
|
+
"./react-bwin.css": "./dist/react-bwin.css"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "vite",
|
|
37
|
+
"build": "tsc -b && vite build"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": ">=16.8.0",
|
|
41
|
+
"react-dom": ">=16.8.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.10.1",
|
|
45
|
+
"@types/react": "^16.14.62",
|
|
46
|
+
"@types/react-dom": "^16.9.24",
|
|
47
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
48
|
+
"bwin": "0.2.0",
|
|
49
|
+
"prettier": "^3.4.1",
|
|
50
|
+
"react": "^16.14.0",
|
|
51
|
+
"react-dom": "^16.14.0",
|
|
52
|
+
"react-router-dom": "6.27.0",
|
|
53
|
+
"typescript": "^5.6.2",
|
|
54
|
+
"vite": "^6.0.1",
|
|
55
|
+
"zustand": "^4.5.5"
|
|
56
|
+
}
|
|
56
57
|
}
|