Files
pole-book/server/node_modules/media-chrome/dist/cjs/media-airplay-button.js

122 lines
4.7 KiB
JavaScript

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var media_airplay_button_exports = {};
__export(media_airplay_button_exports, {
default: () => media_airplay_button_default
});
module.exports = __toCommonJS(media_airplay_button_exports);
var import_media_chrome_button = require("./media-chrome-button.js");
var import_server_safe_globals = require("./utils/server-safe-globals.js");
var import_constants = require("./constants.js");
var import_labels = require("./labels/labels.js");
var import_element_utils = require("./utils/element-utils.js");
const airplayIcon = `<svg aria-hidden="true" viewBox="0 0 26 24">
<path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
</svg>
`;
const slotTemplate = import_server_safe_globals.document.createElement("template");
slotTemplate.innerHTML = /*html*/
`
<style>
:host([${import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
display: none !important;
}
${/* Double negative, but safer if display doesn't equal 'block' */
""}
:host(:not([${import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) {
display: none !important;
}
:host([${import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter],
:host(:not([${import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] {
display: none;
}
</style>
<slot name="icon">
<slot name="enter">${airplayIcon}</slot>
<slot name="exit">${airplayIcon}</slot>
</slot>
`;
const tooltipContent = (
/*html*/
`
<slot name="tooltip-enter">${import_labels.tooltipLabels.ENTER_AIRPLAY}</slot>
<slot name="tooltip-exit">${import_labels.tooltipLabels.EXIT_AIRPLAY}</slot>
`
);
const updateAriaLabel = (el) => {
const label = el.mediaIsAirplaying ? import_labels.verbs.EXIT_AIRPLAY() : import_labels.verbs.ENTER_AIRPLAY();
el.setAttribute("aria-label", label);
};
class MediaAirplayButton extends import_media_chrome_button.MediaChromeButton {
static get observedAttributes() {
return [
...super.observedAttributes,
import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING,
import_constants.MediaUIAttributes.MEDIA_AIRPLAY_UNAVAILABLE
];
}
constructor(options = {}) {
super({ slotTemplate, tooltipContent, ...options });
}
connectedCallback() {
super.connectedCallback();
updateAriaLabel(this);
}
attributeChangedCallback(attrName, oldValue, newValue) {
super.attributeChangedCallback(attrName, oldValue, newValue);
if (attrName === import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING) {
updateAriaLabel(this);
}
}
/**
* Are we currently airplaying
*/
get mediaIsAirplaying() {
return (0, import_element_utils.getBooleanAttr)(this, import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING);
}
set mediaIsAirplaying(value) {
(0, import_element_utils.setBooleanAttr)(this, import_constants.MediaUIAttributes.MEDIA_IS_AIRPLAYING, value);
}
/**
* Airplay unavailability state
*/
get mediaAirplayUnavailable() {
return (0, import_element_utils.getStringAttr)(this, import_constants.MediaUIAttributes.MEDIA_AIRPLAY_UNAVAILABLE);
}
set mediaAirplayUnavailable(value) {
(0, import_element_utils.setStringAttr)(this, import_constants.MediaUIAttributes.MEDIA_AIRPLAY_UNAVAILABLE, value);
}
handleClick() {
const evt = new import_server_safe_globals.globalThis.CustomEvent(
import_constants.MediaUIEvents.MEDIA_AIRPLAY_REQUEST,
{
composed: true,
bubbles: true
}
);
this.dispatchEvent(evt);
}
}
if (!import_server_safe_globals.globalThis.customElements.get("media-airplay-button")) {
import_server_safe_globals.globalThis.customElements.define("media-airplay-button", MediaAirplayButton);
}
var media_airplay_button_default = MediaAirplayButton;