Skip to content

Commit a06ecbb

Browse files
authored
Merge pull request #135 from m93a/patch
Add Type Definitions
2 parents 12d750f + 66defc7 commit a06ecbb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "src/main.cjs.js",
66
"module": "src/main.es.js",
77
"svelte": "src/Portal.svelte",
8+
"types": "src/Portal.svelte.d.ts",
89
"scripts": {
910
"test": "jest test",
1011
"test:watch": "npm run test -- --watch",

src/Portal.svelte.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { SvelteComponentTyped } from "svelte";
2+
/**
3+
* Usage: <div use:portal={'css selector'}> or <div use:portal={document.body}>
4+
*
5+
* @param {HTMLElement} el
6+
* @param {HTMLElement|string} target DOM Element or CSS Selector
7+
*/
8+
export declare function portal(
9+
el: HTMLElement,
10+
target?: HTMLElement | string
11+
): {
12+
update: (newTarget: HTMLElement | string) => Promise<void>;
13+
destroy: () => void;
14+
};
15+
declare const __propDef: {
16+
props: {
17+
/**
18+
* DOM Element or CSS Selector
19+
* @type { HTMLElement|string}
20+
*/ target?: string | HTMLElement | undefined;
21+
};
22+
events: {
23+
[evt: string]: CustomEvent<any>;
24+
};
25+
slots: {
26+
default: {};
27+
};
28+
};
29+
export declare type PortalProps = typeof __propDef.props;
30+
export declare type PortalEvents = typeof __propDef.events;
31+
export declare type PortalSlots = typeof __propDef.slots;
32+
export default class Portal extends SvelteComponentTyped<
33+
PortalProps,
34+
PortalEvents,
35+
PortalSlots
36+
> {}
37+
export {};

0 commit comments

Comments
 (0)