perfect-gui 4.6.5 → 4.7.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.
@@ -1,4 +1,4 @@
1
- function w(m) {
1
+ function A(y) {
2
2
  return (
3
3
  /* css */
4
4
  `
@@ -10,7 +10,7 @@ function w(m) {
10
10
  --color-accent: #1681ca;
11
11
  --color-accent-hover: #218fda;
12
12
 
13
- position: ${m};
13
+ position: ${y};
14
14
  top: 0;
15
15
  left: 0;
16
16
  transform: translate3d(0,0,0);
@@ -276,6 +276,7 @@ function w(m) {
276
276
  cursor: pointer;
277
277
  border-radius: 3px;
278
278
  border: 1px solid var(--color-border-2);
279
+ outline: none;
279
280
  }
280
281
 
281
282
  .p-gui__list-dropdown {
@@ -367,6 +368,7 @@ function w(m) {
367
368
  flex-wrap: wrap;
368
369
  border: 1px solid grey;
369
370
  padding: 0 3px;
371
+ border-radius: var(--main-border-radius);
370
372
  }
371
373
 
372
374
  .p-gui__folder:last-of-type {
@@ -418,7 +420,7 @@ class b {
418
420
  this._folderConstructor(e.folderOptions);
419
421
  return;
420
422
  }
421
- this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), this instanceof b && (typeof b[b.instanceCounter] != "number" ? b[b.instanceCounter] = 0 : b[b.instanceCounter]++), this.instanceId = b[b.instanceCounter], this.wrapperWidth = e.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${w(this.position_type)}`), this._styleInstance(), this._addWrapper(), this.wrapper.setAttribute("data-corner-x", this.screenCorner.x), this.wrapper.setAttribute("data-corner-y", this.screenCorner.y), e.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, e.draggable == !0 && this._makeDraggable(), this.closed = !1, e.closed && this.toggleClose();
423
+ this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), this instanceof b && (typeof b[b.instanceCounter] != "number" ? b[b.instanceCounter] = 0 : b[b.instanceCounter]++), this.instanceId = b[b.instanceCounter], this.wrapperWidth = e.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${A(this.position_type)}`), this._styleInstance(), this._addWrapper(), this.wrapper.setAttribute("data-corner-x", this.screenCorner.x), this.wrapper.setAttribute("data-corner-y", this.screenCorner.y), e.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, e.draggable == !0 && this._makeDraggable(), this.closed = !1, e.closed && this.toggleClose();
422
424
  }
423
425
  _styleInstance() {
424
426
  let e = this._getScrollbarWidth(this.container);
@@ -461,43 +463,20 @@ class b {
461
463
  }
462
464
  this.position = { prevX: this.xOffset, prevY: this.yOffset, x: this.xOffset, y: this.yOffset }, this.wrapper.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`;
463
465
  }
464
- _createElement(e) {
465
- e.el = e.el || "div";
466
- var t = document.createElement(e.el);
467
- if (e.id && (t.id = e.id), e.class && (t.className = e.class), e.inline && (t.style = e.inline), e.href && (t.href = e.href), e.onclick && (t.onclick = e.onclick), e.onchange && (t.onchange = e.onchange), e.textContent && (t.textContent = e.textContent), e.innerHTML && (t.innerHTML = e.innerHTML), e.type && (t.type = e.type), e.value && (t.value = e.value), e.customAttributes)
468
- for (var o in e.customAttributes)
469
- t.setAttribute(o, e.customAttributes[o]);
470
- return e.parent = e.parent ? e.parent : this.wrapper, e.parent.append(t), t;
471
- }
472
466
  _addStyles(e) {
473
467
  this.stylesheet.innerHTML += e;
474
468
  }
475
469
  _addWrapper() {
476
- this.wrapper = this._createElement({
477
- parent: this.container,
478
- id: "p-gui-" + this.instanceId,
479
- class: "p-gui"
480
- }), this.header = this._createElement({
481
- parent: this.wrapper,
482
- class: "p-gui__header",
483
- textContent: this.name,
484
- inline: `${this.backgroundColor ? "border-color: " + this.backgroundColor + ";" : ""}`
485
- }), this._createElement({
486
- parent: this.header,
487
- class: "p-gui__header-close",
488
- onclick: this.toggleClose.bind(this)
489
- });
470
+ this.wrapper = document.createElement("div"), this.wrapper.id = "p-gui-" + this.instanceId, this.wrapper.className = "p-gui", this.container.append(this.wrapper), this.header = document.createElement("div"), this.header.className = "p-gui__header", this.header.textContent = this.name, this.header.style = `${this.backgroundColor ? "border-color: " + this.backgroundColor + ";" : ""}`, this.wrapper.append(this.header);
471
+ const e = document.createElement("div");
472
+ e.className = "p-gui__header-close", e.addEventListener("click", this.toggleClose.bind(this)), this.header.append(e);
490
473
  }
491
474
  button(e, t) {
492
475
  let o = "";
493
476
  typeof e != "string" ? typeof e == "object" && (e != null && e.hasOwnProperty("name")) ? o = e.name == "" ? " " : e.name : o = " " : o = e == "" ? " " : e, this.imageContainer = null, typeof t != "function" && (t = () => {
494
477
  });
495
- const a = this._createElement({
496
- class: "p-gui__button",
497
- textContent: o,
498
- onclick: t
499
- });
500
- typeof e.color == "string" && (a.style.setProperty("--color-accent", e.color), a.style.setProperty("--color-accent-hover", e.hoverColor || e.color));
478
+ const a = document.createElement("div");
479
+ a.className = "p-gui__button", a.textContent = o, a.addEventListener("click", t), this.wrapper.append(a), typeof e.color == "string" && (a.style.setProperty("--color-accent", e.color), a.style.setProperty("--color-accent-hover", e.hoverColor || e.color));
501
480
  }
502
481
  image(e = {}, t) {
503
482
  if (typeof e != "object")
@@ -507,114 +486,86 @@ class b {
507
486
  o = e.path;
508
487
  else
509
488
  throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
510
- let a = o.replace(/^.*[\\\/]/, ""), n;
511
- e.name == null ? n = a : n = typeof e.name == "string" && e.name || " ";
489
+ let a = o.replace(/^.*[\\\/]/, ""), d;
490
+ e.name == null ? d = a : d = typeof e.name == "string" && e.name || " ";
512
491
  const r = e.selected === !0, i = e.selectionBorder !== !1;
513
492
  let s = "";
514
- e.width && (typeof e.width == "number" && (e.width += "px"), s += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), s += `height: ${e.height}; `), this.imageContainer || (this.imageContainer = this._createElement({
515
- class: "p-gui__image-container"
516
- }));
517
- var l = this._createElement({
518
- class: "p-gui__image",
519
- inline: "background-image: url(" + o + "); " + s,
520
- parent: this.imageContainer
521
- });
522
- return r && i && l.classList.add("p-gui__image--selected"), this._createElement({
523
- parent: l,
524
- class: "p-gui__image-text",
525
- textContent: n
526
- }), l.onclick = () => {
527
- let c = l.parentElement.querySelectorAll(".p-gui__image--selected");
528
- for (let d = 0; d < c.length; d++)
529
- c[d].classList.remove("p-gui__image--selected");
530
- i && l.classList.add("p-gui__image--selected"), typeof t == "function" && t({ path: o, text: n });
531
- }, l;
493
+ e.width && (typeof e.width == "number" && (e.width += "px"), s += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), s += `height: ${e.height}; `), this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer));
494
+ const n = document.createElement("div");
495
+ n.className = "p-gui__image", n.style = "background-image: url(" + o + "); " + s, this.imageContainer.append(n), r && i && n.classList.add("p-gui__image--selected");
496
+ const l = document.createElement("div");
497
+ return l.className = "p-gui__image-text", l.textContent = d, n.append(l), n.addEventListener("click", () => {
498
+ let c = n.parentElement.querySelectorAll(".p-gui__image--selected");
499
+ for (let p = 0; p < c.length; p++)
500
+ c[p].classList.remove("p-gui__image--selected");
501
+ i && n.classList.add("p-gui__image--selected"), typeof t == "function" && t({ path: o, text: d });
502
+ }), n;
532
503
  }
533
504
  slider(e = {}, t) {
534
505
  if (typeof e != "object")
535
506
  throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
536
- let o = typeof e.name == "string" && e.name || " ", a = !1, n = null, r = e.obj || e.object, i = e.prop || e.property, s = typeof e.value == "number" ? e.value : null, l = e.min ?? 0, c = e.max ?? 1, d = e.step || (c - l) / 100;
507
+ let o = typeof e.name == "string" && e.name || " ", a = !1, d = null, r = e.obj, i = e.prop, s = typeof e.value == "number" ? e.value : null, n = e.min ?? 0, l = e.max ?? 1, c = e.step || (l - n) / 100;
537
508
  if (s !== null)
538
- (i != null || r != null) && console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');
509
+ (i != null || r != null) && console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
539
510
  else if (i != null && r != null) {
540
511
  if (typeof i != "string")
541
- throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);
512
+ throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof i}.`);
542
513
  if (typeof r != "object")
543
- throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);
544
- o == " " && (o = i), n = this.propReferences.push(r[i]) - 1, a = !0;
514
+ throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof r}.`);
515
+ o == " " && (o = i), d = this.propReferences.push(r[i]) - 1, a = !0;
545
516
  } else
546
- (i != null && r == null || i == null && r == null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), s = (c - l) / 2;
517
+ (i != null && r == null || i == null && r == null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), s = (l - n) / 2;
547
518
  this.imageContainer = null;
