mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
* chore(deps-dev): remove @carbon/themes * chore(deps-dev): bump devDependencies * fix(tabs): forward click event to Tab * feat(toggle): dispatch toggle event * feat(tag): dispatch close event * feat(tooltip-icon): make tooltipText slottable * feat(dropdown): add hideLabel prop * docs(select): add "Hidden label" example * refactor(modal): use class directive * feat(modal): dispatch transitionend event * chore(deps-dev): upgrade carbon-components to 10.28.0-rc.0 * feat(date-picker): add warn state * feat(tag): support small size variant * fix(search): add semantic role * feat(toolbar-search): add disabled state * fix(composed-modal): add aria-label prop, update header semantic tags * chore(deps-dev): upgrade carbon-components to v10.28 * docs(overflow-menu): add light variant example * docs(link): document OutboundLink in Component API * chore(tooltip-icon): rename slot to "tooltipText" * docs(component-api): wrap code blocks to minimize width * docs(aspect-ratio): remove inline outline style * fix(tab): do not trigger focus when mounting * docs(tabs): add reactive example Closes #438
145 lines
2.6 KiB
TypeScript
145 lines
2.6 KiB
TypeScript
/// <reference types="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 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 {
|
|
$$prop_def: DropdownProps;
|
|
$$slot_def: {};
|
|
|
|
$on(
|
|
eventname: "select",
|
|
cb: (event: CustomEvent<{ selectedId: DropdownItemId; selectedIndex: number; selectedItem: DropdownItem }>) => void
|
|
): () => void;
|
|
$on(eventname: string, cb: (event: Event) => void): () => void;
|
|
}
|