@rogieking/figui3 6.9.6 → 6.9.8
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/README.md +16 -5
- package/base.css +5 -1
- package/components.css +18 -15
- package/dist/base.css +1 -1
- package/dist/components.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +12 -12
- package/fig.js +51 -0
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -10740,6 +10740,7 @@ customElements.define("fig-swatch", FigSwatch);
|
|
|
10740
10740
|
* @attr {string} aspect-ratio - CSS aspect-ratio value
|
|
10741
10741
|
* @attr {string} fit - CSS object-fit value
|
|
10742
10742
|
* @attr {boolean} checkerboard - Show checkerboard behind transparent media
|
|
10743
|
+
* @attr {string} caption - Caption text rendered below the media preview
|
|
10743
10744
|
* @attr {boolean} controls - Video controls visibility (default false)
|
|
10744
10745
|
* @attr {boolean} autoplay - Video autoplay
|
|
10745
10746
|
* @attr {boolean} loop - Video loop
|
|
@@ -10783,6 +10784,7 @@ class FigMedia extends HTMLElement {
|
|
|
10783
10784
|
"aspect-ratio",
|
|
10784
10785
|
"fit",
|
|
10785
10786
|
"checkerboard",
|
|
10787
|
+
"caption",
|
|
10786
10788
|
"controls",
|
|
10787
10789
|
"autoplay",
|
|
10788
10790
|
"loop",
|
|
@@ -10869,6 +10871,7 @@ class FigMedia extends HTMLElement {
|
|
|
10869
10871
|
this.#ensureMediaElement();
|
|
10870
10872
|
this.#syncGeneratedMediaElement();
|
|
10871
10873
|
this.#syncMediaAccessibility();
|
|
10874
|
+
this.#syncCaption();
|
|
10872
10875
|
|
|
10873
10876
|
const isUpload = this.hasAttribute("upload") && this.getAttribute("upload") !== "false";
|
|
10874
10877
|
if (isUpload && !this.querySelector("fig-input-file[data-generated]")) {
|
|
@@ -10995,6 +10998,50 @@ class FigMedia extends HTMLElement {
|
|
|
10995
10998
|
});
|
|
10996
10999
|
}
|
|
10997
11000
|
|
|
11001
|
+
#userProvidedCaptionEl() {
|
|
11002
|
+
return this.querySelector(":scope > figcaption:not([data-generated])");
|
|
11003
|
+
}
|
|
11004
|
+
|
|
11005
|
+
#generatedCaptionEls() {
|
|
11006
|
+
return Array.from(
|
|
11007
|
+
this.querySelectorAll(":scope > figcaption[data-generated]"),
|
|
11008
|
+
);
|
|
11009
|
+
}
|
|
11010
|
+
|
|
11011
|
+
#syncCaption() {
|
|
11012
|
+
const userCaption = this.#userProvidedCaptionEl();
|
|
11013
|
+
const generatedCaptions = this.#generatedCaptionEls();
|
|
11014
|
+
|
|
11015
|
+
if (userCaption) {
|
|
11016
|
+
generatedCaptions.forEach((caption) => caption.remove());
|
|
11017
|
+
return;
|
|
11018
|
+
}
|
|
11019
|
+
|
|
11020
|
+
const captionText = this.getAttribute("caption") || "";
|
|
11021
|
+
if (!captionText) {
|
|
11022
|
+
generatedCaptions.forEach((caption) => caption.remove());
|
|
11023
|
+
return;
|
|
11024
|
+
}
|
|
11025
|
+
|
|
11026
|
+
const caption = generatedCaptions[0] || document.createElement("figcaption");
|
|
11027
|
+
generatedCaptions.slice(1).forEach((duplicate) => duplicate.remove());
|
|
11028
|
+
if (!caption.hasAttribute("data-generated")) {
|
|
11029
|
+
caption.setAttribute("data-generated", "");
|
|
11030
|
+
}
|
|
11031
|
+
if (caption.textContent !== captionText) {
|
|
11032
|
+
caption.textContent = captionText;
|
|
11033
|
+
}
|
|
11034
|
+
|
|
11035
|
+
const controls = this.querySelector(":scope > fig-media-controls");
|
|
11036
|
+
if (controls) {
|
|
11037
|
+
controls.before(caption);
|
|
11038
|
+
} else if (this.#previewEl?.isConnected) {
|
|
11039
|
+
this.#previewEl.after(caption);
|
|
11040
|
+
} else if (!caption.isConnected) {
|
|
11041
|
+
this.append(caption);
|
|
11042
|
+
}
|
|
11043
|
+
}
|
|
11044
|
+
|
|
10998
11045
|
#isEnabledAttr(name, defaultEnabled = false) {
|
|
10999
11046
|
if (!this.hasAttribute(name)) return defaultEnabled;
|
|
11000
11047
|
return this.getAttribute(name) !== "false";
|
|
@@ -11379,6 +11426,10 @@ class FigMedia extends HTMLElement {
|
|
|
11379
11426
|
if (["controls", "autoplay", "loop", "muted", "poster"].includes(name)) {
|
|
11380
11427
|
this.#syncGeneratedMediaElement();
|
|
11381
11428
|
}
|
|
11429
|
+
|
|
11430
|
+
if (name === "caption") {
|
|
11431
|
+
this.#syncCaption();
|
|
11432
|
+
}
|
|
11382
11433
|
}
|
|
11383
11434
|
}
|
|
11384
11435
|
|
package/package.json
CHANGED