Skip to content

Commit da69ba4

Browse files
committed
feat: #28 passing params in show method
1 parent 075ad20 commit da69ba4

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

dist/VueFinalModal.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/PluginCore.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function createVfm(options) {
1111
return this.modals.filter(modal => modal.value)
1212
},
1313
modals: [],
14-
show(name) {
15-
this.toggle(name, true)
14+
show(name, params) {
15+
this.toggle(name, true, params)
1616
},
1717
hide(name) {
1818
this.toggle(name, false)
@@ -22,10 +22,10 @@ function createVfm(options) {
2222
modal.$emit('input', false)
2323
})
2424
},
25-
toggle(name, show) {
25+
toggle(name, ...args) {
2626
const modal = this.modals.find(modal => modal.name === name)
2727
if (modal !== undefined) {
28-
modal.$emit('input', show === undefined ? !modal.value : show)
28+
modal.toggle(...args)
2929
}
3030
},
3131
lockScroll() {

lib/VueFinalModal.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
:class="[contentClass, { 'vfm--prevent-auto': preventClick }]"
4747
:style="contentStyle"
4848
>
49-
<slot />
49+
<slot v-bind:params="params" />
5050
</div>
5151
</div>
5252
</transition>
@@ -110,7 +110,8 @@ export default {
110110
},
111111
overlayTransitionState: null,
112112
modalTransitionState: null,
113-
stopEvent: false
113+
stopEvent: false,
114+
params: null
114115
}),
115116
computed: {
116117
api() {
@@ -289,6 +290,7 @@ export default {
289290
this.lockScroll && this.api.unlockScroll()
290291
}
291292
this.$emit('closed', this.createModalEvent({ type: 'closed' }))
293+
this.params = null
292294
},
293295
onClickContainer() {
294296
this.$emit('click-outside', this.createModalEvent({ type: 'click-outside' }))
@@ -299,10 +301,10 @@ export default {
299301
this.$emit('input', false)
300302
}
301303
},
302-
createModalEvent(params = {}) {
304+
createModalEvent(eventProps = {}) {
303305
return {
304306
ref: this,
305-
...params
307+
...eventProps
306308
}
307309
},
308310
emitEvent(eventType, value) {
@@ -320,6 +322,13 @@ export default {
320322
return true
321323
}
322324
return false
325+
},
326+
toggle(show, params) {
327+
const value = typeof show === 'boolean' ? show : !this.value
328+
if (value && arguments.length === 2) {
329+
this.params = params
330+
}
331+
this.$emit('input', value)
323332
}
324333
}
325334
}

0 commit comments

Comments
 (0)