Skip to content

Commit 571d65d

Browse files
Version/2.2 (#95)
* feat: support v-html in dynamic modal slot (#73) * feat: add postcss plugin autoprefixer (#71) * refactor: plugin validation, unit test (#70) * feat: vite (#78) * feat: api return promise (#76) * feat: add close method to scoped-slot (#93)
1 parent 408603f commit 571d65d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3262
-14675
lines changed

.babelrc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
{
2-
"presets": ["@babel/preset-env"]
3-
}
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"exclude": ["@babel/plugin-transform-regenerator"]
7+
}
8+
]
9+
]
10+
}

.browserslistrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# default
12
dist
23
types/**/*.d.ts
3-
docs
4+
5+
# docs
6+
docs/.nuxt
7+
docs/docs
8+
docs/static
9+
10+
# example
11+
example/dist

.eslintrc.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module.exports = {
22
root: true,
33
env: {
4-
node: true
4+
node: true,
5+
jest: true
56
},
67
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
78
parserOptions: {
@@ -10,16 +11,5 @@ module.exports = {
1011
rules: {
1112
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
1213
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
13-
},
14-
overrides: [
15-
{
16-
files: [
17-
'**/__tests__/*.{j,t}s?(x)',
18-
'**/tests/unit/**/*.spec.{j,t}s?(x)'
19-
],
20-
env: {
21-
jest: true
22-
}
23-
}
24-
]
14+
}
2515
}

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/components/examples/basic/VDynamicAdvanced.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</template>
44

55
<script>
6-
import VContent from '../VContent.vue'
6+
import VDescription from '../VDescription.vue'
77
88
export default {
99
methods: {
@@ -48,7 +48,7 @@ export default {
4848
}
4949
},
5050
default: {
51-
component: VContent,
51+
component: VDescription,
5252
bind: {
5353
content: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
5454
}

docs/content/en/api.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ export default {
3131
- Arguments:
3232
- name: `String` - Name of the modal
3333
- params: `?: object` - Any data that you want to pass into the modal, checkout the guide [params](/guide/params).
34+
- Returns: Promise<Object> | Promise<Array>
35+
3436

3537
<show-code text="Example">
3638

3739
<v-api-show class="py-4"></v-api-show>
3840

3941
```js
4042
this.$vfm.show('example', { userName: 'vue-final-modal' })
43+
.then(() => {
44+
// do something on modal opened
45+
})
4146
```
4247

4348
```html[Modal.vue]
@@ -67,6 +72,7 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
6772
- Type: `Function`
6873
- Arguments:
6974
- names: `String` - The names to hide
75+
- Returns: Promise<Object> | Promise<Array>
7076

7177
<show-code text="Example">
7278

@@ -83,7 +89,9 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
8389
show2: true
8490
}),
8591
mounted() {
86-
this.$vfm.hide('example', 'example2')
92+
this.$vfm.hide('example', 'example2').then(() => {
93+
// do something on modal closed
94+
})
8795
}
8896
}
8997
</script>
@@ -93,18 +101,33 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
93101

94102
### `hideAll()`
95103

104+
- Returns: Promise<Object> | Promise<Array>
105+
96106
hide all modals.
97107

108+
```js
109+
this.$vfm.hideAll().then(() => {
110+
// do something on all modals closed
111+
})
112+
```
113+
98114
### `toggle(name, show, params)`
99115

100116
- Type: `Function`
101117
- Arguments:
102118
- name: [`String` | `Array`] - The names of the modal
103119
- show: `?: Boolean` - Show modal or not
104120
- params: `?: object` - Any data that you want to pass into the modal, checkout the guide [params](/guide/params).
121+
- Returns: Promise<Object> | Promise<Array>
105122

106123
toggle modals by name.
107124

125+
```js
126+
this.$vfm.toggle('myModal').then(() => {
127+
// do something on modals opened or closed, it depends on params `show` is true or false
128+
})
129+
```
130+
108131
### `get([names])`
109132

110133
- Type: `Function`

docs/content/en/dynamic-modal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ To show dynamic modal you can use the API `$vfm.show` function.
4242
- Arguments:
4343
- dynamicModalOptions: `Object`
4444
- params: same as [API $vfm.show](/api#showname-params)
45+
- Returns: Promise<Object> | Promise<Array>
4546

4647
```ts
4748
type dynamicModalOptions = {

docs/content/en/guide/scoped-slots.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Scoped Slots
3+
description: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
4+
position: 6
5+
category: Guide
6+
fullscreen: true
7+
---
8+
9+
## close
10+
11+
- type: `Function`
12+
13+
When you are using vue-final-modal as a HOC. you can `close` modal with scoped-slot:
14+
15+
```vue
16+
<template>
17+
<vue-final-modal v-slot="{ close }" v-bind="$attrs" v-on="$listeners">
18+
<div>Hello Vue Final Modal</div>
19+
<button @click="close">close modal</button>
20+
</vue-final-modal>
21+
</template>
22+
23+
<script>
24+
export default {
25+
name: 'VModal',
26+
inheritAttrs: false
27+
}
28+
</script>
29+
```
30+
31+
## params
32+
33+
- type: `Any`
34+
- default: `{}`
35+
36+
When you open a modal though the [API](/api) `$vfm.show(name, params)`, you can get `params` with scoped-slot:
37+
38+
```html
39+
<template v-slot="{ params }">
40+
<!-- modal content -->
41+
</template>
42+
```

docs/content/zh-Hant/api.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ export default {
3131
- 參數:
3232
- name: `String` - 指定 modal 的名字。
3333
- params: `?: object` - Any data that you want to pass into the modal, checkout the guide [params](/zh-Hant/guide/params).
34+
- 回傳: Promise<Object> | Promise<Array>
3435

3536
<show-code text="Example">
3637

3738
<v-api-show class="py-4"></v-api-show>
3839

3940
```js
4041
this.$vfm.show('example', { userName: 'vue-final-modal' })
42+
.then(() => {
43+
// 當 modal 開啟後,做一些事
44+
})
4145
```
4246

4347
```html[Modal.vue]
@@ -67,6 +71,7 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
6771
- 型別: `Function`
6872
- 參數:
6973
- names: `String` - 指定要隱藏 modal 名稱。
74+
- 回傳: Promise<Object> | Promise<Array>
7075

7176
<show-code text="Example">
7277

@@ -83,7 +88,9 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
8388
show2: true
8489
}),
8590
mounted() {
86-
this.$vfm.hide('example', 'example2')
91+
this.$vfm.hide('example', 'example2').then(() => {
92+
// 當 modal 關閉後,做一些事
93+
})
8794
}
8895
}
8996
</script>
@@ -93,18 +100,33 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
93100

94101
### `hideAll()`
95102

103+
- 回傳: Promise<Object> | Promise<Array>
104+
96105
關閉所有的 modal。
97106

107+
```js
108+
this.$vfm.hideAll().then(() => {
109+
// 當所有 modal 關閉後,做一些事
110+
})
111+
```
112+
98113
### `toggle(name, show, params)`
99114

100115
- 型別: `Function`
101116
- 參數:
102117
- name: [`String` | `Array`] - modal 的名稱。
103118
- show: `?: Boolean` - 打開或隱藏這個 modal。
104119
- params: `?: object` - 任何你想要傳入 modal 的資料,詳閱 [參數(params)](/zh-Hant/guide/params)
120+
- 回傳: Promise<Object> | Promise<Array>
105121

106122
根據名字(name)切換 modals 的狀態。
107123

124+
```js
125+
this.$vfm.toggle('myModal').then(() => {
126+
// 當多個 modal 被開啟或被關閉時,做一些事,開啟或關閉取決於 show 參數給的是 true 或 false
127+
})
128+
```
129+
108130
### `get([names])`
109131

110132
- 型別: `Function`

docs/content/zh-Hant/dynamic-modal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ features:
4242
- 參數:
4343
- dynamicModalOptions: `Object`
4444
- params: 與 [API $vfm.show](/zh-Hant/api#showname-params) 相同
45+
- 回傳: Promise<Object> | Promise<Array>
4546

4647
```ts
4748
type dynamicModalOptions = {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: 作用域插槽 (Scoped Slots)
3+
description: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
4+
position: 6
5+
category: Guide
6+
fullscreen: true
7+
---
8+
9+
## close
10+
11+
- 型別: `Function`
12+
13+
當你以 HOC 的方式使用 vue-final-modal 時. 你可以以 scoped-slot 關閉(close) modal:
14+
15+
```vue
16+
<template>
17+
<vue-final-modal v-slot="{ close }" v-bind="$attrs" v-on="$listeners">
18+
<div>哈囉,Vue Final Modal</div>
19+
<button @click="close">close modal</button>
20+
</vue-final-modal>
21+
</template>
22+
23+
<script>
24+
export default {
25+
name: 'VModal',
26+
inheritAttrs: false
27+
}
28+
</script>
29+
```
30+
31+
## params
32+
33+
- 型別: `Any`
34+
- 預設: `{}`
35+
36+
當你透過 [API](/zh-Hant/api) `$vfm.show(name, params)` 開啟 modal,你可以使用 scoped-slot 取得 params:
37+
38+
```html
39+
<template v-slot="{ params }">
40+
<!-- modal content -->
41+
</template>
42+
```

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"generate": "nuxt generate"
1010
},
1111
"dependencies": {
12-
"@nuxt/content-theme-docs": "^0.8.2",
12+
"@nuxt/content-theme-docs": "0.10.0",
1313
"nuxt": "^2.14.12",
1414
"vue-final-modal": "^2.1.0"
1515
},

0 commit comments

Comments
 (0)