@universal-material/web
Version: 
Material web components
94 lines • 2.91 kB
TypeScript
import { HTMLTemplateResult, LitElement } from 'lit';
import { UmMenuItem } from '../menu/menu-item.js';
import { UmMenu } from '../menu/menu.js';
import '../menu/menu.js';
import '../menu/menu-item.js';
import './highlight.js';
export interface Data {
    label: string;
    value: any;
}
export declare class UmTypeahead extends LitElement {
    #private;
    static readonly formAssociated = true;
    static styles: import("lit").CSSResult;
    private target;
    private results;
    /**
     * The datasource of the typeahead. Accepts an `Array` or a `Promise<[]>`.
     */
    source: (any[] | ((term: string) => Promise<any[]>)) | undefined;
    /**
     * A function return a string based on a result from the `source`. Useful when the source results are objects.
     */
    formatter: ((value: any) => string) | undefined;
    /**
     * A string representing an HTML to be rendered inside the menu item. If set, it will replace the `u-highlight`.
     *
     * _Note:_ Subject to signature change
     */
    template: ((term: string, value: any) => string) | undefined;
    /**
     * The time in milliseconds before triggering an update in the results.
     */
    debounce: number;
    /**
     * The number of suggestions to show
     */
    limit: number;
    /**
     * How many characters must be typed before show suggestions
     *
     * _Note:_ Not used when the source is a `Promise`
     */
    minLength: number;
    /**
     * Whether the menu will be show when the target get focus.
     *
     * _Note:_ The `minLength` will still be applied
     */
    openOnFocus: boolean;
    /**
     * If `true`, model values will not be restricted only to items selected from the menu.
     */
    editable: boolean;
    /**
     * The value for the `autocomplete` attribute for the target element.
     */
    autocomplete: 'on' | 'off' | string;
    /**
     * The value for the `spellcheck` attribute for the target element.
     */
    spellcheck: boolean;
    get form(): HTMLFormElement | null;
    /**
     * Gets or sets the current value of the typeahead.
     */
    get value(): any;
    set value(value: any);
    focus(): void;
    clear(): void;
    /**
     * The id of the target element to attach the typeahead.
     */
    get targetId(): string | undefined;
    set targetId(value: string | undefined);
    _menu: UmMenu;
    menuItems: NodeListOf<UmMenuItem>;
    get _menuItems(): UmMenuItem[];
    constructor();
    attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
    connectedCallback(): void;
    disconnectedCallback(): void;
    protected render(): HTMLTemplateResult;
    private getTargetValue;
    private setTargetValue;
    private getMenuAnchor;
    private getTextValue;
}
declare global {
    interface HTMLElementTagNameMap {
        'u-typeahead': UmTypeahead;
    }
}
//# sourceMappingURL=typeahead.d.ts.map