@rogieking/figui3 1.2.5 → 1.2.6
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.
- package/example.html +9 -1
- package/fig.js +17 -6
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -526,7 +526,7 @@
|
|
|
526
526
|
value="25"
|
|
527
527
|
default="50"
|
|
528
528
|
step="25">
|
|
529
|
-
<datalist
|
|
529
|
+
<datalist>
|
|
530
530
|
<option value="0"></option>
|
|
531
531
|
<option value="25"></option>
|
|
532
532
|
<option value="50"></option>
|
|
@@ -535,6 +535,14 @@
|
|
|
535
535
|
</datalist>
|
|
536
536
|
</fig-slider>
|
|
537
537
|
</fig-field>
|
|
538
|
+
<fig-field>
|
|
539
|
+
<label>Stepper slider (auto)</label>
|
|
540
|
+
<fig-slider type="stepper"
|
|
541
|
+
value="25"
|
|
542
|
+
default="50"
|
|
543
|
+
step="25">
|
|
544
|
+
</fig-slider>
|
|
545
|
+
</fig-field>
|
|
538
546
|
|
|
539
547
|
<fig-field>
|
|
540
548
|
<label>Delta slider</label>
|
package/fig.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function
|
|
1
|
+
function figUniqueId() {
|
|
2
2
|
return Date.now().toString(36) + Math.random().toString(36).substring(2);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function figSupportsPopover() {
|
|
5
5
|
return HTMLElement.prototype.hasOwnProperty("popover");
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -502,7 +502,7 @@ class FigPopover2 extends HTMLElement {
|
|
|
502
502
|
this.#trigger = this;
|
|
503
503
|
this.#delay = Number(this.getAttribute("delay")) || 0;
|
|
504
504
|
this.#action = this.getAttribute("trigger-action") || "click";
|
|
505
|
-
this.#id = `tooltip-${
|
|
505
|
+
this.#id = `tooltip-${figUniqueId()}`;
|
|
506
506
|
if (this.#popover) {
|
|
507
507
|
this.#popover.setAttribute("id", this.#id);
|
|
508
508
|
this.#popover.setAttribute("role", "tooltip");
|
|
@@ -741,9 +741,20 @@ class FigSlider extends HTMLElement {
|
|
|
741
741
|
if (this.datalist) {
|
|
742
742
|
this.datalist.setAttribute(
|
|
743
743
|
"id",
|
|
744
|
-
this.datalist.getAttribute("id") ||
|
|
744
|
+
this.datalist.getAttribute("id") || figUniqueId()
|
|
745
745
|
);
|
|
746
746
|
this.input.setAttribute("list", this.datalist.getAttribute("id"));
|
|
747
|
+
} else if (this.type === "stepper") {
|
|
748
|
+
this.datalist = document.createElement("datalist");
|
|
749
|
+
this.datalist.setAttribute("id", figUniqueId());
|
|
750
|
+
let steps = (this.max - this.min) / this.step + 1;
|
|
751
|
+
for (let i = 0; i < steps; i++) {
|
|
752
|
+
let option = document.createElement("option");
|
|
753
|
+
option.setAttribute("value", this.min + i * this.step);
|
|
754
|
+
this.datalist.append(option);
|
|
755
|
+
}
|
|
756
|
+
this.append(this.datalist);
|
|
757
|
+
this.input.setAttribute("list", this.datalist.getAttribute("id"));
|
|
747
758
|
}
|
|
748
759
|
if (this.figInputText) {
|
|
749
760
|
this.figInputText.removeEventListener("input", this.handleTextInput);
|
|
@@ -1129,7 +1140,7 @@ class FigField extends HTMLElement {
|
|
|
1129
1140
|
);
|
|
1130
1141
|
if (this.input && this.label) {
|
|
1131
1142
|
this.label.addEventListener("click", this.focus.bind(this));
|
|
1132
|
-
let inputId = this.input.getAttribute("id") ||
|
|
1143
|
+
let inputId = this.input.getAttribute("id") || figUniqueId();
|
|
1133
1144
|
this.input.setAttribute("id", inputId);
|
|
1134
1145
|
this.label.setAttribute("for", inputId);
|
|
1135
1146
|
}
|
|
@@ -1396,7 +1407,7 @@ class FigCheckbox extends HTMLElement {
|
|
|
1396
1407
|
this.input = document.createElement("input");
|
|
1397
1408
|
this.name = this.getAttribute("name") || "checkbox";
|
|
1398
1409
|
this.value = this.getAttribute("value") || "";
|
|
1399
|
-
this.input.setAttribute("id",
|
|
1410
|
+
this.input.setAttribute("id", figUniqueId());
|
|
1400
1411
|
this.input.setAttribute("name", this.name);
|
|
1401
1412
|
this.input.setAttribute("type", "checkbox");
|
|
1402
1413
|
this.labelElement = document.createElement("label");
|