fix(tooltip): type Tooltip open, close events (#1058)

This commit is contained in:
metonym 2022-02-01 07:20:43 -08:00 committed by GitHub
commit 504cf09dc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 6 deletions

View file

@ -4680,7 +4680,9 @@ None.
### Events ### Events
| Event name | Type | Detail | | Event name | Type | Detail |
| :--------- | :-------- | :----- | | :--------- | :--------- | :--------------- |
| open | dispatched | <code>any</code> |
| close | dispatched | <code>any</code> |
| click | forwarded | -- | | click | forwarded | -- |
| mousedown | forwarded | -- | | mousedown | forwarded | -- |

View file

@ -13090,6 +13090,8 @@
} }
], ],
"events": [ "events": [
{ "type": "dispatched", "name": "open", "detail": "any" },
{ "type": "dispatched", "name": "close", "detail": "any" },
{ "type": "forwarded", "name": "click", "element": "div" }, { "type": "forwarded", "name": "click", "element": "div" },
{ "type": "forwarded", "name": "mousedown", "element": "div" } { "type": "forwarded", "name": "mousedown", "element": "div" }
], ],

View file

@ -1,4 +1,9 @@
<script> <script>
/**
* @event {any} open
* @event {any} close
*/
/** /**
* Set the alignment of the tooltip relative to the icon * Set the alignment of the tooltip relative to the icon
* @type {"start" | "center" | "end"} * @type {"start" | "center" | "end"}

View file

@ -1,9 +1,11 @@
<script lang="ts"> <script lang="ts">
import { Tooltip, Link, Button } from "../types"; import { Tooltip, Link, Button } from "../types";
import Catalog16 from "carbon-icons-svelte/lib/Catalog16"; import Catalog16 from "carbon-icons-svelte/lib/Catalog16";
let open = true;
</script> </script>
<Tooltip> <Tooltip bind:open on:open on:close>
<p>Resources are provisioned based on your account's organization.</p> <p>Resources are provisioned based on your account's organization.</p>
</Tooltip> </Tooltip>

View file

@ -91,6 +91,11 @@ export interface TooltipProps
export default class Tooltip extends SvelteComponentTyped< export default class Tooltip extends SvelteComponentTyped<
TooltipProps, TooltipProps,
{ click: WindowEventMap["click"]; mousedown: WindowEventMap["mousedown"] }, {
open: CustomEvent<any>;
close: CustomEvent<any>;
click: WindowEventMap["click"];
mousedown: WindowEventMap["mousedown"];
},
{ default: {}; icon: {}; triggerText: {} } { default: {}; icon: {}; triggerText: {} }
> {} > {}