@rogieking/figui3 1.0.73 → 1.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/fig.js +35 -21
  2. package/package.json +1 -1
package/fig.js CHANGED
@@ -641,23 +641,7 @@ class FigSlider extends HTMLElement {
641
641
  constructor() {
642
642
  super();
643
643
  }
644
- connectedCallback() {
645
- this.value = this.getAttribute("value");
646
- this.default = this.getAttribute("default") || null;
647
- this.type = this.getAttribute("type") || "range";
648
-
649
- const defaults = this.#typeDefaults[this.type];
650
- this.min = this.getAttribute("min") || defaults.min;
651
- this.max = this.getAttribute("max") || defaults.max;
652
- this.step = this.getAttribute("step") || defaults.step;
653
- this.color = this.getAttribute("color") || defaults?.color;
654
- this.units = this.getAttribute("units") || "";
655
- this.disabled = this.getAttribute("disabled") ? true : false;
656
-
657
- if (this.color) {
658
- this.style.setProperty("--color", this.color);
659
- }
660
-
644
+ #getInnerHTML() {
661
645
  let html = "";
662
646
  let slider = `<div class="fig-slider-input-container">
663
647
  <input
@@ -670,7 +654,7 @@ class FigSlider extends HTMLElement {
670
654
  value="${this.value}">
671
655
  ${this.innerHTML}
672
656
  </div>`;
673
- if (this.getAttribute("text")) {
657
+ if (this.text) {
674
658
  html = `${slider}
675
659
  <fig-input-text
676
660
  placeholder="##"
@@ -688,12 +672,13 @@ class FigSlider extends HTMLElement {
688
672
  } else {
689
673
  html = slider;
690
674
  }
691
-
692
- this.innerHTML = html;
693
-
675
+ return html;
676
+ }
677
+ #setupBindings() {
694
678
  //child nodes hack
695
679
  requestAnimationFrame(() => {
696
680
  this.input = this.querySelector("[type=range]");
681
+ this.input.removeEventListener("input", this.handleInput);
697
682
  this.input.addEventListener("input", this.handleInput.bind(this));
698
683
  this.handleInput();
699
684
 
@@ -711,6 +696,7 @@ class FigSlider extends HTMLElement {
711
696
  this.input.setAttribute("list", this.datalist.getAttribute("id"));
712
697
  }
713
698
  if (this.figInputText) {
699
+ this.figInputText.removeEventListener("input", this.handleTextInput);
714
700
  this.figInputText.addEventListener(
715
701
  "input",
716
702
  this.handleTextInput.bind(this)
@@ -718,6 +704,28 @@ class FigSlider extends HTMLElement {
718
704
  }
719
705
  });
720
706
  }
707
+ connectedCallback() {
708
+ this.value = this.getAttribute("value");
709
+ this.default = this.getAttribute("default") || null;
710
+ this.type = this.getAttribute("type") || "range";
711
+
712
+ const defaults = this.#typeDefaults[this.type];
713
+ this.min = this.getAttribute("min") || defaults.min;
714
+ this.max = this.getAttribute("max") || defaults.max;
715
+ this.step = this.getAttribute("step") || defaults.step;
716
+ this.color = this.getAttribute("color") || defaults?.color;
717
+ this.text = this.getAttribute("text") || false;
718
+ this.units = this.getAttribute("units") || "";
719
+ this.disabled = this.getAttribute("disabled") ? true : false;
720
+
721
+ if (this.color) {
722
+ this.style.setProperty("--color", this.color);
723
+ }
724
+
725
+ this.innerHTML = this.#getInnerHTML();
726
+
727
+ this.#setupBindings();
728
+ }
721
729
  static get observedAttributes() {
722
730
  return [
723
731
  "value",
@@ -754,6 +762,12 @@ class FigSlider extends HTMLElement {
754
762
  this.figInputText.setAttribute("disabled", this.disabled);
755
763
  }
756
764
  break;
765
+ case "text":
766
+ case "units":
767
+ this[name] = newValue;
768
+ this.innerHTML = this.#getInnerHTML();
769
+ this.#setupBindings();
770
+ break;
757
771
  default:
758
772
  this[name] = this.input[name] = newValue;
759
773
  this.handleInput();
package/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.0.73"
3
+ "version": "1.0.74"
4
4
  }