Skip to content

Commit cb87674

Browse files
committed
feat: renamed after-open and after-close events
BREAKING CHANGE - the `after-open` event has been renamed to `opened` - the `after-close` event has been renamed to `closed`
1 parent cdcf2e5 commit cb87674

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If you're looking for a Vue.js 2 compatible version of vue-modal, [please check
2020
- Includes sensible default styling but it's also highly customizable via user CSS classes and styles
2121
- Override modal title and content via slots
2222
- Modal intro and outro effects using CSS animation classes
23-
- Exposes Component events - before-open, opening, after-open, before-close, closing, after-close, update:modelValue (close)
23+
- Exposes Component events - before-open, opening, opened, before-close, closing, closed, update:modelValue (close)
2424
- Scrollable when it's contents exceed screen height
2525
- Closeable by clicking on the upper right "x", the overlay or the `esc` key
2626
- **Stackable** - Multiple modal windows on top of each other

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A customizable, stackable, and lightweight modal component for Vue.js 3.
2121
- Includes sensible default styling but it's also highly customizable via user CSS classes and styles
2222
- Override modal title and content via slots
2323
- Modal intro and outro effects using CSS animation classes
24-
- Exposes Component events - before-open, opening, after-open, before-close, closing, after-close, update:modelValue (close)
24+
- Exposes Component events - before-open, opening, opened, before-close, closing, closed, update:modelValue (close)
2525
- Scrollable when it's contents exceed screen height
2626
- Closeable by clicking on the upper right "x", the overlay or the `esc` key
2727
- **Stackable** - Multiple modal windows on top of each other

docs/options/index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Pass a `Boolean` value to the `v-model` directive to show and hide the modal win
44

55
## Plugin API
66

7-
In order to use the Plugin API you need to import and register the `modalPlugin`.
8-
The Plugin API exposes `show`/`hide` functions that can be called within any component to show and hide the modal window with the given name.
7+
The Plugin API exposes `show`/`hide` functions that can be called within any component to show and hide the modal window with the given name.
8+
In order to use the Plugin API you need to import and register the `modalPlugin`.
99

1010
The functions are available through:
1111

@@ -14,9 +14,9 @@ The functions are available through:
1414

1515
### Functions
1616

17-
**`show(name)`** - Shows the modal with the given name
18-
**`hide(name)`** - Hides the modal with the given name
19-
**`hideAll()`** - Hides all modals
17+
**`show(name: string): void`** : Shows the modal with the given `name` prop
18+
**`hide(name: string): void`** : Hides the modal with the given `name` prop
19+
**`hideAll(): void`** - Hides all modals
2020

2121
## Props
2222

@@ -178,32 +178,32 @@ Default value:
178178
</thead>
179179
<tbody>
180180
<tr>
181-
<td>close</td>
182-
<td>Event that fires when dialog closes</td>
181+
<td>update:modelValue</td>
182+
<td>Event that is emitted when the component’s model changes</td>
183183
</tr>
184184
<tr>
185185
<td>before-open</td>
186-
<td>Event that fires before the modal opening transition starts</td>
186+
<td>Event that is emitted before the modal opening transition starts</td>
187187
</tr>
188188
<tr>
189189
<td>opening</td>
190-
<td>Event that fires while the modal opening transition is in progress</td>
190+
<td>Event that is emitted while the modal opening transition is in progress</td>
191191
</tr>
192192
<tr>
193-
<td>after-open</td>
194-
<td>Event that fires when the modal opening transition is finished</td>
193+
<td>opened</td>
194+
<td>Event that is emitted when the modal is visible and the opening transition ended</td>
195195
</tr>
196196
<tr>
197197
<td>before-close</td>
198-
<td>Event that fires before the modal closing transition starts</td>
198+
<td>Event that is emitted before the modal closing transition starts</td>
199199
</tr>
200200
<tr>
201201
<td>closing</td>
202-
<td>Event that fires while the modal closing transition is in progress</td>
202+
<td>Event that is emitted while the modal closing transition is in progress</td>
203203
</tr>
204204
<tr>
205-
<td>after-close</td>
206-
<td>Event that fires when the modal closing transition is finished</td>
205+
<td>closed</td>
206+
<td>Event that is emitted when the modal is no longer visible and the closing transition ended</td>
207207
</tr>
208208
</tbody>
209209
</table>

docs/usage/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const app = Vue.createApp({...})
4646
app.use(modalPlugin)
4747
```
4848

49-
To control the visibility of the modal with the name `prop` you use the and `show`/`hide` functions.
49+
To control the visibility of the modal with the name `prop` you use the `show`/`hide` functions.
5050

5151
**Composition API**
5252

src/Modal.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
:leave-active-class="outClass"
1616
@before-enter="beforeOpen"
1717
@enter="opening"
18-
@after-enter="afterOpen"
18+
@after-enter="opened"
1919
@before-leave="beforeClose"
2020
@leave="closing"
21-
@after-leave="afterClose"
21+
@after-leave="closed"
2222
>
2323
<div
2424
v-show="show"
@@ -116,7 +116,7 @@ export default {
116116
default: 'Close'
117117
}
118118
},
119-
emits: ['before-open', 'opening', 'after-open', 'before-close', 'closing', 'after-close', 'update:modelValue'],
119+
emits: ['before-open', 'opening', 'opened', 'before-close', 'closing', 'closed', 'update:modelValue'],
120120
data() {
121121
return {
122122
zIndex: 0,
@@ -227,10 +227,10 @@ export default {
227227
// console.log('opening');
228228
this.$emit('opening')
229229
},
230-
afterOpen() {
231-
// console.log('afterOpen');
230+
opened() {
231+
// console.log('opened');
232232
this.handleFocus(this.$refs['vm-wrapper'])
233-
this.$emit('after-open')
233+
this.$emit('opened')
234234
},
235235
beforeClose() {
236236
// console.log('beforeClose');
@@ -240,8 +240,8 @@ export default {
240240
// console.log('closing');
241241
this.$emit('closing')
242242
},
243-
afterClose() {
244-
// console.log('afterClose');
243+
closed() {
244+
// console.log('closed');
245245
this.zIndex = 0
246246
if (!this.live) {
247247
this.mount = false
@@ -272,7 +272,7 @@ export default {
272272
}
273273
}
274274
animatingZIndex = 0
275-
this.$emit('after-close')
275+
this.$emit('closed')
276276
})
277277
})
278278
}

tests/unit/ModalEvents.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Modal events', () => {
2121
document.body.innerHTML = ''
2222
})
2323

24-
it.each(['before-open', 'opening', 'after-open'])('emits a %s event when opening', async (eventName) => {
24+
it.each(['before-open', 'opening', 'opened'])('emits a %s event when opening', async (eventName) => {
2525
const wrapper = createWrapper()
2626

2727
await wrapper.setProps({ modelValue: true })
@@ -31,7 +31,7 @@ describe('Modal events', () => {
3131
wrapper.unmount()
3232
})
3333

34-
it.each(['before-close', 'closing', 'after-close'])('emits a %s event when closing', async (eventName) => {
34+
it.each(['before-close', 'closing', 'closed'])('emits a %s event when closing', async (eventName) => {
3535
const wrapper = createWrapper()
3636

3737
await wrapper.setProps({ modelValue: true })

0 commit comments

Comments
 (0)