From 65904575743ba06344fb75e14685e42494c13cde Mon Sep 17 00:00:00 2001 From: metonym Date: Thu, 1 Feb 2024 07:56:34 -0800 Subject: [PATCH] fix(types): improve `e.detail` type for dispatched events (#1907) * fix(types): improve `e.detail` type for dispatched events * Run "yarn build:docs" * test: assert new types --- COMPONENT_INDEX.md | 44 +++++++++---------- docs/src/COMPONENT_API.json | 20 ++++++--- src/ListBox/ListBoxSelection.svelte | 4 ++ src/Slider/Slider.svelte | 4 ++ src/StructuredList/StructuredList.svelte | 4 ++ src/Tabs/Tabs.svelte | 4 ++ tests/Slider.test.svelte | 3 ++ tests/StructuredList.test.svelte | 8 +++- tests/Tabs.test.svelte | 6 ++- types/ListBox/ListBoxSelection.svelte.d.ts | 2 +- types/Slider/Slider.svelte.d.ts | 2 +- .../StructuredList/StructuredList.svelte.d.ts | 2 +- types/Tabs/Tabs.svelte.d.ts | 2 +- 13 files changed, 70 insertions(+), 35 deletions(-) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 3af93e1254..74342c9564 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -2151,9 +2151,9 @@ None. ### Events -| Event name | Type | Detail | -| :--------- | :--------- | :----- | -| clear | dispatched | -- | +| Event name | Type | Detail | +| :--------- | :--------- | :------------------------------------------- | +| clear | dispatched | KeyboardEvent | MouseEvent | ## `ListItem` @@ -3530,13 +3530,13 @@ None. ### Events -| Event name | Type | Detail | -| :--------- | :--------- | :----- | -| click | forwarded | -- | -| mouseover | forwarded | -- | -| mouseenter | forwarded | -- | -| mouseleave | forwarded | -- | -| change | dispatched | -- | +| Event name | Type | Detail | +| :--------- | :--------- | :------------------ | +| change | dispatched | number | +| click | forwarded | -- | +| mouseover | forwarded | -- | +| mouseenter | forwarded | -- | +| mouseleave | forwarded | -- | ## `SliderSkeleton` @@ -3578,13 +3578,13 @@ None. ### Events -| Event name | Type | Detail | -| :--------- | :--------- | :----- | -| click | forwarded | -- | -| mouseover | forwarded | -- | -| mouseenter | forwarded | -- | -| mouseleave | forwarded | -- | -| change | dispatched | -- | +| Event name | Type | Detail | +| :--------- | :--------- | :------------------ | +| change | dispatched | string | +| click | forwarded | -- | +| mouseover | forwarded | -- | +| mouseenter | forwarded | -- | +| mouseleave | forwarded | -- | ## `StructuredListBody` @@ -3966,11 +3966,11 @@ None. ### Events -| Event name | Type | Detail | -| :--------- | :--------- | :----- | -| keypress | forwarded | -- | -| click | forwarded | -- | -| change | dispatched | -- | +| Event name | Type | Detail | +| :--------- | :--------- | :------------------ | +| change | dispatched | number | +| keypress | forwarded | -- | +| click | forwarded | -- | ## `TabsSkeleton` diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index e7a5e2be59..9270aadf57 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -6294,7 +6294,13 @@ ], "moduleExports": [], "slots": [], - "events": [{ "type": "dispatched", "name": "clear" }], + "events": [ + { + "type": "dispatched", + "name": "clear", + "detail": "KeyboardEvent | MouseEvent" + } + ], "typedefs": [ { "type": "\"clearAll\" | \"clearSelection\"", @@ -11354,11 +11360,11 @@ } ], "events": [ + { "type": "dispatched", "name": "change", "detail": "number" }, { "type": "forwarded", "name": "click", "element": "div" }, { "type": "forwarded", "name": "mouseover", "element": "div" }, { "type": "forwarded", "name": "mouseenter", "element": "div" }, - { "type": "forwarded", "name": "mouseleave", "element": "div" }, - { "type": "dispatched", "name": "change" } + { "type": "forwarded", "name": "mouseleave", "element": "div" } ], "typedefs": [], "rest_props": { "type": "Element", "name": "div" } @@ -11446,11 +11452,11 @@ "moduleExports": [], "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], "events": [ + { "type": "dispatched", "name": "change", "detail": "string" }, { "type": "forwarded", "name": "click", "element": "div" }, { "type": "forwarded", "name": "mouseover", "element": "div" }, { "type": "forwarded", "name": "mouseenter", "element": "div" }, - { "type": "forwarded", "name": "mouseleave", "element": "div" }, - { "type": "dispatched", "name": "change" } + { "type": "forwarded", "name": "mouseleave", "element": "div" } ], "typedefs": [], "rest_props": { "type": "Element", "name": "div" } @@ -12245,9 +12251,9 @@ { "name": "content", "default": false, "slot_props": "{}" } ], "events": [ + { "type": "dispatched", "name": "change", "detail": "number" }, { "type": "forwarded", "name": "keypress", "element": "div" }, - { "type": "forwarded", "name": "click", "element": "a" }, - { "type": "dispatched", "name": "change" } + { "type": "forwarded", "name": "click", "element": "a" } ], "typedefs": [], "rest_props": { "type": "Element", "name": "div" } diff --git a/src/ListBox/ListBoxSelection.svelte b/src/ListBox/ListBoxSelection.svelte index dec717dada..276026ce1d 100644 --- a/src/ListBox/ListBoxSelection.svelte +++ b/src/ListBox/ListBoxSelection.svelte @@ -1,4 +1,8 @@ - + Column A diff --git a/tests/Tabs.test.svelte b/tests/Tabs.test.svelte index 8f1f1b8867..dbf4daceab 100644 --- a/tests/Tabs.test.svelte +++ b/tests/Tabs.test.svelte @@ -2,7 +2,11 @@ import { Tabs, Tab, TabContent, TabsSkeleton } from "../types"; - + diff --git a/types/ListBox/ListBoxSelection.svelte.d.ts b/types/ListBox/ListBoxSelection.svelte.d.ts index cd6f546c32..b3414494b5 100644 --- a/types/ListBox/ListBoxSelection.svelte.d.ts +++ b/types/ListBox/ListBoxSelection.svelte.d.ts @@ -35,7 +35,7 @@ export interface ListBoxSelectionProps extends RestProps { export default class ListBoxSelection extends SvelteComponentTyped< ListBoxSelectionProps, - { clear: CustomEvent }, + { clear: CustomEvent }, {} > { /** diff --git a/types/Slider/Slider.svelte.d.ts b/types/Slider/Slider.svelte.d.ts index 028409a6b8..fb6c6b741e 100644 --- a/types/Slider/Slider.svelte.d.ts +++ b/types/Slider/Slider.svelte.d.ts @@ -126,11 +126,11 @@ export interface SliderProps extends RestProps { export default class Slider extends SvelteComponentTyped< SliderProps, { + change: CustomEvent; click: WindowEventMap["click"]; mouseover: WindowEventMap["mouseover"]; mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; - change: CustomEvent; }, { labelText: {} } > {} diff --git a/types/StructuredList/StructuredList.svelte.d.ts b/types/StructuredList/StructuredList.svelte.d.ts index b8172b4452..04b62f6dac 100644 --- a/types/StructuredList/StructuredList.svelte.d.ts +++ b/types/StructuredList/StructuredList.svelte.d.ts @@ -34,11 +34,11 @@ export interface StructuredListProps extends RestProps { export default class StructuredList extends SvelteComponentTyped< StructuredListProps, { + change: CustomEvent; click: WindowEventMap["click"]; mouseover: WindowEventMap["mouseover"]; mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; - change: CustomEvent; }, { default: {} } > {} diff --git a/types/Tabs/Tabs.svelte.d.ts b/types/Tabs/Tabs.svelte.d.ts index 4a336331c7..14a6fe60f0 100644 --- a/types/Tabs/Tabs.svelte.d.ts +++ b/types/Tabs/Tabs.svelte.d.ts @@ -40,9 +40,9 @@ export interface TabsProps extends RestProps { export default class Tabs extends SvelteComponentTyped< TabsProps, { + change: CustomEvent; keypress: WindowEventMap["keypress"]; click: WindowEventMap["click"]; - change: CustomEvent; }, { default: {}; content: {} } > {}