import { CSSResultGroup, PropertyValues } from 'lit'; import { UOverlayElement } from '../UOverlayElement.js'; /** 팔레트의 항목 하나. */ export interface CommandItem { /** 출처 안에서 고유한 값. */ id: string; /** 보이는 이름. */ label: string; /** 이름 옆의 보조 글(경로 · 상태 등). 접근 가능한 설명으로도 나간다. */ description?: string; /** 아이콘 이름(`u-icon` 의 `name`). */ icon?: string; /** 아이콘 라이브러리(`u-icon` 의 `lib`). */ iconLib?: string; /** 고르면 갈 곳. `command` 이벤트를 취소하지 않으면 그 주소로 이동한다. */ href?: string; /** 일치 판정에 함께 쓰는 낱말(`filterCommands` 가 본다). */ keywords?: string[]; /** 앱이 실어 두는 값 — 팔레트는 읽지 않는다. */ data?: unknown; } /** 출처의 검색 — 새 검색어가 오면 이전 요청의 `signal` 이 중단된다. */ export type CommandSearch = (query: string, options: { signal: AbortSignal; }) => CommandItem[] | Promise; /** 항목을 내는 곳 하나 — 결과는 출처 순서대로 묶이고 묶음 머리는 `label` 이다. */ export interface CommandSource { /** 출처의 고유값(`command` 이벤트의 `source`). */ id: string; /** 묶음 머리. */ label: string; search: CommandSearch; } /** `command` 이벤트의 detail. */ export interface UCommandPaletteCommandDetail { item: CommandItem; /** 그 항목을 낸 출처의 `id`. */ source: string; } /** Events `` dispatches (plus `show` · `hide` from the overlay base). */ export interface UCommandPaletteEventMap { /** An item was chosen (Enter or click). Cancelable — when not canceled and the item has `href`, the page goes there. Does not bubble. */ 'command': CustomEvent; } /** * 정적 항목을 검색어로 거른다 — 이름 · 설명 · 낱말을 활성 로케일의 검색 일치로 견준다(`u-select` 와 같은 규칙). 빈 검색어는 모두다. * 출처의 `search` 를 짓는 도우미: `search: (q) => filterCommands(items, q)`. */ export declare function filterCommands(items: readonly CommandItem[], query: string): CommandItem[]; /** * 명령 팔레트 — 한 칸에서 화면 · 레코드 · 동작을 찾아 고른다(Ctrl/⌘ K 류). 대화상자 안의 검색 칸(WAI-ARIA APG combobox)과 * 결과 목록(listbox)이고, 결과는 출처(`sources`)마다 묶인다. * * - 열면 칸에 초점이 가고 빈 검색어로 출처를 부른다(최근 항목 · 화면 목록처럼 «찾기 전» 에 보일 것). 치면 `debounce` 뒤에 다시 * 부르고, 새 검색어는 이전 요청을 `AbortSignal` 로 중단한다. 한 출처의 실패 · 지연은 다른 출처의 결과를 막지 않는다. * - ↑ ↓ 로 항목을 옮기고(끝에서 처음으로 돈다) Enter 로 고른다 · Escape 로 닫는다. 입력기 조합을 확정하는 Enter 는 고르지 않는다. * - 고르면 `command` 를 내고 닫는다. 취소하지 않았고 항목에 `href` 가 있으면 그 주소로 간다 — 클라이언트 라우터를 쓰는 앱은 * 취소하고 스스로 옮긴다. 닫으면 열기 전의 초점으로 돌아간다. * * 단축키(Ctrl/⌘ K)는 이 요소가 걸지 않는다 — 어디서 여는가는 앱(또는 셸)의 몫이다. * * @event command - 항목을 골랐다. `detail: { item, source }` · 취소 가능 · 거품 없음. * @event show - 열리기 직전(취소하면 열리지 않는다). * @event hide - 닫히기 직전(취소하면 닫히지 않는다). * * @csspart panel - 대화상자 상자 * @csspart input - 검색 칸 * @csspart listbox - 결과 목록 * @csspart group-label - 묶음 머리 * @csspart option - 항목 * @csspart status - 불러오는 중 · 결과 없음 · 출처 오류 줄 */ export declare class UCommandPalette extends UOverlayElement { static styles: CSSResultGroup; /** 항목을 내는 곳들 — 묶음은 이 순서다. 프로퍼티로만 준다. */ sources: CommandSource[]; /** 검색 칸의 자리표시 글. */ placeholder: string; /** 검색 칸의 접근 가능한 이름 — 비면 로캘 `search`. */ label: string; /** 치기를 멈춘 뒤 출처를 부르기까지(ms). */ debounce: number; private query; private results; private activeKey?; private inputEl?; private readonly idBase; private controller?; private timer?; protected ownInitialFocus(): HTMLElement | null; connectedCallback(): void; disconnectedCallback(): void; protected willUpdate(changed: PropertyValues): void; protected updated(changed: PropertyValues): void; protected localeChanged(): void; render(): import('lit-html').TemplateResult<1>; private renderGroup; /** 보이는 순서의 항목들(출처 순 → 출처가 준 순). */ private get rows(); private rowKey; /** 항목의 id — 섀도 안의 같은 트리라 `aria-activedescendant` IDREF 가 닿는다. */ private optionId; private handleInput; private handleKeydown; /** 검색어로 출처를 부른다 — 이전 요청은 중단하고, 출처마다 따로 끝난다. */ private run; private settle; /** 검색어가 바뀌면 첫 항목이 후보다(APG «list autocomplete with automatic selection») — 지금 후보가 남아 있으면 그대로. */ private syncActive; private choose; private cancel; } /** Typed listeners for {@link UCommandPaletteEventMap} — element-scoped, the DOM's own pattern (`HTMLMediaElementEventMap`). */ export interface UCommandPalette { addEventListener(type: K, listener: (this: UCommandPalette, ev: UCommandPaletteEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void; addEventListener(type: K, listener: (this: UCommandPalette, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: UCommandPalette, ev: UCommandPaletteEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void; removeEventListener(type: K, listener: (this: UCommandPalette, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare global { interface HTMLElementTagNameMap { 'u-command-palette': UCommandPalette; } }