@rogieking/figui3 1.2.2 → 1.2.4
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 +28 -0
- package/fig.js +20 -2
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -553,6 +553,34 @@
|
|
|
553
553
|
<fig-spinner></fig-spinner>
|
|
554
554
|
|
|
555
555
|
<h2>Misc.</h2>
|
|
556
|
+
<hstack>
|
|
557
|
+
<fig-tooltip text="Tooltip"
|
|
558
|
+
delay="0">
|
|
559
|
+
<fig-chit />
|
|
560
|
+
</fig-tooltip>
|
|
561
|
+
<fig-tooltip text="Tooltip"
|
|
562
|
+
delay="0">
|
|
563
|
+
<fig-chit />
|
|
564
|
+
</fig-tooltip>
|
|
565
|
+
<fig-tooltip text="Tooltip"
|
|
566
|
+
delay="0">
|
|
567
|
+
<fig-chit />
|
|
568
|
+
</fig-tooltip>
|
|
569
|
+
<fig-tooltip text="Tooltip"
|
|
570
|
+
delay="0">
|
|
571
|
+
<fig-chit />
|
|
572
|
+
</fig-tooltip>
|
|
573
|
+
<fig-tooltip text="Tooltip"
|
|
574
|
+
delay="0">
|
|
575
|
+
<fig-chit />
|
|
576
|
+
</fig-tooltip>
|
|
577
|
+
<fig-tooltip text="Tooltip"
|
|
578
|
+
delay="0">
|
|
579
|
+
<fig-chit />
|
|
580
|
+
</fig-tooltip>
|
|
581
|
+
|
|
582
|
+
</hstack>
|
|
583
|
+
|
|
556
584
|
<fig-field>
|
|
557
585
|
<label>Minimal ranges</label>
|
|
558
586
|
<fig-slider text="true"
|
package/fig.js
CHANGED
|
@@ -204,7 +204,8 @@ class FigTooltip extends HTMLElement {
|
|
|
204
204
|
constructor() {
|
|
205
205
|
super();
|
|
206
206
|
this.action = this.getAttribute("action") || "hover";
|
|
207
|
-
|
|
207
|
+
let delay = parseInt(this.getAttribute("delay"));
|
|
208
|
+
this.delay = !isNaN(delay) ? delay : 500;
|
|
208
209
|
this.isOpen = false;
|
|
209
210
|
}
|
|
210
211
|
connectedCallback() {
|
|
@@ -318,6 +319,18 @@ class FigTooltip extends HTMLElement {
|
|
|
318
319
|
this.hidePopup();
|
|
319
320
|
}
|
|
320
321
|
}
|
|
322
|
+
static get observedAttributes() {
|
|
323
|
+
return ["action", "delay"];
|
|
324
|
+
}
|
|
325
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
326
|
+
if (name === "action") {
|
|
327
|
+
this.action = newValue;
|
|
328
|
+
}
|
|
329
|
+
if (name === "delay") {
|
|
330
|
+
let delay = parseInt(newValue);
|
|
331
|
+
this.delay = !isNaN(delay) ? delay : 500;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
321
334
|
}
|
|
322
335
|
|
|
323
336
|
customElements.define("fig-tooltip", FigTooltip);
|
|
@@ -941,7 +954,6 @@ class FigInputText extends HTMLElement {
|
|
|
941
954
|
Number(this.value) + step,
|
|
942
955
|
false
|
|
943
956
|
).toFixed(2);
|
|
944
|
-
console.log("MM:", value, this.max);
|
|
945
957
|
this.setAttribute("value", value);
|
|
946
958
|
}
|
|
947
959
|
}
|
|
@@ -983,9 +995,15 @@ class FigInputText extends HTMLElement {
|
|
|
983
995
|
sanitized
|
|
984
996
|
);
|
|
985
997
|
}
|
|
998
|
+
sanitized = this.#formatNumber(sanitized);
|
|
986
999
|
}
|
|
987
1000
|
return sanitized;
|
|
988
1001
|
}
|
|
1002
|
+
#formatNumber(num, precision = 2) {
|
|
1003
|
+
// Check if the number has any decimal places after rounding
|
|
1004
|
+
const rounded = Math.round(num * 100) / 100;
|
|
1005
|
+
return Number.isInteger(rounded) ? rounded : rounded.toFixed(precision);
|
|
1006
|
+
}
|
|
989
1007
|
|
|
990
1008
|
static get observedAttributes() {
|
|
991
1009
|
return [
|