548
- var p = this._createElement({
549
- class: "p-gui__slider",
550
- textContent: o
551
- }), u = this._createElement({
552
- parent: p,
553
- el: "input",
554
- class: "p-gui__slider-ctrl",
555
- customAttributes: {
556
- type: "range",
557
- min: l,
558
- max: c,
559
- step: d,
560
- value: a ? r[i] : s
561
- }
562
- }), g = this._createElement({
563
- parent: p,
564
- class: "p-gui__slider-value",
565
- textContent: String(a ? r[i] : s)
566
- });
567
- u.addEventListener("input", () => {
568
- g.textContent = u.value, a ? r[i] = u.value : typeof t == "function" && t(parseFloat(u.value));
519
+ const p = document.createElement("div");
520
+ p.className = "p-gui__slider", p.textContent = o, this.wrapper.append(p);
521
+ const u = document.createElement("input");
522
+ u.className = "p-gui__slider-ctrl", u.setAttribute("type", "range"), u.setAttribute("min", n), u.setAttribute("max", l), u.setAttribute("step", c), u.setAttribute("value", a ? r[i] : s), p.append(u);
523
+ const h = document.createElement("div");
524
+ h.className = "p-gui__slider-value", h.textContent = String(a ? r[i] : s), p.append(h), u.addEventListener("input", () => {
525
+ h.textContent = u.value, a ? r[i] = u.value : typeof t == "function" && t(parseFloat(u.value));
569
526
  }), a && Object.defineProperty(r, i, {
570
- set: (_) => {
571
- this.propReferences[n] = _, u.value = _, g.textContent = String(_), typeof t == "function" && t(parseFloat(u.value));
527
+ set: (m) => {
528
+ this.propReferences[d] = m, u.value = m, h.textContent = String(m), typeof t == "function" && t(parseFloat(u.value));
572
529
  },
573
- get: () => this.propReferences[n]
530
+ get: () => this.propReferences[d]
574
531
  });
575
532
  }
576
533
  toggle(e = {}, t) {
577
534
  if (typeof e != "object")
578
535
  throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);
579
- let o = typeof e.name == "string" && e.name || " ", a = !1, n = null, r = e.obj || e.object, i = e.prop || e.property, s = typeof e.value == "boolean" ? e.value : null;
536
+ let o = typeof e.name == "string" && e.name || " ", a = !1, d = null, r = e.obj, i = e.prop, s = typeof e.value == "boolean" ? e.value : null;
580
537
  if (s !== null)
581
- (i != null || r != null) && console.warn('[GUI] toggle() "obj" and "property" parameters are ignored when a "value" parameter is used.');
538
+ (i != null || r != null) && console.warn('[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
582
539
  else if (i != null && r != null) {
583
540
  if (typeof i != "string")
584
- throw Error(`[GUI] toggle() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);
541
+ throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof i}.`);
585
542
  if (typeof r != "object")
586
- throw Error(`[GUI] toggle() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);
587
- o == " " && (o = i), n = this.propReferences.push(r[i]) - 1, a = !0;
543
+ throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof r}.`);
544
+ o == " " && (o = i), d = this.propReferences.push(r[i]) - 1, a = !0;
588
545
  } else
589
546
  (i != null && r == null || i == null && r == null) && console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');
590
547
  this.imageContainer = null;
591
- const l = this._createElement({
592
- class: "p-gui__switch",
593
- onclick: (p) => {
594
- const u = p.target.childNodes[1];
595
- let g = !0;
596
- u.classList.contains("p-gui__switch-checkbox--active") && (g = !1), u.classList.toggle("p-gui__switch-checkbox--active"), a ? r[i] = g : typeof t == "function" && t(g);
597
- },
598
- textContent: o
599
- });
600
- let c = (() => a ? r[i] ? " p-gui__switch-checkbox--active" : "" : s ? " p-gui__switch-checkbox--active" : "")();
601
- const d = this._createElement({
602
- parent: l,
603
- class: "p-gui__switch-checkbox" + c
548
+ const n = document.createElement("div");
549
+ n.textContent = o, n.className = "p-gui__switch", this.wrapper.append(n), n.addEventListener("click", (p) => {
550
+ const u = p.target.childNodes[1];
551
+ let h = !0;
552
+ u.classList.contains("p-gui__switch-checkbox--active") && (h = !1), u.classList.toggle("p-gui__switch-checkbox--active"), a ? r[i] = h : typeof t == "function" && t(h);
604
553
  });
605
- a && Object.defineProperty(r, i, {
554
+ let l = (() => a ? r[i] ? " p-gui__switch-checkbox--active" : "" : s ? " p-gui__switch-checkbox--active" : "")();
555
+ const c = document.createElement("div");
556
+ c.className = "p-gui__switch-checkbox" + l, n.append(c), a && Object.defineProperty(r, i, {
606
557
  set: (p) => {
607
- this.propReferences[n] = p, p ? d.classList.add("p-gui__switch-checkbox--active") : d.classList.remove("p-gui__switch-checkbox--active"), typeof t == "function" && t(p);
558
+ this.propReferences[d] = p, p ? c.classList.add("p-gui__switch-checkbox--active") : c.classList.remove("p-gui__switch-checkbox--active"), typeof t == "function" && t(p);
608
559
  },
609
- get: () => this.propReferences[n]
560
+ get: () => this.propReferences[d]
610
561
  });
611
562
  }
612
563
  list(e = {}, t) {
613
564
  if (typeof e != "object")
614
565
  throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);
615
- let o = typeof e.name == "string" ? e.name : " ", a = !1, n = null, r = e.obj || e.object, i = e.prop || e.property, s = Array.isArray(e.values) ? e.values : null, l;
566
+ let o = typeof e.name == "string" ? e.name : " ", a = !1, d = null, r = e.obj, i = e.prop, s = Array.isArray(e.values) ? e.values : null, n;
616
567
  if (t = typeof t == "function" ? t : null, e.value !== void 0 || e.value === void 0 && r === void 0 && i === void 0)
617
- (i != null || r != null) && console.warn('[GUI] list() "obj" and "property" parameters are ignored when a "value" parameter is used.'), l = (() => {
568
+ (i != null || r != null) && console.warn('[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.'), n = (() => {
618
569
  if (!s)
619
570
  return null;
620
571
  if (typeof e.value == "string")
@@ -624,46 +575,33 @@ class b {
624
575
  })();
625
576
  else if (i != null && r != null) {
626
577
  if (typeof i != "string")
627
- throw Error(`[GUI] list() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);
578
+ throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof i}.`);
628
579
  if (typeof r != "object")
629
- throw Error(`[GUI] list() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);
630
- l = (() => {
580
+ throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof r}.`);
581
+ n = (() => {
631
582
  if (!s)
632
583
  return null;
633
584
  if (typeof r[i] == "string")
634
585
  return s.indexOf(r[i]);
635
586
  if (typeof r[i] == "number")
636
587
  return r[i];
637
- })(), n = this.propReferences.push(r[i]) - 1, a = !0;
588
+ })(), d = this.propReferences.push(r[i]) - 1, a = !0;
638
589
  } else
639
590
  (i != null && r == null || i == null && r == null) && console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');
640
591
  this.imageContainer = null;
641
- let c = this._createElement({
642
- class: "p-gui__list",
643
- textContent: o
644
- }), d = this._createElement({
645
- parent: c,
646
- el: "select",
647
- class: "p-gui__list-dropdown",
648
- onchange: (p) => {
649
- a ? r[i] = p.target.value : t && t(p.target.value);
650
- }
651
- });
652
- s && s.forEach((p, u) => {
653
- let g = this._createElement({
654
- parent: d,
655
- el: "option",
656
- customAttributes: {
657
- value: p
658
- },
659
- textContent: p
660
- });
661
- l == u && g.setAttribute("selected", "");
592
+ let l = document.createElement("div");
593
+ l.className = "p-gui__list", l.textContent = o, this.wrapper.append(l);
594
+ let c = document.createElement("select");
595
+ l.append(c), c.className = "p-gui__list-dropdown", c.addEventListener("change", (p) => {
596
+ a ? r[i] = p.target.value : t && t(p.target.value);
597
+ }), s && s.forEach((p, u) => {
598
+ let h = document.createElement("option");
599
+ h.setAttribute("value", p), h.textContent = p, c.append(h), n == u && h.setAttribute("selected", "");
662
600
  }), a && Object.defineProperty(r, i, {
663
601
  set: (p) => {
664
- typeof p == "string" && (l = s.indexOf(p)), typeof p == "number" && (l = p), this.propReferences[n] = l, d.querySelector("[selected]").removeAttribute("selected"), d.querySelectorAll("option")[l].setAttribute("selected", ""), typeof t == "function" && t(l);
602
+ typeof p == "string" && (n = s.indexOf(p)), typeof p == "number" && (n = p), this.propReferences[d] = n, c.querySelector("[selected]").removeAttribute("selected"), c.querySelectorAll("option")[n].setAttribute("selected", ""), typeof t == "function" && t(n);
665
603
  },
666
- get: () => this.propReferences[n]
604
+ get: () => this.propReferences[d]
667
605
  });
668
606
  }
669
607
  options(e, t) {
@@ -675,49 +613,37 @@ class b {
675
613
  if (typeof e != "object")
676
614
  throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);
677
615
  let o = typeof e.name == "string" && e.name || " ";
678
- const a = e.x.min ?? 0, n = e.x.max ?? 1, r = e.y.min ?? 0, i = e.y.max ?? 1, s = e.x.obj || e.x.object, l = e.x.prop || e.x.property, c = this.propReferences.push(s[l]) - 1, d = e.y.obj || e.y.object, p = e.y.prop || e.y.property, u = this.propReferences.push(d[p]) - 1;
616
+ const a = e.x.min ?? 0, d = e.x.max ?? 1, r = e.y.min ?? 0, i = e.y.max ?? 1, s = e.x.obj, n = e.x.prop, l = this.propReferences.push(s[n]) - 1, c = e.y.obj, p = e.y.prop, u = this.propReferences.push(c[p]) - 1;
679
617
  t = typeof t == "function" ? t : null, this.imageContainer = null;
680
- const g = this._createElement({
681
- class: "p-gui__vector2",
682
- textContent: o
683
- }), _ = this._createElement({
684
- parent: g,
685
- class: "p-gui__vector-value",
686
- textContent: s[l] + ", " + d[p]
687
- }), h = this._createElement({
688
- parent: g,
689
- el: "div",
690
- class: "p-gui__vector2-area",
691
- onclick: (f) => {
692
- s[l] = parseFloat(this._mapLinear(f.offsetX, 0, h.clientWidth, a, n).toFixed(2)), d[p] = parseFloat(this._mapLinear(f.offsetY, 0, h.clientHeight, i, r).toFixed(2)), t && t(s[l], s[p]);
693
- }
694
- });
695
- let y = !1;
696
- h.addEventListener("pointerdown", (f) => {
697
- y = !0;
698
- }), h.addEventListener("pointerup", () => {
699
- y = !1;
700
- }), h.addEventListener("pointermove", (f) => {
701
- y && (s[l] = parseFloat(this._mapLinear(f.offsetX, 0, h.clientWidth, a, n).toFixed(2)), d[p] = parseFloat(this._mapLinear(f.offsetY, 0, h.clientHeight, i, r).toFixed(2)), t && t(s[l], s[p]));
702
- }), this._createElement({
703
- parent: h,
704
- class: "p-gui__vector2-line p-gui__vector2-line-x"
705
- }), this._createElement({
706
- parent: h,
707
- class: "p-gui__vector2-line p-gui__vector2-line-y"
618
+ const h = document.createElement("div");
619
+ h.className = "p-gui__vector2", h.textContent = o, this.wrapper.append(h);
620
+ const m = document.createElement("div");
621
+ m.className = "p-gui__vector-value", m.textContent = s[n] + ", " + c[p], h.append(m);
622
+ const f = document.createElement("div");
623
+ f.className = "p-gui__vector2-area", h.append(f), f.addEventListener("click", (g) => {
624
+ s[n] = parseFloat(this._mapLinear(g.offsetX, 0, f.clientWidth, a, d).toFixed(2)), c[p] = parseFloat(this._mapLinear(g.offsetY, 0, f.clientHeight, i, r).toFixed(2)), t && t(s[n], s[p]);
708
625
  });
709
- const x = this._createElement({
710
- parent: h,
711
- class: "p-gui__vector2-dot"
626
+ let _ = !1;
627
+ f.addEventListener("pointerdown", (g) => {
628
+ _ = !0;
629
+ }), f.addEventListener("pointerup", () => {
630
+ _ = !1;
631
+ }), f.addEventListener("pointermove", (g) => {
632
+ _ && (s[n] = parseFloat(this._mapLinear(g.offsetX, 0, f.clientWidth, a, d).toFixed(2)), c[p] = parseFloat(this._mapLinear(g.offsetY, 0, f.clientHeight, i, r).toFixed(2)), t && t(s[n], s[p]));
712
633
  });
713
- x.style.left = this._mapLinear(s[l], a, n, 0, h.clientWidth) + "px", x.style.top = this._mapLinear(d[p], r, i, h.clientHeight, 0) + "px", Object.defineProperty(s, l, {
714
- set: (f) => {
715
- this.propReferences[c] = f, x.style.left = this._mapLinear(f, a, n, 0, h.clientWidth) + "px", _.textContent = String(f) + ", " + d[p];
634
+ const w = document.createElement("div");
635
+ w.className = "p-gui__vector2-line p-gui__vector2-line-x", f.append(w);
636
+ const v = document.createElement("div");
637
+ v.className = "p-gui__vector2-line p-gui__vector2-line-y", f.append(v);
638
+ const x = document.createElement("div");
639
+ x.className = "p-gui__vector2-dot", f.append(x), x.style.left = this._mapLinear(s[n], a, d, 0, f.clientWidth) + "px", x.style.top = this._mapLinear(c[p], r, i, f.clientHeight, 0) + "px", Object.defineProperty(s, n, {
640
+ set: (g) => {
641
+ this.propReferences[l] = g, x.style.left = this._mapLinear(g, a, d, 0, f.clientWidth) + "px", m.textContent = String(g) + ", " + c[p];
716
642
  },
717
- get: () => this.propReferences[c]
718
- }), Object.defineProperty(d, p, {
719
- set: (f) => {
720
- this.propReferences[u] = f, x.style.top = this._mapLinear(f, r, i, h.clientHeight, 0) + "px", _.textContent = s[l] + ", " + String(f);
643
+ get: () => this.propReferences[l]
644
+ }), Object.defineProperty(c, p, {
645
+ set: (g) => {
646
+ this.propReferences[u] = g, x.style.top = this._mapLinear(g, r, i, f.clientHeight, 0) + "px", m.textContent = s[n] + ", " + String(g);
721
647
  },
722
648
  get: () => this.propReferences[u]
723
649
  });
@@ -725,56 +651,42 @@ class b {
725
651
  color(e = {}, t) {
726
652
  if (typeof e != "object")
727
653
  throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);
728
- let o = typeof e.name == "string" && e.name || " ", a = !1, n = null, r = e.obj || e.object, i = e.prop || e.property, s;
654
+ let o = typeof e.name == "string" && e.name || " ", a = !1, d = null, r = e.obj, i = e.prop, s;
729
655
  if (typeof e.value == "string" && (e.value.length != 7 || e.value[0] != "#" ? console.error(`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${e.value}".`) : s = e.value), s || (s = "#000000"), e.value !== void 0)
730
- (i != null || r != null) && console.warn('[GUI] color() "obj" and "property" parameters are ignored when a "value" parameter is used.');
656
+ (i != null || r != null) && console.warn('[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
731
657
  else if (i != null && r != null) {
732
658
  if (typeof i != "string")
733
- throw Error(`[GUI] color() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);
659
+ throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof i}.`);
734
660
  if (typeof r != "object")
735
- throw Error(`[GUI] color() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);
736
- o == " " && (o = i), n = this.propReferences.push(r[i]) - 1, a = !0;
661
+ throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof r}.`);
662
+ o == " " && (o = i), d = this.propReferences.push(r[i]) - 1, a = !0;
737
663
  } else
738
664
  (i != null && r == null || i == null && r == null) && console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');
739
665
  this.imageContainer = null;
740
- const l = this._createElement({
741
- el: "div",
742
- class: "p-gui__color",
743
- textContent: o
744
- }), c = this._createElement({
745
- parent: l,
746
- el: "input",
747
- class: "p-gui__color-picker",
748
- type: "color",
749
- value: s
750
- });
751
- typeof t == "function" && c.addEventListener("input", () => {
752
- a ? r[i] = c.value : typeof t == "function" && t(c.value);
666
+ const n = document.createElement("div");
667
+ n.className = "p-gui__color", n.textContent = o, this.wrapper.append(n);
668
+ const l = document.createElement("input");
669
+ l.className = "p-gui__color-picker", l.setAttribute("type", "color"), l.value = s, n.append(l), typeof t == "function" && l.addEventListener("input", () => {
670
+ a ? r[i] = l.value : typeof t == "function" && t(l.value);
753
671
  }), a && Object.defineProperty(r, i, {
754
- set: (d) => {
755
- this.propReferences[n] = d, c.value = d, typeof t == "function" && t(d);
672
+ set: (c) => {
673
+ this.propReferences[d] = c, l.value = c, typeof t == "function" && t(c);
756
674
  },
757
- get: () => this.propReferences[n]
675
+ get: () => this.propReferences[d]
758
676
  });
759
677
  }
760
678
  folder(e = {}) {
761
- let t = typeof e.closed == "boolean" ? e.closed : !1, o = e.name || "", a = e.color || null, n = e.maxHeight || null;
679
+ let t = typeof e.closed == "boolean" ? e.closed : !1, o = e.name || "", a = e.color || null, d = e.maxHeight || null;
762
680
  this.imageContainer = null;
763
681
  let r = "p-gui__folder";
764
682
  this.folders.length == 0 && (r += " p-gui__folder--first"), t && (r += " p-gui__folder--closed");
765
683
  let i = a ? `background-color: ${a};` : "";
766
- i += n ? `max-height: ${n}px;` : "";
767
- let s = this._createElement({
768
- class: r,
769
- inline: i
770
- });
771
- this._createElement({
772
- innerHTML: `<span class="p-gui__folder-arrow"></span>${o}`,
773
- class: "p-gui__folder-header",
774
- onclick: function() {
775
- this.parentNode.classList.toggle("p-gui__folder--closed");
776
- },
777
- parent: s
684
+ i += d ? `max-height: ${d}px;` : "";
685
+ const s = document.createElement("div");
686
+ s.className = r, s.style = i, this.wrapper.append(s);
687
+ const n = document.createElement("div");
688
+ n.innerHTML = `<span class="p-gui__folder-arrow"></span>${o}`, n.className = "p-gui__folder-header", s.append(n), n.addEventListener("click", () => {
689
+ s.classList.toggle("p-gui__folder--closed");
778
690
  });
779
691
  let l = new b({ isFolder: !0, folderOptions: {
780
692
  wrapper: s
@@ -784,13 +696,13 @@ class b {
784
696
  _makeDraggable() {
785
697
  var e = this;
786
698
  this.header.addEventListener("pointerdown", t), this.header.addEventListener("pointerup", a);
787
- function t(n) {
788
- n.preventDefault(), e.position.initX = e.position.x, e.position.initY = e.position.y, e.position.prevX = n.clientX, e.position.prevY = n.clientY, document.addEventListener("pointermove", o);
699
+ function t(d) {
700
+ d.preventDefault(), e.position.initX = e.position.x, e.position.initY = e.position.y, e.position.prevX = d.clientX, e.position.prevY = d.clientY, document.addEventListener("pointermove", o);
789
701
  }
790
- function o(n) {
791
- n.preventDefault(), e.hasBeenDragged || (e.hasBeenDragged = !0, e.wrapper.setAttribute("data-dragged", "true")), e.position.x = e.position.initX + n.clientX - e.position.prevX, e.position.y = e.position.initY + n.clientY - e.position.prevY, e.wrapper.style.transform = "translate3d(" + e.position.x + "px," + e.position.y + "px,0)";
702
+ function o(d) {
703
+ d.preventDefault(), e.hasBeenDragged || (e.hasBeenDragged = !0, e.wrapper.setAttribute("data-dragged", "true")), e.position.x = e.position.initX + d.clientX - e.position.prevX, e.position.y = e.position.initY + d.clientY - e.position.prevY, e.wrapper.style.transform = "translate3d(" + e.position.x + "px," + e.position.y + "px,0)";
792
704
  }
793
- function a(n) {
705
+ function a(d) {
794
706
  document.removeEventListener("pointermove", o);
795
707
  }
796
708
  }
@@ -800,8 +712,8 @@ class b {
800
712
  kill() {
801
713
  this.wrapper.remove();
802
714
  }
803
- _mapLinear(e, t, o, a, n) {
804
- return a + (e - t) * (n - a) / (o - t);
715
+ _mapLinear(e, t, o, a, d) {
716
+ return a + (e - t) * (d - a) / (o - t);
805
717
  }
806
718
  }
807
719
  export {
@@ -1,4 +1,4 @@
1
- (function(x,u){typeof exports=="object"&&typeof module<"u"?module.exports=u():typeof define=="function"&&define.amd?define(u):(x=typeof globalThis<"u"?globalThis:x||self,x["Perfect GUI"]=u())})(this,function(){"use strict";function x(w){return`
1
+ (function(_,g){typeof exports=="object"&&typeof module<"u"?module.exports=g():typeof define=="function"&&define.amd?define(g):(_=typeof globalThis<"u"?globalThis:_||self,_["Perfect GUI"]=g())})(this,function(){"use strict";function _(A){return`
2
2
  .p-gui {
3
3
  --main-border-radius: 5px;
4
4
  --color-bg: #121212;
@@ -7,7 +7,7 @@
7
7
  --color-accent: #1681ca;
8
8
  --color-accent-hover: #218fda;
9
9
 
10
- position: ${w};
10
+ position: ${A};
11
11
  top: 0;
12
12
  left: 0;
13
13
  transform: translate3d(0,0,0);
@@ -273,6 +273,7 @@
273
273
  cursor: pointer;
274
274
  border-radius: 3px;
275
275
  border: 1px solid var(--color-border-2);
276
+ outline: none;
276
277
  }
277
278
 
278
279
  .p-gui__list-dropdown {
@@ -364,6 +365,7 @@
364
365
  flex-wrap: wrap;
365
366
  border: 1px solid grey;
366
367
  padding: 0 3px;
368
+ border-radius: var(--main-border-radius);
367
369
  }
368
370
 
369
371
  .p-gui__folder:last-of-type {
@@ -406,10 +408,10 @@
406
408
  .p-gui__folder--closed .p-gui__folder-arrow {
407
409
  transform: rotate(0deg);
408
410
  }
409
- `}class u{constructor(e={}){if(e.container?(this.container=typeof e.container=="string"?document.querySelector(e.container):e.container,this.position_type="absolute"):(this.container=document.body,this.position_type="fixed"),this.propReferences=[],this.folders=[],e.isFolder){this._folderConstructor(e.folderOptions);return}this.name=e!=null&&typeof e.name=="string"?e.name:"",this.backgroundColor=e.color||null,this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),e.maxHeight&&(this.initMaxHeight=e.maxHeight,this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.screenCorner=this._parseScreenCorner(e.position),this instanceof u&&(typeof u[u.instanceCounter]!="number"?u[u.instanceCounter]=0:u[u.instanceCounter]++),this.instanceId=u[u.instanceCounter],this.wrapperWidth=e.width||290,this.stylesheet=document.createElement("style"),this.stylesheet.setAttribute("type","text/css"),this.stylesheet.setAttribute("id","lm-gui-stylesheet"),document.head.append(this.stylesheet),this.instanceId==0&&this._addStyles(`${x(this.position_type)}`),this._styleInstance(),this._addWrapper(),this.wrapper.setAttribute("data-corner-x",this.screenCorner.x),this.wrapper.setAttribute("data-corner-y",this.screenCorner.y),e.autoRepositioning!=!1&&window.addEventListener("resize",this._handleResize.bind(this)),this._handleResize(),this.hasBeenDragged=!1,e.draggable==!0&&this._makeDraggable(),this.closed=!1,e.closed&&this.toggleClose()}_styleInstance(){let e=this._getScrollbarWidth(this.container);if(this.screenCorner.x=="left"?this.xOffset=0:this.xOffset=this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(".p-gui");for(let o=0;o<t.length;o++)this.screenCorner.y==t[o].dataset.cornerY&&(this.screenCorner.x=="left"&&t[o].dataset.cornerX=="left"?this.xOffset+=t[o].offsetWidth:this.screenCorner.x=="right"&&t[o].dataset.cornerX=="right"&&(this.xOffset-=t[o].offsetWidth))}this.yOffset=0,this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this._addStyles(`#p-gui-${this.instanceId} {
411
+ `}class g{constructor(e={}){if(e.container?(this.container=typeof e.container=="string"?document.querySelector(e.container):e.container,this.position_type="absolute"):(this.container=document.body,this.position_type="fixed"),this.propReferences=[],this.folders=[],e.isFolder){this._folderConstructor(e.folderOptions);return}this.name=e!=null&&typeof e.name=="string"?e.name:"",this.backgroundColor=e.color||null,this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),e.maxHeight&&(this.initMaxHeight=e.maxHeight,this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.screenCorner=this._parseScreenCorner(e.position),this instanceof g&&(typeof g[g.instanceCounter]!="number"?g[g.instanceCounter]=0:g[g.instanceCounter]++),this.instanceId=g[g.instanceCounter],this.wrapperWidth=e.width||290,this.stylesheet=document.createElement("style"),this.stylesheet.setAttribute("type","text/css"),this.stylesheet.setAttribute("id","lm-gui-stylesheet"),document.head.append(this.stylesheet),this.instanceId==0&&this._addStyles(`${_(this.position_type)}`),this._styleInstance(),this._addWrapper(),this.wrapper.setAttribute("data-corner-x",this.screenCorner.x),this.wrapper.setAttribute("data-corner-y",this.screenCorner.y),e.autoRepositioning!=!1&&window.addEventListener("resize",this._handleResize.bind(this)),this._handleResize(),this.hasBeenDragged=!1,e.draggable==!0&&this._makeDraggable(),this.closed=!1,e.closed&&this.toggleClose()}_styleInstance(){let e=this._getScrollbarWidth(this.container);if(this.screenCorner.x=="left"?this.xOffset=0:this.xOffset=this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(".p-gui");for(let o=0;o<t.length;o++)this.screenCorner.y==t[o].dataset.cornerY&&(this.screenCorner.x=="left"&&t[o].dataset.cornerX=="left"?this.xOffset+=t[o].offsetWidth:this.screenCorner.x=="right"&&t[o].dataset.cornerX=="right"&&(this.xOffset-=t[o].offsetWidth))}this.yOffset=0,this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this._addStyles(`#p-gui-${this.instanceId} {
410
412
  width: ${this.wrapperWidth}px;
411
413
  max-height: ${this.maxHeight}px;
412
414
  transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
413
415
  ${this.screenCorner.y=="top"?"":"top: auto; bottom: 0;"}
414
416
  ${this.backgroundColor?"background: "+this.backgroundColor+";":""}
415
- }`)}_folderConstructor(e){this.wrapper=e.wrapper}_parseScreenCorner(e){let t={x:"right",y:"top"};return e==null||(typeof e!="string"&&console.error("[perfect-gui] Position must be a string."),e.includes("left")&&(t.x="left"),e.includes("bottom")&&(t.y="bottom")),t}_getScrollbarWidth(e){return e===document.body?window.innerWidth-document.documentElement.clientWidth:e.offsetWidth-e.clientWidth}_handleResize(){if(this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),this.initMaxHeight&&(this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.wrapper.style.maxHeight=this.maxHeight+"px",this.hasBeenDragged)return;let e=this._getScrollbarWidth(this.container);if(this.xOffset=this.screenCorner.x=="left"?0:this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(`.p-gui:not(#${this.wrapper.id}):not([data-dragged])`);for(let o=0;o<t.length&&!(parseInt(t[o].id.replace("p-gui-",""))>this.instanceId);o++)this.screenCorner.y==t[o].dataset.cornerY&&(this.screenCorner.x=="left"&&t[o].dataset.cornerX=="left"?this.xOffset+=t[o].offsetWidth:this.screenCorner.x=="right"&&t[o].dataset.cornerX=="right"&&(this.xOffset-=t[o].offsetWidth))}this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this.wrapper.style.transform=`translate3d(${this.position.x}px, ${this.position.y}px, 0)`}_createElement(e){e.el=e.el||"div";var t=document.createElement(e.el);if(e.id&&(t.id=e.id),e.class&&(t.className=e.class),e.inline&&(t.style=e.inline),e.href&&(t.href=e.href),e.onclick&&(t.onclick=e.onclick),e.onchange&&(t.onchange=e.onchange),e.textContent&&(t.textContent=e.textContent),e.innerHTML&&(t.innerHTML=e.innerHTML),e.type&&(t.type=e.type),e.value&&(t.value=e.value),e.customAttributes)for(var o in e.customAttributes)t.setAttribute(o,e.customAttributes[o]);return e.parent=e.parent?e.parent:this.wrapper,e.parent.append(t),t}_addStyles(e){this.stylesheet.innerHTML+=e}_addWrapper(){this.wrapper=this._createElement({parent:this.container,id:"p-gui-"+this.instanceId,class:"p-gui"}),this.header=this._createElement({parent:this.wrapper,class:"p-gui__header",textContent:this.name,inline:`${this.backgroundColor?"border-color: "+this.backgroundColor+";":""}`}),this._createElement({parent:this.header,class:"p-gui__header-close",onclick:this.toggleClose.bind(this)})}button(e,t){let o="";typeof e!="string"?typeof e=="object"&&(e!=null&&e.hasOwnProperty("name"))?o=e.name==""?" ":e.name:o=" ":o=e==""?" ":e,this.imageContainer=null,typeof t!="function"&&(t=()=>{});const a=this._createElement({class:"p-gui__button",textContent:o,onclick:t});typeof e.color=="string"&&(a.style.setProperty("--color-accent",e.color),a.style.setProperty("--color-accent-hover",e.hoverColor||e.color))}image(e={},t){if(typeof e!="object")throw Error(`[GUI] image() first parameter must be an object. Received: ${typeof e}.`);let o;if(typeof e.path=="string")o=e.path;else throw typeof e.path==null?Error("[GUI] image() path must be provided."):Error("[GUI] image() path must be a string.");let a=o.replace(/^.*[\\\/]/,""),n;e.name==null?n=a:n=typeof e.name=="string"&&e.name||" ";const r=e.selected===!0,i=e.selectionBorder!==!1;let s="";e.width&&(typeof e.width=="number"&&(e.width+="px"),s+=`flex: 0 0 calc(${e.width} - 5px); `),e.height&&(typeof e.height=="number"&&(e.height+="px"),s+=`height: ${e.height}; `),this.imageContainer||(this.imageContainer=this._createElement({class:"p-gui__image-container"}));var l=this._createElement({class:"p-gui__image",inline:"background-image: url("+o+"); "+s,parent:this.imageContainer});return r&&i&&l.classList.add("p-gui__image--selected"),this._createElement({parent:l,class:"p-gui__image-text",textContent:n}),l.onclick=()=>{let c=l.parentElement.querySelectorAll(".p-gui__image--selected");for(let d=0;d<c.length;d++)c[d].classList.remove("p-gui__image--selected");i&&l.classList.add("p-gui__image--selected"),typeof t=="function"&&t({path:o,text:n})},l}slider(e={},t){if(typeof e!="object")throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ",a=!1,n=null,r=e.obj||e.object,i=e.prop||e.property,s=typeof e.value=="number"?e.value:null,l=e.min??0,c=e.max??1,d=e.step||(c-l)/100;if(s!==null)(i!=null||r!=null)&&console.warn('[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.');else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);o==" "&&(o=i),n=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'),s=(c-l)/2;this.imageContainer=null;var p=this._createElement({class:"p-gui__slider",textContent:o}),f=this._createElement({parent:p,el:"input",class:"p-gui__slider-ctrl",customAttributes:{type:"range",min:l,max:c,step:d,value:a?r[i]:s}}),b=this._createElement({parent:p,class:"p-gui__slider-value",textContent:String(a?r[i]:s)});f.addEventListener("input",()=>{b.textContent=f.value,a?r[i]=f.value:typeof t=="function"&&t(parseFloat(f.value))}),a&&Object.defineProperty(r,i,{set:_=>{this.propReferences[n]=_,f.value=_,b.textContent=String(_),typeof t=="function"&&t(parseFloat(f.value))},get:()=>this.propReferences[n]})}toggle(e={},t){if(typeof e!="object")throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ",a=!1,n=null,r=e.obj||e.object,i=e.prop||e.property,s=typeof e.value=="boolean"?e.value:null;if(s!==null)(i!=null||r!=null)&&console.warn('[GUI] toggle() "obj" and "property" parameters are ignored when a "value" parameter is used.');else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] toggle() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] toggle() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);o==" "&&(o=i),n=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');this.imageContainer=null;const l=this._createElement({class:"p-gui__switch",onclick:p=>{const f=p.target.childNodes[1];let b=!0;f.classList.contains("p-gui__switch-checkbox--active")&&(b=!1),f.classList.toggle("p-gui__switch-checkbox--active"),a?r[i]=b:typeof t=="function"&&t(b)},textContent:o});let c=(()=>a?r[i]?" p-gui__switch-checkbox--active":"":s?" p-gui__switch-checkbox--active":"")();const d=this._createElement({parent:l,class:"p-gui__switch-checkbox"+c});a&&Object.defineProperty(r,i,{set:p=>{this.propReferences[n]=p,p?d.classList.add("p-gui__switch-checkbox--active"):d.classList.remove("p-gui__switch-checkbox--active"),typeof t=="function"&&t(p)},get:()=>this.propReferences[n]})}list(e={},t){if(typeof e!="object")throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"?e.name:" ",a=!1,n=null,r=e.obj||e.object,i=e.prop||e.property,s=Array.isArray(e.values)?e.values:null,l;if(t=typeof t=="function"?t:null,e.value!==void 0||e.value===void 0&&r===void 0&&i===void 0)(i!=null||r!=null)&&console.warn('[GUI] list() "obj" and "property" parameters are ignored when a "value" parameter is used.'),l=(()=>{if(!s)return null;if(typeof e.value=="string")return s.indexOf(e.value);if(typeof e.value=="number")return e.value})();else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] list() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] list() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);l=(()=>{if(!s)return null;if(typeof r[i]=="string")return s.indexOf(r[i]);if(typeof r[i]=="number")return r[i]})(),n=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');this.imageContainer=null;let c=this._createElement({class:"p-gui__list",textContent:o}),d=this._createElement({parent:c,el:"select",class:"p-gui__list-dropdown",onchange:p=>{a?r[i]=p.target.value:t&&t(p.target.value)}});s&&s.forEach((p,f)=>{let b=this._createElement({parent:d,el:"option",customAttributes:{value:p},textContent:p});l==f&&b.setAttribute("selected","")}),a&&Object.defineProperty(r,i,{set:p=>{typeof p=="string"&&(l=s.indexOf(p)),typeof p=="number"&&(l=p),this.propReferences[n]=l,d.querySelector("[selected]").removeAttribute("selected"),d.querySelectorAll("option")[l].setAttribute("selected",""),typeof t=="function"&&t(l)},get:()=>this.propReferences[n]})}options(e,t){if(typeof e!="object")throw Error(`[GUI] options() first parameter must be an object. Received: ${typeof e}.`);this.list(e,t)}vector2(e={},t){if(typeof e!="object")throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ";const a=e.x.min??0,n=e.x.max??1,r=e.y.min??0,i=e.y.max??1,s=e.x.obj||e.x.object,l=e.x.prop||e.x.property,c=this.propReferences.push(s[l])-1,d=e.y.obj||e.y.object,p=e.y.prop||e.y.property,f=this.propReferences.push(d[p])-1;t=typeof t=="function"?t:null,this.imageContainer=null;const b=this._createElement({class:"p-gui__vector2",textContent:o}),_=this._createElement({parent:b,class:"p-gui__vector-value",textContent:s[l]+", "+d[p]}),h=this._createElement({parent:b,el:"div",class:"p-gui__vector2-area",onclick:g=>{s[l]=parseFloat(this._mapLinear(g.offsetX,0,h.clientWidth,a,n).toFixed(2)),d[p]=parseFloat(this._mapLinear(g.offsetY,0,h.clientHeight,i,r).toFixed(2)),t&&t(s[l],s[p])}});let m=!1;h.addEventListener("pointerdown",g=>{m=!0}),h.addEventListener("pointerup",()=>{m=!1}),h.addEventListener("pointermove",g=>{m&&(s[l]=parseFloat(this._mapLinear(g.offsetX,0,h.clientWidth,a,n).toFixed(2)),d[p]=parseFloat(this._mapLinear(g.offsetY,0,h.clientHeight,i,r).toFixed(2)),t&&t(s[l],s[p]))}),this._createElement({parent:h,class:"p-gui__vector2-line p-gui__vector2-line-x"}),this._createElement({parent:h,class:"p-gui__vector2-line p-gui__vector2-line-y"});const y=this._createElement({parent:h,class:"p-gui__vector2-dot"});y.style.left=this._mapLinear(s[l],a,n,0,h.clientWidth)+"px",y.style.top=this._mapLinear(d[p],r,i,h.clientHeight,0)+"px",Object.defineProperty(s,l,{set:g=>{this.propReferences[c]=g,y.style.left=this._mapLinear(g,a,n,0,h.clientWidth)+"px",_.textContent=String(g)+", "+d[p]},get:()=>this.propReferences[c]}),Object.defineProperty(d,p,{set:g=>{this.propReferences[f]=g,y.style.top=this._mapLinear(g,r,i,h.clientHeight,0)+"px",_.textContent=s[l]+", "+String(g)},get:()=>this.propReferences[f]})}color(e={},t){if(typeof e!="object")throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ",a=!1,n=null,r=e.obj||e.object,i=e.prop||e.property,s;if(typeof e.value=="string"&&(e.value.length!=7||e.value[0]!="#"?console.error(`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${e.value}".`):s=e.value),s||(s="#000000"),e.value!==void 0)(i!=null||r!=null)&&console.warn('[GUI] color() "obj" and "property" parameters are ignored when a "value" parameter is used.');else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] color() "prop" (or "property") parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] color() "obj" (or "object") parameter must be an object. Received: ${typeof r}.`);o==" "&&(o=i),n=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');this.imageContainer=null;const l=this._createElement({el:"div",class:"p-gui__color",textContent:o}),c=this._createElement({parent:l,el:"input",class:"p-gui__color-picker",type:"color",value:s});typeof t=="function"&&c.addEventListener("input",()=>{a?r[i]=c.value:typeof t=="function"&&t(c.value)}),a&&Object.defineProperty(r,i,{set:d=>{this.propReferences[n]=d,c.value=d,typeof t=="function"&&t(d)},get:()=>this.propReferences[n]})}folder(e={}){let t=typeof e.closed=="boolean"?e.closed:!1,o=e.name||"",a=e.color||null,n=e.maxHeight||null;this.imageContainer=null;let r="p-gui__folder";this.folders.length==0&&(r+=" p-gui__folder--first"),t&&(r+=" p-gui__folder--closed");let i=a?`background-color: ${a};`:"";i+=n?`max-height: ${n}px;`:"";let s=this._createElement({class:r,inline:i});this._createElement({innerHTML:`<span class="p-gui__folder-arrow"></span>${o}`,class:"p-gui__folder-header",onclick:function(){this.parentNode.classList.toggle("p-gui__folder--closed")},parent:s});let l=new u({isFolder:!0,folderOptions:{wrapper:s}});return this.folders.push(l),l}_makeDraggable(){var e=this;this.header.addEventListener("pointerdown",t),this.header.addEventListener("pointerup",a);function t(n){n.preventDefault(),e.position.initX=e.position.x,e.position.initY=e.position.y,e.position.prevX=n.clientX,e.position.prevY=n.clientY,document.addEventListener("pointermove",o)}function o(n){n.preventDefault(),e.hasBeenDragged||(e.hasBeenDragged=!0,e.wrapper.setAttribute("data-dragged","true")),e.position.x=e.position.initX+n.clientX-e.position.prevX,e.position.y=e.position.initY+n.clientY-e.position.prevY,e.wrapper.style.transform="translate3d("+e.position.x+"px,"+e.position.y+"px,0)"}function a(n){document.removeEventListener("pointermove",o)}}toggleClose(){this.closed=!this.closed,this.wrapper.classList.toggle("p-gui--collapsed")}kill(){this.wrapper.remove()}_mapLinear(e,t,o,a,n){return a+(e-t)*(n-a)/(o-t)}}return u});
417
+ }`)}_folderConstructor(e){this.wrapper=e.wrapper}_parseScreenCorner(e){let t={x:"right",y:"top"};return e==null||(typeof e!="string"&&console.error("[perfect-gui] Position must be a string."),e.includes("left")&&(t.x="left"),e.includes("bottom")&&(t.y="bottom")),t}_getScrollbarWidth(e){return e===document.body?window.innerWidth-document.documentElement.clientWidth:e.offsetWidth-e.clientWidth}_handleResize(){if(this.container==document.body?this.maxHeight=window.innerHeight:this.maxHeight=Math.min(this.container.clientHeight,window.innerHeight),this.initMaxHeight&&(this.maxHeight=Math.min(this.initMaxHeight,this.maxHeight)),this.wrapper.style.maxHeight=this.maxHeight+"px",this.hasBeenDragged)return;let e=this._getScrollbarWidth(this.container);if(this.xOffset=this.screenCorner.x=="left"?0:this.container.clientWidth-this.wrapperWidth-e,this.instanceId>0){let t=this.container.querySelectorAll(`.p-gui:not(#${this.wrapper.id}):not([data-dragged])`);for(let o=0;o<t.length&&!(parseInt(t[o].id.replace("p-gui-",""))>this.instanceId);o++)this.screenCorner.y==t[o].dataset.cornerY&&(this.screenCorner.x=="left"&&t[o].dataset.cornerX=="left"?this.xOffset+=t[o].offsetWidth:this.screenCorner.x=="right"&&t[o].dataset.cornerX=="right"&&(this.xOffset-=t[o].offsetWidth))}this.position={prevX:this.xOffset,prevY:this.yOffset,x:this.xOffset,y:this.yOffset},this.wrapper.style.transform=`translate3d(${this.position.x}px, ${this.position.y}px, 0)`}_addStyles(e){this.stylesheet.innerHTML+=e}_addWrapper(){this.wrapper=document.createElement("div"),this.wrapper.id="p-gui-"+this.instanceId,this.wrapper.className="p-gui",this.container.append(this.wrapper),this.header=document.createElement("div"),this.header.className="p-gui__header",this.header.textContent=this.name,this.header.style=`${this.backgroundColor?"border-color: "+this.backgroundColor+";":""}`,this.wrapper.append(this.header);const e=document.createElement("div");e.className="p-gui__header-close",e.addEventListener("click",this.toggleClose.bind(this)),this.header.append(e)}button(e,t){let o="";typeof e!="string"?typeof e=="object"&&(e!=null&&e.hasOwnProperty("name"))?o=e.name==""?" ":e.name:o=" ":o=e==""?" ":e,this.imageContainer=null,typeof t!="function"&&(t=()=>{});const a=document.createElement("div");a.className="p-gui__button",a.textContent=o,a.addEventListener("click",t),this.wrapper.append(a),typeof e.color=="string"&&(a.style.setProperty("--color-accent",e.color),a.style.setProperty("--color-accent-hover",e.hoverColor||e.color))}image(e={},t){if(typeof e!="object")throw Error(`[GUI] image() first parameter must be an object. Received: ${typeof e}.`);let o;if(typeof e.path=="string")o=e.path;else throw typeof e.path==null?Error("[GUI] image() path must be provided."):Error("[GUI] image() path must be a string.");let a=o.replace(/^.*[\\\/]/,""),d;e.name==null?d=a:d=typeof e.name=="string"&&e.name||" ";const r=e.selected===!0,i=e.selectionBorder!==!1;let s="";e.width&&(typeof e.width=="number"&&(e.width+="px"),s+=`flex: 0 0 calc(${e.width} - 5px); `),e.height&&(typeof e.height=="number"&&(e.height+="px"),s+=`height: ${e.height}; `),this.imageContainer||(this.imageContainer=document.createElement("div"),this.imageContainer.className="p-gui__image-container",this.wrapper.append(this.imageContainer));const n=document.createElement("div");n.className="p-gui__image",n.style="background-image: url("+o+"); "+s,this.imageContainer.append(n),r&&i&&n.classList.add("p-gui__image--selected");const l=document.createElement("div");return l.className="p-gui__image-text",l.textContent=d,n.append(l),n.addEventListener("click",()=>{let c=n.parentElement.querySelectorAll(".p-gui__image--selected");for(let p=0;p<c.length;p++)c[p].classList.remove("p-gui__image--selected");i&&n.classList.add("p-gui__image--selected"),typeof t=="function"&&t({path:o,text:d})}),n}slider(e={},t){if(typeof e!="object")throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ",a=!1,d=null,r=e.obj,i=e.prop,s=typeof e.value=="number"?e.value:null,n=e.min??0,l=e.max??1,c=e.step||(l-n)/100;if(s!==null)(i!=null||r!=null)&&console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof r}.`);o==" "&&(o=i),d=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'),s=(l-n)/2;this.imageContainer=null;const p=document.createElement("div");p.className="p-gui__slider",p.textContent=o,this.wrapper.append(p);const u=document.createElement("input");u.className="p-gui__slider-ctrl",u.setAttribute("type","range"),u.setAttribute("min",n),u.setAttribute("max",l),u.setAttribute("step",c),u.setAttribute("value",a?r[i]:s),p.append(u);const f=document.createElement("div");f.className="p-gui__slider-value",f.textContent=String(a?r[i]:s),p.append(f),u.addEventListener("input",()=>{f.textContent=u.value,a?r[i]=u.value:typeof t=="function"&&t(parseFloat(u.value))}),a&&Object.defineProperty(r,i,{set:m=>{this.propReferences[d]=m,u.value=m,f.textContent=String(m),typeof t=="function"&&t(parseFloat(u.value))},get:()=>this.propReferences[d]})}toggle(e={},t){if(typeof e!="object")throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ",a=!1,d=null,r=e.obj,i=e.prop,s=typeof e.value=="boolean"?e.value:null;if(s!==null)(i!=null||r!=null)&&console.warn('[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.');else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof r}.`);o==" "&&(o=i),d=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');this.imageContainer=null;const n=document.createElement("div");n.textContent=o,n.className="p-gui__switch",this.wrapper.append(n),n.addEventListener("click",p=>{const u=p.target.childNodes[1];let f=!0;u.classList.contains("p-gui__switch-checkbox--active")&&(f=!1),u.classList.toggle("p-gui__switch-checkbox--active"),a?r[i]=f:typeof t=="function"&&t(f)});let l=(()=>a?r[i]?" p-gui__switch-checkbox--active":"":s?" p-gui__switch-checkbox--active":"")();const c=document.createElement("div");c.className="p-gui__switch-checkbox"+l,n.append(c),a&&Object.defineProperty(r,i,{set:p=>{this.propReferences[d]=p,p?c.classList.add("p-gui__switch-checkbox--active"):c.classList.remove("p-gui__switch-checkbox--active"),typeof t=="function"&&t(p)},get:()=>this.propReferences[d]})}list(e={},t){if(typeof e!="object")throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"?e.name:" ",a=!1,d=null,r=e.obj,i=e.prop,s=Array.isArray(e.values)?e.values:null,n;if(t=typeof t=="function"?t:null,e.value!==void 0||e.value===void 0&&r===void 0&&i===void 0)(i!=null||r!=null)&&console.warn('[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.'),n=(()=>{if(!s)return null;if(typeof e.value=="string")return s.indexOf(e.value);if(typeof e.value=="number")return e.value})();else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof r}.`);n=(()=>{if(!s)return null;if(typeof r[i]=="string")return s.indexOf(r[i]);if(typeof r[i]=="number")return r[i]})(),d=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');this.imageContainer=null;let l=document.createElement("div");l.className="p-gui__list",l.textContent=o,this.wrapper.append(l);let c=document.createElement("select");l.append(c),c.className="p-gui__list-dropdown",c.addEventListener("change",p=>{a?r[i]=p.target.value:t&&t(p.target.value)}),s&&s.forEach((p,u)=>{let f=document.createElement("option");f.setAttribute("value",p),f.textContent=p,c.append(f),n==u&&f.setAttribute("selected","")}),a&&Object.defineProperty(r,i,{set:p=>{typeof p=="string"&&(n=s.indexOf(p)),typeof p=="number"&&(n=p),this.propReferences[d]=n,c.querySelector("[selected]").removeAttribute("selected"),c.querySelectorAll("option")[n].setAttribute("selected",""),typeof t=="function"&&t(n)},get:()=>this.propReferences[d]})}options(e,t){if(typeof e!="object")throw Error(`[GUI] options() first parameter must be an object. Received: ${typeof e}.`);this.list(e,t)}vector2(e={},t){if(typeof e!="object")throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ";const a=e.x.min??0,d=e.x.max??1,r=e.y.min??0,i=e.y.max??1,s=e.x.obj,n=e.x.prop,l=this.propReferences.push(s[n])-1,c=e.y.obj,p=e.y.prop,u=this.propReferences.push(c[p])-1;t=typeof t=="function"?t:null,this.imageContainer=null;const f=document.createElement("div");f.className="p-gui__vector2",f.textContent=o,this.wrapper.append(f);const m=document.createElement("div");m.className="p-gui__vector-value",m.textContent=s[n]+", "+c[p],f.append(m);const h=document.createElement("div");h.className="p-gui__vector2-area",f.append(h),h.addEventListener("click",b=>{s[n]=parseFloat(this._mapLinear(b.offsetX,0,h.clientWidth,a,d).toFixed(2)),c[p]=parseFloat(this._mapLinear(b.offsetY,0,h.clientHeight,i,r).toFixed(2)),t&&t(s[n],s[p])});let w=!1;h.addEventListener("pointerdown",b=>{w=!0}),h.addEventListener("pointerup",()=>{w=!1}),h.addEventListener("pointermove",b=>{w&&(s[n]=parseFloat(this._mapLinear(b.offsetX,0,h.clientWidth,a,d).toFixed(2)),c[p]=parseFloat(this._mapLinear(b.offsetY,0,h.clientHeight,i,r).toFixed(2)),t&&t(s[n],s[p]))});const v=document.createElement("div");v.className="p-gui__vector2-line p-gui__vector2-line-x",h.append(v);const y=document.createElement("div");y.className="p-gui__vector2-line p-gui__vector2-line-y",h.append(y);const x=document.createElement("div");x.className="p-gui__vector2-dot",h.append(x),x.style.left=this._mapLinear(s[n],a,d,0,h.clientWidth)+"px",x.style.top=this._mapLinear(c[p],r,i,h.clientHeight,0)+"px",Object.defineProperty(s,n,{set:b=>{this.propReferences[l]=b,x.style.left=this._mapLinear(b,a,d,0,h.clientWidth)+"px",m.textContent=String(b)+", "+c[p]},get:()=>this.propReferences[l]}),Object.defineProperty(c,p,{set:b=>{this.propReferences[u]=b,x.style.top=this._mapLinear(b,r,i,h.clientHeight,0)+"px",m.textContent=s[n]+", "+String(b)},get:()=>this.propReferences[u]})}color(e={},t){if(typeof e!="object")throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);let o=typeof e.name=="string"&&e.name||" ",a=!1,d=null,r=e.obj,i=e.prop,s;if(typeof e.value=="string"&&(e.value.length!=7||e.value[0]!="#"?console.error(`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${e.value}".`):s=e.value),s||(s="#000000"),e.value!==void 0)(i!=null||r!=null)&&console.warn('[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.');else if(i!=null&&r!=null){if(typeof i!="string")throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof i}.`);if(typeof r!="object")throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof r}.`);o==" "&&(o=i),d=this.propReferences.push(r[i])-1,a=!0}else(i!=null&&r==null||i==null&&r==null)&&console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');this.imageContainer=null;const n=document.createElement("div");n.className="p-gui__color",n.textContent=o,this.wrapper.append(n);const l=document.createElement("input");l.className="p-gui__color-picker",l.setAttribute("type","color"),l.value=s,n.append(l),typeof t=="function"&&l.addEventListener("input",()=>{a?r[i]=l.value:typeof t=="function"&&t(l.value)}),a&&Object.defineProperty(r,i,{set:c=>{this.propReferences[d]=c,l.value=c,typeof t=="function"&&t(c)},get:()=>this.propReferences[d]})}folder(e={}){let t=typeof e.closed=="boolean"?e.closed:!1,o=e.name||"",a=e.color||null,d=e.maxHeight||null;this.imageContainer=null;let r="p-gui__folder";this.folders.length==0&&(r+=" p-gui__folder--first"),t&&(r+=" p-gui__folder--closed");let i=a?`background-color: ${a};`:"";i+=d?`max-height: ${d}px;`:"";const s=document.createElement("div");s.className=r,s.style=i,this.wrapper.append(s);const n=document.createElement("div");n.innerHTML=`<span class="p-gui__folder-arrow"></span>${o}`,n.className="p-gui__folder-header",s.append(n),n.addEventListener("click",()=>{s.classList.toggle("p-gui__folder--closed")});let l=new g({isFolder:!0,folderOptions:{wrapper:s}});return this.folders.push(l),l}_makeDraggable(){var e=this;this.header.addEventListener("pointerdown",t),this.header.addEventListener("pointerup",a);function t(d){d.preventDefault(),e.position.initX=e.position.x,e.position.initY=e.position.y,e.position.prevX=d.clientX,e.position.prevY=d.clientY,document.addEventListener("pointermove",o)}function o(d){d.preventDefault(),e.hasBeenDragged||(e.hasBeenDragged=!0,e.wrapper.setAttribute("data-dragged","true")),e.position.x=e.position.initX+d.clientX-e.position.prevX,e.position.y=e.position.initY+d.clientY-e.position.prevY,e.wrapper.style.transform="translate3d("+e.position.x+"px,"+e.position.y+"px,0)"}function a(d){document.removeEventListener("pointermove",o)}}toggleClose(){this.closed=!this.closed,this.wrapper.classList.toggle("p-gui--collapsed")}kill(){this.wrapper.remove()}_mapLinear(e,t,o,a,d){return a+(e-t)*(d-a)/(o-t)}}return g});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perfect-gui",
3
- "version": "4.6.5",
3
+ "version": "4.7.2",
4
4
  "description": "Nice and simple GUI for JavaScript",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -172,53 +172,27 @@ export default class GUI {
172
172
  this.position = {prevX:this.xOffset, prevY:this.yOffset, x:this.xOffset, y:this.yOffset};
173
173
  this.wrapper.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`;
174
174
  }
175
-
176
- _createElement(element) {
177
- element.el = element.el || 'div';
178
- var domElement = document.createElement(element.el);
179
- if (element.id) domElement.id = element.id;
180
- if (element.class) domElement.className = element.class;
181
- if (element.inline) domElement.style = element.inline;
182
- if (element.href) domElement.href = element.href;
183
- if (element.onclick) domElement.onclick = element.onclick;
184
- if (element.onchange) domElement.onchange = element.onchange;
185
- if (element.textContent) domElement.textContent = element.textContent;
186
- if (element.innerHTML) domElement.innerHTML = element.innerHTML;
187
- if (element.type) domElement.type = element.type;
188
- if (element.value) domElement.value = element.value;
189
- if (element.customAttributes) {
190
- for (var i in element.customAttributes) {
191
- domElement.setAttribute(i, element.customAttributes[i]);
192
- }
193
- }
194
- element.parent = element.parent ? element.parent : this.wrapper;
195
- element.parent.append(domElement);
196
- return domElement;
197
- }
198
175
 
199
176
  _addStyles(styles) {
200
177
  this.stylesheet.innerHTML += styles;
201
178
  }
202
179
 
203
180
  _addWrapper() {
204
- this.wrapper = this._createElement({
205
- parent: this.container,
206
- id: 'p-gui-'+this.instanceId,
207
- class: 'p-gui'
208
- });
181
+ this.wrapper = document.createElement('div');
182
+ this.wrapper.id = 'p-gui-'+this.instanceId;
183
+ this.wrapper.className = 'p-gui';
184
+ this.container.append(this.wrapper);
209
185
 
210
- this.header = this._createElement({
211
- parent: this.wrapper,
212
- class: 'p-gui__header',
213
- textContent: this.name,
214
- inline: `${ this.backgroundColor ? 'border-color: ' + this.backgroundColor + ';' : ''}`
215
- });
186
+ this.header = document.createElement('div');
187
+ this.header.className = 'p-gui__header';
188
+ this.header.textContent = this.name;
189
+ this.header.style = `${ this.backgroundColor ? 'border-color: ' + this.backgroundColor + ';' : ''}`;
190
+ this.wrapper.append(this.header);
216
191
 
217
- this._createElement({
218
- parent: this.header,
219
- class: 'p-gui__header-close',
220
- onclick: this.toggleClose.bind(this)
221
- });
192
+ const close_btn = document.createElement('div');
193
+ close_btn.className = 'p-gui__header-close';
194
+ close_btn.addEventListener('click', this.toggleClose.bind(this));
195
+ this.header.append(close_btn);
222
196
  }
223
197
 
224
198
  button(options, callback) {
@@ -238,25 +212,12 @@ export default class GUI {
238
212
  if (typeof callback != 'function') {
239
213
  callback = () => {};
240
214
  }
241
-
242
- /* let create_options = {
243
- class: 'p-gui__button',
244
- textContent: name,
245
- onclick: callback
246
- };
247
-
248
- if (typeof options.color == 'string') {
249
- create_options.inline = 'background-color: ' + options.color;
250
- }
251
-
252
- this._createElement(create_options); */
253
215
 
254
-
255
- const el = this._createElement({
256
- class: 'p-gui__button',
257
- textContent: name,
258
- onclick: callback
259
- });
216
+ const el = document.createElement('div');
217
+ el.className = 'p-gui__button';
218
+ el.textContent = name;
219
+ el.addEventListener('click', callback);
220
+ this.wrapper.append(el);
260
221
 
261
222
  if (typeof options.color == 'string') {
262
223
  el.style.setProperty('--color-accent', options.color);
@@ -307,31 +268,28 @@ export default class GUI {
307
268
  }
308
269
 
309
270
  if (!this.imageContainer) {
310
- this.imageContainer = this._createElement({
311
- class: 'p-gui__image-container'
312
- });
271
+ this.imageContainer = document.createElement('div');
272
+ this.imageContainer.className = 'p-gui__image-container';
273
+ this.wrapper.append(this.imageContainer);
313
274
  }
314
275
 
315
- // Image
316
- var image = this._createElement({
317
- class: 'p-gui__image',
318
- inline: 'background-image: url(' + path + '); ' + inline_styles,
319
- parent: this.imageContainer
320
- });
276
+ // Image button
277
+ const image = document.createElement('div');
278
+ image.className = 'p-gui__image';
279
+ image.style = 'background-image: url(' + path + '); ' + inline_styles;
280
+ this.imageContainer.append(image);
321
281
 
322
282
  if (selected && selectionBorder) {
323
283
  image.classList.add('p-gui__image--selected');
324
284
  }
325
285
 
326
286
  // Text inside image
327
- this._createElement({
328
- parent: image,
329
- class: 'p-gui__image-text',
330
- textContent: name
331
- });
287
+ const text = document.createElement('div');
288
+ text.className = 'p-gui__image-text';
289
+ text.textContent = name;
290
+ image.append(text);
332
291
 
333
-
334
- image.onclick = () => {
292
+ image.addEventListener('click', () => {
335
293
  let selected_items = image.parentElement.querySelectorAll('.p-gui__image--selected');
336
294
  for (let i = 0; i < selected_items.length; i++) {
337
295
  selected_items[i].classList.remove('p-gui__image--selected');
@@ -342,7 +300,7 @@ export default class GUI {
342
300
  if (typeof callback == 'function') {
343
301
  callback({ path, text: name });
344
302
  }
345
- };
303
+ });
346
304
 
347
305
  return image;
348
306
  }
@@ -355,8 +313,8 @@ export default class GUI {
355
313
  let name = typeof params.name == 'string' ? params.name || ' ' : ' ';
356
314
  let isObject = false;
357
315
  let propReferenceIndex = null;
358
- let obj = params.obj || params.object;
359
- let prop = params.prop || params.property;
316
+ let obj = params.obj;
317
+ let prop = params.prop;
360
318
  let value = typeof params.value == 'number' ? params.value : null;
361
319
  let min = params.min ?? 0;
362
320
  let max = params.max ?? 1;
@@ -365,16 +323,16 @@ export default class GUI {
365
323
  // callback mode
366
324
  if ( value !== null ) {
367
325
  if (prop != undefined || obj != undefined) {
368
- console.warn(`[GUI] slider() "obj" and "property" parameters are ignored when a "value" parameter is used.`);
326
+ console.warn(`[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.`);
369
327
  }
370
328
  }
371
329
  // object-binding
372
330
  else if (prop != undefined && obj != undefined) {
373
331
  if (typeof prop != 'string') {
374
- throw Error(`[GUI] slider() "prop" (or "property") parameter must be an string. Received: ${typeof prop}.`);
332
+ throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof prop}.`);
375
333
  }
376
334
  if (typeof obj != 'object') {
377
- throw Error(`[GUI] slider() "obj" (or "object") parameter must be an object. Received: ${typeof obj}.`);
335
+ throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof obj}.`);
378
336
  }
379
337
 
380
338
  if (name == ' ') {
@@ -394,29 +352,24 @@ export default class GUI {
394
352
 
395
353
  this.imageContainer = null;
396
354
 
397
- var container = this._createElement({
398
- class: 'p-gui__slider',
399
- textContent: name
400
- });
401
-
402
- var slider_ctrl = this._createElement({
403
- parent: container,
404
- el: 'input',
405
- class: 'p-gui__slider-ctrl',
406
- customAttributes: {
407
- type: 'range',
408
- min,
409
- max,
410
- step,
411
- value: isObject ? obj[prop] : value
412
- }
413
- });
355
+ const container = document.createElement('div');
356
+ container.className = 'p-gui__slider';
357
+ container.textContent = name;
358
+ this.wrapper.append(container);
414
359
 
415
- var slider_value = this._createElement({
416
- parent: container,
417
- class: 'p-gui__slider-value',
418
- textContent: isObject ? String(obj[prop]) : String(value)
419
- });
360
+ const slider_ctrl = document.createElement('input');
361
+ slider_ctrl.className = 'p-gui__slider-ctrl';
362
+ slider_ctrl.setAttribute('type', 'range');
363
+ slider_ctrl.setAttribute('min', min);
364
+ slider_ctrl.setAttribute('max', max);
365
+ slider_ctrl.setAttribute('step', step);
366
+ slider_ctrl.setAttribute('value', isObject ? obj[prop] : value);
367
+ container.append(slider_ctrl);
368
+
369
+ const slider_value = document.createElement('div');
370
+ slider_value.className = 'p-gui__slider-value';
371
+ slider_value.textContent = isObject ? String(obj[prop]) : String(value);
372
+ container.append(slider_value);
420
373
 
421
374
  slider_ctrl.addEventListener('input', () => {
422
375
  slider_value.textContent = slider_ctrl.value;
@@ -457,24 +410,24 @@ export default class GUI {
457
410
  let name = typeof params.name == 'string' ? params.name || ' ' : ' ';
458
411
  let isObject = false;
459
412
  let propReferenceIndex = null;
460
- let obj = params.obj || params.object;
461
- let prop = params.prop || params.property;
413
+ let obj = params.obj;
414
+ let prop = params.prop;
462
415
  let value = typeof params.value === 'boolean' ? params.value : null;
463
416
 
464
417
  // callback mode
465
418
  if ( value !== null ) {
466
419
  if (prop != undefined || obj != undefined) {
467
- console.warn(`[GUI] toggle() "obj" and "property" parameters are ignored when a "value" parameter is used.`);
420
+ console.warn(`[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.`);
468
421
  }
469
422
  }
470
423
 
471
424
  // object-binding
472
425
  else if (prop != undefined && obj != undefined) {
473
426
  if (typeof prop != 'string') {
474
- throw Error(`[GUI] toggle() "prop" (or "property") parameter must be an string. Received: ${typeof prop}.`);
427
+ throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof prop}.`);
475
428
  }
476
429
  if (typeof obj != 'object') {
477
- throw Error(`[GUI] toggle() "obj" (or "object") parameter must be an object. Received: ${typeof obj}.`);
430
+ throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof obj}.`);
478
431
  }
479
432
 
480
433
  if (name == ' ') {
@@ -492,30 +445,31 @@ export default class GUI {
492
445
 
493
446
  this.imageContainer = null;
494
447
 
495
- const container = this._createElement({
496
- class: 'p-gui__switch',
497
- onclick: (ev) => {
498
- const checkbox = ev.target.childNodes[1];
499
-
500
- let value = true;
501
-
502
- if (checkbox.classList.contains('p-gui__switch-checkbox--active')) {
503
- value = false;
504
- }
505
-
506
- checkbox.classList.toggle('p-gui__switch-checkbox--active');
448
+ const container = document.createElement('div');
449
+ container.textContent = name;
450
+ container.className = 'p-gui__switch';
451
+ this.wrapper.append(container);
507
452
 
508
- if ( isObject ) {
509
- obj[prop] = value;
510
- }
511
-
512
- else {
513
- if (typeof callback == 'function') {
514
- callback(value);
515
- }
453
+ container.addEventListener('click', (ev) => {
454
+ const checkbox = ev.target.childNodes[1];
455
+
456
+ let value = true;
457
+
458
+ if (checkbox.classList.contains('p-gui__switch-checkbox--active')) {
459
+ value = false;
460
+ }
461
+
462
+ checkbox.classList.toggle('p-gui__switch-checkbox--active');
463
+
464
+ if ( isObject ) {
465
+ obj[prop] = value;
466
+ }
467
+
468
+ else {
469
+ if (typeof callback == 'function') {
470
+ callback(value);
516
471
  }
517
- },
518
- textContent: name
472
+ }
519
473
  });
520
474
 
521
475
  let activeClass = (() => {
@@ -526,10 +480,9 @@ export default class GUI {
526
480
  }
527
481
  })();
528
482
 
529
- const checkbox = this._createElement({
530
- parent: container,
531
- class: 'p-gui__switch-checkbox' + activeClass
532
- });
483
+ const checkbox = document.createElement('div');
484
+ checkbox.className = 'p-gui__switch-checkbox' + activeClass;
485
+ container.append(checkbox);
533
486
 
534
487
  if ( isObject ) {
535
488
  Object.defineProperty( obj, prop, {
@@ -561,8 +514,8 @@ export default class GUI {
561
514
  let name = typeof params.name == 'string' ? params.name : ' ';
562
515
  let isObject = false;
563
516
  let propReferenceIndex = null;
564
- let obj = params.obj || params.object;
565
- let prop = params.prop || params.property;
517
+ let obj = params.obj;
518
+ let prop = params.prop;
566
519
  let values = Array.isArray(params.values) ? params.values : null;
567
520
  let value;
568
521
 
@@ -572,7 +525,7 @@ export default class GUI {
572
525
  if ( params.value !== undefined ||
573
526
  (params.value === undefined && obj === undefined && prop === undefined)) {
574
527
  if (prop != undefined || obj != undefined) {
575
- console.warn(`[GUI] list() "obj" and "property" parameters are ignored when a "value" parameter is used.`);
528
+ console.warn(`[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.`);
576
529
  }
577
530
 
578
531
  value = (() => {
@@ -588,16 +541,16 @@ export default class GUI {
588
541
  })();
589
542
  }
590
543
 
591
- // object-binding
544
+ // object-binding mode
592
545
  else if (prop != undefined && obj != undefined) {
593
546
  if (typeof prop != 'string') {
594
- throw Error(`[GUI] list() "prop" (or "property") parameter must be an string. Received: ${typeof prop}.`);
547
+ throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof prop}.`);
595
548
  }
596
549
  if (typeof obj != 'object') {
597
- throw Error(`[GUI] list() "obj" (or "object") parameter must be an object. Received: ${typeof obj}.`);
550
+ throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof obj}.`);
598
551
  }
599
552
 
600
- value = (() => {
553
+ value = (() => {
601
554
  if (!values) {
602
555
  return null;
603
556
  }
@@ -620,23 +573,21 @@ export default class GUI {
620
573
 
621
574
  this.imageContainer = null;
622
575
 
623
- let container = this._createElement({
624
- class: 'p-gui__list',
625
- textContent: name
626
- });
576
+ let container = document.createElement('div');
577
+ container.className = 'p-gui__list';
578
+ container.textContent = name;
579
+ this.wrapper.append(container);
627
580
 
628
- let select = this._createElement({
629
- parent: container,
630
- el: 'select',
631
- class: 'p-gui__list-dropdown',
632
- onchange: (ev) => {
633
- if ( isObject ) {
634
- obj[prop] = ev.target.value;
635
- }
581
+ let select = document.createElement('select');
582
+ container.append(select);
583
+ select.className = 'p-gui__list-dropdown';
584
+ select.addEventListener('change', (ev) => {
585
+ if ( isObject ) {
586
+ obj[prop] = ev.target.value;
587
+ }
636
588
 
637
- else if (callback) {
638
- callback(ev.target.value);
639
- }
589
+ else if (callback) {
590
+ callback(ev.target.value);
640
591
  }
641
592
  });
642
593
 
@@ -644,14 +595,11 @@ export default class GUI {
644
595
  {
645
596
  values.forEach((item, index) =>
646
597
  {
647
- let option = this._createElement({
648
- parent: select,
649
- el: 'option',
650
- customAttributes: {
651
- value: item,
652
- },
653
- textContent: item
654
- });
598
+ let option = document.createElement('option');
599
+ option.setAttribute('value', item);
600
+ option.textContent = item;
601
+ select.append(option);
602
+
655
603
  if (value == index) {
656
604
  option.setAttribute('selected', '');
657
605
  }
@@ -703,42 +651,40 @@ export default class GUI {
703
651
  const minY = params.y.min ?? 0;
704
652
  const maxY = params.y.max ?? 1;
705
653
 
706
- const objectX = params.x.obj || params.x.object;
707
- const propX = params.x.prop || params.x.property;
654
+ const objectX = params.x.obj;
655
+ const propX = params.x.prop;
708
656
  const propXReferenceIndex = this.propReferences.push(objectX[propX]) - 1;
709
657
 
710
- const objectY = params.y.obj || params.y.object;
711
- const propY = params.y.prop || params.y.property;
658
+ const objectY = params.y.obj;
659
+ const propY = params.y.prop;
712
660
  const propYReferenceIndex = this.propReferences.push(objectY[propY]) - 1;
713
661
 
714
662
  callback = typeof callback == 'function' ? callback : null;
715
663
 
716
664
  this.imageContainer = null;
717
665
 
718
- const container = this._createElement({
719
- class: 'p-gui__vector2',
720
- textContent: name
721
- });
666
+ const container = document.createElement('div');
667
+ container.className = 'p-gui__vector2';
668
+ container.textContent = name;
669
+ this.wrapper.append(container);
722
670
 
723
- const vector_value = this._createElement({
724
- parent: container,
725
- class: 'p-gui__vector-value',
726
- textContent: objectX[propX] + ', ' + objectY[propY]
727
- });
671
+ const vector_value = document.createElement('div');
672
+ vector_value.className = 'p-gui__vector-value';
673
+ vector_value.textContent = objectX[propX] + ', ' + objectY[propY];
674
+ container.append(vector_value);
728
675
 
729
- const area = this._createElement({
730
- parent: container,
731
- el: 'div',
732
- class: 'p-gui__vector2-area',
733
- onclick: (evt) => {
734
- objectX[propX] = parseFloat(this._mapLinear(evt.offsetX, 0, area.clientWidth, minX, maxX).toFixed(2));
735
- objectY[propY] = parseFloat(this._mapLinear(evt.offsetY, 0, area.clientHeight, maxY, minY).toFixed(2));
676
+ const area = document.createElement('div');
677
+ area.className = 'p-gui__vector2-area';
678
+ container.append(area);
679
+ area.addEventListener('click', evt => {
680
+ objectX[propX] = parseFloat(this._mapLinear(evt.offsetX, 0, area.clientWidth, minX, maxX).toFixed(2));
681
+ objectY[propY] = parseFloat(this._mapLinear(evt.offsetY, 0, area.clientHeight, maxY, minY).toFixed(2));
736
682
 
737
- if (callback) {
738
- callback(objectX[propX], objectX[propY]);
739
- }
740
- },
683
+ if (callback) {
684
+ callback(objectX[propX], objectX[propY]);
685
+ }
741
686
  });
687
+
742
688
  let pointer_is_down = false;
743
689
  area.addEventListener('pointerdown', (evt) => {
744
690
  pointer_is_down = true;
@@ -757,20 +703,17 @@ export default class GUI {
757
703
  }
758
704
  });
759
705
 
760
- this._createElement({
761
- parent: area,
762
- class: 'p-gui__vector2-line p-gui__vector2-line-x'
763
- });
764
-
765
- this._createElement({
766
- parent: area,
767
- class: 'p-gui__vector2-line p-gui__vector2-line-y'
768
- });
706
+ const line_x = document.createElement('div');
707
+ line_x.className = 'p-gui__vector2-line p-gui__vector2-line-x';
708
+ area.append(line_x);
769
709
 
770
- const dot = this._createElement({
771
- parent: area,
772
- class: 'p-gui__vector2-dot'
773
- });
710
+ const line_y = document.createElement('div');
711
+ line_y.className = 'p-gui__vector2-line p-gui__vector2-line-y';
712
+ area.append(line_y);
713
+
714
+ const dot = document.createElement('div');
715
+ dot.className = 'p-gui__vector2-dot';
716
+ area.append(dot);
774
717
 
775
718
  dot.style.left = this._mapLinear(objectX[propX], minX, maxX, 0, area.clientWidth) + 'px';
776
719
  dot.style.top = this._mapLinear(objectY[propY], minY, maxY, area.clientHeight, 0) + 'px';
@@ -807,8 +750,8 @@ export default class GUI {
807
750
 
808
751
  let isObject = false;
809
752
  let propReferenceIndex = null;
810
- let obj = params.obj || params.object;
811
- let prop = params.prop || params.property;
753
+ let obj = params.obj;
754
+ let prop = params.prop;
812
755
  let value;
813
756
 
814
757
  if (typeof params.value == 'string') {
@@ -824,17 +767,17 @@ export default class GUI {
824
767
  // callback mode
825
768
  if ( params.value !== undefined ) {
826
769
  if (prop != undefined || obj != undefined) {
827
- console.warn(`[GUI] color() "obj" and "property" parameters are ignored when a "value" parameter is used.`);
770
+ console.warn(`[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.`);
828
771
  }
829
772
  }
830
773
 
831
774
  // object-binding
832
775
  else if (prop != undefined && obj != undefined) {
833
776
  if (typeof prop != 'string') {
834
- throw Error(`[GUI] color() "prop" (or "property") parameter must be an string. Received: ${typeof prop}.`);
777
+ throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof prop}.`);
835
778
  }
836
779
  if (typeof obj != 'object') {
837
- throw Error(`[GUI] color() "obj" (or "object") parameter must be an object. Received: ${typeof obj}.`);
780
+ throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof obj}.`);
838
781
  }
839
782
 
840
783
  if (name == ' ') {
@@ -852,19 +795,16 @@ export default class GUI {
852
795
 
853
796
  this.imageContainer = null;
854
797
 
855
- const container = this._createElement({
856
- el: 'div',
857
- class: 'p-gui__color',
858
- textContent: name,
859
- });
798
+ const container = document.createElement('div');
799
+ container.className = 'p-gui__color';
800
+ container.textContent = name;
801
+ this.wrapper.append(container);
860
802
 
861
- const colorpicker = this._createElement({
862
- parent: container,
863
- el: 'input',
864
- class: 'p-gui__color-picker',
865
- type: 'color',
866
- value
867
- });
803
+ const colorpicker = document.createElement('input');
804
+ colorpicker.className = 'p-gui__color-picker';
805
+ colorpicker.setAttribute('type', 'color');
806
+ colorpicker.value = value;
807
+ container.append(colorpicker);
868
808
 
869
809
  if (typeof callback == 'function') {
870
810
  colorpicker.addEventListener('input', () => {
@@ -916,19 +856,18 @@ export default class GUI {
916
856
 
917
857
  let container_style = color ? `background-color: ${color};` : '';
918
858
  container_style += maxHeight ? `max-height: ${maxHeight}px;` : '';
859
+
860
+ const container = document.createElement('div');
861
+ container.className = className;
862
+ container.style = container_style;
863
+ this.wrapper.append(container);
919
864
 
920
- let container = this._createElement({
921
- class: className,
922
- inline: container_style,
923
- });
924
-
925
- let folderHeader = this._createElement({
926
- innerHTML: `<span class="p-gui__folder-arrow"></span>${name}`,
927
- class: 'p-gui__folder-header',
928
- onclick: function() {
929
- this.parentNode.classList.toggle('p-gui__folder--closed');
930
- },
931
- parent: container
865
+ const folderHeader = document.createElement('div');
866
+ folderHeader.innerHTML = `<span class="p-gui__folder-arrow"></span>${name}`;
867
+ folderHeader.className = 'p-gui__folder-header';
868
+ container.append(folderHeader);
869
+ folderHeader.addEventListener('click', () => {
870
+ container.classList.toggle('p-gui__folder--closed');
932
871
  });
933
872
 
934
873
  let folder = new GUI({isFolder: true, folderOptions: {
package/src/styles.js CHANGED
@@ -279,6 +279,7 @@ export default function( position_type ) {
279
279
  cursor: pointer;
280
280
  border-radius: 3px;
281
281
  border: 1px solid var(--color-border-2);
282
+ outline: none;
282
283
  }
283
284
 
284
285
  .p-gui__list-dropdown {
@@ -370,6 +371,7 @@ export default function( position_type ) {
370
371
  flex-wrap: wrap;
371
372
  border: 1px solid grey;
372
373
  padding: 0 3px;
374
+ border-radius: var(--main-border-radius);
373
375
  }
374
376
 
375
377
  .p-gui__folder:last-of-type {