@rogieking/figui3 1.2.4 → 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 +16 -3
- package/fig.js +20 -7
- 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>
|
|
@@ -584,9 +592,14 @@
|
|
|
584
592
|
<fig-field>
|
|
585
593
|
<label>Minimal ranges</label>
|
|
586
594
|
<fig-slider text="true"
|
|
587
|
-
|
|
595
|
+
min="0"
|
|
596
|
+
max="1"
|
|
597
|
+
style="width: 100%;"
|
|
598
|
+
step="0.01"
|
|
599
|
+
transform="100"
|
|
600
|
+
default="0.5"
|
|
588
601
|
variant="minimal"
|
|
589
|
-
value="
|
|
602
|
+
value="0.5"></fig-slider>
|
|
590
603
|
</fig-field>
|
|
591
604
|
<fig-field direction="horizontal">
|
|
592
605
|
<label>Opacity</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);
|
|
@@ -936,7 +947,9 @@ class FigInputText extends HTMLElement {
|
|
|
936
947
|
this.input.focus();
|
|
937
948
|
}
|
|
938
949
|
#transformNumber(value) {
|
|
939
|
-
|
|
950
|
+
let transformed = value === "" ? "" : Number(value) * (this.transform || 1);
|
|
951
|
+
transformed = this.#formatNumber(transformed);
|
|
952
|
+
return transformed;
|
|
940
953
|
}
|
|
941
954
|
#handleInput(e) {
|
|
942
955
|
let value = e.target.value;
|
|
@@ -1127,7 +1140,7 @@ class FigField extends HTMLElement {
|
|
|
1127
1140
|
);
|
|
1128
1141
|
if (this.input && this.label) {
|
|
1129
1142
|
this.label.addEventListener("click", this.focus.bind(this));
|
|
1130
|
-
let inputId = this.input.getAttribute("id") ||
|
|
1143
|
+
let inputId = this.input.getAttribute("id") || figUniqueId();
|
|
1131
1144
|
this.input.setAttribute("id", inputId);
|
|
1132
1145
|
this.label.setAttribute("for", inputId);
|
|
1133
1146
|
}
|
|
@@ -1394,7 +1407,7 @@ class FigCheckbox extends HTMLElement {
|
|
|
1394
1407
|
this.input = document.createElement("input");
|
|
1395
1408
|
this.name = this.getAttribute("name") || "checkbox";
|
|
1396
1409
|
this.value = this.getAttribute("value") || "";
|
|
1397
|
-
this.input.setAttribute("id",
|
|
1410
|
+
this.input.setAttribute("id", figUniqueId());
|
|
1398
1411
|
this.input.setAttribute("name", this.name);
|
|
1399
1412
|
this.input.setAttribute("type", "checkbox");
|
|
1400
1413
|
this.labelElement = document.createElement("label");
|