11<template >
2- <div :class =" !windowViewOnly && 'siren-sdk-inbox-container'" ref =" notificationRef" data-testid =" siren-inbox-container" >
3- <div v-if =" !windowViewOnly" ref =" iconRef" data-testid =" siren-inbox-icon" >
4- <NotificationIcon :handleNotification =" handleNotification"
5- :badgeType =" showNotifications ? BadgeType.NONE : BadgeType.DEFAULT"
6- :darkMode =" darkMode" :styles =" styles" :hideBadge =" hideBadge" />
7- </div >
8- <div v-if =" showNotifications || windowViewOnly" :style =" {
2+ <div :class =" windowViewOnly ? 'siren-sdk-window-container' : 'siren-sdk-inbox-container'" ref =" notificationRef"
3+ data-testid =" siren-inbox-container" >
4+ <div v-if =" !windowViewOnly" ref =" iconRef" data-testid =" siren-inbox-icon" >
5+ <NotificationIcon :handleNotification =" handleNotification"
6+ :darkMode =" darkMode" :styles =" styles"
7+ :hideBadge =" hideBadge" :isModalOpen =" isModalOpen" >
8+ <template #notificationIcon >
9+ <slot name =" notificationIcon" />
10+ </template >
11+ </NotificationIcon >
12+ </div >
13+ <div v-if =" isModalOpen || windowViewOnly" :style =" {
914 ...styles.container,
1015 ...(!windowViewOnly && styles.windowShadow),
1116 width:
1520 position: windowViewOnly ? 'initial' : 'absolute',
1621 ...modalPosition,
1722 }" >
18- <SirenPanel :styles =" styles"
19- :itemsPerFetch =" itemsPerFetch"
20- :hideBadge =" hideBadge"
21- :headerProps =" headerProps ?? defaultHeaderProps"
22- :onCardClick =" onCardClick"
23- :onError =" onError"
24- :darkMode =" darkMode"
25- :windowViewOnly =" windowViewOnly"
26- :showNotifications =" showNotifications"
27- :hideClearAll =" headerProps?.hideClearAll ?? false"
28- :loadMoreLabel =" loadMoreLabel"
29- :cardProps =" cardProps ?? defaultCardProps"
30- :modalWidth =" updatedModalWidth" >
31- <template #loadMoreComponent >
32- <slot name =" loadMoreComponent" />
33- </template >
34- <template #customHeader >
35- <slot name =" customHeader" />
36- </template >
37- <template #customLoader >
38- <slot name =" customLoader" />
39- </template >
40- <template #customErrorWindow >
41- <slot name =" customErrorWindow" />
42- </template >
43- <template #listEmptyComponent >
44- <slot name =" listEmptyComponent" />
45- </template >
46- <template #customCard =" { item } " >
47- <slot name =" customCard" :item =" item" />
48- </template >
49- <template #customFooter >
50- <slot name =" customFooter" />
51- </template >
52- </SirenPanel >
53- </div >
23+ <SirenPanel :styles =" styles" :itemsPerFetch =" itemsPerFetch" :hideBadge =" hideBadge"
24+ :headerProps =" headerProps ?? defaultHeaderProps"
25+ :onCardClick =" onCardClick" :onError =" onError"
26+ :darkMode =" darkMode" :windowViewOnly =" windowViewOnly" :isModalOpen =" isModalOpen"
27+ :hideClearAll =" headerProps?.hideClearAll ?? false" :loadMoreLabel =" loadMoreLabel"
28+ :cardProps =" cardProps ?? defaultCardProps" :modalWidth =" updatedModalWidth" >
29+ <template #loadMoreComponent >
30+ <slot name =" loadMoreComponent" />
31+ </template >
32+ <template #customHeader >
33+ <slot name =" customHeader" />
34+ </template >
35+ <template #customLoader >
36+ <slot name =" customLoader" />
37+ </template >
38+ <template #customErrorWindow >
39+ <slot name =" customErrorWindow" />
40+ </template >
41+ <template #listEmptyComponent >
42+ <slot name =" listEmptyComponent" />
43+ </template >
44+ <template #customCard =" { item } " >
45+ <slot name =" customCard" :item =" item" />
46+ </template >
47+ <template #customFooter >
48+ <slot name =" customFooter" />
49+ </template >
50+ </SirenPanel >
5451 </div >
52+ </div >
5553</template >
5654
5755<script setup lang="ts">
5856import type {
59- Ref
57+ Ref
6058} from ' vue' ;
6159import {
6260 ref ,
@@ -74,10 +72,9 @@ import type { SirenProps } from '../types';
7472import { applyTheme , calculateModalPosition , calculateModalWidth , debounce } from ' ../utils/commonUtils' ;
7573import {
7674 ThemeMode ,
77- BadgeType ,
7875 DEFAULT_WINDOW_TITLE ,
7976 DEFAULT_NOTIFICATION_FETCH_COUNT ,
80- EventType
77+ EventType
8178} from ' ../utils/constants' ;
8279import SirenPanel from ' ./SirenPanel.vue' ;
8380import NotificationIcon from ' ./NotificationIcon.vue' ;
@@ -103,7 +100,7 @@ const defaultCardProps = { hideAvatar: false, showMedia: false };
103100
104101const notificationRef = ref <HTMLElement | null >(null );
105102const iconRef = ref <HTMLElement | null >(null );
106- const showNotifications = ref <boolean >(false );
103+ const isModalOpen = ref <boolean >(false );
107104const modalPosition = ref <{
108105 right? : string ;
109106 left? : string ;
@@ -126,11 +123,11 @@ const styles = computed(() =>
126123
127124const handleNotification = (event : any ) => {
128125 event .preventDefault ();
129- showNotifications .value = ! showNotifications .value ;
126+ isModalOpen .value = ! isModalOpen .value ;
130127};
131128
132129const closeNotification = () => {
133- showNotifications .value = false ;
130+ isModalOpen .value = false ;
134131};
135132
136133const handleOutsideClick = (event : MouseEvent ) => {
@@ -168,8 +165,8 @@ onMounted(() => {
168165 window .addEventListener (' resize' , debouncedUpdate );
169166});
170167
171- watch (showNotifications , () => {
172- if (showNotifications .value )
168+ watch (isModalOpen , () => {
169+ if (isModalOpen .value )
173170 document .addEventListener (' click' , handleOutsideClick );
174171 else document .removeEventListener (' click' , handleOutsideClick );
175172});
0 commit comments