@rogieking/figui3 1.5.0 → 1.5.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 +3 -0
- package/fig.css +1 -0
- package/fig.js +26 -5
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -793,6 +793,9 @@
|
|
|
793
793
|
elements.filter(n => n.tagName.toLowerCase().indexOf("fig-slider") > -1).forEach(n => n.addEventListener('input', (e) => {
|
|
794
794
|
console.log('input:', n.tagName, e.target)
|
|
795
795
|
}))
|
|
796
|
+
document.querySelectorAll('fig-input-color').forEach(n => n.addEventListener('change', (e) => {
|
|
797
|
+
console.log('change:', n.tagName, e.target.value)
|
|
798
|
+
}))
|
|
796
799
|
</script>
|
|
797
800
|
</body>
|
|
798
801
|
|
package/fig.css
CHANGED
package/fig.js
CHANGED
|
@@ -1108,6 +1108,7 @@ class FigInputText extends HTMLElement {
|
|
|
1108
1108
|
this.value = value;
|
|
1109
1109
|
this.input.value = valueTransformed;
|
|
1110
1110
|
this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
|
|
1111
|
+
this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
|
|
1111
1112
|
}
|
|
1112
1113
|
#handleMouseMove(e) {
|
|
1113
1114
|
if (this.type !== "number") return;
|
|
@@ -1122,6 +1123,7 @@ class FigInputText extends HTMLElement {
|
|
|
1122
1123
|
this.value = value;
|
|
1123
1124
|
this.input.value = valueTransformed;
|
|
1124
1125
|
this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
|
|
1126
|
+
this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
|
|
1125
1127
|
}
|
|
1126
1128
|
}
|
|
1127
1129
|
#handleMouseDown(e) {
|
|
@@ -1336,7 +1338,11 @@ class FigInputColor extends HTMLElement {
|
|
|
1336
1338
|
|
|
1337
1339
|
let html = ``;
|
|
1338
1340
|
if (this.getAttribute("text")) {
|
|
1339
|
-
let label = `<fig-input-text
|
|
1341
|
+
let label = `<fig-input-text
|
|
1342
|
+
type="text"
|
|
1343
|
+
placeholder="#000000"
|
|
1344
|
+
value="${this.value}">
|
|
1345
|
+
</fig-input-text>`;
|
|
1340
1346
|
if (this.getAttribute("alpha") === "true") {
|
|
1341
1347
|
label += `<fig-tooltip text="Opacity">
|
|
1342
1348
|
<fig-input-text
|
|
@@ -1375,6 +1381,10 @@ class FigInputColor extends HTMLElement {
|
|
|
1375
1381
|
"input",
|
|
1376
1382
|
this.#handleTextInput.bind(this)
|
|
1377
1383
|
);
|
|
1384
|
+
this.#textInput.addEventListener(
|
|
1385
|
+
"change",
|
|
1386
|
+
this.#handleChange.bind(this)
|
|
1387
|
+
);
|
|
1378
1388
|
}
|
|
1379
1389
|
|
|
1380
1390
|
if (this.#alphaInput) {
|
|
@@ -1389,13 +1399,13 @@ class FigInputColor extends HTMLElement {
|
|
|
1389
1399
|
this.rgba = this.convertToRGBA(hexValue);
|
|
1390
1400
|
this.value = this.rgbAlphaToHex(
|
|
1391
1401
|
{
|
|
1392
|
-
r: this.rgba.r,
|
|
1393
|
-
g: this.rgba.g,
|
|
1394
|
-
b: this.rgba.b,
|
|
1402
|
+
r: isNaN(this.rgba.r) ? 0 : this.rgba.r,
|
|
1403
|
+
g: isNaN(this.rgba.g) ? 0 : this.rgba.g,
|
|
1404
|
+
b: isNaN(this.rgba.b) ? 0 : this.rgba.b,
|
|
1395
1405
|
},
|
|
1396
1406
|
this.rgba.a
|
|
1397
1407
|
);
|
|
1398
|
-
this.hexWithAlpha = this.value;
|
|
1408
|
+
this.hexWithAlpha = this.value.toUpperCase();
|
|
1399
1409
|
this.hexOpaque = this.hexWithAlpha.slice(0, 7);
|
|
1400
1410
|
if (hexValue.length > 7) {
|
|
1401
1411
|
this.alpha = (this.rgba.a * 100).toFixed(0);
|
|
@@ -1425,6 +1435,10 @@ class FigInputColor extends HTMLElement {
|
|
|
1425
1435
|
this.#emitInputEvent();
|
|
1426
1436
|
}
|
|
1427
1437
|
|
|
1438
|
+
#handleChange(event) {
|
|
1439
|
+
this.#emitChangeEvent();
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1428
1442
|
focus() {
|
|
1429
1443
|
this.#swatch.focus();
|
|
1430
1444
|
}
|
|
@@ -1446,6 +1460,13 @@ class FigInputColor extends HTMLElement {
|
|
|
1446
1460
|
});
|
|
1447
1461
|
this.dispatchEvent(e);
|
|
1448
1462
|
}
|
|
1463
|
+
#emitChangeEvent() {
|
|
1464
|
+
const e = new CustomEvent("change", {
|
|
1465
|
+
bubbles: true,
|
|
1466
|
+
cancelable: true,
|
|
1467
|
+
});
|
|
1468
|
+
this.dispatchEvent(e);
|
|
1469
|
+
}
|
|
1449
1470
|
|
|
1450
1471
|
static get observedAttributes() {
|
|
1451
1472
|
return ["value", "style"];
|