analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
633 lines (606 loc) • 34.4 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunkBXORK7GMjs = require('./chunk-BXORK7GM.js');
var _chunkZHWRUIVEjs = require('./chunk-ZHWRUIVE.js');
var _chunkNEDUOGWUjs = require('./chunk-NEDUOGWU.js');
var _chunkBVUPM6EYjs = require('./chunk-BVUPM6EY.js');
var _chunkBJMKBBN3js = require('./chunk-BJMKBBN3.js');
var _chunk76VXVNA2js = require('./chunk-76VXVNA2.js');
var _chunkTCLRDUMFjs = require('./chunk-TCLRDUMF.js');
var _chunkANT66KVKjs = require('./chunk-ANT66KVK.js');
var _chunkTN3AYOMVjs = require('./chunk-TN3AYOMV.js');
// src/components/NotificationCard/NotificationCard.tsx
var _DotsThreeVertical = require('@phosphor-icons/react/dist/csr/DotsThreeVertical');
var _Bell = require('@phosphor-icons/react/dist/csr/Bell');
var _react = require('react');
// src/assets/img/mock-content.png
var mock_content_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPQAAAD0CAYAAACsLwv+AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAA9KADAAQAAAABAAAA9AAAAABTYKvEAAATMUlEQVR4Ae2dbYwd1XnHn5l98Xq9Xu8a6rV5MbuOE3BUm6UCB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ASUVORK5CYII=";
// src/components/NotificationCard/NotificationCard.tsx
var _jsxruntime = require('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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center justify-center gap-4 p-6 w-full", children: [
emptyStateImage && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-20 h-20 flex items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"img",
{
src: emptyStateImage,
alt: "Sem notifica\xE7\xF5es",
width: 82,
height: 82,
className: "object-contain"
}
) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-xl font-semibold text-text-950 text-center leading-[23px]", children: emptyStateTitle }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2", children: [
variant === "modal" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "sm", weight: "bold", className: "text-text-950", children: "Notifica\xE7\xF5es" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-text-950", children: "Notifica\xE7\xF5es" }),
unreadCount > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkBJMKBBN3js.Badge_default,
{
variant: "solid",
action: "info",
size: "small",
iconLeft: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Bell.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__ */ _jsxruntime.jsxs.call(void 0,
"div",
{
className: _chunkTN3AYOMVjs.cn.call(void 0,
"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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2 w-full", children: [
!isRead && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-[7px] h-[7px] bg-info-300 rounded-full flex-shrink-0" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-bold text-sm leading-4 text-text-950 flex-grow", children: title }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk76VXVNA2js.DropdownMenu_default, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunk76VXVNA2js.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__ */ _jsxruntime.jsx.call(void 0, _DotsThreeVertical.DotsThreeVerticalIcon, { size: 24 })
}
),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk76VXVNA2js.DropdownMenuContent, { align: "end", className: "min-w-[160px]", children: [
!isRead && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunk76VXVNA2js.DropdownMenuItem,
{
onClick: handleMarkAsRead,
className: "text-text-950",
children: "Marcar como lida"
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk76VXVNA2js.DropdownMenuItem, { onClick: handleDelete, className: "text-error-600", children: "Deletar" })
] })
] })
] }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm leading-[21px] text-text-800 w-full", children: message }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between w-full", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium text-text-400", children: time }),
onNavigate && actionLabel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"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] = _react.useState.call(void 0, { isOpen: false, notification: null });
const handleGlobalNotificationClick = (notification) => {
if (onGlobalNotificationClick) {
onGlobalNotificationClick(notification);
} else {
setGlobalNotificationModal({
isOpen: true,
notification
});
}
};
if (error) {
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-error-600", children: error }),
onRetry && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-0 w-full", children: ["skeleton-first", "skeleton-second", "skeleton-third"].map(
(skeletonId) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkNEDUOGWUjs.SkeletonCard,
{
className: "p-4 border-b border-border-200"
},
skeletonId
)
) });
}
if (!groupedNotifications || groupedNotifications.length === 0) {
return renderEmpty ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full", children: renderEmpty() }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotificationEmpty, {});
}
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkTN3AYOMVjs.cn.call(void 0, "flex flex-col gap-0 w-full", className), children: [
groupedNotifications.map((group, idx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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(
_nullishCoalesce(notification.entityType, () => ( void 0)),
_nullishCoalesce(notification.entityId, () => ( void 0))
);
}
let actionLabel;
if (isGlobalNotification) {
actionLabel = _optionalChain([getActionLabel, 'optionalCall', _ => _(void 0)]);
} else {
actionLabel = _optionalChain([getActionLabel, 'optionalCall', _2 => _2(
_nullishCoalesce(notification.entityType, () => ( void 0))
)]);
}
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
SingleNotificationCard,
{
title: notification.title,
message: notification.message,
time: _nullishCoalesce(notification.time, () => ( _chunkBXORK7GMjs.formatTimeAgo.call(void 0, new Date(notification.createdAt)))),
isRead: notification.isRead,
onMarkAsRead: () => _optionalChain([onMarkAsReadById, 'optionalCall', _3 => _3(notification.id)]),
onDelete: () => _optionalChain([onDeleteById, 'optionalCall', _4 => _4(notification.id)]),
onNavigate: navigationHandler,
actionLabel
},
notification.id
);
})
] }, `${group.label}-${idx}`)),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkTCLRDUMFjs.Modal_default,
{
isOpen: globalNotificationModal.isOpen,
onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
title: _optionalChain([globalNotificationModal, 'access', _5 => _5.notification, 'optionalAccess', _6 => _6.title]) || "",
description: _optionalChain([globalNotificationModal, 'access', _7 => _7.notification, 'optionalAccess', _8 => _8.message]) || "",
variant: "activity",
image: _optionalChain([globalNotificationModal, 'access', _9 => _9.notification, 'optionalAccess', _10 => _10.linkImg]) || emptyStateImage || mock_content_default,
actionLink: _optionalChain([globalNotificationModal, 'access', _11 => _11.notification, 'optionalAccess', _12 => _12.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 } = _chunkZHWRUIVEjs.useMobile.call(void 0, );
const [isModalOpen, setIsModalOpen] = _react.useState.call(void 0, false);
const [globalNotificationModal, setGlobalNotificationModal] = _react.useState.call(void 0, { isOpen: false, notification: null });
const handleMobileClick = () => {
setIsModalOpen(true);
_optionalChain([onFetchNotifications, 'optionalCall', _13 => _13()]);
};
const handleDesktopClick = () => {
_optionalChain([onToggleActive, 'optionalCall', _14 => _14()]);
};
const handleOpenChange = (open) => {
const controlledByParent = typeof isActive === "boolean" && typeof onToggleActive === "function";
_optionalChain([onOpenChange, 'optionalCall', _15 => _15(open)]);
if (controlledByParent && !onOpenChange && !open && isActive) {
_optionalChain([onToggleActive, 'optionalCall', _16 => _16()]);
}
};
_react.useEffect.call(void 0, () => {
if (isActive) {
_optionalChain([onFetchNotifications, 'optionalCall', _17 => _17()]);
}
}, [isActive, onFetchNotifications]);
const isCenterOpen = isMobile ? isModalOpen : Boolean(isActive);
_react.useEffect.call(void 0, () => {
if (!isCenterOpen || !onFetchNotifications || refreshIntervalMs <= 0) {
return;
}
const intervalId = setInterval(() => {
onFetchNotifications();
}, refreshIntervalMs);
return () => clearInterval(intervalId);
}, [isCenterOpen, onFetchNotifications, refreshIntervalMs]);
const renderEmptyState = () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
NotificationEmpty,
{
emptyStateImage,
emptyStateTitle,
emptyStateDescription
}
);
if (isMobile) {
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkBVUPM6EYjs.IconButton_default,
{
active: isModalOpen,
onClick: handleMobileClick,
icon: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkBJMKBBN3js.Badge_default,
{
variant: "notification",
notificationActive: unreadCount > 0,
className: "p-0"
}
),
unreadCount > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkANT66KVKjs.Text_default, { as: "span", className: "sr-only", children: [
unreadCount,
" notifica\xE7\xF5es n\xE3o lidas"
] })
] }),
className
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkTCLRDUMFjs.Modal_default,
{
isOpen: isModalOpen,
onClose: () => setIsModalOpen(false),
title: "Notifica\xE7\xF5es",
size: "md",
hideCloseButton: false,
closeOnEscape: true,
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full max-h-[80vh]", children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "px-0 pb-3 border-b border-border-200", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotificationHeader, { unreadCount, variant: "modal" }),
unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
NotificationList,
{
groupedNotifications,
loading,
error,
onRetry,
onMarkAsReadById,
onDeleteById,
onNavigateById: (entityType, entityId) => {
setIsModalOpen(false);
_optionalChain([onNavigateById, 'optionalCall', _18 => _18(entityType, entityId)]);
},
onGlobalNotificationClick: (notification) => {
setIsModalOpen(false);
setGlobalNotificationModal({
isOpen: true,
notification
});
},
getActionLabel,
renderEmpty: renderEmptyState,
emptyStateImage
}
) })
] })
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkTCLRDUMFjs.Modal_default,
{
isOpen: globalNotificationModal.isOpen,
onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
title: _optionalChain([globalNotificationModal, 'access', _19 => _19.notification, 'optionalAccess', _20 => _20.title]) || "",
variant: "activity",
description: _optionalChain([globalNotificationModal, 'access', _21 => _21.notification, 'optionalAccess', _22 => _22.message]),
image: _optionalChain([globalNotificationModal, 'access', _23 => _23.notification, 'optionalAccess', _24 => _24.linkImg]) || emptyStateImage || mock_content_default,
actionLink: _optionalChain([globalNotificationModal, 'access', _25 => _25.notification, 'optionalAccess', _26 => _26.actionLink]) || void 0,
actionLabel: "Ver mais",
size: "lg"
}
)
] });
}
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
_chunk76VXVNA2js.DropdownMenu_default,
{
...typeof isActive === "boolean" ? { open: isActive, onOpenChange: handleOpenChange } : { onOpenChange: handleOpenChange },
children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk76VXVNA2js.DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkBVUPM6EYjs.IconButton_default,
{
active: isActive,
onClick: handleDesktopClick,
icon: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkBJMKBBN3js.Badge_default,
{
variant: "notification",
notificationActive: unreadCount > 0,
className: _chunkTN3AYOMVjs.cn.call(void 0, "p-0", isActive && "text-primary-950!")
}
),
unreadCount > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkANT66KVKjs.Text_default, { as: "span", className: "sr-only", children: [
unreadCount,
" notifica\xE7\xF5es n\xE3o lidas"
] })
] }),
className
}
) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunk76VXVNA2js.DropdownMenuContent,
{
className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
side: "bottom",
align: "end",
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "px-4 py-3 border-b border-border-200", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
NotificationHeader,
{
unreadCount,
variant: "dropdown"
}
),
unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
NotificationList,
{
groupedNotifications,
loading,
error,
onRetry,
onMarkAsReadById,
onDeleteById,
onNavigateById,
onGlobalNotificationClick: (notification) => {
setGlobalNotificationModal({
isOpen: true,
notification
});
},
getActionLabel,
renderEmpty: renderEmptyState,
emptyStateImage
}
) })
] })
}
)
]
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkTCLRDUMFjs.Modal_default,
{
isOpen: globalNotificationModal.isOpen,
onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
title: _optionalChain([globalNotificationModal, 'access', _27 => _27.notification, 'optionalAccess', _28 => _28.title]) || "",
variant: "activity",
description: _optionalChain([globalNotificationModal, 'access', _29 => _29.notification, 'optionalAccess', _30 => _30.message]),
image: _optionalChain([globalNotificationModal, 'access', _31 => _31.notification, 'optionalAccess', _32 => _32.linkImg]) || emptyStateImage || mock_content_default,
actionLink: _optionalChain([globalNotificationModal, 'access', _33 => _33.notification, 'optionalAccess', _34 => _34.actionLink]) || void 0,
actionLabel: "Ver mais",
size: "lg"
}
)
] });
};
var NotificationCard = (props) => {
switch (props.mode) {
case "single":
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0,
NotificationList,
{
groupedNotifications: _nullishCoalesce(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__ */ _jsxruntime.jsx.call(void 0, NotificationCenter, { ...props });
default:
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, NotificationCenter, { ...centerProps });
}
if (props.groupedNotifications !== void 0 || props.notifications !== void 0 || props.loading || props.error) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
NotificationList,
{
groupedNotifications: _nullishCoalesce(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__ */ _jsxruntime.jsx.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-text-600", children: "Nenhuma notifica\xE7\xE3o configurada" }) });
};
var NotificationCard_default = NotificationCard;
exports.LegacyNotificationCard = LegacyNotificationCard; exports.NotificationCard_default = NotificationCard_default;
//# sourceMappingURL=chunk-5THJFVXH.js.map