/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import {
classMap,
html,
ifDefined,
when,
} from "chrome://global/content/vendor/lit.all.mjs";
import {
FxviewTabListBase,
FxviewTabRowBase,
} from "chrome://browser/content/firefoxview/fxview-tab-list.mjs";
export class SidebarTabList extends FxviewTabListBase {
constructor() {
super();
// Panel is open, assume we always want to react to updates.
this.updatesPaused = false;
}
static queries = {
...FxviewTabListBase.queries,
rowEls: {
all: "sidebar-tab-row",
},
};
/**
* Only handle vertical navigation in sidebar.
*
* @param {KeyboardEvent} e
*/
handleFocusElementInRow(e) {
if (e.code == "ArrowUp" || e.code == "ArrowDown") {
super.handleFocusElementInRow(e);
}
}
itemTemplate = (tabItem, i) => {
return html`
e.currentTarget.primaryActionHandler(e)}
>
`;
};
stylesheets() {
return [
super.stylesheets(),
html``,
];
}
}
customElements.define("sidebar-tab-list", SidebarTabList);
export class SidebarTabRow extends FxviewTabRowBase {
/**
* Fallback to the native implementation in sidebar. We want to focus the
* entire row instead of delegating it to link or hover buttons.
*/
focus() {
HTMLElement.prototype.focus.call(this);
}
secondaryButtonTemplate() {
return html`${when(
this.secondaryL10nId && this.secondaryActionClass,
() =>
html``
)}`;
}
render() {
return html`
${this.stylesheets()}
${this.faviconTemplate()} ${this.titleTemplate()}
${this.secondaryButtonTemplate()}
`;
}
}
customElements.define("sidebar-tab-row", SidebarTabRow);