bwin 0.1.1 → 0.1.3

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 +444 -357
  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-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%, 100%);--bw-glass-header-height: 30px;--bw-glass-header-gap: 4px;--bw-glass-header-bg-color: hsl(0, 0%, 97%)}.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{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:.3}bw-glass-header{white-space:nowrap;box-sizing:border-box;display:flex;align-items:center;gap:var(--bw-glass-header-gap);padding-inline:var(--bw-glass-header-gap);flex-basis:var(--bw-glass-header-height);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-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;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--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 D(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") {
@@ -61,23 +61,27 @@ function O(e, t) {
61
61
  }
62
62
  return e;
63
63
  }
64
- function F(e) {
64
+ 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")
72
72
  try {
73
- const t = F(e);
73
+ const t = G(e);
74
74
  return t.childNodes.length === 1 ? t.firstChild : t;
75
75
  } catch {
76
76
  return document.createTextNode(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,16 +91,16 @@ const h = {
87
91
  Unknown: "unknown",
88
92
  Outside: "outside"
89
93
  };
90
- function G(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
  }
@@ -104,47 +108,47 @@ function G(e) {
104
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 a = 0.3, c = _({ width: o, height: s, x: r }), d = 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 - a / 2) && l > c && l < d ? h.Left : r > o * (0.5 + a / 2) && l < c && l > d ? h.Right : l < s * (0.5 - a / 2) && r > f && r < u ? h.Top : l > s * (0.5 + a / 2) && r < f && r > u ? h.Bottom : r > o * (0.5 - a / 2) && r < o * (0.5 + a / 2) && l > s * (0.5 - a / 2) && l < s * (0.5 + a / 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: 50,
130
- minHeight: 50
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
145
  store: a = {},
142
146
  position: c,
143
147
  id: d
144
148
  } = w) {
145
- if (this.id = d ?? D(), !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 = a;
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, a = i * (r.width / l), c = l + i;
282
- let d = r.width + a, f = c - d, u = o.left + a;
283
- const m = r.calcMinWidth(), b = o.calcMinWidth();
284
- d < m && f > b ? (d = m, f = c - d, u = r.left + d) : f < b && d > m && (f = b, d = c - f, u = r.left + d), r.width = d, 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, a = i * (n.height / l), c = l + i;
297
- let d = n.height + a, f = c - d, u = s.top + a;
298
- const m = n.calcMinHeight(), b = s.calcMinHeight();
299
- d < m && f > b ? (d = m, f = c - d, u = n.top + d) : f < b && d > m && (f = b, d = c - f, u = n.top + d), n.height = d, 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
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(a), 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 = G(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 }, a) {
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
431
  siblingConfigNode: a,
428
- id: o,
429
- minWidth: s,
430
- minHeight: r,
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
- }, R = {
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 = R.fitContainer,
462
- ...r
463
+ width: n = A.width,
464
+ height: s = A.height,
465
+ fitContainer: o = D.fitContainer,
466
+ ...h
463
467
  } = {
464
- ...v,
465
- ...R
468
+ ...A,
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, R);
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 = D(), 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
@@ -518,117 +616,31 @@ const K = {
518
616
  const t = this.rootSash.getDescendantParentById(e);
519
617
  if (!t) throw new Error("[bwin] Parent sash not found when removing pane");
520
618
  const i = t.getChildSiblingById(e);
521
- 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 === 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 = {
635
+ const st = {
624
636
  createWindow() {
625
637
  const e = document.createElement("bw-window");
626
638
  return e.style.width = `${this.rootSash.width}px`, e.style.height = `${this.rootSash.height}px`, e.setAttribute("sash-id", this.rootSash.id), e;
627
639
  },
628
- glaze(e) {
629
- this.rootSash.walk((t) => {
630
- let i = null;
631
- 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;
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;
632
644
  });
633
645
  },
634
646
  update() {
@@ -641,7 +653,7 @@ const it = {
641
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));
642
654
  });
643
655
  }
644
- }, nt = {
656
+ }, ot = {
645
657
  muntinSize: 4,
646
658
  createMuntin(e) {
647
659
  const t = document.createElement("bw-muntin"), i = e.leftChild, n = e.topChild;
@@ -655,7 +667,7 @@ const it = {
655
667
  },
656
668
  onMuntinUpdate(e, t) {
657
669
  }
658
- }, ot = {
670
+ }, ht = {
659
671
  fitContainer: !1,
660
672
  enableFitContainer() {
661
673
  new ResizeObserver((t) => {
@@ -663,7 +675,7 @@ const it = {
663
675
  i.target === this.containerElement && this.fitContainer && (this.rootSash.width = i.contentRect.width, this.rootSash.height = i.contentRect.height, this.update());
664
676
  }).observe(this.containerElement);
665
677
  }
666
- }, st = {
678
+ }, rt = {
667
679
  activeMuntinSash: null,
668
680
  isResizeStarted: !1,
669
681
  isDropStarted: !1,
@@ -682,13 +694,13 @@ const it = {
682
694
  this.activeMuntinSash = this.rootSash.getById(t), this.activeMuntinSash && (this.isResizeStarted = !0, this.lastX = e.pageX, this.lastY = e.pageY, this.applyResizeStyles());
683
695
  }), document.addEventListener("mousemove", (e) => {
684
696
  if (!this.isResizeStarted || !this.activeMuntinSash) return;
685
- const [t, i, n, o] = this.activeMuntinSash.getChildren(), s = this.activeMuntinSash.isLeftRightSplit(), r = this.activeMuntinSash.isTopBottomSplit();
686
- if (s && o && i) {
687
- const l = e.pageX - this.lastX, a = o.width + l, c = i.width - l;
688
- if (a <= 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())
689
701
  return;
690
- o.width = a, i.width = c, i.left = i.left + l, this.update(), this.lastX = e.pageX;
691
- } else if (r && t && n) {
702
+ s.width = a, i.width = c, i.left = i.left + l, this.update(), this.lastX = e.pageX;
703
+ } else if (h && t && n) {
692
704
  const l = e.pageY - this.lastY, a = t.height + l, c = n.height - l;
693
705
  if (a <= t.calcMinHeight() || c <= n.calcMinHeight())
694
706
  return;
@@ -698,7 +710,7 @@ const it = {
698
710
  this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
699
711
  });
700
712
  }
701
- }, ht = {
713
+ }, lt = {
702
714
  activeDropPaneEl: null,
703
715
  // Intended to be overridden in `BinaryWindow` class
704
716
  onPaneDrop(e, t) {
@@ -708,7 +720,7 @@ const it = {
708
720
  e.preventDefault();
709
721
  const t = e.target.matches("bw-pane") ? e.target : e.target.closest("bw-pane");
710
722
  if (!t || (t !== this.activeDropPaneEl && (this.activeDropPaneEl && this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = t), t.getAttribute("can-drop") === "false")) return;
711
- const i = k(t, e);
723
+ const i = X(t, e);
712
724
  t.setAttribute("drop-area", i);
713
725
  }), this.windowElement.addEventListener("dragleave", (e) => {
714
726
  e.currentTarget.contains(e.relatedTarget) && e.currentTarget !== e.relatedTarget || this.activeDropPaneEl && (this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null);
@@ -718,22 +730,24 @@ const it = {
718
730
  this.onPaneDrop(e, i), typeof i.store.onDrop == "function" && i.store.onDrop(e, i), this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null;
719
731
  });
720
732
  }
721
- };
722
- class L {
733
+ }, at = !1;
734
+ class T {
723
735
  constructor(t) {
724
- p(this, "windowElement", null);
725
- p(this, "containerElement", null);
726
- p(this, "debug", !1);
736
+ f(this, "windowElement", null);
737
+ f(this, "containerElement", null);
738
+ f(this, "debug", at);
727
739
  let i = null;
728
- 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;
741
+ }
742
+ frame(t) {
743
+ this.containerElement = t, this.windowElement = this.createWindow(), this.glaze(), this.containerElement.append(this.windowElement);
729
744
  }
730
745
  // Features can work independently to each other
731
746
  enableFeatures() {
732
747
  this.enableResize(), this.enableDrop(), this.fitContainer && this.enableFitContainer();
733
748
  }
734
749
  mount(t) {
735
- const i = this.createWindow();
736
- this.glaze(i), this.containerElement = t, this.containerElement.append(i), this.windowElement = i, this.enableFeatures();
750
+ this.frame(t), this.enableFeatures();
737
751
  }
738
752
  static assemble(...t) {
739
753
  t.forEach((i) => {
@@ -741,15 +755,15 @@ class L {
741
755
  });
742
756
  }
743
757
  }
744
- L.assemble(
745
- it,
746
- nt,
747
- K,
758
+ T.assemble(
759
+ st,
748
760
  ot,
761
+ nt,
749
762
  ht,
750
- st
763
+ lt,
764
+ rt
751
765
  );
752
- function T(e) {
766
+ function L(e) {
753
767
  if (e.tagName === "BW-PANE")
754
768
  return e.getAttribute("sash-id");
755
769
  const t = e.closest("bw-pane");
@@ -757,62 +771,147 @@ function T(e) {
757
771
  throw new Error("[bwin] Pane element not found");
758
772
  return t.getAttribute("sash-id");
759
773
  }
760
- const x = "bw-glass-action--close", rt = [
761
- {
762
- label: "",
763
- className: x,
764
- onClick: (e, t) => {
765
- const i = T(e.target);
766
- t.removePane(i);
774
+ const dt = {
775
+ label: "",
776
+ className: "bw-glass-action--close",
777
+ onClick: (e, t) => {
778
+ const i = L(e.target);
779
+ t.removePane(i);
780
+ }
781
+ }, ct = {
782
+ label: "",
783
+ className: "bw-glass-action--minimize",
784
+ onClick: (e, t) => {
785
+ const i = t.sillElement;
786
+ if (!i) throw new Error("[bwin] Sill element not found when minimizing");
787
+ const n = C('<button class="bw-minimized-glass" />');
788
+ i.append(n);
789
+ const s = e.target.closest("bw-pane"), o = e.target.closest("bw-glass"), h = s.getAttribute("sash-id"), l = s.getAttribute("position");
790
+ n.bwGlassElement = o, n.bwOriginalPosition = l, n.bwOriginalBoundingRect = P(s), t.removePane(h);
791
+ }
792
+ }, gt = {
793
+ label: "",
794
+ className: "bw-glass-action--maximize",
795
+ onClick: (e) => {
796
+ const t = e.target.closest("bw-pane");
797
+ 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%");
798
+ }
799
+ };
800
+ function ut(e, t) {
801
+ const i = e.left + e.width, n = e.top + e.height, s = t.left + t.width, o = t.top + t.height;
802
+ if (e.left >= s || t.left >= i || e.top >= o || t.top >= n)
803
+ return null;
804
+ 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);
805
+ return {
806
+ left: h,
807
+ top: l,
808
+ width: a - h,
809
+ height: c - l
810
+ };
811
+ }
812
+ const ft = [ct, gt, dt], pt = {
813
+ enableActions() {
814
+ this.handleMinimizedGlassClick(), this.observeActionButtons();
815
+ },
816
+ restoreGlass(e) {
817
+ const t = e.bwOriginalBoundingRect;
818
+ let i = 0, n = null;
819
+ if (this.windowElement.querySelectorAll("bw-pane").forEach((s) => {
820
+ const o = P(s), h = ut(t, o);
821
+ if (h) {
822
+ const l = h.width * h.height;
823
+ l > i && (i = l, n = s);
824
+ }
825
+ }), n) {
826
+ const s = e.bwOriginalPosition, o = P(n);
827
+ let h = 0;
828
+ if (s === r.Left || s === r.Right)
829
+ h = t.width >= o.width ? o.width / 2 : t.width;
830
+ else if (s === r.Top || s === r.Bottom)
831
+ h = t.height >= o.height ? o.height / 2 : t.height;
832
+ else
833
+ throw new Error("[bwin] Invalid position when restoring glass");
834
+ this.addPane(n.getAttribute("sash-id"), {
835
+ position: s,
836
+ size: h
837
+ }).domNode.append(e.bwGlassElement);
767
838
  }
839
+ },
840
+ handleMinimizedGlassClick() {
841
+ this.sillElement.addEventListener("click", (e) => {
842
+ if (!e.target.matches(".bw-minimized-glass")) return;
843
+ const t = e.target;
844
+ this.restoreGlass(t), t.remove();
845
+ });
846
+ },
847
+ updateDisabledStateOfActionButtons() {
848
+ this.updateDisabledState(".bw-glass-action--close"), this.updateDisabledState(".bw-glass-action--minimize"), this.updateDisabledState(".bw-glass-action--maximize");
849
+ },
850
+ updateDisabledState(e) {
851
+ if (this.windowElement.querySelectorAll("bw-pane").length === 1) {
852
+ const i = this.windowElement.querySelector(e);
853
+ i && i.setAttribute("disabled", "");
854
+ } else
855
+ this.windowElement.querySelectorAll(e).forEach((i) => {
856
+ i.removeAttribute("disabled");
857
+ });
858
+ },
859
+ observeActionButtons() {
860
+ this.updateDisabledStateOfActionButtons(), new MutationObserver((t) => {
861
+ t.forEach((i) => {
862
+ i.type === "childList" && this.updateDisabledStateOfActionButtons();
863
+ });
864
+ }).observe(this.windowElement, {
865
+ childList: !0
866
+ });
768
867
  }
769
- ], y = {
868
+ }, N = {
770
869
  title: null,
771
870
  content: null,
772
871
  tabs: [],
773
872
  actions: void 0,
774
873
  draggable: !0
775
874
  };
776
- class z {
875
+ class x {
777
876
  constructor({
778
- title: t = y.title,
779
- content: i = y.content,
780
- tabs: n = y.tabs,
781
- actions: o = y.actions,
782
- draggable: s = y.draggable,
783
- sash: r,
877
+ title: t = N.title,
878
+ content: i = N.content,
879
+ tabs: n = N.tabs,
880
+ actions: s = N.actions,
881
+ draggable: o = N.draggable,
882
+ sash: h,
784
883
  binaryWindow: l
785
884
  }) {
786
- p(this, "domNode");
787
- this.title = t, this.content = i, this.tabs = n, this.actions = o, this.sash = r, this.draggable = s, this.binaryWindow = l, this.build();
885
+ f(this, "domNode");
886
+ this.title = t, this.content = i, this.tabs = n, this.actions = s, this.sash = h, this.draggable = o, this.binaryWindow = l, this.build();
788
887
  }
789
888
  build() {
790
889
  const t = document.createElement("bw-glass-header");
791
890
  if (Array.isArray(this.tabs) && this.tabs.length > 0)
792
891
  t.append(this.createTabs());
793
892
  else if (this.title) {
794
- const o = document.createElement("bw-glass-title");
795
- o.append(E(this.title)), t.append(o);
893
+ const s = document.createElement("bw-glass-title");
894
+ s.append(C(this.title)), t.append(s);
796
895
  }
797
896
  t.setAttribute("can-drag", this.draggable), t.append(this.createActions());
798
- const i = document.createElement("bw-glass-content"), n = E(this.content);
897
+ const i = document.createElement("bw-glass-content"), n = C(this.content);
799
898
  n && i.append(n), this.domNode = document.createElement("bw-glass"), this.domNode.append(t, i);
800
899
  }
801
900
  createTabs() {
802
901
  const t = document.createElement("bw-glass-tab-container");
803
902
  for (const i of this.tabs) {
804
- const n = (i == null ? void 0 : i.label) ?? i, o = E(`<button class="bw-glass-tab">${n}</button>`);
805
- t.append(o);
903
+ const n = (i == null ? void 0 : i.label) ?? i, s = C(`<button class="bw-glass-tab">${n}</button>`);
904
+ t.append(s);
806
905
  }
807
906
  return t;
808
907
  }
809
908
  createActions() {
810
- const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ? rt : Array.isArray(this.actions) ? this.actions : [];
909
+ const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ? ft : Array.isArray(this.actions) ? this.actions : [];
811
910
  for (const n of i) {
812
- 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>`);
813
- typeof n.onClick == "function" && r.addEventListener("click", (l) => {
911
+ 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>`);
912
+ typeof n.onClick == "function" && h.addEventListener("click", (l) => {
814
913
  n.onClick(l, this.binaryWindow);
815
- }), t.append(r);
914
+ }), t.append(h);
816
915
  }
817
916
  return t;
818
917
  }
@@ -823,40 +922,19 @@ class z {
823
922
  return this.domNode.querySelector("bw-glass-header");
824
923
  }
825
924
  }
826
- const lt = {
827
- enableObservers() {
828
- this.observeCloseButtons();
829
- },
830
- observeCloseButtons() {
831
- const e = `.${x}`;
832
- new MutationObserver((i) => {
833
- i.forEach((n) => {
834
- if (n.type === "childList")
835
- if (this.windowElement.querySelectorAll("bw-pane").length === 1) {
836
- const s = this.windowElement.querySelector(e);
837
- s && s.setAttribute("disabled", "");
838
- } else
839
- this.windowElement.querySelectorAll(e).forEach((s) => {
840
- s.removeAttribute("disabled");
841
- });
842
- });
843
- }).observe(this.windowElement, {
844
- childList: !0
845
- });
846
- }
847
- }, at = {
925
+ const wt = {
848
926
  activeDragGlassEl: null,
849
927
  activeDragGlassPaneCanDrop: !1,
850
928
  onPaneDrop(e, t) {
851
929
  if (!this.activeDragGlassEl) return;
852
930
  const i = this.activeDropPaneEl.getAttribute("drop-area");
853
931
  if (i === "center") {
854
- const n = this.activeDragGlassEl.closest("bw-pane"), o = this.activeDropPaneEl.getAttribute("can-drop") !== "false";
855
- H(n, this.activeDropPaneEl), n.setAttribute("can-drop", o);
932
+ const n = this.activeDragGlassEl.closest("bw-pane"), s = this.activeDropPaneEl.getAttribute("can-drop") !== "false";
933
+ H(n, this.activeDropPaneEl), n.setAttribute("can-drop", s);
856
934
  return;
857
935
  } else {
858
- const n = T(this.activeDragGlassEl);
859
- this.addPane(t.id, i).domNode.append(this.activeDragGlassEl), this.removePane(n);
936
+ const n = L(this.activeDragGlassEl);
937
+ this.addPane(t.id, { position: i }).domNode.append(this.activeDragGlassEl), this.removePane(n);
860
938
  }
861
939
  },
862
940
  enableDrag() {
@@ -880,7 +958,7 @@ const lt = {
880
958
  this.activeDragGlassEl && (this.activeDragGlassEl.removeAttribute("draggable"), this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop", this.activeDragGlassPaneCanDrop), this.activeDragGlassEl = null);
881
959
  });
882
960
  }
883
- }, dt = {
961
+ }, mt = {
884
962
  trimMuntin(e) {
885
963
  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`);
886
964
  },
@@ -891,13 +969,22 @@ const lt = {
891
969
  this.trimMuntin(e);
892
970
  }
893
971
  };
894
- class ct extends L {
972
+ class bt extends T {
973
+ constructor() {
974
+ super(...arguments);
975
+ f(this, "sillElement", null);
976
+ }
977
+ frame() {
978
+ super.frame(...arguments);
979
+ const i = C("<bw-sill />");
980
+ this.windowElement.append(i), this.sillElement = i;
981
+ }
895
982
  enableFeatures() {
896
- super.enableFeatures(), this.enableObservers(), this.enableDrag();
983
+ super.enableFeatures(), this.enableDrag(), this.enableActions();
897
984
  }
898
- onPaneCreate(t, i) {
899
- const n = new z({ ...i.store, sash: i, binaryWindow: this });
900
- t.innerHTML = "", t.append(n.domNode), this.debug && n.contentElement.prepend(`${i.id}`);
985
+ onPaneCreate(i, n) {
986
+ const s = new x({ ...n.store, sash: n, binaryWindow: this });
987
+ i.innerHTML = "", i.append(s.domNode), this.debug && s.contentElement.prepend(`${n.id}`);
901
988
  }
902
989
  onPaneUpdate() {
903
990
  }
@@ -909,9 +996,9 @@ class ct extends L {
909
996
  * @param {Object} glassProps - The glass properties
910
997
  *
911
998
  */
912
- addGlass(t, i, n) {
913
- const o = this.addPane(t, i), s = new z({ ...n, sash: o, binaryWindow: this });
914
- o.domNode.append(s.domNode);
999
+ addGlass(i, n, s) {
1000
+ const o = this.addPane(i, { position: n }), h = new x({ ...s, sash: o, binaryWindow: this });
1001
+ o.domNode.append(h.domNode);
915
1002
  }
916
1003
  /**
917
1004
  * Remove glass from or together with the pane
@@ -919,24 +1006,24 @@ class ct extends L {
919
1006
  * @param {string} paneSashId - The Sash ID of the pane that contains the glass
920
1007
  * @param {boolean} removePane - Whether to remove the pane together
921
1008
  */
922
- removeGlass(t, i) {
923
- if (i)
924
- this.removePane(t);
1009
+ removeGlass(i, n) {
1010
+ if (n)
1011
+ this.removePane(i);
925
1012
  else {
926
- const n = this.rootSash.getById(t);
927
- if (!n) throw new Error("[bwin] Pane not found when removing glass");
928
- const o = n.domNode.querySelector("bw-glass");
1013
+ const s = this.rootSash.getById(i);
1014
+ if (!s) throw new Error("[bwin] Pane not found when removing glass");
1015
+ const o = s.domNode.querySelector("bw-glass");
929
1016
  o && o.remove();
930
1017
  }
931
1018
  }
932
1019
  }
933
- ct.assemble(lt, at, dt);
1020
+ bt.assemble(wt, mt, pt);
934
1021
  export {
935
- rt as BUILTIN_ACTIONS,
936
- ct as BinaryWindow,
937
- q as ConfigRoot,
938
- L as Frame,
939
- h as Position,
940
- g as Sash,
941
- j as SashConfig
1022
+ ft as BUILTIN_ACTIONS,
1023
+ bt as BinaryWindow,
1024
+ K as ConfigRoot,
1025
+ T as Frame,
1026
+ r as Position,
1027
+ p as Sash,
1028
+ V as SashConfig
942
1029
  };
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.1",
5
+ "version": "0.1.3",
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
  }