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 */ },

0 commit comments

Comments
 (0)