diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 31f94601..141b6c7d 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -648,8 +648,10 @@ None. ### Types ```ts +export type ComboBoxItemId = any; + export interface ComboBoxItem { - id: string; + id: ComboBoxItemId; text: string; } ``` @@ -662,7 +664,7 @@ export interface ComboBoxItem { | ref | let | Yes | null | HTMLInputElement | null | Obtain a reference to the input HTML element | | open | let | Yes | boolean | false | Set to `true` to open the combobox menu dropdown | | value | let | Yes | string | "" | Specify the selected combobox value | -| selectedId | let | Yes | string | -- | Set the selected item by value id | +| selectedId | let | Yes | ComboBoxItemId | -- | Set the selected item by value id | | items | let | No | ComboBoxItem[] | [] | Set the combobox items | | itemToString | let | No | (item: ComboBoxItem) => string | (item) => item.text || item.id | Override the display of a combobox item | | direction | let | No | "bottom" | "top" | "bottom" | Specify the direction of the combobox dropdown menu | @@ -688,15 +690,15 @@ None. ### Events -| Event name | Type | Detail | -| :--------- | :--------- | :-------------------------------------------------------------- | -| select | dispatched | { selectedId: string; selectedItem: ComboBoxItem } | -| keydown | forwarded | -- | -| keyup | forwarded | -- | -| focus | forwarded | -- | -| blur | forwarded | -- | -| clear | forwarded | -- | -| scroll | forwarded | -- | +| Event name | Type | Detail | +| :--------- | :--------- | :---------------------------------------------------------------------- | +| select | dispatched | { selectedId: ComboBoxItemId; selectedItem: ComboBoxItem } | +| keydown | forwarded | -- | +| keyup | forwarded | -- | +| focus | forwarded | -- | +| blur | forwarded | -- | +| clear | forwarded | -- | +| scroll | forwarded | -- | ## `ComposedModal` diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index d76f65f4..43209cf6 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -1398,7 +1398,7 @@ "name": "selectedId", "kind": "let", "description": "Set the selected item by value id", - "type": "string", + "type": "ComboBoxItemId", "isFunction": false, "isFunctionDeclaration": false, "constant": false, @@ -1627,7 +1627,7 @@ { "type": "dispatched", "name": "select", - "detail": "{ selectedId: string; selectedItem: ComboBoxItem }" + "detail": "{ selectedId: ComboBoxItemId; selectedItem: ComboBoxItem }" }, { "type": "forwarded", "name": "keydown", "element": "input" }, { "type": "forwarded", "name": "keyup", "element": "input" }, @@ -1638,9 +1638,14 @@ ], "typedefs": [ { - "type": "{ id: string; text: string; }", + "type": "any", + "name": "ComboBoxItemId", + "ts": "type ComboBoxItemId = any" + }, + { + "type": "{ id: ComboBoxItemId; text: string; }", "name": "ComboBoxItem", - "ts": "interface ComboBoxItem { id: string; text: string; }" + "ts": "interface ComboBoxItem { id: ComboBoxItemId; text: string; }" } ], "rest_props": { "type": "Element", "name": "input" } diff --git a/types/ComboBox/ComboBox.svelte.d.ts b/types/ComboBox/ComboBox.svelte.d.ts index 17bf77d1..1b2db20b 100644 --- a/types/ComboBox/ComboBox.svelte.d.ts +++ b/types/ComboBox/ComboBox.svelte.d.ts @@ -1,8 +1,10 @@ /// 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"];