Skip to content

Commit

Permalink
Merge pull request #415 from vue-final/feat/4.5
Browse files Browse the repository at this point in the history
Feat/4.5
  • Loading branch information
hunterliu1003 committed Dec 7, 2023
2 parents 6bcded3 + a053aa6 commit 0e8592d
Show file tree
Hide file tree
Showing 53 changed files with 6,988 additions and 4,763 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pnpm build:vfm
# Run both docs and viteplay
pnpm dev

# Run dev for vue-final-modal
pnpm dev:vfm

# Run docs: http://localhost:3000/
pnpm dev:docs

Expand Down
8 changes: 5 additions & 3 deletions docs/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ export default defineAppConfig({
docus: {
title: 'Vue Final Modal',
description: 'Vue Final Modal is the most powerful yet most light-weight modal library for Vue 3',
layout: 'docs',
layout: 'default',
image: 'https://vue-final-modal.org/preview.png',
url: 'https://vue-final-modal.org',
socials: {
twitter: '@hunterliu1003',
github: 'vue-final/vue-final-modal',
},
github: true,
aside: {
level: 1,
},
header: {
logo: true,
logo: {
dark: '/logo-new.svg',
light: '/logo-new.svg',
},
},
footer: {},
},
Expand Down
4 changes: 3 additions & 1 deletion docs/components/content/LoginFormVorms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const { value: remember, attrs: rememberAttrs } = register('remember')
</script>

<template>
<h1 class="text-2xl mb-4">Login</h1>
<h1 class="text-2xl mb-4">
Login
</h1>
<form @submit="handleSubmit">
<div class="field">
<input
Expand Down
20 changes: 0 additions & 20 deletions docs/components/content/Logo.vue

This file was deleted.

4 changes: 3 additions & 1 deletion docs/components/content/ModalBottom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ defineProps<{
<h1 class="text-xl">
{{ title }}
</h1>
<div class="text-3xl">Swipe down to close the modal</div>
<div class="text-3xl">
Swipe down to close the modal
</div>
<slot />
</VueFinalModal>
</template>
2 changes: 1 addition & 1 deletion docs/content/2.get-started/1.guide/2.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default defineNuxtPlugin((nuxtApp) => {

## Import required CSS

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)_
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.

### Vue 3

Expand Down
5 changes: 0 additions & 5 deletions docs/content/2.get-started/1.guide/3.migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ open()
`params` is not a good practice and hard to keep type-save in Typescript.
So if you are using `params`, you have to re-written it with [useModal()](/api/composables/use-modal) composable.

### Removed `event.stop()` from both `@before-close` and `@before-open`

`event.stop()` made the source code hard to read and maintain.
It's easy to have a condition before open or before close the modal. So it's not a required feature.

### Delete Drag & Resize

To keep vue-final-modal simple and easier to maintain, I decided to remove the Drag & Resize feature.
Expand Down
22 changes: 8 additions & 14 deletions docs/content/2.get-started/1.guide/4.types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

The exported types in VueFinalModal.

## ComponentProps

```ts
export type ComponentProps = ComponentPublicInstance['$props']
```
## ModalId

```ts
Expand All @@ -23,18 +17,18 @@ export type StyleValue = string | CSSProperties | (string | CSSProperties)[]
## ModalSlot
```ts
export interface ModalSlotOptions { component: Raw<Component>; attrs?: Record<string, any> }
export type ModalSlot = string | Component | ModalSlotOptions
export interface ModalSlotOptions { component: Raw<ComponentType>; attrs?: Record<string, any> }
export type ModalSlot = string | ComponentType | ModalSlotOptions
```
## UseModalOptions
```ts
export type UseModalOptions<P> = {
export type UseModalOptions<T extends ComponentType> = {
defaultModelValue?: boolean
keepAlive?: boolean
component?: Constructor<P>
attrs?: (RawProps & P) | ({} extends P ? null : never)
component?: T
attrs?: ComponentProps<T>
slots?: {
[key: string]: ModalSlot
}
Expand All @@ -55,11 +49,11 @@ export type UseModalOptionsPrivate = {
## UseModalReturnType
```ts
export interface UseModalReturnType<P> {
options: UseModalOptions<P> & UseModalOptionsPrivate
export interface UseModalReturnType<T extends ComponentType> {
options: UseModalOptions<T> & UseModalOptionsPrivate
open: () => Promise<string>
close: () => Promise<string>
patchOptions: (options: Partial<UseModalOptions<P>>) => void
patchOptions: (options: Partial<UseModalOptions<T>>) => void
destroy: () => void
}
```
Expand Down
18 changes: 16 additions & 2 deletions docs/content/3.api/1.components/1.vue-final-modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,28 @@ When set `:preventNavigationGestures="true"`{lang=ts}, there will be two invisib

## Events

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

## Slots

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

You can also use scoped slots to close modal, for example:

```html
<VueFinalModal>
<template #default="{ close }">
<button @click="() => close()">
Cancel
</button>
</template>
</VueFinalModal>
```

- The `swipe-banner`{lang=ts} slot can be used to define the area that can be swipe to close
1 change: 1 addition & 0 deletions docs/content/3.api/2.composables/1.use-modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const { open, close, destroy, options, patchOptions } = useModal({
clickToClose: true,
escToClose: true,
// Bind events to the modal component (VueFinalModal in this case).
// Any custom events can be listened for when prefixed with "on", e.g. "onEventName".
onBeforeOpen() { /* on before open */ },
onOpened() { /* on opened */ },
onBeforeClose() { /* on before close */ },
Expand Down
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"preview": "nuxi preview"
},
"devDependencies": {
"@nuxt-themes/docus": "^1.10.1",
"@nuxtjs/tailwindcss": "^6.6.4",
"nuxt": "^3.3.2"
"@nuxt-themes/docus": "^1.15.0",
"@nuxtjs/tailwindcss": "^6.10.1",
"nuxt": "^3.8.2"
},
"dependencies": {
"@vorms/core": "^1.1.0",
Expand Down
3 changes: 1 addition & 2 deletions examples/nuxt3/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default defineNuxtConfig({
extends: '@nuxt-themes/docus',
modules: ['@nuxtjs/tailwindcss'],
css: ['vue-final-modal/style.css'],
modules: ['@nuxtjs/tailwindcss', '@vue-final-modal/nuxt'],
})
6 changes: 3 additions & 3 deletions examples/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@nuxt-themes/docus": "^1.6.0",
"@nuxtjs/tailwindcss": "^6.2.0",
"nuxt": "3.1.0"
"@nuxt-themes/docus": "^1.15.0",
"@nuxtjs/tailwindcss": "^6.10.1",
"nuxt": "3.8.2"
},
"dependencies": {
"@vue-final-modal/nuxt": "^1.0.2",
Expand Down
6 changes: 0 additions & 6 deletions examples/nuxt3/plugins/vfm.ts

This file was deleted.

19 changes: 9 additions & 10 deletions examples/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.3.4",
"vue": "^3.3.7",
"vue-final-modal": "^4.4.6"
},
"devDependencies": {
"@iconify/vue": "^4.0.0",
"@vitejs/plugin-vue": "^4.2.3",
"autoprefixer": "^10.4.13",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.4",
"typescript": "^5.1.6",
"vite": "^4.3.9",
"vue-tsc": "^1.8.3"
"@iconify/vue": "^4.1.1",
"@vitejs/plugin-vue": "^4.5.0",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.5",
"typescript": "^5.3.2",
"vite": "^5.0.3"
}
}
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vfm",
"private": true,
"scripts": {
"dev": "concurrently \"pnpm:dev:*\"",
"dev": "concurrently \"pnpm:dev:docs\" \"pnpm:dev:viteplay\"",
"dev:docs": "pnpm --filter docs dev",
"build:docs": "pnpm --filter docs build",
"generate:docs": "pnpm --filter docs generate",
Expand All @@ -18,19 +18,18 @@
"postinstall": "pnpm build:vfm && pnpm prepare:module"
},
"dependencies": {
"vue": "^3.3.4"
"vue": "^3.3.7"
},
"devDependencies": {
"@antfu/eslint-config": "^0.37.0",
"@types/node": "^18.15.10",
"@vitejs/plugin-vue": "^4.2.3",
"@types/node": "^20.10.0",
"@vitejs/plugin-vue": "^4.5.0",
"@vue/test-utils": "^2.3.2",
"concurrently": "^7.6.0",
"concurrently": "^8.2.2",
"eslint": "^8.36.0",
"pnpm": "^8.10.2",
"sass": "^1.60.0",
"typescript": "^5.1.6",
"vite": "^4.3.9",
"vue-tsc": "^1.8.3"
"pnpm": "^8.11.0",
"typescript": "^5.3.2",
"vite": "^5.0.3",
"vue-tsc": "1.8.20"
}
}
10 changes: 5 additions & 5 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"release": "pnpm prepack && release-it"
},
"dependencies": {
"@nuxt/kit": "^3.3.2",
"@nuxt/kit": "^3.8.2",
"vue-final-modal": "^4.4.6"
},
"devDependencies": {
"@nuxt/module-builder": "^0.2.1",
"@nuxt/schema": "^3.3.2",
"@nuxtjs/eslint-config-typescript": "^12.0.0",
"nuxt": "^3.3.2",
"@nuxt/module-builder": "^0.5.4",
"@nuxt/schema": "^3.8.2",
"@nuxtjs/eslint-config-typescript": "^12.1.0",
"nuxt": "^3.8.2",
"release-it": "^16.1.3"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default defineNuxtModule({
configKey: 'vue-final-modal',
},
setup(options, nuxt) {
const resolver = createResolver(import.meta.url)
const { resolve } = createResolver(import.meta.url)

// Transpile runtime
nuxt.options.build.transpile.push(resolver.resolve('./runtime'))
nuxt.options.build.transpile.push(resolve('./runtime'))

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

nuxt.options.css.push('vue-final-modal/style.css')
Expand Down
21 changes: 9 additions & 12 deletions packages/vue-final-modal/cypress/components/useZIndex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,22 @@ describe('Test useZIndex()', () => {
stubs: { transition: false },
},
}).as('app')
cy.get('@app').then(() => {
firstModal.open()
})

cy.get('@app').then(() => firstModal.open())
cy.get('.first-modal').should(($el) => {
expect($el).to.have.css('zIndex', '1000')
})
cy.get('@app').then(() => {
secondModal.open()
})

cy.get('@app').then(() => secondModal.open())
cy.get('.second-modal').should(($el) => {
expect($el).to.have.css('zIndex', '1002')
})
cy.get('@app').then(() => {
thirdModal.open()
})

cy.get('@app').then(() => thirdModal.open())
cy.get('.third-modal').should(($el) => {
expect($el).to.have.css('zIndex', '1004')
})

cy.get('@app').then(() => {
thirdModal.patchOptions({
attrs: {
Expand All @@ -53,9 +51,8 @@ describe('Test useZIndex()', () => {
cy.get('.third-modal').should(($el) => {
expect($el).to.have.css('zIndex', '1238')
})
cy.get('@app').then(() => {
firstModal.close()
})

cy.get('@app').then(() => firstModal.close())
cy.get('.second-modal').should(($el) => {
expect($el).to.have.css('zIndex', '1000')
})
Expand Down

0 comments on commit 0e8592d

Please sign in to comment.