carbon-components-svelte/types/MultiSelect/MultiSelect.d.ts
Eric Liu 5fad0cb3c7
Alignment with Carbon version 10.31 (#571)
* chore(deps-dev): upgrade carbon-components to v10.31.0

* fix(slider): use CSS to hide input if hideTextInput is true

* docs(slider): add hidden text input, invalid, disabled examples

* feat(tabs): support "container" type for TabsSkeleton

* chore(list-box): remove hotfix inline style to center dropdown chevron

* fix(number-input): use add, subtract icons and update markup

* feat(select): add warning state

* docs(select): add invalid state example

* docs(select): add helper text example

* fix(structured-list): add "rowgroup" role to StructuredListBody

* docs: release code snippet max-width

* docs(select): add skeleton hidden label example

* feat(popover): add Popover component

* feat(pagination): dispatch button click events to be consistent with PaginationNav

* fix(multi-select): type clear as a custom event

* docs(radio-button): add disabled buttons example

* chore(tabs): use absolute icon import

* fix(link): remove line breaks within anchor link

* docs(radio-button): adjust section copy verbiage

* chore(deps-dev): upgrade carbon-icons-svelte to v10.27

v10.27 uses the SvelteComponentTyped interface

* docs(accordion): adjust section title verbiage

* test(types): fix warnings from svelte-check

* fix(search): only set autofocus attribute if equals true

* feat(popover): add closeOnOutsideClick prop

* docs: style [data-outline] as relative positioned

* feat(context-menu): add initial ContextMenu

* feat(context-menu): annotate props, generate types

* feat(context-menu): add initial focus logic

* fix(context-menu): correctly tab in/out of nested menus

* chore(context-menu): update types

* fix(context-menu): obtain radio id from node directly

* docs(context-menu): add examples and test

* fix(context-menu): prevent default keydown behavior
2021-03-20 10:39:14 -07:00

193 lines
3.7 KiB
TypeScript

/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
export type MultiSelectItemId = string;
export type MultiSelectItemText = string;
export interface MultiSelectItem {
id: MultiSelectItemId;
text: MultiSelectItemText;
}
export interface MultiSelectProps
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["input"]> {
/**
* Set the multiselect items
* @default []
*/
items?: MultiSelectItem[];
/**
* Override the display of a multiselect item
* @default (item) => item.text || item.id
*/
itemToString?: (item: MultiSelectItem) => string;
/**
* Set the selected ids
* @default []
*/
selectedIds?: MultiSelectItemId[];
/**
* Specify the multiselect value
* @default ""
*/
value?: string;
/**
* Set the size of the combobox
*/
size?: "sm" | "lg" | "xl";
/**
* Specify the type of multiselect
* @default "default"
*/
type?: "default" | "inline";
/**
* Specify the direction of the multiselect dropdown menu
* @default "bottom"
*/
direction?: "bottom" | "top";
/**
* Specify the selection feedback after selecting items
* @default "top-after-reopen"
*/
selectionFeedback?: "top" | "fixed" | "top-after-reopen";
/**
* Set to `true` to disable the dropdown
* @default false
*/
disabled?: boolean;
/**
* Set to `true` to filter items
* @default false
*/
filterable?: boolean;
/**
* Override the filtering logic
* The default filtering is an exact string comparison
* @default (item, value) => item.text.toLowerCase().includes(value.toLowerCase())
*/
filterItem?: (item: MultiSelectItem, value: string) => string;
/**
* Set to `true` to open the dropdown
* @default false
*/
open?: boolean;
/**
* Set to `true` to enable the light variant
* @default false
*/
light?: boolean;
/**
* Specify the locale
* @default "en"
*/
locale?: string;
/**
* Specify the placeholder text
* @default ""
*/
placeholder?: string;
/**
* Override the sorting logic
* The default sorting compare the item text value
* @default (a, b) => a.text.localeCompare(b.text, locale, { numeric: true })
*/
sortItem?:
| ((a: MultiSelectItem, b: MultiSelectItem) => MultiSelectItem)
| (() => void);
/**
* Override the default translation ids
*/
translateWithId?: (id: any) => string;
/**
* Specify the title text
* @default ""
*/
titleText?: string;
/**
* Set to `true` to pass the item to `itemToString` in the checkbox
* @default false
*/
useTitleInItem?: boolean;
/**
* 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
* @default ""
*/
label?: string;
/**
* Set an id for the list box component
* @default "ccs-" + Math.random().toString(36)
*/
id?: string;
/**
* Specify a name attribute for the select
*/
name?: string;
}
export default class MultiSelect extends SvelteComponentTyped<
MultiSelectProps,
{
select: CustomEvent<{
selectedIds: string[];
selected: MultiSelectItem[];
unselected: MultiSelectItem[];
}>;
clear: CustomEvent<any>;
keydown: WindowEventMap["keydown"];
focus: WindowEventMap["focus"];
blur: WindowEventMap["blur"];
},
{}
> {}