Skip to content

Commit 0e8592d

Browse files
Merge pull request #415 from vue-final/feat/4.5
Feat/4.5
2 parents 6bcded3 + a053aa6 commit 0e8592d

Some content is hidden

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

53 files changed

+6988
-4763
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ pnpm build:vfm
4545
# Run both docs and viteplay
4646
pnpm dev
4747

48+
# Run dev for vue-final-modal
49+
pnpm dev:vfm
50+
4851
# Run docs: http://localhost:3000/
4952
pnpm dev:docs
5053

docs/app.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ export default defineAppConfig({
22
docus: {
33
title: 'Vue Final Modal',
44
description: 'Vue Final Modal is the most powerful yet most light-weight modal library for Vue 3',
5-
layout: 'docs',
5+
layout: 'default',
66
image: 'https://vue-final-modal.org/preview.png',
77
url: 'https://vue-final-modal.org',
88
socials: {
99
twitter: '@hunterliu1003',
1010
github: 'vue-final/vue-final-modal',
1111
},
12-
github: true,
1312
aside: {
1413
level: 1,
1514
},
1615
header: {
17-
logo: true,
16+
logo: {
17+
dark: '/logo-new.svg',
18+
light: '/logo-new.svg',
19+
},
1820
},
1921
footer: {},
2022
},

docs/components/content/LoginFormVorms.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const { value: remember, attrs: rememberAttrs } = register('remember')
3333
</script>
3434

3535
<template>
36-
<h1 class="text-2xl mb-4">Login</h1>
36+
<h1 class="text-2xl mb-4">
37+
Login
38+
</h1>
3739
<form @submit="handleSubmit">
3840
<div class="field">
3941
<input

docs/components/content/Logo.vue

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

docs/components/content/ModalBottom.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ defineProps<{
1616
<h1 class="text-xl">
1717
{{ title }}
1818
</h1>
19-
<div class="text-3xl">Swipe down to close the modal</div>
19+
<div class="text-3xl">
20+
Swipe down to close the modal
21+
</div>
2022
<slot />
2123
</VueFinalModal>
2224
</template>

docs/content/2.get-started/1.guide/2.setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default defineNuxtPlugin((nuxtApp) => {
6060

6161
## Import required CSS
6262

63-
vue-final-modal 4 has tiny size of required CSS (gzipped 0.49kb). All classes have a `.vfm-` prefix, so you don't have to worry about any CSS pollution. _[See style of `<VueFinalModal>`.](https://github.com/vue-final/vue-final-modal/blob/v4/packages/vue-final-modal/src/components/CoreModal/CoreModal.vue#L184-L217)_
63+
vue-final-modal 4 has tiny size of required CSS (gzipped 0.49kb). All classes have a `.vfm-` prefix, so you don't have to worry about any CSS pollution.
6464

6565
### Vue 3
6666

docs/content/2.get-started/1.guide/3.migration-guide.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ open()
125125
`params` is not a good practice and hard to keep type-save in Typescript.
126126
So if you are using `params`, you have to re-written it with [useModal()](/api/composables/use-modal) composable.
127127

128-
### Removed `event.stop()` from both `@before-close` and `@before-open`
129-
130-
`event.stop()` made the source code hard to read and maintain.
131-
It's easy to have a condition before open or before close the modal. So it's not a required feature.
132-
133128
### Delete Drag & Resize
134129

135130
To keep vue-final-modal simple and easier to maintain, I decided to remove the Drag & Resize feature.

docs/content/2.get-started/1.guide/4.types.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
The exported types in VueFinalModal.
44

5-
## ComponentProps
6-
7-
```ts
8-
export type ComponentProps = ComponentPublicInstance['$props']
9-
```
10-
115
## ModalId
126

137
```ts
@@ -23,18 +17,18 @@ export type StyleValue = string | CSSProperties | (string | CSSProperties)[]
2317
## ModalSlot
2418
2519
```ts
26-
export interface ModalSlotOptions { component: Raw<Component>; attrs?: Record<string, any> }
27-
export type ModalSlot = string | Component | ModalSlotOptions
20+
export interface ModalSlotOptions { component: Raw<ComponentType>; attrs?: Record<string, any> }
21+
export type ModalSlot = string | ComponentType | ModalSlotOptions
2822
```
2923
3024
## UseModalOptions
3125
3226
```ts
33-
export type UseModalOptions<P> = {
27+
export type UseModalOptions<T extends ComponentType> = {
3428
defaultModelValue?: boolean
3529
keepAlive?: boolean
36-
component?: Constructor<P>
37-
attrs?: (RawProps & P) | ({} extends P ? null : never)
30+
component?: T
31+
attrs?: ComponentProps<T>
3832
slots?: {
3933
[key: string]: ModalSlot
4034
}
@@ -55,11 +49,11 @@ export type UseModalOptionsPrivate = {
5549
## UseModalReturnType
5650
5751
```ts
58-
export interface UseModalReturnType<P> {
59-
options: UseModalOptions<P> & UseModalOptionsPrivate
52+
export interface UseModalReturnType<T extends ComponentType> {
53+
options: UseModalOptions<T> & UseModalOptionsPrivate
6054
open: () => Promise<string>
6155
close: () => Promise<string>
62-
patchOptions: (options: Partial<UseModalOptions<P>>) => void
56+
patchOptions: (options: Partial<UseModalOptions<T>>) => void
6357
destroy: () => void
6458
}
6559
```

docs/content/3.api/1.components/1.vue-final-modal.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,28 @@ When set `:preventNavigationGestures="true"`{lang=ts}, there will be two invisib
228228

229229
## Events
230230

231-
- `(e: 'beforeOpen'): void`{lang=ts}: Emits while modal is still invisible, but before transition starting.
231+
- `(e: 'beforeOpen', event: { stop: () => void }): void`{lang=ts}: Emits while modal is still invisible, but before transition starting.
232+
- `event.stop()` is use to prevent the modal from opening.
232233
- `(e: 'opened'): void`{lang=ts}: Emits after modal became visible and transition ended.
233-
- `(e: 'beforeClose'): void`{lang=ts}: Emits before modal is going to be closed.
234+
- `(e: 'beforeClose', event: { stop: () => void }): void`{lang=ts}: Emits before modal is going to be closed.
235+
- `event.stop()` is use to prevent the modal from closing.
234236
- `(e: 'closed'): void`{lang=ts}: Emits right before modal is destroyed.
235237
- `(e: 'clickOutside'): void`{lang=ts}: Emits while `.vfm` element on click.
236238

237239
## Slots
238240

239241
- The `default`{lang=ts} slot can be used to render the modal content.
240242

243+
You can also use scoped slots to close modal, for example:
244+
245+
```html
246+
<VueFinalModal>
247+
<template #default="{ close }">
248+
<button @click="() => close()">
249+
Cancel
250+
</button>
251+
</template>
252+
</VueFinalModal>
253+
```
254+
241255
- The `swipe-banner`{lang=ts} slot can be used to define the area that can be swipe to close

docs/content/3.api/2.composables/1.use-modal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const { open, close, destroy, options, patchOptions } = useModal({
4444
clickToClose: true,
4545
escToClose: true,
4646
// Bind events to the modal component (VueFinalModal in this case).
47+
// Any custom events can be listened for when prefixed with "on", e.g. "onEventName".
4748
onBeforeOpen() { /* on before open */ },
4849
onOpened() { /* on opened */ },
4950
onBeforeClose() { /* on before close */ },

docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"preview": "nuxi preview"
1010
},
1111
"devDependencies": {
12-
"@nuxt-themes/docus": "^1.10.1",
13-
"@nuxtjs/tailwindcss": "^6.6.4",
14-
"nuxt": "^3.3.2"
12+
"@nuxt-themes/docus": "^1.15.0",
13+
"@nuxtjs/tailwindcss": "^6.10.1",
14+
"nuxt": "^3.8.2"
1515
},
1616
"dependencies": {
1717
"@vorms/core": "^1.1.0",

examples/nuxt3/nuxt.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export default defineNuxtConfig({
22
extends: '@nuxt-themes/docus',
3-
modules: ['@nuxtjs/tailwindcss'],
4-
css: ['vue-final-modal/style.css'],
3+
modules: ['@nuxtjs/tailwindcss', '@vue-final-modal/nuxt'],
54
})

examples/nuxt3/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"postinstall": "nuxt prepare"
1010
},
1111
"devDependencies": {
12-
"@nuxt-themes/docus": "^1.6.0",
13-
"@nuxtjs/tailwindcss": "^6.2.0",
14-
"nuxt": "3.1.0"
12+
"@nuxt-themes/docus": "^1.15.0",
13+
"@nuxtjs/tailwindcss": "^6.10.1",
14+
"nuxt": "3.8.2"
1515
},
1616
"dependencies": {
1717
"@vue-final-modal/nuxt": "^1.0.2",

examples/nuxt3/plugins/vfm.ts

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

examples/vue3/package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "vue-tsc && vite build",
8+
"build": "vite build",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"vue": "^3.3.4",
12+
"vue": "^3.3.7",
1313
"vue-final-modal": "^4.4.6"
1414
},
1515
"devDependencies": {
16-
"@iconify/vue": "^4.0.0",
17-
"@vitejs/plugin-vue": "^4.2.3",
18-
"autoprefixer": "^10.4.13",
19-
"postcss": "^8.4.21",
20-
"tailwindcss": "^3.2.4",
21-
"typescript": "^5.1.6",
22-
"vite": "^4.3.9",
23-
"vue-tsc": "^1.8.3"
16+
"@iconify/vue": "^4.1.1",
17+
"@vitejs/plugin-vue": "^4.5.0",
18+
"autoprefixer": "^10.4.16",
19+
"postcss": "^8.4.31",
20+
"tailwindcss": "^3.3.5",
21+
"typescript": "^5.3.2",
22+
"vite": "^5.0.3"
2423
}
2524
}

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vfm",
33
"private": true,
44
"scripts": {
5-
"dev": "concurrently \"pnpm:dev:*\"",
5+
"dev": "concurrently \"pnpm:dev:docs\" \"pnpm:dev:viteplay\"",
66
"dev:docs": "pnpm --filter docs dev",
77
"build:docs": "pnpm --filter docs build",
88
"generate:docs": "pnpm --filter docs generate",
@@ -18,19 +18,18 @@
1818
"postinstall": "pnpm build:vfm && pnpm prepare:module"
1919
},
2020
"dependencies": {
21-
"vue": "^3.3.4"
21+
"vue": "^3.3.7"
2222
},
2323
"devDependencies": {
2424
"@antfu/eslint-config": "^0.37.0",
25-
"@types/node": "^18.15.10",
26-
"@vitejs/plugin-vue": "^4.2.3",
25+
"@types/node": "^20.10.0",
26+
"@vitejs/plugin-vue": "^4.5.0",
2727
"@vue/test-utils": "^2.3.2",
28-
"concurrently": "^7.6.0",
28+
"concurrently": "^8.2.2",
2929
"eslint": "^8.36.0",
30-
"pnpm": "^8.10.2",
31-
"sass": "^1.60.0",
32-
"typescript": "^5.1.6",
33-
"vite": "^4.3.9",
34-
"vue-tsc": "^1.8.3"
30+
"pnpm": "^8.11.0",
31+
"typescript": "^5.3.2",
32+
"vite": "^5.0.3",
33+
"vue-tsc": "1.8.20"
3534
}
3635
}

packages/nuxt/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"release": "pnpm prepack && release-it"
2424
},
2525
"dependencies": {
26-
"@nuxt/kit": "^3.3.2",
26+
"@nuxt/kit": "^3.8.2",
2727
"vue-final-modal": "^4.4.6"
2828
},
2929
"devDependencies": {
30-
"@nuxt/module-builder": "^0.2.1",
31-
"@nuxt/schema": "^3.3.2",
32-
"@nuxtjs/eslint-config-typescript": "^12.0.0",
33-
"nuxt": "^3.3.2",
30+
"@nuxt/module-builder": "^0.5.4",
31+
"@nuxt/schema": "^3.8.2",
32+
"@nuxtjs/eslint-config-typescript": "^12.1.0",
33+
"nuxt": "^3.8.2",
3434
"release-it": "^16.1.3"
3535
},
3636
"peerDependencies": {

packages/nuxt/src/module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export default defineNuxtModule({
66
configKey: 'vue-final-modal',
77
},
88
setup(options, nuxt) {
9-
const resolver = createResolver(import.meta.url)
9+
const { resolve } = createResolver(import.meta.url)
1010

1111
// Transpile runtime
12-
nuxt.options.build.transpile.push(resolver.resolve('./runtime'))
12+
nuxt.options.build.transpile.push(resolve('./runtime'))
1313

1414
nuxt.hook('prepare:types', ({ references }) => {
1515
references.push({ types: '@vue-final-modal/nuxt' })
@@ -18,7 +18,7 @@ export default defineNuxtModule({
1818
// Add runtime plugin before the router plugin
1919
// https://github.com/nuxt/framework/issues/9130
2020
nuxt.hook('modules:done', () => {
21-
addPlugin(resolver.resolve('./runtime/plugin'))
21+
addPlugin(resolve('./runtime/plugin'))
2222
})
2323

2424
nuxt.options.css.push('vue-final-modal/style.css')

packages/vue-final-modal/cypress/components/useZIndex.spec.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,22 @@ describe('Test useZIndex()', () => {
2525
stubs: { transition: false },
2626
},
2727
}).as('app')
28-
cy.get('@app').then(() => {
29-
firstModal.open()
30-
})
28+
29+
cy.get('@app').then(() => firstModal.open())
3130
cy.get('.first-modal').should(($el) => {
3231
expect($el).to.have.css('zIndex', '1000')
3332
})
34-
cy.get('@app').then(() => {
35-
secondModal.open()
36-
})
33+
34+
cy.get('@app').then(() => secondModal.open())
3735
cy.get('.second-modal').should(($el) => {
3836
expect($el).to.have.css('zIndex', '1002')
3937
})
40-
cy.get('@app').then(() => {
41-
thirdModal.open()
42-
})
38+
39+
cy.get('@app').then(() => thirdModal.open())
4340
cy.get('.third-modal').should(($el) => {
4441
expect($el).to.have.css('zIndex', '1004')
4542
})
43+
4644
cy.get('@app').then(() => {
4745
thirdModal.patchOptions({
4846
attrs: {
@@ -53,9 +51,8 @@ describe('Test useZIndex()', () => {
5351
cy.get('.third-modal').should(($el) => {
5452
expect($el).to.have.css('zIndex', '1238')
5553
})
56-
cy.get('@app').then(() => {
57-
firstModal.close()
58-
})
54+
55+
cy.get('@app').then(() => firstModal.close())
5956
cy.get('.second-modal').should(($el) => {
6057
expect($el).to.have.css('zIndex', '1000')
6158
})

0 commit comments

Comments
 (0)