import { LitElement, PropertyValues } from "lit"; /** A tag as displayed in the list. */ type TagItem = { /** Unique (case-insensitive) identity of the tag. */ readonly value: string; /** Display text. Defaults to `value`. */ readonly label?: string; /** * Indeterminate tags represent "some of the data has this tag". Tapping one * turns it on (requires `editing` to allow adding). */ readonly indeterminate?: boolean; }; /** Tags and options may be given as plain strings or as full items. */ type TagInput = string | TagItem; /** An item of the suggestion list shown when adding a tag. */ type TagOption = string | { readonly value: string; readonly label?: string; }; /** * What the user may change: * - `readonly`: nothing * - `delete`: remove tags only * - `add`: add tags only (includes turning indeterminate tags on) * - `all`: add and remove */ type TagEditing = `readonly` | `delete` | `add` | `all`; /** * How tags are deleted: * - `button`: a small 'X' after each tag * - `menu`: tapping a tag opens a popover with Delete (and Rename, when * `editing="all"` and `allow-new` are set) */ type TagDeleteMode = `button` | `menu`; type TagValidationContext = { /** `add` for a newly typed tag, `rename` when an existing tag is being renamed. */ readonly kind: `add` | `rename`; /** The tag's current value, when renaming. */ readonly previous?: string; /** The tags currently shown. */ readonly tags: readonly TagItem[]; }; /** * Checks a typed-in tag name (already trimmed). Return `true` (or nothing) to * accept it, `false` to reject it, or a string to reject it with that message. * Empty and (when renaming) duplicate names are rejected before this is called. * Tags picked from `options` are not validated. */ type TagValidator = (value: string, context: TagValidationContext) => boolean | string | null | undefined; type TagAddDetail = { readonly value: string; readonly label: string; /** True if the tag was typed in rather than picked from the options. */ readonly isNew: boolean; }; type TagRemoveDetail = { readonly value: string; }; type TagRenameDetail = { readonly from: string; readonly to: string; }; type TagActivateDetail = { readonly value: string; }; type TagChangeDetail = { readonly tags: readonly TagItem[]; }; type TagAddEvent = CustomEvent; type TagRemoveEvent = CustomEvent; type TagActivateEvent = CustomEvent; type TagRenameEvent = CustomEvent; type TagChangeEvent = CustomEvent; interface TagListElementEventMap { 'tag-add': TagAddEvent; 'tag-remove': TagRemoveEvent; 'tag-activate': TagActivateEvent; 'tag-rename': TagRenameEvent; 'change': TagChangeEvent; } /** * — shows tags as a wrapping horizontal flow, and lets the user * add and remove them. * * Attributes: * editing — "all" (default) | "add" | "delete" | "readonly" * delete-mode — "button" (default; an X after each tag) | "menu" (tapping a tag opens a popover with Delete, and Rename when editing="all" and allow-new) * allow-new — let the user type tags that are not in `options` * search-placeholder — placeholder text of the add-tag search box * * Properties: * tags — tags shown: strings or { value, label?, indeterminate? } * options — suggestions offered when adding: strings or { value, label? } * validate — (value, { kind, previous, tags }) => true | false | error message; applied to typed-in new tags and renames * * Events: * tag-add — { value, label, isNew } * tag-remove — { value } * tag-activate — { value }: an indeterminate tag was tapped and is now on * tag-rename — { from, to } * change — { tags } after any of the above * * CSS custom properties: * --tag-list-gap, --tag-list-height, --tag-list-radius, --tag-list-bg, * --tag-list-text, --tag-list-indeterminate-text */ export declare class TagListElement extends LitElement { editing: TagEditing; deleteMode: TagDeleteMode; allowNew: boolean; searchPlaceholder: string; tags: readonly TagInput[]; options: readonly TagOption[]; validate: TagValidator | undefined; private _items; private _addOpen; private _query; private _cursor; private _menuTarget; private _menuMode; private _renameText; private _addPopup; private _menuPopup; private _input; private _search; private _available; private _menuAnchor; private get _canAdd(); private get _canDelete(); private get _canRename(); private get _menuDelete(); protected willUpdate(changed: PropertyValues): void; private _emit; private _commitTags; private _addTag; private _activate; private _remove; /** * Checks a typed-in tag name (new or renamed) and returns an error message, or * undefined if it's fine. `renaming` is the tag being renamed, which may keep its own name. */ private _check; private _rename; private _show; private _hide; private _openAdd; private _closeAdd; private _onAddToggle; private _openMenu; private _releaseMenuAnchor; private _closeMenu; private _onMenuToggle; private _menuDeleteClick; private _menuRenameClick; private _onRenameInput; private _onRenameKeydown; private _commitRename; private _rows; private _commitRow; private _onSearchInput; private _onSearchKeydown; protected updated(): void; private _onTagClick; private _onTagContextMenu; private _onTagKeydown; private _renderTag; private _renderLabel; private _renderAddPopup; private _renderMenuPopup; protected render(): import("lit").TemplateResult<1>; static styles: import("lit").CSSResult[]; } declare global { interface HTMLElementTagNameMap { 'ixfx-tag-list': TagListElement; } } export interface TagListElement { addEventListener(type: K, listener: (this: TagListElement, event: TagListElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; } export type { TagActivateDetail, TagActivateEvent, TagAddDetail, TagAddEvent, TagChangeDetail, TagChangeEvent, TagDeleteMode, TagEditing, TagInput, TagItem, TagListElementEventMap, TagOption, TagRemoveDetail, TagRemoveEvent, TagRenameDetail, TagRenameEvent, TagValidationContext, TagValidator };