import { customElement, property } from "lit/decorators.js"; import { html } from "lit"; import groupBy from "lodash-es/groupBy"; import NightingaleElement from "@nightingale-elements/nightingale-new-core"; export type Filter = { name: string; type: { name: string; text: string; }; options: { label: string; color: string; }; filterData: (data: unknown) => unknown; }; @customElement("nightingale-filter") class NightingaleFilter extends NightingaleElement { @property({ attribute: false }) filters?: Filter[] = []; @property({ type: String }) for: string = ""; #deselected = new Set(); // eslint-disable-next-line @typescript-eslint/no-explicit-any #manager: any; constructor() { super(); this.filters = []; } override connectedCallback() { super.connectedCallback(); if (this.closest("nightingale-manager")) { this.#manager = this.closest("nightingale-manager"); this.#manager.register(this); } } override disconnectedCallback() { super.disconnectedCallback(); if (this.#manager) { this.#manager.unregister(this); } } override render() { const groupByType = groupBy(this.filters, (f: Filter) => f.type.text); return html` ${Object.entries(groupByType).map( ([type, group]) => html`