@rogieking/figui3 1.0.84 → 1.0.86

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 +7 -1
  2. package/fig.js +9 -12
  3. package/package.json +1 -1
package/example.html CHANGED
@@ -19,7 +19,13 @@
19
19
  <h2>Heading 2</h2>
20
20
  <h3>Heading 3</h3>
21
21
  <br />
22
-
22
+ <fig-dropdown>
23
+ <option>One</option>
24
+ <option>Two</option>
25
+ <option>Three</option>
26
+ <option selected>Four</option>
27
+ </fig-dropdown>
28
+ <br />
23
29
  <fig-slider min="0"
24
30
  max="1"
25
31
  transform="100"
package/fig.js CHANGED
@@ -102,7 +102,6 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
102
102
 
103
103
  connectedCallback() {
104
104
  this.type = this.getAttribute("type") || "select";
105
- this.value = this.getAttribute("value") || "";
106
105
 
107
106
  this.appendChild(this.select);
108
107
  this.shadowRoot.appendChild(this.optionsSlot);
@@ -112,13 +111,10 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
112
111
  this.slotChange.bind(this)
113
112
  );
114
113
 
115
- this.select.addEventListener(
116
- "input",
117
- this.handleDropdownInput.bind(this)
118
- );
114
+ this.select.addEventListener("input", this.#handleSelectInput.bind(this));
119
115
  this.select.addEventListener(
120
116
  "change",
121
- this.handleDropdownChange.bind(this)
117
+ this.#handleSelectChange.bind(this)
122
118
  );
123
119
  }
124
120
 
@@ -134,9 +130,6 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
134
130
  }
135
131
  this.optionsSlot.assignedNodes().forEach((option) => {
136
132
  if (option.nodeName === "OPTION" || option.nodeName === "OPTGROUP") {
137
- if (option.hasAttribute("value") && option.hasAttribute("selected")) {
138
- this.value = option.getAttribute("value");
139
- }
140
133
  this.select.appendChild(option.cloneNode(true));
141
134
  }
142
135
  });
@@ -145,11 +138,12 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
145
138
  }
146
139
  }
147
140
 
148
- handleDropdownInput() {
149
- this.value = this.select.value;
141
+ #handleSelectInput(e) {
142
+ console.log("FigDropdown #handleSelectInput:", e.target.value);
143
+ this.value = e.target.value;
150
144
  this.setAttribute("value", this.value);
151
145
  }
152
- handleDropdownChange() {
146
+ #handleSelectChange() {
153
147
  if (this.type === "dropdown") {
154
148
  this.select.selectedIndex = -1;
155
149
  }
@@ -165,6 +159,8 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
165
159
  }
166
160
  set value(value) {
167
161
  this.setAttribute("value", value);
162
+ this.select.value = value;
163
+ this.select.setAttribute("value", value);
168
164
  }
169
165
  static get observedAttributes() {
170
166
  return ["value", "type"];
@@ -172,6 +168,7 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
172
168
  attributeChangedCallback(name, oldValue, newValue) {
173
169
  if (name === "value") {
174
170
  this.select.value = newValue;
171
+ this.select.setAttribute("value", newValue);
175
172
  }
176
173
  if (name === "type") {
177
174
  this.type = newValue;
package/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.0.84"
3
+ "version": "1.0.86"
4
4
  }