Skip to content

Commit 87864f9

Browse files
authored
Support dynamic modal method type for version 2.0.0 (#45)
* build: add vue dependencies * chore: replace type with interface * feat(type): support dynamic modal
1 parent 1d1f03b commit 87864f9

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@
7575
"vetur": {
7676
"tags": "vetur/tags.json",
7777
"attributes": "vetur/attributes.json"
78+
},
79+
"dependencies": {
80+
"vue": "^2.6.12"
7881
}
7982
}

types/index.d.ts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Vue, { PluginObject } from 'vue'
1+
import Vue, { PluginObject, VNodeData, Component, AsyncComponent } from 'vue'
22
import './lib'
33

44
export class VueFinalModalComponant extends Vue {
@@ -8,11 +8,52 @@ export class VueFinalModalComponant extends Vue {
88
}
99
}
1010

11-
export type VueFinalModalProperty = {
11+
export interface DynamicModalOptions {
12+
/**
13+
* modal component
14+
*/
15+
component?: string | Component | AsyncComponent
16+
/**
17+
* bind props and attrs to modal
18+
*/
19+
bind?: {[key: string]: any}
20+
/**
21+
* register events to modal
22+
*/
23+
on?: VNodeData['on']
24+
/**
25+
* modal component slot
26+
*
27+
* @example
28+
* ```js
29+
* {
30+
* slot: {
31+
* default: {
32+
* component: 'RegistedComponentName'
33+
* bind: {
34+
* yourPropsKey: propsValue
35+
* }
36+
* }
37+
* }
38+
* }
39+
* ```
40+
*/
41+
slots?: {
42+
[key: string]: {
43+
component: string | Component | AsyncComponent
44+
bind: {[key: string]: any}
45+
}
46+
}
47+
}
48+
49+
export interface VueFinalModalProperty {
1250
readonly openedModals: VueFinalModalComponant[]
1351
readonly modals: VueFinalModalComponant[],
1452
get(name: string): VueFinalModalComponant | undefined
15-
show(name: string): void
53+
54+
show(name: string, params?: any): void
55+
show(options: DynamicModalOptions, params?: any): void
56+
1657
hide(name: string): void
1758
hideAll(): void
1859
toggle(name: string, params?: any): void

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9089,6 +9089,11 @@ vue-template-es2015-compiler@^1.9.0:
90899089
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
90909090
integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==
90919091

9092+
vue@^2.6.12:
9093+
version "2.6.12"
9094+
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.12.tgz#f5ebd4fa6bd2869403e29a896aed4904456c9123"
9095+
integrity sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg==
9096+
90929097
watchpack-chokidar2@^2.0.1:
90939098
version "2.0.1"
90949099
resolved "https://registry.yarnpkg.com/watchpack-chokidar2/-/watchpack-chokidar2-2.0.1.tgz#38500072ee6ece66f3769936950ea1771be1c957"

0 commit comments

Comments
 (0)