bwin 0.1.0 → 0.1.2

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