carbon-components-svelte/types/Dropdown/Dropdown.d.ts
Eric Liu 14e714fa61
Alignment with Carbon version 10.29 (#529)
* chore: patch prettier-plugin-svelte

* docs(tag): add filterable small tag example

* feat(ui-shell): add SideNavDivider

* feat(combo-box): support warning state

* docs(combo-box): add invalid state example

* fix(progress-step): add title to warning icon

* docs(progress-indicator): add invalid step example

* docs(progress-indicator): add disabled steps example

* feat(truncate): add text truncation component and action

* docs(radio-tile): fix light variant example

* fix(side-effects): add pre-compiled CSS to library side effects

* refactor(css): use shorthand scss imports, add comments

* refactor(truncate): rename "direction" prop to "clamp"

* chore(deps-dev): bump carbon-components to v10.29.0

* feat(combo-box): add direction prop

* feat(dropdown): add direction prop

* feat(multi-select): add direction prop
2021-02-19 16:08:16 -08:00

154 lines
2.6 KiB
TypeScript

/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
export type DropdownItemId = string;
export type DropdownItemText = string;
export interface DropdownItem {
id: DropdownItemId;
text: DropdownItemText;
}
export interface DropdownProps
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["div"]> {
/**
* Set the dropdown items
* @default []
*/
items?: DropdownItem[];
/**
* Override the display of a dropdown item
* @default (item) => item.text || item.id
*/
itemToString?: (item: DropdownItem) => string;
/**
* Specify the selected item index
* @default -1
*/
selectedIndex?: number;
/**
* Specify the type of dropdown
* @default "default"
*/
type?: "default" | "inline";
/**
* Specify the direction of the dropdown menu
* @default "bottom"
*/
direction?: "bottom" | "top";
/**
* Specify the size of the dropdown field
*/
size?: "sm" | "lg" | "xl";
/**
* Set to `true` to open the dropdown
* @default false
*/
open?: boolean;
/**
* Set to `true` to use the inline variant
* @default false
*/
inline?: boolean;
/**
* Set to `true` to enable the light variant
* @default false
*/
light?: boolean;
/**
* Set to `true` to disable the dropdown
* @default false
*/
disabled?: boolean;
/**
* Specify the title text
* @default ""
*/
titleText?: string;
/**
* Set to `true` to indicate an invalid state
* @default false
*/
invalid?: boolean;
/**
* Specify the invalid state text
* @default ""
*/
invalidText?: string;
/**
* Set to `true` to indicate an warning state
* @default false
*/
warn?: boolean;
/**
* Specify the warning state text
* @default ""
*/
warnText?: string;
/**
* Specify the helper text
* @default ""
*/
helperText?: string;
/**
* Specify the list box label
*/
label?: string;
/**
* Set to `true` to visually hide the label text
* @default false
*/
hideLabel?: boolean;
/**
* Override the default translation ids
*/
translateWithId?: (id: any) => string;
/**
* Set an id for the list box component
* @default "ccs-" + Math.random().toString(36)
*/
id?: string;
/**
* Specify a name attribute for the list box
*/
name?: string;
/**
* Obtain a reference to the button HTML element
* @default null
*/
ref?: null | HTMLButtonElement;
}
export default class Dropdown extends SvelteComponentTyped<
DropdownProps,
{
select: CustomEvent<{
selectedId: DropdownItemId;
selectedIndex: number;
selectedItem: DropdownItem;
}>;
},
{}
> {}