UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

633 lines (629 loc) 29.7 kB
import { formatTimeAgo } from "./chunk-6Y3UKXTF.mjs"; import { useMobile } from "./chunk-GKY77WVA.mjs"; import { SkeletonCard } from "./chunk-NKVUUWCA.mjs"; import { IconButton_default } from "./chunk-LGQNMQOT.mjs"; import { Badge_default } from "./chunk-OEW3ST4F.mjs"; import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, DropdownMenu_default } from "./chunk-DHHHYBOU.mjs"; import { Modal_default } from "./chunk-TNLGS7SB.mjs"; import { Text_default } from "./chunk-IMCIR6TJ.mjs"; import { cn } from "./chunk-53ICLDGS.mjs"; // src/components/NotificationCard/NotificationCard.tsx import { DotsThreeVerticalIcon } from "@phosphor-icons/react/dist/csr/DotsThreeVertical"; import { BellIcon } from "@phosphor-icons/react/dist/csr/Bell"; import { useState, useEffect } from "react"; // src/assets/img/mock-content.png var mock_content_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPQAAAD0CAYAAACsLwv+AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAA9KADAAQAAAABAAAA9AAAAABTYKvEAAATMUlEQVR4Ae2dbYwd1XnHn5l98Xq9Xu8a6rV5MbuOE3BUm6UCB5IKLOJIFBVwpCRNgDaUQD5USYPVfiuRQUSi7RcSaD80SgQkwaKtSgSRKFKoMXyAJiTYmASTQFljQ7AT/P7K7t47Pc/1nd3ZuzN3Z3fuvXvOzO9Is3fmvMw85/ec/z1nzpm5K0KAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgAAEIQAACEIAABCAAAQhAIIGAlxBPNASsIDD80L4NpcD/h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oeoep+dh6D1veuza/JQlULVAUFX3f3FiiDHzUz3m9MagDZuXbaqFzTP3Tevq5eFNAg0nQCCjiC+wyzTaC8cPliy2AyjLzPH16+/gAdLIpzYtZcAgq7xjQq63tC6JjuHELCKAJNiVrkDYyCQjQCCzsaP0hCwigCCtsodGAOBbAQQdDZ+lIaAVQQQtFXuwBgIZCOAoLPxozQErCKAoK1yB8ZAIBsBBJ2NH6UhYBUBBG2VOzAGAtkIIOhs/CgNAasIIGir3IExEMhGAEFn40dpCFhFAEFb5Q6MgUA2Agg6Gz9KQ8AqAgjaKndgDASyEUDQ2fhRGgJWEXBG0J54e6wihzGFIeBS23NG0FKW7YVpQVTUKgLlUvl5qwyqY4wzgh6X9p2mHkfq1IUkCDSFQId0bG/KiZtwUmcEPdTvHfHKwb1NYMApIZBMoCz3ruh353bPS66JnSn7Do/dI75ssdM6rMoTgaAcPLqyv/M2l+rkTA8dQr2wv+Me01Nv9iTYE8bxCYEGE9DR4GbXxKwMnOuhQ8eNHA762mRsU+DLcJvnLwnj+YRAJgKl8qtj0vGI3uJlOg+FIQABCEAAAhCAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgAAEIQAACELCNwP8DRkBquZDwDI8AAAAASUVORK5CYII="; // src/components/NotificationCard/NotificationCard.tsx import { Fragment, jsx, jsxs } from "react/jsx-runtime"; var DEFAULT_REFRESH_INTERVAL_MS = 3e3; var NotificationEmpty = ({ emptyStateImage, emptyStateTitle = "Nenhuma notifica\xE7\xE3o no momento", emptyStateDescription = "Voc\xEA est\xE1 em dia com todas as novidades. Volte depois para conferir atualiza\xE7\xF5es!" }) => { return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-6 w-full", children: [ emptyStateImage && /* @__PURE__ */ jsx("div", { className: "w-20 h-20 flex items-center justify-center", children: /* @__PURE__ */ jsx( "img", { src: emptyStateImage, alt: "Sem notifica\xE7\xF5es", width: 82, height: 82, className: "object-contain" } ) }), /* @__PURE__ */ jsx("h3", { className: "text-xl font-semibold text-text-950 text-center leading-[23px]", children: emptyStateTitle }), /* @__PURE__ */ jsx("p", { className: "text-sm font-normal text-text-400 text-center max-w-[316px] leading-[21px]", children: emptyStateDescription }) ] }); }; var NotificationHeader = ({ unreadCount, variant = "modal" }) => { return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [ variant === "modal" ? /* @__PURE__ */ jsx(Text_default, { size: "sm", weight: "bold", className: "text-text-950", children: "Notifica\xE7\xF5es" }) : /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-text-950", children: "Notifica\xE7\xF5es" }), unreadCount > 0 && /* @__PURE__ */ jsx( Badge_default, { variant: "solid", action: "info", size: "small", iconLeft: /* @__PURE__ */ jsx(BellIcon, { size: 12, "aria-hidden": "true", focusable: "false" }), className: "border-0", children: unreadCount === 1 ? "1 n\xE3o lida" : `${unreadCount} n\xE3o lidas` } ) ] }); }; var SingleNotificationCard = ({ title, message, time, isRead, onMarkAsRead, onDelete, onNavigate, actionLabel, className }) => { const handleMarkAsRead = (e) => { e.preventDefault(); e.stopPropagation(); if (!isRead) { onMarkAsRead(); } }; const handleDelete = (e) => { e.preventDefault(); e.stopPropagation(); onDelete(); }; const handleNavigate = (e) => { e.stopPropagation(); if (onNavigate) { onNavigate(); } }; return /* @__PURE__ */ jsxs( "div", { className: cn( "flex flex-col justify-center items-start p-4 gap-2 w-full bg-background border-b border-border-200", "last:border-b-0", className ), children: [ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 w-full", children: [ !isRead && /* @__PURE__ */ jsx("div", { className: "w-[7px] h-[7px] bg-info-300 rounded-full flex-shrink-0" }), /* @__PURE__ */ jsx("h3", { className: "font-bold text-sm leading-4 text-text-950 flex-grow", children: title }), /* @__PURE__ */ jsxs(DropdownMenu_default, { children: [ /* @__PURE__ */ jsx( DropdownMenuTrigger, { className: "flex-shrink-0 inline-flex items-center justify-center font-medium bg-transparent text-text-950 cursor-pointer hover:bg-info-50 w-6 h-6 rounded-lg", "aria-label": "Menu de a\xE7\xF5es", children: /* @__PURE__ */ jsx(DotsThreeVerticalIcon, { size: 24 }) } ), /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-[160px]", children: [ !isRead && /* @__PURE__ */ jsx( DropdownMenuItem, { onClick: handleMarkAsRead, className: "text-text-950", children: "Marcar como lida" } ), /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: handleDelete, className: "text-error-600", children: "Deletar" }) ] }) ] }) ] }), /* @__PURE__ */ jsx("p", { className: "text-sm leading-[21px] text-text-800 w-full", children: message }), /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between w-full", children: [ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-text-400", children: time }), onNavigate && actionLabel && /* @__PURE__ */ jsx( "button", { type: "button", onClick: handleNavigate, className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer", children: actionLabel } ) ] }) ] } ); }; var NotificationList = ({ groupedNotifications = [], loading = false, error = null, onRetry, onMarkAsReadById, onDeleteById, onNavigateById, onGlobalNotificationClick, getActionLabel, renderEmpty, className, emptyStateImage }) => { const [globalNotificationModal, setGlobalNotificationModal] = useState({ isOpen: false, notification: null }); const handleGlobalNotificationClick = (notification) => { if (onGlobalNotificationClick) { onGlobalNotificationClick(notification); } else { setGlobalNotificationModal({ isOpen: true, notification }); } }; if (error) { return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: [ /* @__PURE__ */ jsx("p", { className: "text-sm text-error-600", children: error }), onRetry && /* @__PURE__ */ jsx( "button", { type: "button", onClick: onRetry, className: "text-sm text-info-600 hover:text-info-700", children: "Tentar novamente" } ) ] }); } if (loading && groupedNotifications.length === 0) { return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0 w-full", children: ["skeleton-first", "skeleton-second", "skeleton-third"].map( (skeletonId) => /* @__PURE__ */ jsx( SkeletonCard, { className: "p-4 border-b border-border-200" }, skeletonId ) ) }); } if (!groupedNotifications || groupedNotifications.length === 0) { return renderEmpty ? /* @__PURE__ */ jsx("div", { className: "w-full", children: renderEmpty() }) : /* @__PURE__ */ jsx(NotificationEmpty, {}); } return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-0 w-full", className), children: [ groupedNotifications.map((group, idx) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [ /* @__PURE__ */ jsx("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ jsx("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }), group.notifications.map((notification) => { const isGlobalNotification = !notification.entityType && !notification.entityId && !notification.activity && !notification.recommendedClass; let navigationHandler; if (isGlobalNotification) { navigationHandler = () => handleGlobalNotificationClick(notification); } else if (notification.entityType && notification.entityId && onNavigateById) { navigationHandler = () => onNavigateById( notification.entityType ?? void 0, notification.entityId ?? void 0 ); } let actionLabel; if (isGlobalNotification) { actionLabel = getActionLabel?.(void 0); } else { actionLabel = getActionLabel?.( notification.entityType ?? void 0 ); } return /* @__PURE__ */ jsx( SingleNotificationCard, { title: notification.title, message: notification.message, time: notification.time ?? formatTimeAgo(new Date(notification.createdAt)), isRead: notification.isRead, onMarkAsRead: () => onMarkAsReadById?.(notification.id), onDelete: () => onDeleteById?.(notification.id), onNavigate: navigationHandler, actionLabel }, notification.id ); }) ] }, `${group.label}-${idx}`)), /* @__PURE__ */ jsx( Modal_default, { isOpen: globalNotificationModal.isOpen, onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }), title: globalNotificationModal.notification?.title || "", description: globalNotificationModal.notification?.message || "", variant: "activity", image: globalNotificationModal.notification?.linkImg || emptyStateImage || mock_content_default, actionLink: globalNotificationModal.notification?.actionLink || void 0, actionLabel: "Ver mais", size: "lg" } ) ] }); }; var NotificationCenter = ({ isActive, onToggleActive, unreadCount = 0, groupedNotifications = [], loading = false, error = null, onRetry, onMarkAsReadById, onDeleteById, onNavigateById, getActionLabel, onFetchNotifications, onMarkAllAsRead, onOpenChange, emptyStateImage, emptyStateTitle, emptyStateDescription, className, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS }) => { const { isMobile } = useMobile(); const [isModalOpen, setIsModalOpen] = useState(false); const [globalNotificationModal, setGlobalNotificationModal] = useState({ isOpen: false, notification: null }); const handleMobileClick = () => { setIsModalOpen(true); onFetchNotifications?.(); }; const handleDesktopClick = () => { onToggleActive?.(); }; const handleOpenChange = (open) => { const controlledByParent = typeof isActive === "boolean" && typeof onToggleActive === "function"; onOpenChange?.(open); if (controlledByParent && !onOpenChange && !open && isActive) { onToggleActive?.(); } }; useEffect(() => { if (isActive) { onFetchNotifications?.(); } }, [isActive, onFetchNotifications]); const isCenterOpen = isMobile ? isModalOpen : Boolean(isActive); useEffect(() => { if (!isCenterOpen || !onFetchNotifications || refreshIntervalMs <= 0) { return; } const intervalId = setInterval(() => { onFetchNotifications(); }, refreshIntervalMs); return () => clearInterval(intervalId); }, [isCenterOpen, onFetchNotifications, refreshIntervalMs]); const renderEmptyState = () => /* @__PURE__ */ jsx( NotificationEmpty, { emptyStateImage, emptyStateTitle, emptyStateDescription } ); if (isMobile) { return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx( IconButton_default, { active: isModalOpen, onClick: handleMobileClick, icon: /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx( Badge_default, { variant: "notification", notificationActive: unreadCount > 0, className: "p-0" } ), unreadCount > 0 && /* @__PURE__ */ jsxs(Text_default, { as: "span", className: "sr-only", children: [ unreadCount, " notifica\xE7\xF5es n\xE3o lidas" ] }) ] }), className } ), /* @__PURE__ */ jsx( Modal_default, { isOpen: isModalOpen, onClose: () => setIsModalOpen(false), title: "Notifica\xE7\xF5es", size: "md", hideCloseButton: false, closeOnEscape: true, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full max-h-[80vh]", children: [ /* @__PURE__ */ jsxs("div", { className: "px-0 pb-3 border-b border-border-200", children: [ /* @__PURE__ */ jsx(NotificationHeader, { unreadCount, variant: "modal" }), unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ jsx( "button", { type: "button", onClick: onMarkAllAsRead, className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2", children: "Marcar todas como lidas" } ) ] }), /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx( NotificationList, { groupedNotifications, loading, error, onRetry, onMarkAsReadById, onDeleteById, onNavigateById: (entityType, entityId) => { setIsModalOpen(false); onNavigateById?.(entityType, entityId); }, onGlobalNotificationClick: (notification) => { setIsModalOpen(false); setGlobalNotificationModal({ isOpen: true, notification }); }, getActionLabel, renderEmpty: renderEmptyState, emptyStateImage } ) }) ] }) } ), /* @__PURE__ */ jsx( Modal_default, { isOpen: globalNotificationModal.isOpen, onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }), title: globalNotificationModal.notification?.title || "", variant: "activity", description: globalNotificationModal.notification?.message, image: globalNotificationModal.notification?.linkImg || emptyStateImage || mock_content_default, actionLink: globalNotificationModal.notification?.actionLink || void 0, actionLabel: "Ver mais", size: "lg" } ) ] }); } return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsxs( DropdownMenu_default, { ...typeof isActive === "boolean" ? { open: isActive, onOpenChange: handleOpenChange } : { onOpenChange: handleOpenChange }, children: [ /* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ jsx( IconButton_default, { active: isActive, onClick: handleDesktopClick, icon: /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx( Badge_default, { variant: "notification", notificationActive: unreadCount > 0, className: cn("p-0", isActive && "text-primary-950!") } ), unreadCount > 0 && /* @__PURE__ */ jsxs(Text_default, { as: "span", className: "sr-only", children: [ unreadCount, " notifica\xE7\xF5es n\xE3o lidas" ] }) ] }), className } ) }), /* @__PURE__ */ jsx( DropdownMenuContent, { className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden", side: "bottom", align: "end", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [ /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 border-b border-border-200", children: [ /* @__PURE__ */ jsx( NotificationHeader, { unreadCount, variant: "dropdown" } ), unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ jsx( "button", { type: "button", onClick: onMarkAllAsRead, className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2", children: "Marcar todas como lidas" } ) ] }), /* @__PURE__ */ jsx("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ jsx( NotificationList, { groupedNotifications, loading, error, onRetry, onMarkAsReadById, onDeleteById, onNavigateById, onGlobalNotificationClick: (notification) => { setGlobalNotificationModal({ isOpen: true, notification }); }, getActionLabel, renderEmpty: renderEmptyState, emptyStateImage } ) }) ] }) } ) ] } ), /* @__PURE__ */ jsx( Modal_default, { isOpen: globalNotificationModal.isOpen, onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }), title: globalNotificationModal.notification?.title || "", variant: "activity", description: globalNotificationModal.notification?.message, image: globalNotificationModal.notification?.linkImg || emptyStateImage || mock_content_default, actionLink: globalNotificationModal.notification?.actionLink || void 0, actionLabel: "Ver mais", size: "lg" } ) ] }); }; var NotificationCard = (props) => { switch (props.mode) { case "single": return /* @__PURE__ */ jsx( SingleNotificationCard, { title: props.title, message: props.message, time: props.time, isRead: props.isRead, onMarkAsRead: props.onMarkAsRead, onDelete: props.onDelete, onNavigate: props.onNavigate, actionLabel: props.actionLabel, className: props.className } ); case "list": return /* @__PURE__ */ jsx( NotificationList, { groupedNotifications: props.groupedNotifications ?? (props.notifications ? [ { label: "Notifica\xE7\xF5es", notifications: props.notifications } ] : []), loading: props.loading, error: props.error, onRetry: props.onRetry, onMarkAsReadById: props.onMarkAsReadById, onDeleteById: props.onDeleteById, onNavigateById: props.onNavigateById, onGlobalNotificationClick: props.onGlobalNotificationClick, getActionLabel: props.getActionLabel, renderEmpty: props.renderEmpty, className: props.className, emptyStateImage: props.emptyStateImage } ); case "center": return /* @__PURE__ */ jsx(NotificationCenter, { ...props }); default: return /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-text-600", children: "Modo de notifica\xE7\xE3o n\xE3o reconhecido" }) }); } }; var LegacyNotificationCard = (props) => { if (props.variant === "center") { const centerProps = { mode: "center", ...props }; return /* @__PURE__ */ jsx(NotificationCenter, { ...centerProps }); } if (props.groupedNotifications !== void 0 || props.notifications !== void 0 || props.loading || props.error) { return /* @__PURE__ */ jsx( NotificationList, { groupedNotifications: props.groupedNotifications ?? (props.notifications ? [ { label: "Notifica\xE7\xF5es", notifications: props.notifications } ] : []), loading: props.loading, error: props.error, onRetry: props.onRetry, onMarkAsReadById: props.onMarkAsReadById, onDeleteById: props.onDeleteById, onNavigateById: props.onNavigateById, onGlobalNotificationClick: props.onGlobalNotificationClick, getActionLabel: props.getActionLabel, renderEmpty: props.renderEmpty, className: props.className, emptyStateImage: props.emptyStateImage } ); } if (props.title !== void 0 && props.message !== void 0 && props.time !== void 0 && props.isRead !== void 0 && props.onMarkAsRead && props.onDelete) { const singleProps = { mode: "single", title: props.title, message: props.message, time: props.time, isRead: props.isRead, onMarkAsRead: props.onMarkAsRead, onDelete: props.onDelete, onNavigate: props.onNavigate, actionLabel: props.actionLabel, className: props.className, emptyStateImage: props.emptyStateImage, emptyStateTitle: props.emptyStateTitle, emptyStateDescription: props.emptyStateDescription }; return /* @__PURE__ */ jsx( SingleNotificationCard, { title: singleProps.title, message: singleProps.message, time: singleProps.time, isRead: singleProps.isRead, onMarkAsRead: singleProps.onMarkAsRead, onDelete: singleProps.onDelete, onNavigate: singleProps.onNavigate, actionLabel: singleProps.actionLabel, className: singleProps.className } ); } return /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-text-600", children: "Nenhuma notifica\xE7\xE3o configurada" }) }); }; var NotificationCard_default = NotificationCard; export { LegacyNotificationCard, NotificationCard_default }; //# sourceMappingURL=chunk-YRF7O7TN.mjs.map