Skip to content

Commit 18cc84c

Browse files
committed
Merge branch 'dev' into feature/dynamic-modal
2 parents 331c6af + 3e5fe41 commit 18cc84c

18 files changed

+227
-157
lines changed

README.md

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export default {
143143

144144
### **Open modal with API**
145145

146+
> `v-model` is necessary when you open a modal with `$vfm.show(name)` API.
147+
146148
```html
147149
<vue-final-modal v-model="showModal" name="example">
148150
Modal Content Here
@@ -182,23 +184,23 @@ Changes API name from "$vfm" to any other string value. It is useful when you us
182184

183185
## **API**
184186

185-
Plugin API can be called within any component through `this.$vfm`.
186-
187-
### `$vfm.openedModals`
188-
189-
- Type: `Array`
187+
- In Options API:
190188

191-
A stack array store the opened modal's vue component instance.
189+
Plugin API can be called within any component through `this.$vfm`.
192190

193-
You can use:
194-
1. `$vfm.openedModals[0]` to get the first opened modal instance.
195-
2. `$vfm.openedModals.length` to get how many modals is opened.
191+
- In Composition API (Only in Vue 3 version):
196192

197-
### `$vfm.modals`
193+
> Only support in Vue 3
198194
199-
- Type: `Array`
195+
```js
196+
import { inject } from 'vue'
200197

201-
All modal instances include show and hide.
198+
export default {
199+
setup() {
200+
const $vfm = inject('$vfm')
201+
}
202+
}
203+
```
202204

203205
### `$vfm.show(name, params)`
204206

@@ -227,22 +229,27 @@ Or get `params` on `@beforeOpen` event:
227229

228230
```html
229231
<template>
230-
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
232+
<vue-final-modal v-model="show" name="example">
233+
<template v-slot="{ params }">
234+
Hi {{ params.userName }}
235+
</template>
236+
</vue-final-modal>
231237
</template>
232238

233239
<script>
234-
export default {
235-
name: 'MyComponent',
240+
export default {
236241
data: () => ({
237242
show: false
238243
}),
239-
mounted () {
240-
this.$vfm.show('example')
244+
mounted() {
245+
this.$vfm.show('example', { userName: 'vue-final-modal' })
241246
}
242-
}
247+
}
243248
</script>
244249
```
245250

251+
> `v-model` is necessary when you open a modal with `$vfm.show(name)` API.
252+
246253
### `$vfm.hide(name)`
247254

248255
- Type: `Function`
@@ -257,7 +264,6 @@ export default {
257264

258265
<script>
259266
export default {
260-
name: 'MyComponent',
261267
data: () => ({
262268
show: true
263269
}),
@@ -298,11 +304,36 @@ Or get `params` on `@beforeOpen` event:
298304
299305
toggle modal by name.
300306

307+
### `$vfm.get(name)`
308+
309+
- Type: `Function`
310+
- Arguments:
311+
- name: `String` - Name of the modal
312+
313+
return the modal comopnent instance.
314+
315+
### `$vfm.openedModals`
316+
317+
- Type: `Array`
318+
319+
A stack array store the opened modal's vue component instance.
320+
321+
You can use:
322+
1. `$vfm.openedModals[0]` to get the first opened modal instance.
323+
2. `$vfm.openedModals.length` to get how many modals is opened.
324+
325+
### `$vfm.modals`
326+
327+
- Type: `Array`
328+
329+
All modal instances include show and hide.
330+
301331
## **Props**
302332

303333
```js
304334
{
305335
value: { type: Boolean, default: false },
336+
name: { type: String, default: null },
306337
ssr: { type: Boolean, default: true },
307338
classes: { type: [String, Object, Array], default: '' },
308339
overlayClass: { type: [String, Object, Array], default: '' },

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.

docs/content/en/index.md

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Introduction
33
description: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
44
position: 0
55
category: Getting Start
6-
version: 0.20
6+
version: 0.21
77
features:
88
- Support Vue 3 and Vue 2
99
- Tailwind CSS friendly
@@ -37,7 +37,6 @@ features:
3737
<a href="https://www.npmjs.com/package/vue-final-modal"><img src="https://badgen.net/badgesize/brotli/hunterliu1003/vue-final-modal/next/dist/VueFinalModal.umd.js" alt="Size"></a>
3838
</p>
3939

40-
4140
<p align="right">
4241
<a href="https://www.buymeacoffee.com/PL2qJIx" target="_blank" rel="noopener noreferrer">
4342
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-green.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" >
@@ -117,18 +116,16 @@ Vue.use(VueFinalModal())
117116

118117
```js[nuxt.config.js]
119118
export default {
120-
plugins: [
121-
'~plugins/vue-final-modal.js'
122-
],
119+
plugins: ['~plugins/vue-final-modal.js'],
123120
build: {
124-
transpile: ['vue-final-modal'],
121+
transpile: ['vue-final-modal']
125122
}
126123
}
127124
```
128125

129126
### CDN
130127

131-
> [Live demo](https://codepen.io/hunterliu1003/pen/ZEWoYeE)
128+
<alert>[Live demo](https://codepen.io/hunterliu1003/pen/ZEWoYeE)</alert>
132129

133130
- **jsDelivr**
134131

@@ -156,6 +153,8 @@ export default {
156153

157154
### **Open modal with API**
158155

156+
<alert>`v-model` is necessary when you open a modal with `$vfm.show(name)` API.</alert>
157+
159158
```html
160159
<vue-final-modal v-model="showModal" name="example">
161160
Modal Content Here
@@ -188,15 +187,15 @@ Changes component name from "VueFinalModal" to any other string value. It is use
188187
- Type: `String`
189188
- default: `'$vfm'`
190189

191-
Changes API name from "$vfm" to any other string value. It is useful when you use `vue-final-modal` as spinner, toast, notify, etc.
190+
Changes API name from "\$vfm" to any other string value. It is useful when you use `vue-final-modal` as spinner, toast, notify, etc.
192191

193192
## **API**
194193

195-
- In Options API:
194+
- **Options API**
196195

197196
Plugin API can be called within any component through `this.$vfm`.
198197

199-
- In Composition API:
198+
- **Composition API** <badge>Only in Vue 3 version</badge>
200199

201200
```js
202201
import { inject } from 'vue'
@@ -229,28 +228,33 @@ Or get `params` on `@beforeOpen` event:
229228
</vue-final-modal>
230229
```
231230

232-
> `parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.
231+
<alert>`parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.</alert>
233232

234233
- Example:
235234

236235
```html
237236
<template>
238-
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
237+
<vue-final-modal v-model="show" name="example">
238+
<template v-slot="{ params }">
239+
Hi {{ params.userName }}
240+
</template>
241+
</vue-final-modal>
239242
</template>
240243

241244
<script>
242-
export default {
243-
name: 'MyComponent',
245+
export default {
244246
data: () => ({
245247
show: false
246248
}),
247-
mounted () {
248-
this.$vfm.show('example')
249+
mounted() {
250+
this.$vfm.show('example', { userName: 'vue-final-modal' })
249251
}
250-
}
252+
}
251253
</script>
252254
```
253255

256+
<alert>`v-model` is necessary when you open a modal with `$vfm.show(name)` API.</alert>
257+
254258
### `$vfm.hide(name)`
255259

256260
- Type: `Function`
@@ -260,19 +264,18 @@ export default {
260264

261265
```html
262266
<template>
263-
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
267+
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
264268
</template>
265269

266270
<script>
267-
export default {
268-
name: 'MyComponent',
271+
export default {
269272
data: () => ({
270273
show: true
271274
}),
272-
mounted () {
273-
this.$vfm.hide('example')
275+
mounted() {
276+
this.$vfm.hide('example')
274277
}
275-
}
278+
}
276279
</script>
277280
```
278281

@@ -302,7 +305,7 @@ Or get `params` on `@beforeOpen` event:
302305
</vue-final-modal>
303306
```
304307

305-
> `parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.
308+
<alert>`parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.</alert>
306309

307310
toggle modal by name.
308311

@@ -321,6 +324,7 @@ return the modal comopnent instance.
321324
A stack array store the opened modal's vue component instance.
322325

323326
You can use:
327+
324328
1. `$vfm.openedModals[0]` to get the first opened modal instance.
325329
2. `$vfm.openedModals.length` to get how many modals is opened.
326330

@@ -332,6 +336,15 @@ All modal instances include show and hide.
332336

333337
## **Props**
334338

339+
### `name`
340+
341+
- Type: `String`
342+
- Default: `null`
343+
344+
Modal name for global API `$vfm.show(name)`, `$vfm.hide(name)`, etc.
345+
346+
<alert>`v-model` is necessary when you open a modal with `$vfm.show(name)` API.</alert>
347+
335348
### `ssr`
336349

337350
- Type: `Boolean`
@@ -464,7 +477,7 @@ Set the root element of `vue-final-modal` style to `pointer-events: none;`.
464477

465478
Specifies which DOM element that this component should detach to.
466479

467-
1. Set `false` will disabled this feature.
480+
1. Set `false` will disabled this feature.
468481
2. String can be any valid `querySelector`, e.g. `'body'`, `'#app'`.
469482
3. Object can be any valid `Node`, e.g. `this.$refs.container`.
470483

@@ -513,21 +526,20 @@ Enables focus trap meaning that only inputs/buttons that are withing the modal w
513526

514527
```vue
515528
<template>
516-
<vue-final-modal
517-
@click-outside="clickOutside"
518-
@before-open="beforeOpen"
519-
@opened="opened"
520-
@before-close="beforeClose"
521-
@closed="closed"
522-
>
523-
...modal content
524-
</vue-final-modal>
529+
<vue-final-modal
530+
@click-outside="clickOutside"
531+
@before-open="beforeOpen"
532+
@opened="opened"
533+
@before-close="beforeClose"
534+
@closed="closed"
535+
>
536+
...modal content
537+
</vue-final-modal>
525538
</template>
526539
```
527540

528541
</show-code>
529542

530-
531543
### `@click-outside`
532544

533545
- Emits while modal container on click.
@@ -544,7 +556,7 @@ If prop `clickToClose` is `false`, the event will still be emitted.
544556

545557
### `@opened`
546558

547-
- Emits after modal became visible and transition ended.
559+
- Emits after modal became visible and transition ended.
548560

549561
### `@before-close`
550562

@@ -572,12 +584,11 @@ Or get `params` on `@beforeOpen` event:
572584
</vue-final-modal>
573585
```
574586

575-
> `parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.
576-
587+
<alert>`parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.</alert>
577588

578589
## **Contribution**
579590

580-
👋 Hi I'm Hunter, the author of `vue-final-modal`.
591+
👋 Hi I'm Hunter, the author of `vue-final-modal`.
581592

582593
To develop vue-final-modal, I learn a lot from these awesome libraries:
583594

@@ -594,6 +605,6 @@ To develop vue-final-modal, I learn a lot from these awesome libraries:
594605
- [Bootstrap Vue](https://bootstrap-vue.org/)
595606
- lockScroll
596607

597-
> There is no perfect library even the `final` of vue modal.
608+
<alert>There is no perfect library even the `final` of vue modal.</alert>
598609

599-
If you have any ideas for optimization of `vue-final-modal`, feel free to open [issues](https://github.com/hunterliu1003/vue-final-modal/issues) or [pull requests](https://github.com/hunterliu1003/vue-final-modal/pulls).
610+
🚀 If you have any ideas for optimization of `vue-final-modal`, feel free to open [issues](https://github.com/hunterliu1003/vue-final-modal/issues) or [pull requests](https://github.com/hunterliu1003/vue-final-modal/pulls).

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@nuxt/content-theme-docs": "^0.6.1",
1313
"nuxt": "^2.14.8",
14-
"vue-final-modal": "^0.20.1"
14+
"vue-final-modal": "^0.21.1"
1515
},
1616
"devDependencies": {
1717
"@nuxtjs/google-analytics": "^2.4.0",

0 commit comments

Comments
 (0)