();
private _prevValue = '';
override render() {
let breadcrumbs: TemplateResult<1> | '' = '';
if (!this.hideBreadcrumbs) {
const itemTemplates = [];
for (const breadcrumb of this.breadcrumbs) {
itemTemplates.push(
html``
);
}
breadcrumbs = html`
${itemTemplates}
`;
}
return html`
${breadcrumbs}
`;
}
setSearch(value: string) {
if (this._inputRef.value) {
this._prevValue = value;
this._inputRef.value.value = value;
}
}
focusSearch() {
requestAnimationFrame(() => this._inputRef.value!.focus());
}
private _handleInput(event: KeyboardEvent) {
const input = event.target as HTMLInputElement;
this.handleChange(input.value);
}
private _handleKeyup(event: KeyboardEvent) {
const input = event.target as HTMLInputElement;
if (input.value === this._prevValue) {
return;
}
this.handleChange(input.value);
}
private handleChange(value: string) {
this._prevValue = value;
this.dispatchEvent(
new CustomEvent('change', {
detail: {search: value},
bubbles: false,
composed: false,
})
);
}
private selectParent(breadcrumb?: string) {
this.dispatchEvent(
new CustomEvent('setParent', {
detail: {parent: breadcrumb},
bubbles: true,
composed: true,
})
);
}
override firstUpdated() {
this.focusSearch();
}
_close() {
this.dispatchEvent(new CustomEvent('close', {bubbles: true, composed: true}));
}
}
declare global {
interface HTMLElementTagNameMap {
'ninja-header': NinjaHeader;
}
}