2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
|
|
|
<Portal v-if="fullScreen">
|
2023-06-07 10:46:13 +00:00
|
|
|
<div v-if="containerVisible" :ref="maskRef" :class="[cx('mask'), maskClass]" :role="fullScreen ? 'dialog' : 'region'" :aria-modal="fullScreen ? 'true' : undefined" v-bind="ptm('mask')">
|
2022-09-06 12:03:37 +00:00
|
|
|
<transition name="p-galleria" @before-enter="onBeforeEnter" @enter="onEnter" @before-leave="onBeforeLeave" @after-leave="onAfterLeave" appear>
|
2023-05-31 22:28:41 +00:00
|
|
|
<GalleriaContent v-if="visible" :ref="containerRef" v-focustrap @mask-hide="maskHide" :templates="$slots" @activeitem-change="onActiveItemChange" :pt="pt" :unstyled="unstyled" v-bind="$props" />
|
2022-09-06 12:03:37 +00:00
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</Portal>
|
2023-05-31 22:28:41 +00:00
|
|
|
<GalleriaContent v-else :templates="$slots" @activeitem-change="onActiveItemChange" :pt="pt" :unstyled="unstyled" v-bind="$props" />
|
2022-09-06 12:03:37 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-31 22:28:41 +00:00
|
|
|
import BaseGalleria from './BaseGalleria.vue';
|
2022-12-08 11:04:25 +00:00
|
|
|
import FocusTrap from 'primevue/focustrap';
|
2022-09-06 12:03:37 +00:00
|
|
|
import Portal from 'primevue/portal';
|
2022-12-08 11:04:25 +00:00
|
|
|
import { DomHandler, ZIndexUtils } from 'primevue/utils';
|
|
|
|
import GalleriaContent from './GalleriaContent.vue';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Galleria',
|
2023-05-31 22:28:41 +00:00
|
|
|
extends: BaseGalleria,
|
2022-09-06 12:03:37 +00:00
|
|
|
inheritAttrs: false,
|
|
|
|
emits: ['update:activeIndex', 'update:visible'],
|
|
|
|
container: null,
|
|
|
|
mask: null,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
containerVisible: this.visible
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
if (this.fullScreen && this.visible) {
|
|
|
|
this.containerVisible = this.visible;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
if (this.fullScreen) {
|
2023-05-31 23:19:04 +00:00
|
|
|
!this.isUnstyled && DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.mask = null;
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
if (this.container) {
|
|
|
|
ZIndexUtils.clear(this.container);
|
|
|
|
this.container = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onBeforeEnter(el) {
|
|
|
|
ZIndexUtils.set('modal', el, this.baseZIndex || this.$primevue.config.zIndex.modal);
|
|
|
|
},
|
|
|
|
onEnter(el) {
|
|
|
|
this.mask.style.zIndex = String(parseInt(el.style.zIndex, 10) - 1);
|
2023-05-31 23:19:04 +00:00
|
|
|
!this.isUnstyled && DomHandler.addClass(document.body, 'p-overflow-hidden');
|
2022-12-08 11:04:25 +00:00
|
|
|
this.focus();
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
onBeforeLeave() {
|
2023-05-31 23:19:04 +00:00
|
|
|
!this.isUnstyled && DomHandler.addClass(this.mask, 'p-component-overlay-leave');
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
onAfterLeave(el) {
|
|
|
|
ZIndexUtils.clear(el);
|
|
|
|
this.containerVisible = false;
|
2023-05-31 23:19:04 +00:00
|
|
|
!this.isUnstyled && DomHandler.removeClass(document.body, 'p-overflow-hidden');
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
onActiveItemChange(index) {
|
|
|
|
if (this.activeIndex !== index) {
|
|
|
|
this.$emit('update:activeIndex', index);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
maskHide() {
|
|
|
|
this.$emit('update:visible', false);
|
|
|
|
},
|
|
|
|
containerRef(el) {
|
|
|
|
this.container = el;
|
|
|
|
},
|
|
|
|
maskRef(el) {
|
|
|
|
this.mask = el;
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
focus() {
|
|
|
|
let focusTarget = this.container.$el.querySelector('[autofocus]');
|
|
|
|
|
|
|
|
if (focusTarget) {
|
|
|
|
focusTarget.focus();
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2022-09-14 11:26:01 +00:00
|
|
|
GalleriaContent: GalleriaContent,
|
|
|
|
Portal: Portal
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
focustrap: FocusTrap
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|