/** * EDC Sort Controls Component * * Reusable sort controls with dropdown and direction toggle. * * @customElement edc-sort-controls */ import { css, html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; export interface SortOption { value: string; label: string; } export type SortDirection = 'asc' | 'desc'; @customElement('edc-sort-controls') export class EdcSortControls extends LitElement { @property({ type: Array }) options: SortOption[] = []; @property({ type: String }) value: string = ''; @property({ type: String }) direction: SortDirection = 'asc'; private handleSortChange(e: Event) { const select = e.target as HTMLSelectElement; this.dispatchEvent(new CustomEvent('sort-change', { detail: { value: select.value, direction: this.direction }, bubbles: true, composed: true })); } private toggleDirection() { const newDirection: SortDirection = this.direction === 'asc' ? 'desc' : 'asc'; this.dispatchEvent(new CustomEvent('sort-change', { detail: { value: this.value, direction: newDirection }, bubbles: true, composed: true })); } render() { return html`
`; } static styles = css` :host { display: block; } .sort-controls { display: flex; gap: 0.5rem; align-items: center; } .sort-select { padding: 0.75rem; border: 1px solid #ddd; border-radius: 6px; font-size: 1rem; background: white; cursor: pointer; transition: border-color 0.2s; } .sort-select:hover { border-color: var(--tems-color-primary, #e91e63); } .sort-select:focus { outline: none; border-color: var(--tems-color-primary, #e91e63); box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1); } .sort-direction { padding: 0.75rem 1rem; border: 1px solid #ddd; border-radius: 6px; background: white; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; } .sort-direction:hover { background: var(--tems-color-primary, #e91e63); color: white; border-color: var(--tems-color-primary, #e91e63); } .sort-direction:focus { outline: none; box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1); } `; } declare global { interface HTMLElementTagNameMap { 'edc-sort-controls': EdcSortControls; } }