@rogieking/figui3 8.9.24 → 8.9.25

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/fig-editor.js CHANGED
@@ -1958,7 +1958,6 @@ class FigFillPicker extends HTMLElement {
1958
1958
  }
1959
1959
  this.#webcamPosterStream = stream;
1960
1960
  this.#updateSwatch();
1961
- this.#emitInput();
1962
1961
  };
1963
1962
 
1964
1963
  const attempt = async () => {
@@ -2258,9 +2257,9 @@ class FigFillPicker extends HTMLElement {
2258
2257
  this.#dialog.anchor = this.anchorElement || this.#trigger;
2259
2258
  }
2260
2259
 
2260
+ this.#switchTab(this.#fillType, { emit: false });
2261
2261
  this.#valueAtOpen = JSON.stringify(this.value);
2262
2262
  this.#lastChangeValue = this.#valueAtOpen;
2263
- this.#switchTab(this.#fillType, { emit: false });
2264
2263
 
2265
2264
  if (this.#swatch) this.#swatch.setAttribute("selected", "true");
2266
2265
 
@@ -2609,7 +2608,7 @@ class FigFillPicker extends HTMLElement {
2609
2608
  });
2610
2609
  }
2611
2610
 
2612
- if (tabName === "video") this.#applyDefaultVideo();
2611
+ if (tabName === "video") this.#applyDefaultVideo({ emit: false });
2613
2612
  if (tabName === "webcam") {
2614
2613
  this.#webcam.live = this.#webcamMode() === "live";
2615
2614
  this.#webcamStart?.(this.#webcam.deviceId);
@@ -4299,10 +4298,17 @@ class FigFillPicker extends HTMLElement {
4299
4298
  preview.addEventListener("loaded", (e) => {
4300
4299
  const src = e.detail?.src || preview.src;
4301
4300
  if (!src) return;
4301
+ const changed = src !== this.#image.url;
4302
4302
  this.#image.url = src;
4303
4303
  this.#updateImagePreview(preview);
4304
4304
  this.#updateSwatch();
4305
- this.#emitInput();
4305
+ if (changed) this.#emitInput();
4306
+ this.dispatchEvent(
4307
+ new CustomEvent("loaded", {
4308
+ bubbles: true,
4309
+ detail: e.detail ?? { src },
4310
+ }),
4311
+ );
4306
4312
  });
4307
4313
 
4308
4314
  preview.addEventListener("change", () => {
@@ -4462,7 +4468,7 @@ class FigFillPicker extends HTMLElement {
4462
4468
  container.replaceChildren(header, preview);
4463
4469
 
4464
4470
  this.#setupVideoEvents(container);
4465
- this.#applyDefaultVideo();
4471
+ this.#applyDefaultVideo({ emit: false });
4466
4472
  }
4467
4473
 
4468
4474
  #revokeVideoPoster() {
@@ -4473,7 +4479,7 @@ class FigFillPicker extends HTMLElement {
4473
4479
  this.#video.poster = null;
4474
4480
  }
4475
4481
 
4476
- #applyDefaultVideo({ emit = true } = {}) {
4482
+ #applyDefaultVideo({ emit = false } = {}) {
4477
4483
  if (this.#video.url) {
4478
4484
  this.#video.missing = false;
4479
4485
  if (!this.#video.poster) this.#captureVideoPoster(this.#video.url);
@@ -4603,12 +4609,19 @@ class FigFillPicker extends HTMLElement {
4603
4609
  preview.addEventListener("loaded", (e) => {
4604
4610
  const src = e.detail?.src || preview.src;
4605
4611
  if (!src) return;
4612
+ const changed = src !== this.#video.url;
4606
4613
  this.#video.url = src;
4607
4614
  this.#video.missing = false;
4608
4615
  this.#updateVideoPreviewStyle(preview);
4609
4616
  this.#captureVideoPoster(src);
4610
4617
  this.#updateSwatch();
4611
- this.#emitInput();
4618
+ if (changed) this.#emitInput();
4619
+ this.dispatchEvent(
4620
+ new CustomEvent("loaded", {
4621
+ bubbles: true,
4622
+ detail: e.detail ?? { src },
4623
+ }),
4624
+ );
4612
4625
  });
4613
4626
 
4614
4627
  preview.addEventListener("change", () => {
package/fig.js CHANGED
@@ -9476,6 +9476,16 @@ class FigInputFill extends HTMLElement {
9476
9476
  this.#emitChange();
9477
9477
  });
9478
9478
 
9479
+ this.#fillPicker.addEventListener("loaded", (e) => {
9480
+ e.stopPropagation();
9481
+ this.dispatchEvent(
9482
+ new CustomEvent("loaded", {
9483
+ bubbles: true,
9484
+ detail: e.detail,
9485
+ }),
9486
+ );
9487
+ });
9488
+
9479
9489
  this.#fillPicker.addEventListener("webcamstream", (e) => {
9480
9490
  this.dispatchEvent(
9481
9491
  new CustomEvent("webcamstream", {
@@ -9773,7 +9783,10 @@ class FigInputFill extends HTMLElement {
9773
9783
  #webcamValue() {
9774
9784
  return {
9775
9785
  live: this.#webcam.live !== false,
9776
- snapshot: this.#webcam.snapshot ?? null,
9786
+ snapshot:
9787
+ this.#webcam.snapshot ??
9788
+ this.#fillPicker?.value?.webcam?.snapshot ??
9789
+ null,
9777
9790
  deviceId: this.#webcam.deviceId ?? null,
9778
9791
  scaleMode: this.#webcam.scaleMode || "fill",
9779
9792
  scale: this.#webcam.scale ?? 50,
@@ -12992,6 +13005,23 @@ class FigMedia extends HTMLElement {
12992
13005
  detail,
12993
13006
  }),
12994
13007
  );
13008
+ if (
13009
+ (media.tagName === "IMG" && event.type === "load") ||
13010
+ (media.tagName === "VIDEO" && event.type === "loadeddata")
13011
+ ) {
13012
+ this.dispatchEvent(
13013
+ new CustomEvent("loaded", {
13014
+ bubbles: true,
13015
+ cancelable: true,
13016
+ composed: true,
13017
+ detail: {
13018
+ src: detail.src,
13019
+ file: this.#file,
13020
+ media,
13021
+ },
13022
+ }),
13023
+ );
13024
+ }
12995
13025
  }
12996
13026
 
12997
13027
  #handleMediaPlay() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "8.9.24",
3
+ "version": "8.9.25",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "SEE LICENSE IN LICENSE",