@rogieking/figui3 1.8.0 → 1.8.2
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 +17 -0
- package/fig.js +29 -10
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
<h2><label>Effects/</label>UI3 Components</h2>
|
|
27
27
|
</fig-header>
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
|
|
29
31
|
<fig-input-text disabled
|
|
30
32
|
value="Disabled"><span slot="append">%</span></fig-input-text>
|
|
31
33
|
|
|
@@ -71,7 +73,10 @@
|
|
|
71
73
|
|
|
72
74
|
<fig-content>
|
|
73
75
|
|
|
76
|
+
|
|
74
77
|
<br /><br /><br /><br /><br /><br /><br /><br /><br />
|
|
78
|
+
|
|
79
|
+
|
|
75
80
|
<hstack>
|
|
76
81
|
<fig-tooltip text="Tooltip"
|
|
77
82
|
delay="0">
|
|
@@ -112,6 +117,7 @@
|
|
|
112
117
|
|
|
113
118
|
</hstack>
|
|
114
119
|
<br /><br /><br /><br /><br /><br /><br /><br /><br />
|
|
120
|
+
|
|
115
121
|
<fig-button type="link"
|
|
116
122
|
href="https://www.google.com">
|
|
117
123
|
<svg width="24"
|
|
@@ -284,6 +290,17 @@
|
|
|
284
290
|
label="Upload image"
|
|
285
291
|
size="large"></fig-image>
|
|
286
292
|
</fig-field>
|
|
293
|
+
<script>
|
|
294
|
+
function updateImages() {
|
|
295
|
+
const images = document.querySelectorAll('fig-image');
|
|
296
|
+
images.forEach(image => {
|
|
297
|
+
//image.setAttribute("src", "https://picsum.photos/200?random=" + Math.random());
|
|
298
|
+
image.src = "https://picsum.photos/200?random=" + Math.random();
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
</script>
|
|
302
|
+
|
|
303
|
+
<button onclick="updateImages()">Change src</button>
|
|
287
304
|
|
|
288
305
|
<br /><br />
|
|
289
306
|
<fig-header>
|
package/fig.js
CHANGED
|
@@ -292,14 +292,23 @@ class FigTooltip extends HTMLElement {
|
|
|
292
292
|
}
|
|
293
293
|
document.body.addEventListener("click", this.hidePopupOutsideClick);
|
|
294
294
|
}
|
|
295
|
+
isTouchDevice() {
|
|
296
|
+
return (
|
|
297
|
+
"ontouchstart" in window ||
|
|
298
|
+
navigator.maxTouchPoints > 0 ||
|
|
299
|
+
navigator.msMaxTouchPoints > 0
|
|
300
|
+
);
|
|
301
|
+
}
|
|
295
302
|
|
|
296
303
|
setupEventListeners() {
|
|
297
304
|
if (this.action === "hover") {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
305
|
+
if (!this.isTouchDevice()) {
|
|
306
|
+
this.addEventListener("pointerenter", this.showDelayedPopup.bind(this));
|
|
307
|
+
this.addEventListener(
|
|
308
|
+
"pointerleave",
|
|
309
|
+
this.#handlePointerLeave.bind(this)
|
|
310
|
+
);
|
|
311
|
+
}
|
|
303
312
|
// Add mousedown listener instead of dragstart
|
|
304
313
|
this.addEventListener("mousedown", this.#boundHideOnDragStart);
|
|
305
314
|
|
|
@@ -1860,12 +1869,13 @@ window.customElements.define("fig-combo-input", FigComboInput);
|
|
|
1860
1869
|
* @attr {boolean} disabled - Whether the chip is disabled
|
|
1861
1870
|
*/
|
|
1862
1871
|
class FigChit extends HTMLElement {
|
|
1872
|
+
#src = null;
|
|
1863
1873
|
constructor() {
|
|
1864
1874
|
super();
|
|
1865
1875
|
}
|
|
1866
1876
|
connectedCallback() {
|
|
1867
1877
|
this.type = this.getAttribute("type") || "color";
|
|
1868
|
-
this
|
|
1878
|
+
this.#src = this.getAttribute("src") || "";
|
|
1869
1879
|
this.value = this.getAttribute("value") || "#000000";
|
|
1870
1880
|
this.size = this.getAttribute("size") || "small";
|
|
1871
1881
|
this.disabled = this.getAttribute("disabled") === "true";
|
|
@@ -1878,15 +1888,23 @@ class FigChit extends HTMLElement {
|
|
|
1878
1888
|
}
|
|
1879
1889
|
#updateSrc(src) {
|
|
1880
1890
|
if (src) {
|
|
1881
|
-
this
|
|
1891
|
+
this.#src = src;
|
|
1882
1892
|
this.style.setProperty("--src", `url(${src})`);
|
|
1883
1893
|
} else {
|
|
1884
1894
|
this.style.removeProperty("--src");
|
|
1895
|
+
this.#src = null;
|
|
1885
1896
|
}
|
|
1886
1897
|
}
|
|
1887
1898
|
static get observedAttributes() {
|
|
1888
1899
|
return ["src", "value", "disabled"];
|
|
1889
1900
|
}
|
|
1901
|
+
get src() {
|
|
1902
|
+
return this.#src;
|
|
1903
|
+
}
|
|
1904
|
+
set src(value) {
|
|
1905
|
+
this.#src = value;
|
|
1906
|
+
this.setAttribute("src", value);
|
|
1907
|
+
}
|
|
1890
1908
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
1891
1909
|
switch (name) {
|
|
1892
1910
|
case "src":
|
|
@@ -1939,12 +1957,13 @@ class FigImage extends HTMLElement {
|
|
|
1939
1957
|
}</div>`;
|
|
1940
1958
|
}
|
|
1941
1959
|
connectedCallback() {
|
|
1942
|
-
this
|
|
1960
|
+
this.#src = this.getAttribute("src") || "";
|
|
1943
1961
|
this.upload = this.getAttribute("upload") === "true";
|
|
1944
1962
|
this.download = this.getAttribute("download") === "true";
|
|
1945
1963
|
this.label = this.getAttribute("label") || "Upload";
|
|
1946
1964
|
this.size = this.getAttribute("size") || "small";
|
|
1947
1965
|
this.innerHTML = this.#getInnerHTML();
|
|
1966
|
+
this.#updateRefs();
|
|
1948
1967
|
}
|
|
1949
1968
|
disconnectedCallback() {
|
|
1950
1969
|
this.fileInput.removeEventListener(
|
|
@@ -1969,7 +1988,6 @@ class FigImage extends HTMLElement {
|
|
|
1969
1988
|
);
|
|
1970
1989
|
}
|
|
1971
1990
|
if (this.download) {
|
|
1972
|
-
console.log("binding download");
|
|
1973
1991
|
this.downloadButton = this.querySelector("fig-button[type='download']");
|
|
1974
1992
|
this.downloadButton.removeEventListener(
|
|
1975
1993
|
"click",
|
|
@@ -2070,11 +2088,12 @@ class FigImage extends HTMLElement {
|
|
|
2070
2088
|
}
|
|
2071
2089
|
set src(value) {
|
|
2072
2090
|
this.#src = value;
|
|
2091
|
+
this.setAttribute("src", value);
|
|
2073
2092
|
}
|
|
2074
2093
|
|
|
2075
2094
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2076
2095
|
if (name === "src") {
|
|
2077
|
-
this.src = newValue;
|
|
2096
|
+
//this.src = newValue;
|
|
2078
2097
|
if (this.chit) {
|
|
2079
2098
|
this.chit.setAttribute("src", this.#src);
|
|
2080
2099
|
}
|