@rogieking/figui3 1.0.46 → 1.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/example.html +6 -0
  2. package/fig.js +34 -11
  3. package/package.json +1 -1
package/example.html CHANGED
@@ -96,6 +96,11 @@
96
96
 
97
97
  </fig-combo-input>
98
98
  <br /><br />
99
+ <fig-input-text type="number"
100
+ value="90">
101
+ <span slot="append">°</span>
102
+ </fig-input-text>
103
+ <br /><br />
99
104
  <hstack>
100
105
  <fig-chit type="color"
101
106
  selected="true"
@@ -212,6 +217,7 @@
212
217
  <fig-slider type="opacity"
213
218
  value="0.75"
214
219
  color="#ff0000"
220
+ units="%"
215
221
  text="true"></fig-slider>
216
222
  </fig-field>
217
223
 
package/fig.js CHANGED
@@ -592,6 +592,7 @@ class FigSlider extends HTMLElement {
592
592
  this.max = this.getAttribute("max") || defaults.max;
593
593
  this.step = this.getAttribute("step") || defaults.step;
594
594
  this.color = this.getAttribute("color") || defaults?.color;
595
+ this.units = this.getAttribute("units") || "";
595
596
  this.disabled = this.getAttribute("disabled") ? true : false;
596
597
 
597
598
  if (this.color) {
@@ -619,6 +620,11 @@ class FigSlider extends HTMLElement {
619
620
  max="${this.max}"
620
621
  step="${this.step}"
621
622
  value="${this.value}">
623
+ ${
624
+ this.units
625
+ ? `<span slot="append">${this.units}</span>`
626
+ : ""
627
+ }
622
628
  </fig-input-text>`;
623
629
  } else {
624
630
  html = slider;
@@ -637,6 +643,7 @@ class FigSlider extends HTMLElement {
637
643
  }
638
644
 
639
645
  this.datalist = this.querySelector("datalist");
646
+ this.figInputText = this.querySelector("fig-input-text");
640
647
  this.textInput = this.querySelector("input[type=number]");
641
648
  if (this.datalist) {
642
649
  this.datalist.setAttribute(
@@ -645,8 +652,8 @@ class FigSlider extends HTMLElement {
645
652
  );
646
653
  this.input.setAttribute("list", this.datalist.getAttribute("id"));
647
654
  }
648
- if (this.textInput) {
649
- this.textInput.addEventListener(
655
+ if (this.figInputText) {
656
+ this.figInputText.addEventListener(
650
657
  "input",
651
658
  this.handleTextInput.bind(this)
652
659
  );
@@ -654,7 +661,16 @@ class FigSlider extends HTMLElement {
654
661
  });
655
662
  }
656
663
  static get observedAttributes() {
657
- return ["value", "step", "min", "max", "type", "disabled"];
664
+ return [
665
+ "value",
666
+ "step",
667
+ "min",
668
+ "max",
669
+ "type",
670
+ "disabled",
671
+ "color",
672
+ "units",
673
+ ];
658
674
  }
659
675
 
660
676
  focus() {
@@ -675,14 +691,15 @@ class FigSlider extends HTMLElement {
675
691
  this.disabled = this.input.disabled =
676
692
  newValue === "true" ||
677
693
  (newValue === undefined && newValue !== null);
678
- if (this.textInput) {
679
- this.textInput.disabled = this.disabled;
694
+ if (this.figInputText) {
695
+ this.figInputText.disabled = this.disabled;
696
+ this.figInputText.setAttribute("disabled", this.disabled);
680
697
  }
681
698
  break;
682
699
  default:
683
700
  this[name] = this.input[name] = newValue;
684
- if (this.textInput) {
685
- this.textInput.setAttribute(name, newValue);
701
+ if (this.figInputText) {
702
+ this.figInputText.setAttribute(name, newValue);
686
703
  }
687
704
  this.handleInput();
688
705
  break;
@@ -690,8 +707,8 @@ class FigSlider extends HTMLElement {
690
707
  }
691
708
  }
692
709
  handleTextInput() {
693
- if (this.textInput) {
694
- this.input.value = Number(this.textInput.value);
710
+ if (this.figInputText) {
711
+ this.input.value = Number(this.figInputText.value);
695
712
  this.handleInput();
696
713
  }
697
714
  }
@@ -725,7 +742,7 @@ class FigInputText extends HTMLElement {
725
742
  this.multiline = this.hasAttribute("multiline") || false;
726
743
  this.value = this.getAttribute("value") || "";
727
744
  this.type = this.getAttribute("type") || "text";
728
- this.placeholder = this.getAttribute("placeholder");
745
+ this.placeholder = this.getAttribute("placeholder") || "";
729
746
 
730
747
  let html = `<input
731
748
  type="${this.type}"
@@ -792,9 +809,15 @@ class FigInputText extends HTMLElement {
792
809
  case "label":
793
810
  this.disabled = this.input.disabled = newValue;
794
811
  break;
812
+ case "value":
813
+ this.value = newValue;
814
+ this.handleInput();
815
+ break;
795
816
  default:
796
817
  this[name] = this.input[name] = newValue;
797
- this.input.setAttribute(name, newValue);
818
+ if (this.input) {
819
+ this.input.setAttribute(name, newValue);
820
+ }
798
821
  break;
799
822
  }
800
823
  }
package/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.0.46"
3
+ "version": "1.0.48"
4
4
  }