Skip to content

Commit 176a6e6

Browse files
committed
Merge branch 'dev' into next
2 parents 3aea496 + c42962b commit 176a6e6

File tree

10 files changed

+65
-13
lines changed

10 files changed

+65
-13
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.

docs/content/en/index.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,47 @@ Or get `params` on `@beforeOpen` event:
586586

587587
<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>
588588

589+
## TypeScript
590+
591+
### Vue
592+
Works out of the box in Vue, no other settings are required. But if you customized your access key, you must define the type yourself like below:
593+
594+
```ts
595+
import Vue from 'vue'
596+
import VueFinalModal, {
597+
VfmOptions,
598+
VueFinalModalProperty
599+
} from 'vue-final-modal'
600+
601+
Vue.use<VfmOptions>(VueFinalModal(), {
602+
componentName: 'MyComponentName',
603+
key: 'myKey',
604+
})
605+
606+
// define the type of access key yourself
607+
declare module 'vue/types/vue' {
608+
interface Vue {
609+
myKey: VueFinalModalProperty;
610+
}
611+
}
612+
```
613+
614+
### Nuxt
615+
616+
Add the types to your "types" array in tsconfig.json file
617+
618+
```js
619+
{
620+
"compilerOptions": {
621+
"types": [
622+
// other types
623+
// ...
624+
"vue-final-modal"
625+
]
626+
}
627+
}
628+
```
629+
589630
## **Contribution**
590631

591632
👋 Hi I'm Hunter, the author of `vue-final-modal`.

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.21.1"
14+
"vue-final-modal": "^0.21.2"
1515
},
1616
"devDependencies": {
1717
"@nuxtjs/google-analytics": "^2.4.0",

docs/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9948,10 +9948,10 @@ vue-client-only@^2.0.0:
99489948
resolved "https://registry.yarnpkg.com/vue-client-only/-/vue-client-only-2.0.0.tgz#ddad8d675ee02c761a14229f0e440e219de1da1c"
99499949
integrity sha512-arhk1wtWAfLsJyxGMoEYhoBowM87/i6HLSG2LH/03Yog6i2d9JEN1peMP0Ceis+/n9DxdenGYZZTxbPPJyHciA==
99509950

9951-
vue-final-modal@^0.21.1:
9952-
version "0.21.1"
9953-
resolved "https://registry.yarnpkg.com/vue-final-modal/-/vue-final-modal-0.21.1.tgz#ae869a06eeaf727cb6810b4c4c2ca806acba6a9b"
9954-
integrity sha512-BdvqIb7pHCLTOlf+ldP8VcUg3/rm9Sk1fXCa3fuR9buTceIT+rtKsVLoTPFSVwI7wYwVv9ZBwHNjDRiyj2ydCQ==
9951+
vue-final-modal@^0.21.2:
9952+
version "0.21.2"
9953+
resolved "https://registry.yarnpkg.com/vue-final-modal/-/vue-final-modal-0.21.2.tgz#c471c9473727357306dce0f2b0f493cbb7424a42"
9954+
integrity sha512-cstJnbJ3sgyoih14J4zHbuxk+zPTRU745nIA80oMQXyf0uTneV2epxIuBPeQDr1DGDCDQNcE6aFHUQVQ7luyBA==
99559955

99569956
vue-hot-reload-api@^2.3.0:
99579957
version "2.3.4"

lib/PluginCore.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ function createVfm() {
2525
get(name) {
2626
return this.modals.find(modal => modal.props.name === name)
2727
},
28-
get openedModals() {
29-
return this.modals.filter(modal => modal.props.modelValue)
30-
},
28+
openedModals: [],
3129
modals: []
3230
}
3331
return vfm

lib/VueFinalModal.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ export default {
227227
if (target || props.attach === false) {
228228
props.attach !== false && target.appendChild(root.value)
229229
230+
let index = $vfm.openedModals.findIndex(vm => vm.uid === uid)
231+
232+
if (index !== -1) {
233+
// if this is already exist in modalStack, delete it
234+
$vfm.openedModals.splice(index, 1)
235+
}
236+
$vfm.openedModals.push(getModalInfo())
237+
230238
modalStackIndex.value = $vfm.openedModals.length - 1
231239
232240
handleLockScroll()
@@ -251,6 +259,11 @@ export default {
251259
}
252260
}
253261
function close() {
262+
let index = $vfm.openedModals.findIndex(vm => vm.uid === uid)
263+
if (index !== -1) {
264+
// remove this in modalStack
265+
$vfm.openedModals.splice(index, 1)
266+
}
254267
if ($vfm.openedModals.length > 0) {
255268
// If there are still nested modals opened
256269
const $_vm = $vfm.openedModals[$vfm.openedModals.length - 1]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"files": [
1313
"lib",
1414
"dist",
15-
"types/index.d.ts",
15+
"types",
1616
"vetur"
1717
],
1818
"scripts": {

0 commit comments

Comments
 (0)