1 import type { CSSProperties, Ref } from 'react';
3 import formatUTC from '@proton/shared/lib/date-fns-utc/format';
4 import { dateLocale } from '@proton/shared/lib/i18n';
8 CalendarViewEventTemporaryEvent,
10 } from '../../containers/calendar/interface';
11 import { DAY_EVENT_HEIGHT } from '../calendar/constants';
12 import getIsBeforeNow from '../calendar/getIsBeforeNow';
13 import { TYPE } from '../calendar/interactions/constants';
14 import FullDayEvent from './FullDayEvent';
15 import PopoverContainer from './PopoverContainer';
16 import PopoverHeader from './PopoverHeader';
19 isSmallViewport: boolean;
23 formatTime: (date: Date) => string;
25 events: (CalendarViewEvent | CalendarViewEventTemporaryEvent)[];
26 popoverRef: Ref<HTMLDivElement>;
27 onClickEvent: (data: TargetEventData) => void;
28 targetEventRef: Ref<HTMLDivElement>;
29 targetEventData?: TargetEventData;
32 const MorePopoverEvent = ({
46 const dateString = formatUTC(date, 'cccc PPP', { locale: dateLocale });
48 const eventsContent = events.map((event) => {
49 const isSelected = targetEventData?.uniqueId === event.uniqueId;
50 const isThisSelected =
53 targetEventData.idx === date.getUTCDate() &&
54 targetEventData.type === TYPE.MORE;
56 const isBeforeNow = getIsBeforeNow(event, now);
60 formatTime={formatTime}
63 className="calendar-dayeventcell w-full text-left h-custom"
64 isSelected={isSelected}
66 isBeforeNow={isBeforeNow}
67 isOutsideStart={false}
69 onClick={() => onClickEvent({ uniqueId: event.uniqueId, idx: date.getUTCDate(), type: TYPE.MORE })}
71 '--h-custom': `${DAY_EVENT_HEIGHT}px`,
73 eventRef={isThisSelected ? targetEventRef : undefined}
80 style={isSmallViewport ? undefined : style}
81 className="eventpopover flex flex-nowrap flex-column py-7 px-5"
84 <PopoverHeader onClose={onClose} className="shrink-0">
86 className="eventpopover-title lh-rg text-ellipsis-four-lines text-cut"
87 title={`${date.getUTCDate()}`}
92 <div className="overflow-auto unstyled">{eventsContent}</div>
97 export default MorePopoverEvent;