Fixed #1453 - [OverlayPanel] add @show and @hide events

pull/1527/head
Cagatay Civici 2021-09-06 12:04:01 +03:00
parent 9ecd219fb2
commit 0f4c9f0da8
4 changed files with 33 additions and 1 deletions

View File

@ -43,10 +43,22 @@ const OverlayPanelProps = [
} }
]; ];
const OverlayPanelEvents = [
{
name: "show",
description: "Callback to invoke before the overlay is shown."
},
{
name: "hide",
description: "Callback to invoke before the overlay is hidden."
},
];
module.exports = { module.exports = {
overlaypanel: { overlaypanel: {
name: "OverlayPanel", name: "OverlayPanel",
description: "OverlayPanel is a container component positioned as connected to its target.", description: "OverlayPanel is a container component positioned as connected to its target.",
props: OverlayPanelProps props: OverlayPanelProps,
events: OverlayPanelEvents
} }
}; };

View File

@ -15,6 +15,8 @@ declare class OverlayPanel {
toggle(event: Event): void; toggle(event: Event): void;
show(event: Event, target?: any): void; show(event: Event, target?: any): void;
hide(): void; hide(): void;
$emit(eventName: 'show'): this;
$emit(eventName: 'hide'): this;
$slots: { $slots: {
'': VNode[]; '': VNode[];
} }

View File

@ -133,6 +133,7 @@ export default {
}; };
OverlayEventBus.on('overlay-click', this.overlayEventListener); OverlayEventBus.on('overlay-click', this.overlayEventListener);
this.$emit('show');
}, },
onLeave() { onLeave() {
this.unbindOutsideClickListener(); this.unbindOutsideClickListener();
@ -140,6 +141,7 @@ export default {
this.unbindResizeListener(); this.unbindResizeListener();
OverlayEventBus.off('overlay-click', this.overlayEventListener); OverlayEventBus.off('overlay-click', this.overlayEventListener);
this.overlayEventListener = null; this.overlayEventListener = null;
this.$emit('hide');
}, },
onAfterLeave(el) { onAfterLeave(el) {
if (this.autoZIndex) { if (this.autoZIndex) {

View File

@ -135,6 +135,22 @@ toggle(event) {
</table> </table>
</div> </div>
<h5>Events</h5>
<div class="doc-tablewrapper">
<table class="doc-table">
<tr>
<td>show</td>
<td>-</td>
<td>Callback to invoke when the overlay is shown.</td>
</tr>
<tr>
<td>hide</td>
<td>-</td>
<td>Callback to invoke when the overlay is hidden.</td>
</tr>
</table>
</div>
<h5>Styling</h5> <h5>Styling</h5>
<p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p> <p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p>
<div class="doc-tablewrapper"> <div class="doc-tablewrapper">