Skip to content

Commit a2b7737

Browse files
Merge pull request #16 from Mini-ghost/next
feat(types): add typescript support for vue 3
2 parents a87622e + 9cd0275 commit a2b7737

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
dist
1+
dist
2+
types/**/*.d.ts

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
"jsnext:main": "dist/VueFinalModal.esm.js",
99
"unpkg": "dist/VueFinalModal.umd.js",
1010
"jsdelivr": "dist/VueFinalModal.umd.js",
11+
"types": "types/index.d.ts",
1112
"files": [
1213
"lib",
13-
"dist"
14+
"dist",
15+
"types/index.d.ts"
1416
],
1517
"scripts": {
1618
"build": "rollup -c",

types/index.d.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import {
2+
App,
3+
Ref,
4+
SetupContext,
5+
EmitsOptions,
6+
ComponentPublicInstance
7+
} from 'vue'
8+
9+
interface VueFinalModal {
10+
install(app: App): void
11+
}
12+
13+
interface VueFinalModalInfo {
14+
uid: symbol
15+
name: string
16+
emit: SetupContext<EmitsOptions>
17+
vfmContent: Ref<HTMLDivElement>
18+
getAttachElement(): false | HTMLElement
19+
modalStackIndex: Ref<number | null>
20+
visibility: {
21+
modal: boolean
22+
overlay: boolean
23+
}
24+
handleLockScroll(): void
25+
hideOverlay: boolean
26+
focusTrap: boolean
27+
}
28+
29+
export type VueFinalModalComponent = ComponentPublicInstance & {
30+
vfmContainer: HTMLDivElement,
31+
vfmContent: HTMLDivElement
32+
}
33+
34+
export type VusFinalModalProperty = {
35+
openedModals: VueFinalModalInfo[]
36+
modals: VueFinalModalInfo[]
37+
show(name: string): void
38+
hide(name: string): void
39+
hideAll(): void
40+
toggle(name: string, show: boolean): void
41+
}
42+
43+
declare module '@vue/runtime-core' {
44+
interface ComponentCustomProperties {
45+
readonly $vfm: VusFinalModalProperty
46+
}
47+
}
48+
49+
declare const VueFinalModal: VueFinalModal
50+
export default VueFinalModal

0 commit comments

Comments
 (0)