Refactor #4433 - Sidebar
parent
66cfbe54fc
commit
0f86b62fe2
|
@ -96,6 +96,10 @@ const SidebarSlots = [
|
||||||
{
|
{
|
||||||
name: 'closeicon',
|
name: 'closeicon',
|
||||||
description: 'Custom close icon template.'
|
description: 'Custom close icon template.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'container',
|
||||||
|
description: 'Custom container template.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,16 @@ export interface SidebarSlots {
|
||||||
*/
|
*/
|
||||||
class: any;
|
class: any;
|
||||||
}): VNode[];
|
}): VNode[];
|
||||||
|
/**
|
||||||
|
* Custom container slot.
|
||||||
|
* @param {Object} scope - container slot's params.
|
||||||
|
*/
|
||||||
|
container(scope: {
|
||||||
|
/**
|
||||||
|
* Close sidebar function.
|
||||||
|
*/
|
||||||
|
onClose: () => void;
|
||||||
|
}): VNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
<div v-if="containerVisible" :ref="maskRef" @mousedown="onMaskClick" :class="cx('mask')" :style="sx('mask', true, { position })" v-bind="ptm('mask')">
|
<div v-if="containerVisible" :ref="maskRef" @mousedown="onMaskClick" :class="cx('mask')" :style="sx('mask', true, { position })" v-bind="ptm('mask')">
|
||||||
<transition name="p-sidebar" @enter="onEnter" @after-enter="onAfterEnter" @before-leave="onBeforeLeave" @leave="onLeave" @after-leave="onAfterLeave" appear v-bind="ptm('transition')">
|
<transition name="p-sidebar" @enter="onEnter" @after-enter="onAfterEnter" @before-leave="onBeforeLeave" @leave="onLeave" @after-leave="onAfterLeave" appear v-bind="ptm('transition')">
|
||||||
<div v-if="visible" :ref="containerRef" v-focustrap :class="cx('root')" role="complementary" :aria-modal="modal" @keydown="onKeydown" v-bind="{ ...$attrs, ...ptm('root') }">
|
<div v-if="visible" :ref="containerRef" v-focustrap :class="cx('root')" role="complementary" :aria-modal="modal" @keydown="onKeydown" v-bind="{ ...$attrs, ...ptm('root') }">
|
||||||
|
<slot v-if="$slots.container" name="container" :onClose="hide"></slot>
|
||||||
|
<template v-else>
|
||||||
<div :ref="headerContainerRef" :class="cx('header')" v-bind="ptm('header')">
|
<div :ref="headerContainerRef" :class="cx('header')" v-bind="ptm('header')">
|
||||||
<div v-if="$slots.header" :class="cx('headerContent')" v-bind="ptm('headerContent')">
|
<div v-if="$slots.header" :class="cx('headerContent')" v-bind="ptm('headerContent')">
|
||||||
<slot name="header"></slot>
|
<slot name="header"></slot>
|
||||||
|
@ -16,6 +18,7 @@
|
||||||
<div :ref="contentRef" :class="cx('content')" v-bind="ptm('content')">
|
<div :ref="contentRef" :class="cx('content')" v-bind="ptm('content')">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue