@rogieking/figui3 1.5.1 → 1.5.3

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.
Files changed (3) hide show
  1. package/example.html +2 -2
  2. package/fig.js +22 -1
  3. package/package.json +1 -1
package/example.html CHANGED
@@ -793,8 +793,8 @@
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('input', (e) => {
797
- console.log('input:', n.tagName, e.target.value)
796
+ document.querySelectorAll('fig-input-color').forEach(n => n.addEventListener('change', (e) => {
797
+ console.log('change:', n.tagName, e.target.value)
798
798
  }))
799
799
  </script>
800
800
  </body>
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 type="text" placeholder="Text" value="${this.value}"></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) {
@@ -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"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {