perfect-gui 5.0.1 → 5.0.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.
@@ -11,7 +11,7 @@ class $ {
11
11
  }), typeof e.color == "string" && (i.style.setProperty("--color-accent", e.color), i.style.setProperty(
12
12
  "--color-accent-hover",
13
13
  e.hoverColor || e.color
14
- )), this.parent.wrapper.append(i);
14
+ )), this.parent.wrapper.append(i), this.element = i;
15
15
  }
16
16
  onClick(t) {
17
17
  return this.callback = t, this;
@@ -20,23 +20,23 @@ class $ {
20
20
  class Y {
21
21
  constructor(t, e, r, c) {
22
22
  this.parent = t, this.propReferences = [];
23
- let i = {}, a = null;
23
+ let i = {}, l = null;
24
24
  if (e && typeof e == "object" && typeof r == "string")
25
25
  this.obj = e, this.prop = r, this.isObject = !0, i = c || {}, this.callback = null;
26
26
  else if (e && typeof e == "object")
27
- this.isObject = !1, i = e, a = typeof i.value == "number" ? i.value : null;
27
+ this.isObject = !1, i = e, l = typeof i.value == "number" ? i.value : null;
28
28
  else
29
29
  throw Error("[GUI] slider() invalid parameters.");
30
30
  let s = typeof i.label == "string" && i.label || " ";
31
31
  this.isObject && s == " " && (s = this.prop), this.min = i.min ?? 0, this.max = i.max ?? 1, this.step = i.step || (this.max - this.min) / 100, this.decimals = this.parent._countDecimals(this.step);
32
32
  let o = null;
33
- this.isObject ? o = this.propReferences.push(this.obj[this.prop]) - 1 : a === null && (a = (this.max - this.min) / 2);
34
- const n = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? s : null, l = document.createElement("div");
35
- l.className = "p-gui__slider", n && l.setAttribute("title", n), this.parent.wrapper.append(l);
33
+ this.isObject ? o = this.propReferences.push(this.obj[this.prop]) - 1 : l === null && (l = (this.max - this.min) / 2);
34
+ const n = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? s : null, a = document.createElement("div");
35
+ a.className = "p-gui__slider", n && a.setAttribute("title", n), this.parent.wrapper.append(a), this.element = a;
36
36
  const u = document.createElement("div");
37
- u.className = "p-gui__slider-name", u.textContent = s, l.append(u), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", this.min), this.ctrlDiv.setAttribute("max", this.max), l.append(this.ctrlDiv);
37
+ u.className = "p-gui__slider-name", u.textContent = s, a.append(u), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", this.min), this.ctrlDiv.setAttribute("max", this.max), a.append(this.ctrlDiv);
38
38
  const d = document.createElement("div");
39
- d.className = "p-gui__slider-bar", this.ctrlDiv.append(d), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", d.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : a, l.append(this.valueInput), setTimeout(() => {
39
+ d.className = "p-gui__slider-bar", this.ctrlDiv.append(d), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", d.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : l, a.append(this.valueInput), setTimeout(() => {
40
40
  const p = this.handle.offsetWidth;
41
41
  this.handle.position = this._mapLinear(
42
42
  this.valueInput.value,
@@ -67,16 +67,16 @@ class Y {
67
67
  });
68
68
  }
69
69
  _updateHandlePositionFromPointer(t, e = !1) {
70
- const r = this.ctrlDiv.offsetWidth, c = this.handle.offsetWidth, i = t.clientX - this.ctrlDiv.prevPosition, a = parseFloat(this.valueInput.value);
70
+ const r = this.ctrlDiv.offsetWidth, c = this.handle.offsetWidth, i = t.clientX - this.ctrlDiv.prevPosition, l = parseFloat(this.valueInput.value);
71
71
  let s;
72
72
  e ? s = t.offsetX : s = this.handle.position + i, s = Math.max(
73
73
  c / 2,
74
74
  Math.min(s, r - c / 2)
75
75
  );
76
76
  let o = this.min + (this.max - this.min) * (s - c / 2) / (r - c);
77
- o > a ? o = this._quantizeFloor(o, this.step) : o = this._quantizeCeil(o, this.step), o = parseFloat(o.toFixed(9));
78
- const n = parseFloat((a + this.step).toFixed(9)), l = parseFloat((a - this.step).toFixed(9));
79
- (o >= n || o <= l) && (o = o.toFixed(this.decimals), this.valueInput.value = o, this.ctrlDiv.prevPosition = t.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${s}px)`, this.handle.position = s, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
77
+ o > l ? o = this._quantizeFloor(o, this.step) : o = this._quantizeCeil(o, this.step), o = parseFloat(o.toFixed(9));
78
+ const n = parseFloat((l + this.step).toFixed(9)), a = parseFloat((l - this.step).toFixed(9));
79
+ (o >= n || o <= a) && (o = o.toFixed(this.decimals), this.valueInput.value = o, this.ctrlDiv.prevPosition = t.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${s}px)`, this.handle.position = s, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
80
80
  }
81
81
  _updateHandlePositionFromValue() {
82
82
  const t = this.ctrlDiv.offsetWidth, e = this.handle.offsetWidth;
@@ -124,19 +124,19 @@ class z {
124
124
  throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
125
125
  let c = r.replace(/^.*[\\\/]/, ""), i;
126
126
  e.label == null ? i = c : i = typeof e.label == "string" && e.label || " ";
127
- const a = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? i : null, s = e.selected === !0, o = e.selectionBorder !== !1;
127
+ const l = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? i : null, s = e.selected === !0, o = e.selectionBorder !== !1;
128
128
  let n = "";
129
129
  e.width && (typeof e.width == "number" && (e.width += "px"), n += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), n += `height: ${e.height}; `);
130
- const l = document.createElement("div");
131
- l.className = "p-gui__image", l.style = "background-image: url(" + r + "); " + n, a && l.setAttribute("title", a), this.parent.imageContainer.append(l), s && o && l.classList.add("p-gui__image--selected");
130
+ const a = document.createElement("div");
131
+ a.className = "p-gui__image", a.style = "background-image: url(" + r + "); " + n, l && a.setAttribute("title", l), this.parent.imageContainer.append(a), this.element = a, s && o && a.classList.add("p-gui__image--selected");
132
132
  const u = document.createElement("div");
133
- u.className = "p-gui__image-text", u.textContent = i, l.append(u), l.addEventListener("click", () => {
134
- let d = l.parentElement.querySelectorAll(
133
+ u.className = "p-gui__image-text", u.textContent = i, a.append(u), a.addEventListener("click", () => {
134
+ let d = a.parentElement.querySelectorAll(
135
135
  ".p-gui__image--selected"
136
136
  );
137
137
  for (let p = 0; p < d.length; p++)
138
138
  d[p].classList.remove("p-gui__image--selected");
139
- o && l.classList.add("p-gui__image--selected"), typeof this.callback == "function" && this.callback({ path: r, text: i }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
139
+ o && a.classList.add("p-gui__image--selected"), typeof this.callback == "function" && this.callback({ path: r, text: i }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
140
140
  });
141
141
  }
142
142
  onClick(t) {
@@ -146,22 +146,22 @@ class z {
146
146
  class B {
147
147
  constructor(t, e, r, c) {
148
148
  this.parent = t, this.callback = null;
149
- let i = {}, a = null, s = !1, o, n;
149
+ let i = {}, l = null, s = !1, o, n;
150
150
  if (e && typeof e == "object" && typeof r == "string")
151
151
  o = e, n = r, s = !0, i = c || {};
152
152
  else if (e && typeof e == "object")
153
- s = !1, i = e, a = typeof i.value == "boolean" ? i.value : null;
153
+ s = !1, i = e, l = typeof i.value == "boolean" ? i.value : null;
154
154
  else
155
155
  throw Error("[GUI] toggle() invalid parameters.");
156
- let l = typeof i.label == "string" && i.label || " ", u = null;
157
- s && l == " " && (l = n), s && (u = this.parent.propReferences.push(o[n]) - 1);
158
- const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null, p = document.createElement("div");
159
- p.textContent = l, p.className = "p-gui__toggle", d && p.setAttribute("title", d), this.parent.wrapper.append(p), p.addEventListener("click", (b) => {
156
+ let a = typeof i.label == "string" && i.label || " ", u = null;
157
+ s && a == " " && (a = n), s && (u = this.parent.propReferences.push(o[n]) - 1);
158
+ const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null, p = document.createElement("div");
159
+ p.textContent = a, p.className = "p-gui__toggle", d && p.setAttribute("title", d), this.parent.wrapper.append(p), this.element = p, p.addEventListener("click", (b) => {
160
160
  const h = b.target.childNodes[1];
161
161
  let _ = !0;
162
162
  h.classList.contains("p-gui__toggle-checkbox--active") && (_ = !1), h.classList.toggle("p-gui__toggle-checkbox--active"), s ? o[n] = _ : typeof this.callback == "function" && this.callback(_), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
163
163
  });
164
- let g = s ? o[n] ? " p-gui__toggle-checkbox--active" : "" : a ? " p-gui__toggle-checkbox--active" : "";
164
+ let g = s ? o[n] ? " p-gui__toggle-checkbox--active" : "" : l ? " p-gui__toggle-checkbox--active" : "";
165
165
  const f = document.createElement("div");
166
166
  f.className = "p-gui__toggle-checkbox" + g, p.append(f), s && Object.defineProperty(o, n, {
167
167
  set: (b) => {
@@ -181,23 +181,23 @@ class B {
181
181
  class V {
182
182
  constructor(t, e, r, c) {
183
183
  this.parent = t, this.callback = null;
184
- let i = {}, a = null, s = !1, o, n;
184
+ let i = {}, l = null, s = !1, o, n;
185
185
  if (e && typeof e == "object" && typeof r == "string")
186
186
  o = e, n = r, s = !0, i = c || {};
187
187
  else if (e && typeof e == "object")
188
188
  s = !1, i = e;
189
189
  else
190
190
  throw Error("[GUI] list() invalid parameters.");
191
- let l = typeof i.label == "string" ? i.label : " ", u = null, d = Array.isArray(i.values) ? i.values : null, p = d && d.length > 0 && typeof d[0] == "object";
192
- const g = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null;
193
- s ? (a = (() => {
191
+ let a = typeof i.label == "string" ? i.label : " ", u = null, d = Array.isArray(i.values) ? i.values : null, p = d && d.length > 0 && typeof d[0] == "object";
192
+ const g = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null;
193
+ s ? (l = (() => {
194
194
  if (!d)
195
195
  return null;
196
196
  if (typeof o[n] == "string")
197
197
  return p ? d.find((h) => h.value === o[n]).value : d.indexOf(o[n]);
198
198
  if (typeof o[n] == "number")
199
199
  return p ? d.find((h) => h.value === o[n]).value : o[n];
200
- })(), u = this.parent.propReferences.push(o[n]) - 1) : a = (() => {
200
+ })(), u = this.parent.propReferences.push(o[n]) - 1) : l = (() => {
201
201
  if (!d)
202
202
  return null;
203
203
  if (typeof i.value == "string")
@@ -206,14 +206,14 @@ class V {
206
206
  return i.value;
207
207
  })();
208
208
  let f = document.createElement("div");
209
- f.className = "p-gui__list", f.textContent = l, g && f.setAttribute("title", g), this.parent.wrapper.append(f);
209
+ f.className = "p-gui__list", f.textContent = a, g && f.setAttribute("title", g), this.parent.wrapper.append(f), this.element = f;
210
210
  let b = document.createElement("select");
211
211
  f.append(b), b.className = "p-gui__list-dropdown", b.addEventListener("change", (h) => {
212
212
  s ? o[n] = h.target.value : this.callback && this.callback(h.target.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
213
213
  }), d && d.forEach((h, _) => {
214
214
  const y = p ? h.label : h, v = p ? h.value : h;
215
215
  let w = document.createElement("option");
216
- w.setAttribute("value", v), w.textContent = y, b.append(w), (!p && a == _ || p && a == v) && w.setAttribute("selected", "");
216
+ w.setAttribute("value", v), w.textContent = y, b.append(w), (!p && l == _ || p && l == v) && w.setAttribute("selected", "");
217
217
  }), s && Object.defineProperty(o, n, {
218
218
  set: (h) => {
219
219
  let _, y, v;
@@ -231,22 +231,22 @@ class V {
231
231
  class G {
232
232
  constructor(t, e, r, c) {
233
233
  this.parent = t, this.callback = null;
234
- let i = {}, a = null, s = !1, o, n;
234
+ let i = {}, l = null, s = !1, o, n;
235
235
  if (e && typeof e == "object" && typeof r == "string")
236
236
  o = e, n = r, s = !0, i = c || {};
237
237
  else if (e && typeof e == "object")
238
238
  s = !1, i = e;
239
239
  else
240
240
  throw Error("[GUI] color() invalid parameters.");
241
- let l = typeof i.label == "string" && i.label || " ", u = null;
242
- const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null;
243
- s ? (l == " " && (l = n), u = this.parent.propReferences.push(o[n]) - 1, a = o[n] || "#000000") : (typeof i.value == "string" && (i.value.length != 7 || i.value[0] != "#" ? console.error(
241
+ let a = typeof i.label == "string" && i.label || " ", u = null;
242
+ const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null;
243
+ s ? (a == " " && (a = n), u = this.parent.propReferences.push(o[n]) - 1, l = o[n] || "#000000") : (typeof i.value == "string" && (i.value.length != 7 || i.value[0] != "#" ? console.error(
244
244
  `[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${i.value}".`
245
- ) : a = i.value), a || (a = "#000000"));
245
+ ) : l = i.value), l || (l = "#000000"));
246
246
  const p = document.createElement("div");
247
- p.className = "p-gui__color", p.textContent = l, d && p.setAttribute("title", d), this.parent.wrapper.append(p);
247
+ p.className = "p-gui__color", p.textContent = a, d && p.setAttribute("title", d), this.parent.wrapper.append(p), this.element = p;
248
248
  const g = document.createElement("input");
249
- g.className = "p-gui__color-picker", g.setAttribute("type", "color"), g.value = a, p.append(g), g.addEventListener("input", () => {
249
+ g.className = "p-gui__color-picker", g.setAttribute("type", "color"), g.value = l, p.append(g), g.addEventListener("input", () => {
250
250
  s ? o[n] = g.value : typeof this.callback == "function" && this.callback(g.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
251
251
  }), s && Object.defineProperty(o, n, {
252
252
  set: (f) => {
@@ -262,21 +262,21 @@ class G {
262
262
  class T {
263
263
  constructor(t, e, r, c, i) {
264
264
  this.parent = t, this.callback = null;
265
- let a = {}, s, o, n, l;
265
+ let l = {}, s, o, n, a;
266
266
  if (e && typeof e == "object" && typeof r == "string" && typeof c == "string")
267
- s = e, o = e, n = r, l = c, a = i || {};
267
+ s = e, o = e, n = r, a = c, l = i || {};
268
268
  else if (e && typeof e == "object" && e.x && e.x.obj)
269
- a = e, s = a.x.obj, n = a.x.prop, o = a.y.obj, l = a.y.prop;
269
+ l = e, s = l.x.obj, n = l.x.prop, o = l.y.obj, a = l.y.prop;
270
270
  else
271
271
  throw Error(
272
272
  "[GUI] vector2() invalid parameters. Use: gui.vector2(obj, 'propX', 'propY', params)"
273
273
  );
274
- let u = typeof a.label == "string" && a.label || " ";
275
- u === " " && (u = n + " / " + l);
276
- const d = a.x || {}, p = a.y || {}, g = d.min ?? a.min ?? 0, f = d.max ?? a.max ?? 1, b = p.min ?? a.min ?? 0, h = p.max ?? a.max ?? 1, _ = d.step || a.step || (f - g) / 100, y = p.step || a.step || (h - b) / 100, v = this.parent._countDecimals(_), w = this.parent._countDecimals(y), C = this.parent.propReferences.push(s[n]) - 1, D = this.parent.propReferences.push(o[l]) - 1, L = typeof a.tooltip == "string" ? a.tooltip : a.tooltip === !0 ? u : null, A = document.createElement("div");
274
+ let u = typeof l.label == "string" && l.label || " ";
275
+ u === " " && (u = n + " / " + a);
276
+ const d = l.x || {}, p = l.y || {}, g = d.min ?? l.min ?? 0, f = d.max ?? l.max ?? 1, b = p.min ?? l.min ?? 0, h = p.max ?? l.max ?? 1, _ = d.step || l.step || (f - g) / 100, y = p.step || l.step || (h - b) / 100, v = this.parent._countDecimals(_), w = this.parent._countDecimals(y), C = this.parent.propReferences.push(s[n]) - 1, D = this.parent.propReferences.push(o[a]) - 1, L = typeof l.tooltip == "string" ? l.tooltip : l.tooltip === !0 ? u : null, A = document.createElement("div");
277
277
  A.className = "p-gui__vector2", A.textContent = u, L && A.setAttribute("title", L), this.parent.wrapper.append(A);
278
278
  const E = document.createElement("div");
279
- E.className = "p-gui__vector-value", E.textContent = s[n] + ", " + o[l], A.append(E);
279
+ E.className = "p-gui__vector-value", E.textContent = s[n] + ", " + o[a], A.append(E);
280
280
  const m = document.createElement("div");
281
281
  m.className = "p-gui__vector2-area", A.append(m), m.addEventListener("click", (x) => {
282
282
  const j = parseFloat(
@@ -296,7 +296,7 @@ class T {
296
296
  b
297
297
  )
298
298
  );
299
- s[n] = j.toFixed(v), o[l] = R.toFixed(w), this.callback && this.callback(s[n], s[l]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
299
+ s[n] = j.toFixed(v), o[a] = R.toFixed(w), this.callback && this.callback(s[n], s[a]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
300
300
  });
301
301
  const P = (x) => {
302
302
  const j = m.getBoundingClientRect(), R = x.clientX - j.left, N = x.clientY - j.top, H = this.parent._mapLinear(
@@ -312,7 +312,7 @@ class T {
312
312
  h,
313
313
  b
314
314
  ), S = Math.max(g, Math.min(f, H)), W = Math.max(b, Math.min(h, X));
315
- s[n] = parseFloat(S.toFixed(v)), o[l] = parseFloat(W.toFixed(w)), this.callback && this.callback(s[n], o[l]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
315
+ s[n] = parseFloat(S.toFixed(v)), o[a] = parseFloat(W.toFixed(w)), this.callback && this.callback(s[n], o[a]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
316
316
  };
317
317
  m.addEventListener("pointerdown", (x) => {
318
318
  P(x), document.addEventListener("pointermove", P), document.addEventListener(
@@ -340,7 +340,7 @@ class T {
340
340
  0,
341
341
  m.clientWidth
342
342
  ) + "px", U.style.top = this.parent._mapLinear(
343
- o[l],
343
+ o[a],
344
344
  b,
345
345
  h,
346
346
  m.clientHeight,
@@ -351,10 +351,10 @@ class T {
351
351
  I();
352
352
  }).observe(m), Object.defineProperty(s, n, {
353
353
  set: (x) => {
354
- this.parent.propReferences[C] = x, I(), E.textContent = String(x) + ", " + o[l];
354
+ this.parent.propReferences[C] = x, I(), E.textContent = String(x) + ", " + o[a];
355
355
  },
356
356
  get: () => this.parent.propReferences[C]
357
- }), Object.defineProperty(o, l, {
357
+ }), Object.defineProperty(o, a, {
358
358
  set: (x) => {
359
359
  this.parent.propReferences[D] = x, I(), E.textContent = s[n] + ", " + String(x);
360
360
  },
@@ -629,18 +629,18 @@ class O {
629
629
  folder(t = {}) {
630
630
  let e = typeof t.closed == "boolean" ? t.closed : !1, r = t.label || "", c = t.color || null, i = t.maxHeight || null;
631
631
  this.imageContainer = null;
632
- let a = "p-gui__folder";
633
- this.folders.length == 0 && (a += " p-gui__folder--first"), e && (a += " p-gui__folder--closed");
632
+ let l = "p-gui__folder";
633
+ this.folders.length == 0 && (l += " p-gui__folder--first"), e && (l += " p-gui__folder--closed");
634
634
  let s = c ? `background-color: ${c};` : "";
635
- s += i ? `max-height: ${i}px;` : "";
635
+ s += i ? `max-height: ${i}px; overflow-y: auto;` : "";
636
636
  const o = document.createElement("div");
637
- o.className = a, o.style = s, this.wrapper.append(o);
637
+ o.className = l, o.style = s, this.wrapper.append(o);
638
638
  const n = document.createElement("div");
639
639
  n.innerHTML = `<span class="p-gui__folder-arrow"></span>${r}`, n.className = "p-gui__folder-header", o.append(n);
640
- const l = document.createElement("div");
641
- l.className = "p-gui__folder-content", o.append(l);
640
+ const a = document.createElement("div");
641
+ a.className = "p-gui__folder-content", o.append(a);
642
642
  const u = document.createElement("div");
643
- u.className = "p-gui__folder-inner", l.append(u), n.addEventListener("click", () => {
643
+ u.className = "p-gui__folder-inner", a.append(u), n.addEventListener("click", () => {
644
644
  o.classList.toggle("p-gui__folder--closed");
645
645
  });
646
646
  let d = new O({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "perfect-gui",
3
3
  "type": "module",
4
- "version": "5.0.1",
4
+ "version": "5.0.3",
5
5
  "description": "GUI for JavaScript",
6
6
  "main": "dist/perfect-gui.js",
7
7
  "module": "dist/perfect-gui.js",
@@ -48,6 +48,9 @@ export default class Button {
48
48
  }
49
49
 
50
50
  this.parent.wrapper.append(el);
51
+
52
+ // Expose the DOM element
53
+ this.element = el;
51
54
  }
52
55
 
53
56
  onClick(callback) {
@@ -55,6 +55,9 @@ export default class Color {
55
55
  container.setAttribute('title', tooltip);
56
56
  }
57
57
  this.parent.wrapper.append(container);
58
+
59
+ // Expose the DOM element
60
+ this.element = container;
58
61
 
59
62
  const colorpicker = document.createElement('input');
60
63
  colorpicker.className = 'p-gui__color-picker';
@@ -61,6 +61,9 @@ export default class Image {
61
61
  image.setAttribute('title', tooltip);
62
62
  }
63
63
  this.parent.imageContainer.append(image);
64
+
65
+ // Expose the DOM element
66
+ this.element = image;
64
67
 
65
68
  if (selected && selectionBorder) {
66
69
  image.classList.add('p-gui__image--selected');
@@ -81,6 +81,9 @@ export default class List {
81
81
  container.setAttribute('title', tooltip);
82
82
  }
83
83
  this.parent.wrapper.append(container);
84
+
85
+ // Expose the DOM element
86
+ this.element = container;
84
87
 
85
88
  let select = document.createElement('select');
86
89
  container.append(select);
@@ -56,6 +56,9 @@ export default class Slider {
56
56
  }
57
57
 
58
58
  this.parent.wrapper.append(container);
59
+
60
+ // Expose the DOM element
61
+ this.element = container;
59
62
 
60
63
  const slider_name = document.createElement('div');
61
64
  slider_name.className = 'p-gui__slider-name';
@@ -46,6 +46,9 @@ export default class Toggle {
46
46
  container.setAttribute('title', tooltip);
47
47
  }
48
48
  this.parent.wrapper.append(container);
49
+
50
+ // Expose the DOM element
51
+ this.element = container;
49
52
 
50
53
  container.addEventListener('click', (ev) => {
51
54
  const checkbox = ev.target.childNodes[1];
package/src/index.js CHANGED
@@ -270,8 +270,8 @@ export default class GUI {
270
270
 
271
271
  button(params = {}) {
272
272
  this.imageContainer = null;
273
- const el = new Button(this, params);
274
- return el;
273
+ const instance = new Button(this, params);
274
+ return instance;
275
275
  }
276
276
 
277
277
  image(params = {}) {
@@ -280,38 +280,38 @@ export default class GUI {
280
280
  this.imageContainer.className = 'p-gui__image-container';
281
281
  this.wrapper.append(this.imageContainer);
282
282
  }
283
- const el = new Image(this, params);
284
- return el;
283
+ const instance = new Image(this, params);
284
+ return instance;
285
285
  }
286
286
 
287
287
  slider(arg1, arg2, arg3) {
288
288
  this.imageContainer = null;
289
- const el = new Slider(this, arg1, arg2, arg3);
290
- return el;
289
+ const instance = new Slider(this, arg1, arg2, arg3);
290
+ return instance;
291
291
  }
292
292
 
293
293
  toggle(arg1, arg2, arg3) {
294
294
  this.imageContainer = null;
295
- const el = new Toggle(this, arg1, arg2, arg3);
296
- return el;
295
+ const instance = new Toggle(this, arg1, arg2, arg3);
296
+ return instance;
297
297
  }
298
298
 
299
299
  list(arg1, arg2, arg3) {
300
300
  this.imageContainer = null;
301
- const el = new List(this, arg1, arg2, arg3);
302
- return el;
301
+ const instance = new List(this, arg1, arg2, arg3);
302
+ return instance;
303
303
  }
304
304
 
305
305
  color(arg1, arg2, arg3) {
306
306
  this.imageContainer = null;
307
- const el = new Color(this, arg1, arg2, arg3);
308
- return el;
307
+ const instance = new Color(this, arg1, arg2, arg3);
308
+ return instance;
309
309
  }
310
310
 
311
311
  vector2(arg1, arg2, arg3, arg4) {
312
312
  this.imageContainer = null;
313
- const el = new Vector2(this, arg1, arg2, arg3, arg4);
314
- return el;
313
+ const instance = new Vector2(this, arg1, arg2, arg3, arg4);
314
+ return instance;
315
315
  }
316
316
 
317
317
  folder(options = {}) {
@@ -334,7 +334,7 @@ export default class GUI {
334
334
  }
335
335
 
336
336
  let container_style = color ? `background-color: ${color};` : '';
337
- container_style += maxHeight ? `max-height: ${maxHeight}px;` : '';
337
+ container_style += maxHeight ? `max-height: ${maxHeight}px; overflow-y: auto;` : '';
338
338
 
339
339
  const container = document.createElement('div');
340
340
  container.className = className;