analytica-frontend-lib 1.1.56 → 1.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NotificationCard/index.d.mts +1 -1
- package/dist/NotificationCard/index.d.ts +1 -1
- package/dist/NotificationCard/index.js +166 -82
- package/dist/NotificationCard/index.js.map +1 -1
- package/dist/NotificationCard/index.mjs +166 -82
- package/dist/NotificationCard/index.mjs.map +1 -1
- package/dist/{NotificationCard-kGUKNOqT.d.mts → NotificationCard-DpSGkWEa.d.mts} +10 -0
- package/dist/{NotificationCard-kGUKNOqT.d.ts → NotificationCard-DpSGkWEa.d.ts} +10 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +165 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +165 -82
- package/dist/index.mjs.map +1 -1
- package/dist/mock-content-K2CDVG6P.png +0 -0
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'react/jsx-runtime';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { j as LegacyNotificationCard, L as LegacyNotificationCardProps, i as NotificationCardProps, b as NotificationGroup, f as NotificationItem, e as default } from '../NotificationCard-
|
|
3
|
+
export { j as LegacyNotificationCard, L as LegacyNotificationCardProps, i as NotificationCardProps, b as NotificationGroup, f as NotificationItem, e as default } from '../NotificationCard-DpSGkWEa.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'react/jsx-runtime';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { j as LegacyNotificationCard, L as LegacyNotificationCardProps, i as NotificationCardProps, b as NotificationGroup, f as NotificationItem, e as default } from '../NotificationCard-
|
|
3
|
+
export { j as LegacyNotificationCard, L as LegacyNotificationCardProps, i as NotificationCardProps, b as NotificationGroup, f as NotificationItem, e as default } from '../NotificationCard-DpSGkWEa.js';
|
|
@@ -1413,6 +1413,9 @@ var formatTimeAgo = (date) => {
|
|
|
1413
1413
|
return new Date(date).toLocaleDateString("pt-BR");
|
|
1414
1414
|
};
|
|
1415
1415
|
|
|
1416
|
+
// src/assets/img/mock-content.png
|
|
1417
|
+
var mock_content_default = "../mock-content-K2CDVG6P.png";
|
|
1418
|
+
|
|
1416
1419
|
// src/components/NotificationCard/NotificationCard.tsx
|
|
1417
1420
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1418
1421
|
var NotificationEmpty = ({
|
|
@@ -1542,10 +1545,23 @@ var NotificationList = ({
|
|
|
1542
1545
|
onMarkAsReadById,
|
|
1543
1546
|
onDeleteById,
|
|
1544
1547
|
onNavigateById,
|
|
1548
|
+
onGlobalNotificationClick,
|
|
1545
1549
|
getActionLabel,
|
|
1546
1550
|
renderEmpty,
|
|
1547
|
-
className
|
|
1551
|
+
className,
|
|
1552
|
+
emptyStateImage
|
|
1548
1553
|
}) => {
|
|
1554
|
+
const [globalNotificationModal, setGlobalNotificationModal] = (0, import_react9.useState)({ isOpen: false, notification: null });
|
|
1555
|
+
const handleGlobalNotificationClick = (notification) => {
|
|
1556
|
+
if (onGlobalNotificationClick) {
|
|
1557
|
+
onGlobalNotificationClick(notification);
|
|
1558
|
+
} else {
|
|
1559
|
+
setGlobalNotificationModal({
|
|
1560
|
+
isOpen: true,
|
|
1561
|
+
notification
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
};
|
|
1549
1565
|
if (error) {
|
|
1550
1566
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: [
|
|
1551
1567
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-sm text-error-600", children: error }),
|
|
@@ -1574,28 +1590,59 @@ var NotificationList = ({
|
|
|
1574
1590
|
if (!groupedNotifications || groupedNotifications.length === 0) {
|
|
1575
1591
|
return renderEmpty ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "w-full", children: renderEmpty() }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NotificationEmpty, {});
|
|
1576
1592
|
}
|
|
1577
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: cn("flex flex-col gap-0 w-full", className), children: [
|
|
1594
|
+
groupedNotifications.map((group, idx) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col", children: [
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }),
|
|
1596
|
+
group.notifications.map((notification) => {
|
|
1597
|
+
const isGlobalNotification = !notification.entityType && !notification.entityId && !notification.activity && !notification.goal;
|
|
1598
|
+
let navigationHandler;
|
|
1599
|
+
if (isGlobalNotification) {
|
|
1600
|
+
navigationHandler = () => handleGlobalNotificationClick(notification);
|
|
1601
|
+
} else if (notification.entityType && notification.entityId && onNavigateById) {
|
|
1602
|
+
navigationHandler = () => onNavigateById(
|
|
1603
|
+
notification.entityType ?? void 0,
|
|
1604
|
+
notification.entityId ?? void 0
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
let actionLabel;
|
|
1608
|
+
if (isGlobalNotification) {
|
|
1609
|
+
actionLabel = getActionLabel?.(void 0);
|
|
1610
|
+
} else {
|
|
1611
|
+
actionLabel = getActionLabel?.(
|
|
1612
|
+
notification.entityType ?? void 0
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1616
|
+
SingleNotificationCard,
|
|
1617
|
+
{
|
|
1618
|
+
title: notification.title,
|
|
1619
|
+
message: notification.message,
|
|
1620
|
+
time: notification.time ?? formatTimeAgo(new Date(notification.createdAt)),
|
|
1621
|
+
isRead: notification.isRead,
|
|
1622
|
+
onMarkAsRead: () => onMarkAsReadById?.(notification.id),
|
|
1623
|
+
onDelete: () => onDeleteById?.(notification.id),
|
|
1624
|
+
onNavigate: navigationHandler,
|
|
1625
|
+
actionLabel
|
|
1626
|
+
},
|
|
1627
|
+
notification.id
|
|
1628
|
+
);
|
|
1629
|
+
})
|
|
1630
|
+
] }, `${group.label}-${idx}`)),
|
|
1631
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1632
|
+
Modal_default,
|
|
1581
1633
|
{
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
)
|
|
1595
|
-
},
|
|
1596
|
-
notification.id
|
|
1597
|
-
))
|
|
1598
|
-
] }, `${group.label}-${idx}`)) });
|
|
1634
|
+
isOpen: globalNotificationModal.isOpen,
|
|
1635
|
+
onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
|
|
1636
|
+
title: globalNotificationModal.notification?.title || "",
|
|
1637
|
+
description: globalNotificationModal.notification?.message || "",
|
|
1638
|
+
variant: "activity",
|
|
1639
|
+
image: emptyStateImage || mock_content_default,
|
|
1640
|
+
actionLink: globalNotificationModal.notification?.actionLink || void 0,
|
|
1641
|
+
actionLabel: "Ver mais",
|
|
1642
|
+
size: "lg"
|
|
1643
|
+
}
|
|
1644
|
+
)
|
|
1645
|
+
] });
|
|
1599
1646
|
};
|
|
1600
1647
|
var NotificationCenter = ({
|
|
1601
1648
|
isActive,
|
|
@@ -1618,6 +1665,7 @@ var NotificationCenter = ({
|
|
|
1618
1665
|
}) => {
|
|
1619
1666
|
const { isMobile } = useMobile();
|
|
1620
1667
|
const [isModalOpen, setIsModalOpen] = (0, import_react9.useState)(false);
|
|
1668
|
+
const [globalNotificationModal, setGlobalNotificationModal] = (0, import_react9.useState)({ isOpen: false, notification: null });
|
|
1621
1669
|
const handleMobileClick = () => {
|
|
1622
1670
|
setIsModalOpen(true);
|
|
1623
1671
|
onFetchNotifications?.();
|
|
@@ -1630,10 +1678,6 @@ var NotificationCenter = ({
|
|
|
1630
1678
|
onFetchNotifications?.();
|
|
1631
1679
|
}
|
|
1632
1680
|
}, [isActive, onFetchNotifications]);
|
|
1633
|
-
const handleNavigate = (entityType, entityId, onCleanup) => {
|
|
1634
|
-
onCleanup?.();
|
|
1635
|
-
onNavigateById?.(entityType, entityId);
|
|
1636
|
-
};
|
|
1637
1681
|
const renderEmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1638
1682
|
NotificationEmpty,
|
|
1639
1683
|
{
|
|
@@ -1684,13 +1728,20 @@ var NotificationCenter = ({
|
|
|
1684
1728
|
onRetry,
|
|
1685
1729
|
onMarkAsReadById,
|
|
1686
1730
|
onDeleteById,
|
|
1687
|
-
onNavigateById: (entityType, entityId) =>
|
|
1688
|
-
|
|
1689
|
-
entityId
|
|
1690
|
-
|
|
1691
|
-
)
|
|
1731
|
+
onNavigateById: (entityType, entityId) => {
|
|
1732
|
+
setIsModalOpen(false);
|
|
1733
|
+
onNavigateById?.(entityType, entityId);
|
|
1734
|
+
},
|
|
1735
|
+
onGlobalNotificationClick: (notification) => {
|
|
1736
|
+
setIsModalOpen(false);
|
|
1737
|
+
setGlobalNotificationModal({
|
|
1738
|
+
isOpen: true,
|
|
1739
|
+
notification
|
|
1740
|
+
});
|
|
1741
|
+
},
|
|
1692
1742
|
getActionLabel,
|
|
1693
|
-
renderEmpty: renderEmptyState
|
|
1743
|
+
renderEmpty: renderEmptyState,
|
|
1744
|
+
emptyStateImage
|
|
1694
1745
|
}
|
|
1695
1746
|
) })
|
|
1696
1747
|
] })
|
|
@@ -1698,56 +1749,85 @@ var NotificationCenter = ({
|
|
|
1698
1749
|
)
|
|
1699
1750
|
] });
|
|
1700
1751
|
}
|
|
1701
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1702
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
size: 24,
|
|
1711
|
-
className: isActive ? "text-primary-950" : "text-primary"
|
|
1712
|
-
}
|
|
1713
|
-
),
|
|
1714
|
-
className
|
|
1715
|
-
}
|
|
1716
|
-
) }),
|
|
1717
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1718
|
-
DropdownMenuContent,
|
|
1719
|
-
{
|
|
1720
|
-
className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
|
|
1721
|
-
side: "bottom",
|
|
1722
|
-
align: "end",
|
|
1723
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col", children: [
|
|
1724
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "px-4 py-3 border-b border-border-200", children: [
|
|
1725
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NotificationHeader, { unreadCount, variant: "dropdown" }),
|
|
1726
|
-
unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1727
|
-
"button",
|
|
1728
|
-
{
|
|
1729
|
-
type: "button",
|
|
1730
|
-
onClick: onMarkAllAsRead,
|
|
1731
|
-
className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2",
|
|
1732
|
-
children: "Marcar todas como lidas"
|
|
1733
|
-
}
|
|
1734
|
-
)
|
|
1735
|
-
] }),
|
|
1736
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1737
|
-
NotificationList,
|
|
1752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(DropdownMenu_default, { children: [
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1755
|
+
IconButton_default,
|
|
1756
|
+
{
|
|
1757
|
+
active: isActive,
|
|
1758
|
+
onClick: handleDesktopClick,
|
|
1759
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1760
|
+
import_phosphor_react5.Bell,
|
|
1738
1761
|
{
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
error,
|
|
1742
|
-
onRetry,
|
|
1743
|
-
onMarkAsReadById,
|
|
1744
|
-
onDeleteById,
|
|
1745
|
-
onNavigateById: (entityType, entityId) => handleNavigate(entityType, entityId),
|
|
1746
|
-
getActionLabel,
|
|
1747
|
-
renderEmpty: renderEmptyState
|
|
1762
|
+
size: 24,
|
|
1763
|
+
className: isActive ? "text-primary-950" : "text-primary"
|
|
1748
1764
|
}
|
|
1749
|
-
)
|
|
1750
|
-
|
|
1765
|
+
),
|
|
1766
|
+
className
|
|
1767
|
+
}
|
|
1768
|
+
) }),
|
|
1769
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1770
|
+
DropdownMenuContent,
|
|
1771
|
+
{
|
|
1772
|
+
className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
|
|
1773
|
+
side: "bottom",
|
|
1774
|
+
align: "end",
|
|
1775
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col", children: [
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "px-4 py-3 border-b border-border-200", children: [
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1778
|
+
NotificationHeader,
|
|
1779
|
+
{
|
|
1780
|
+
unreadCount,
|
|
1781
|
+
variant: "dropdown"
|
|
1782
|
+
}
|
|
1783
|
+
),
|
|
1784
|
+
unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1785
|
+
"button",
|
|
1786
|
+
{
|
|
1787
|
+
type: "button",
|
|
1788
|
+
onClick: onMarkAllAsRead,
|
|
1789
|
+
className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer mt-2",
|
|
1790
|
+
children: "Marcar todas como lidas"
|
|
1791
|
+
}
|
|
1792
|
+
)
|
|
1793
|
+
] }),
|
|
1794
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1795
|
+
NotificationList,
|
|
1796
|
+
{
|
|
1797
|
+
groupedNotifications,
|
|
1798
|
+
loading,
|
|
1799
|
+
error,
|
|
1800
|
+
onRetry,
|
|
1801
|
+
onMarkAsReadById,
|
|
1802
|
+
onDeleteById,
|
|
1803
|
+
onNavigateById,
|
|
1804
|
+
onGlobalNotificationClick: (notification) => {
|
|
1805
|
+
setGlobalNotificationModal({
|
|
1806
|
+
isOpen: true,
|
|
1807
|
+
notification
|
|
1808
|
+
});
|
|
1809
|
+
},
|
|
1810
|
+
getActionLabel,
|
|
1811
|
+
renderEmpty: renderEmptyState,
|
|
1812
|
+
emptyStateImage
|
|
1813
|
+
}
|
|
1814
|
+
) })
|
|
1815
|
+
] })
|
|
1816
|
+
}
|
|
1817
|
+
)
|
|
1818
|
+
] }),
|
|
1819
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1820
|
+
Modal_default,
|
|
1821
|
+
{
|
|
1822
|
+
isOpen: globalNotificationModal.isOpen,
|
|
1823
|
+
onClose: () => setGlobalNotificationModal({ isOpen: false, notification: null }),
|
|
1824
|
+
title: globalNotificationModal.notification?.title || "",
|
|
1825
|
+
variant: "activity",
|
|
1826
|
+
description: globalNotificationModal.notification?.message,
|
|
1827
|
+
image: emptyStateImage || mock_content_default,
|
|
1828
|
+
actionLink: globalNotificationModal.notification?.actionLink || void 0,
|
|
1829
|
+
actionLabel: "Ver mais",
|
|
1830
|
+
size: "lg"
|
|
1751
1831
|
}
|
|
1752
1832
|
)
|
|
1753
1833
|
] });
|
|
@@ -1785,9 +1865,11 @@ var NotificationCard = (props) => {
|
|
|
1785
1865
|
onMarkAsReadById: props.onMarkAsReadById,
|
|
1786
1866
|
onDeleteById: props.onDeleteById,
|
|
1787
1867
|
onNavigateById: props.onNavigateById,
|
|
1868
|
+
onGlobalNotificationClick: props.onGlobalNotificationClick,
|
|
1788
1869
|
getActionLabel: props.getActionLabel,
|
|
1789
1870
|
renderEmpty: props.renderEmpty,
|
|
1790
|
-
className: props.className
|
|
1871
|
+
className: props.className,
|
|
1872
|
+
emptyStateImage: props.emptyStateImage
|
|
1791
1873
|
}
|
|
1792
1874
|
);
|
|
1793
1875
|
case "center":
|
|
@@ -1820,9 +1902,11 @@ var LegacyNotificationCard = (props) => {
|
|
|
1820
1902
|
onMarkAsReadById: props.onMarkAsReadById,
|
|
1821
1903
|
onDeleteById: props.onDeleteById,
|
|
1822
1904
|
onNavigateById: props.onNavigateById,
|
|
1905
|
+
onGlobalNotificationClick: props.onGlobalNotificationClick,
|
|
1823
1906
|
getActionLabel: props.getActionLabel,
|
|
1824
1907
|
renderEmpty: props.renderEmpty,
|
|
1825
|
-
className: props.className
|
|
1908
|
+
className: props.className,
|
|
1909
|
+
emptyStateImage: props.emptyStateImage
|
|
1826
1910
|
}
|
|
1827
1911
|
);
|
|
1828
1912
|
}
|