Type id as any in ComboBox, Dropdown, MultiSelect (#1019)

Loosen the prop type for `id`, `selectedId` to be `any` instead of a `string`.
This commit is contained in:
Eric Liu 2022-01-20 18:50:36 -08:00 committed by GitHub
commit 1f7b5560a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 68 additions and 49 deletions

View file

@ -1,8 +1,10 @@
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
export type ComboBoxItemId = any;
export interface ComboBoxItem {
id: string;
id: ComboBoxItemId;
text: string;
}
@ -23,7 +25,7 @@ export interface ComboBoxProps
/**
* Set the selected item by value id
*/
selectedId?: string;
selectedId?: ComboBoxItemId;
/**
* Specify the selected combobox value
@ -140,7 +142,10 @@ export interface ComboBoxProps
export default class ComboBox extends SvelteComponentTyped<
ComboBoxProps,
{
select: CustomEvent<{ selectedId: string; selectedItem: ComboBoxItem }>;
select: CustomEvent<{
selectedId: ComboBoxItemId;
selectedItem: ComboBoxItem;
}>;
keydown: WindowEventMap["keydown"];
keyup: WindowEventMap["keyup"];
focus: WindowEventMap["focus"];

View file

@ -1,7 +1,7 @@
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
export type DropdownItemId = string;
export type DropdownItemId = any;
export type DropdownItemText = string;

View file

@ -1,7 +1,7 @@
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
export type MultiSelectItemId = string;
export type MultiSelectItemId = any;
export type MultiSelectItemText = string;
@ -22,7 +22,7 @@ export interface MultiSelectProps
* Override the display of a multiselect item
* @default (item) => item.text || item.id
*/
itemToString?: (item: MultiSelectItem) => string;
itemToString?: (item: MultiSelectItem) => any;
/**
* Set the selected ids
@ -210,7 +210,7 @@ export default class MultiSelect extends SvelteComponentTyped<
MultiSelectProps,
{
select: CustomEvent<{
selectedIds: string[];
selectedIds: MultiSelectItemId[];
selected: MultiSelectItem[];
unselected: MultiSelectItem[];
}>;