analytica-frontend-lib 1.1.35 → 1.1.37

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.
@@ -1,5 +1,6 @@
1
1
  // src/components/NotificationCard/NotificationCard.tsx
2
- import { DotsThreeVertical } from "phosphor-react";
2
+ import { DotsThreeVertical, Bell } from "phosphor-react";
3
+ import { useState as useState3, useEffect as useEffect4 } from "react";
3
4
 
4
5
  // src/utils/utils.ts
5
6
  import { clsx } from "clsx";
@@ -589,8 +590,327 @@ var SkeletonTable = forwardRef2(
589
590
  }
590
591
  );
591
592
 
593
+ // src/components/IconButton/IconButton.tsx
594
+ import { forwardRef as forwardRef3 } from "react";
595
+ import { jsx as jsx4 } from "react/jsx-runtime";
596
+ var IconButton = forwardRef3(
597
+ ({ icon, size = "md", active = false, className = "", disabled, ...props }, ref) => {
598
+ const baseClasses = [
599
+ "inline-flex",
600
+ "items-center",
601
+ "justify-center",
602
+ "rounded-lg",
603
+ "font-medium",
604
+ "bg-transparent",
605
+ "text-text-950",
606
+ "cursor-pointer",
607
+ "hover:bg-primary-600",
608
+ "hover:text-text",
609
+ "focus-visible:outline-none",
610
+ "focus-visible:ring-2",
611
+ "focus-visible:ring-offset-0",
612
+ "focus-visible:ring-indicator-info",
613
+ "disabled:opacity-50",
614
+ "disabled:cursor-not-allowed",
615
+ "disabled:pointer-events-none"
616
+ ];
617
+ const sizeClasses = {
618
+ sm: ["w-6", "h-6", "text-sm"],
619
+ md: ["w-10", "h-10", "text-base"]
620
+ };
621
+ const activeClasses = active ? ["!bg-primary-50", "!text-primary-950", "hover:!bg-primary-100"] : [];
622
+ const allClasses = [
623
+ ...baseClasses,
624
+ ...sizeClasses[size],
625
+ ...activeClasses
626
+ ].join(" ");
627
+ const ariaLabel = props["aria-label"] ?? "Bot\xE3o de a\xE7\xE3o";
628
+ return /* @__PURE__ */ jsx4(
629
+ "button",
630
+ {
631
+ ref,
632
+ type: "button",
633
+ className: cn(allClasses, className),
634
+ disabled,
635
+ "aria-pressed": active,
636
+ "aria-label": ariaLabel,
637
+ ...props,
638
+ children: /* @__PURE__ */ jsx4("span", { className: "flex items-center justify-center", children: icon })
639
+ }
640
+ );
641
+ }
642
+ );
643
+ IconButton.displayName = "IconButton";
644
+ var IconButton_default = IconButton;
645
+
646
+ // src/components/Modal/Modal.tsx
647
+ import { useEffect as useEffect2 } from "react";
648
+ import { X } from "phosphor-react";
649
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
650
+ var SIZE_CLASSES2 = {
651
+ xs: "max-w-[360px]",
652
+ sm: "max-w-[420px]",
653
+ md: "max-w-[510px]",
654
+ lg: "max-w-[640px]",
655
+ xl: "max-w-[970px]"
656
+ };
657
+ var Modal = ({
658
+ isOpen,
659
+ onClose,
660
+ title,
661
+ children,
662
+ size = "md",
663
+ className = "",
664
+ closeOnBackdropClick = true,
665
+ closeOnEscape = true,
666
+ footer,
667
+ hideCloseButton = false
668
+ }) => {
669
+ useEffect2(() => {
670
+ if (!isOpen || !closeOnEscape) return;
671
+ const handleEscape = (event) => {
672
+ if (event.key === "Escape") {
673
+ onClose();
674
+ }
675
+ };
676
+ document.addEventListener("keydown", handleEscape);
677
+ return () => document.removeEventListener("keydown", handleEscape);
678
+ }, [isOpen, closeOnEscape, onClose]);
679
+ useEffect2(() => {
680
+ const originalOverflow = document.body.style.overflow;
681
+ if (isOpen) {
682
+ document.body.style.overflow = "hidden";
683
+ } else {
684
+ document.body.style.overflow = originalOverflow;
685
+ }
686
+ return () => {
687
+ document.body.style.overflow = originalOverflow;
688
+ };
689
+ }, [isOpen]);
690
+ const handleBackdropClick = (event) => {
691
+ if (closeOnBackdropClick && event.target === event.currentTarget) {
692
+ onClose();
693
+ }
694
+ };
695
+ const handleBackdropKeyDown = (event) => {
696
+ if (closeOnBackdropClick && (event.key === "Enter" || event.key === " ")) {
697
+ onClose();
698
+ }
699
+ };
700
+ if (!isOpen) return null;
701
+ const sizeClasses = SIZE_CLASSES2[size];
702
+ const baseClasses = "bg-secondary-50 rounded-3xl shadow-hard-shadow-2 border border-border-100 w-full mx-4";
703
+ const dialogResetClasses = "p-0 m-0 border-none outline-none max-h-none static";
704
+ const modalClasses = cn(
705
+ baseClasses,
706
+ sizeClasses,
707
+ dialogResetClasses,
708
+ className
709
+ );
710
+ return /* @__PURE__ */ jsx5(
711
+ "div",
712
+ {
713
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-xs",
714
+ onClick: handleBackdropClick,
715
+ onKeyDown: handleBackdropKeyDown,
716
+ role: "button",
717
+ tabIndex: closeOnBackdropClick ? 0 : -1,
718
+ "aria-label": "Fechar modal clicando no fundo",
719
+ children: /* @__PURE__ */ jsxs4("dialog", { className: modalClasses, "aria-labelledby": "modal-title", open: true, children: [
720
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between px-6 py-6", children: [
721
+ /* @__PURE__ */ jsx5("h2", { id: "modal-title", className: "text-lg font-semibold text-text-950", children: title }),
722
+ !hideCloseButton && /* @__PURE__ */ jsx5(
723
+ "button",
724
+ {
725
+ onClick: onClose,
726
+ className: "p-1 text-text-500 hover:text-text-700 hover:bg-background-50 rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-indicator-info focus:ring-offset-2",
727
+ "aria-label": "Fechar modal",
728
+ children: /* @__PURE__ */ jsx5(X, { size: 18 })
729
+ }
730
+ )
731
+ ] }),
732
+ /* @__PURE__ */ jsx5("div", { className: "px-6 pb-6", children: /* @__PURE__ */ jsx5("div", { className: "text-text-500 font-normal text-sm leading-6", children }) }),
733
+ footer && /* @__PURE__ */ jsx5("div", { className: "flex justify-end gap-3 px-6 pb-6", children: footer })
734
+ ] })
735
+ }
736
+ );
737
+ };
738
+ var Modal_default = Modal;
739
+
740
+ // src/components/Text/Text.tsx
741
+ import { jsx as jsx6 } from "react/jsx-runtime";
742
+ var Text = ({
743
+ children,
744
+ size = "md",
745
+ weight = "normal",
746
+ color = "text-text-950",
747
+ as,
748
+ className = "",
749
+ ...props
750
+ }) => {
751
+ let sizeClasses = "";
752
+ let weightClasses = "";
753
+ const sizeClassMap = {
754
+ "2xs": "text-2xs",
755
+ xs: "text-xs",
756
+ sm: "text-sm",
757
+ md: "text-md",
758
+ lg: "text-lg",
759
+ xl: "text-xl",
760
+ "2xl": "text-2xl",
761
+ "3xl": "text-3xl",
762
+ "4xl": "text-4xl",
763
+ "5xl": "text-5xl",
764
+ "6xl": "text-6xl"
765
+ };
766
+ sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
767
+ const weightClassMap = {
768
+ hairline: "font-hairline",
769
+ light: "font-light",
770
+ normal: "font-normal",
771
+ medium: "font-medium",
772
+ semibold: "font-semibold",
773
+ bold: "font-bold",
774
+ extrabold: "font-extrabold",
775
+ black: "font-black"
776
+ };
777
+ weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
778
+ const baseClasses = "font-primary";
779
+ const Component = as ?? "p";
780
+ return /* @__PURE__ */ jsx6(
781
+ Component,
782
+ {
783
+ className: cn(baseClasses, sizeClasses, weightClasses, color, className),
784
+ ...props,
785
+ children
786
+ }
787
+ );
788
+ };
789
+ var Text_default = Text;
790
+
791
+ // src/hooks/useMobile.ts
792
+ import { useState as useState2, useEffect as useEffect3 } from "react";
793
+ var MOBILE_WIDTH = 500;
794
+ var TABLET_WIDTH = 931;
795
+ var DEFAULT_WIDTH = 1200;
796
+ var getWindowWidth = () => {
797
+ if (typeof window === "undefined") {
798
+ return DEFAULT_WIDTH;
799
+ }
800
+ return window.innerWidth;
801
+ };
802
+ var getDeviceType = () => {
803
+ const width = getWindowWidth();
804
+ return width < TABLET_WIDTH ? "responsive" : "desktop";
805
+ };
806
+ var useMobile = () => {
807
+ const [isMobile, setIsMobile] = useState2(false);
808
+ const [isTablet, setIsTablet] = useState2(false);
809
+ useEffect3(() => {
810
+ const checkScreenSize = () => {
811
+ const width = getWindowWidth();
812
+ setIsMobile(width < MOBILE_WIDTH);
813
+ setIsTablet(width < TABLET_WIDTH);
814
+ };
815
+ checkScreenSize();
816
+ window.addEventListener("resize", checkScreenSize);
817
+ return () => window.removeEventListener("resize", checkScreenSize);
818
+ }, []);
819
+ const getFormContainerClasses = () => {
820
+ if (isMobile) {
821
+ return "w-full px-4";
822
+ }
823
+ if (isTablet) {
824
+ return "w-full px-6";
825
+ }
826
+ return "w-full max-w-[992px] mx-auto px-0";
827
+ };
828
+ const getMobileHeaderClasses = () => {
829
+ return "flex flex-col items-start gap-4 mb-6";
830
+ };
831
+ const getDesktopHeaderClasses = () => {
832
+ return "flex flex-row justify-between items-center gap-6 mb-8";
833
+ };
834
+ const getHeaderClasses = () => {
835
+ return isMobile ? getMobileHeaderClasses() : getDesktopHeaderClasses();
836
+ };
837
+ return {
838
+ isMobile,
839
+ isTablet,
840
+ getFormContainerClasses,
841
+ getHeaderClasses,
842
+ getMobileHeaderClasses,
843
+ getDesktopHeaderClasses,
844
+ getDeviceType
845
+ };
846
+ };
847
+
848
+ // src/store/notificationStore.ts
849
+ import { create as create2 } from "zustand";
850
+ import { devtools } from "zustand/middleware";
851
+ var formatTimeAgo = (date) => {
852
+ const now = /* @__PURE__ */ new Date();
853
+ const diffInMs = now.getTime() - new Date(date).getTime();
854
+ const diffInHours = Math.floor(diffInMs / (1e3 * 60 * 60));
855
+ const diffInDays = Math.floor(diffInMs / (1e3 * 60 * 60 * 24));
856
+ if (diffInHours < 24) {
857
+ return `H\xE1 ${diffInHours}h`;
858
+ } else if (diffInDays < 30) {
859
+ const day = new Date(date).getDate();
860
+ const months = [
861
+ "Jan",
862
+ "Fev",
863
+ "Mar",
864
+ "Abr",
865
+ "Mai",
866
+ "Jun",
867
+ "Jul",
868
+ "Ago",
869
+ "Set",
870
+ "Out",
871
+ "Nov",
872
+ "Dez"
873
+ ];
874
+ const month = months[new Date(date).getMonth()];
875
+ return `${day} ${month}`;
876
+ }
877
+ return new Date(date).toLocaleDateString("pt-BR");
878
+ };
879
+
592
880
  // src/components/NotificationCard/NotificationCard.tsx
593
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
881
+ import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
882
+ var NotificationEmpty = ({
883
+ emptyStateImage,
884
+ emptyStateTitle = "Nenhuma notifica\xE7\xE3o no momento",
885
+ emptyStateDescription = "Voc\xEA est\xE1 em dia com todas as novidades. Volte depois para conferir atualiza\xE7\xF5es!"
886
+ }) => {
887
+ return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center justify-center gap-4 p-6 w-full", children: [
888
+ emptyStateImage && /* @__PURE__ */ jsx7("div", { className: "w-20 h-20 flex items-center justify-center", children: /* @__PURE__ */ jsx7(
889
+ "img",
890
+ {
891
+ src: emptyStateImage,
892
+ alt: "Sem notifica\xE7\xF5es",
893
+ width: 82,
894
+ height: 82,
895
+ className: "object-contain"
896
+ }
897
+ ) }),
898
+ /* @__PURE__ */ jsx7("h3", { className: "text-xl font-semibold text-text-950 text-center leading-[23px]", children: emptyStateTitle }),
899
+ /* @__PURE__ */ jsx7("p", { className: "text-sm font-normal text-text-400 text-center max-w-[316px] leading-[21px]", children: emptyStateDescription })
900
+ ] });
901
+ };
902
+ var NotificationHeader = ({
903
+ unreadCount,
904
+ variant = "modal"
905
+ }) => {
906
+ return /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between", children: [
907
+ variant === "modal" ? /* @__PURE__ */ jsx7(Text_default, { size: "sm", weight: "bold", className: "text-text-950", children: "Notifica\xE7\xF5es" }) : /* @__PURE__ */ jsx7("h3", { className: "text-sm font-semibold text-text-950", children: "Notifica\xE7\xF5es" }),
908
+ unreadCount > 0 && /* @__PURE__ */ jsxs5("span", { className: "px-2 py-1 bg-info-100 text-info-700 text-xs rounded-full", children: [
909
+ unreadCount,
910
+ " n\xE3o lidas"
911
+ ] })
912
+ ] });
913
+ };
594
914
  var SingleNotificationCard = ({
595
915
  title,
596
916
  message,
@@ -620,7 +940,7 @@ var SingleNotificationCard = ({
620
940
  onNavigate();
621
941
  }
622
942
  };
623
- return /* @__PURE__ */ jsxs4(
943
+ return /* @__PURE__ */ jsxs5(
624
944
  "div",
625
945
  {
626
946
  className: cn(
@@ -629,20 +949,20 @@ var SingleNotificationCard = ({
629
949
  className
630
950
  ),
631
951
  children: [
632
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2 w-full", children: [
633
- !isRead && /* @__PURE__ */ jsx4("div", { className: "w-[7px] h-[7px] bg-info-300 rounded-full flex-shrink-0" }),
634
- /* @__PURE__ */ jsx4("h3", { className: "font-bold text-sm leading-4 text-text-950 flex-grow", children: title }),
635
- /* @__PURE__ */ jsxs4(DropdownMenu_default, { children: [
636
- /* @__PURE__ */ jsx4(
952
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 w-full", children: [
953
+ !isRead && /* @__PURE__ */ jsx7("div", { className: "w-[7px] h-[7px] bg-info-300 rounded-full flex-shrink-0" }),
954
+ /* @__PURE__ */ jsx7("h3", { className: "font-bold text-sm leading-4 text-text-950 flex-grow", children: title }),
955
+ /* @__PURE__ */ jsxs5(DropdownMenu_default, { children: [
956
+ /* @__PURE__ */ jsx7(
637
957
  DropdownMenuTrigger,
638
958
  {
639
959
  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",
640
960
  "aria-label": "Menu de a\xE7\xF5es",
641
- children: /* @__PURE__ */ jsx4(DotsThreeVertical, { size: 24 })
961
+ children: /* @__PURE__ */ jsx7(DotsThreeVertical, { size: 24 })
642
962
  }
643
963
  ),
644
- /* @__PURE__ */ jsxs4(DropdownMenuContent, { align: "end", className: "min-w-[160px]", children: [
645
- !isRead && /* @__PURE__ */ jsx4(
964
+ /* @__PURE__ */ jsxs5(DropdownMenuContent, { align: "end", className: "min-w-[160px]", children: [
965
+ !isRead && /* @__PURE__ */ jsx7(
646
966
  DropdownMenuItem,
647
967
  {
648
968
  onClick: handleMarkAsRead,
@@ -650,14 +970,14 @@ var SingleNotificationCard = ({
650
970
  children: "Marcar como lida"
651
971
  }
652
972
  ),
653
- /* @__PURE__ */ jsx4(DropdownMenuItem, { onClick: handleDelete, className: "text-error-600", children: "Deletar" })
973
+ /* @__PURE__ */ jsx7(DropdownMenuItem, { onClick: handleDelete, className: "text-error-600", children: "Deletar" })
654
974
  ] })
655
975
  ] })
656
976
  ] }),
657
- /* @__PURE__ */ jsx4("p", { className: "text-sm leading-[21px] text-text-800 w-full", children: message }),
658
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between w-full", children: [
659
- /* @__PURE__ */ jsx4("span", { className: "text-sm font-medium text-text-400", children: time }),
660
- onNavigate && actionLabel && /* @__PURE__ */ jsx4(
977
+ /* @__PURE__ */ jsx7("p", { className: "text-sm leading-[21px] text-text-800 w-full", children: message }),
978
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between w-full", children: [
979
+ /* @__PURE__ */ jsx7("span", { className: "text-sm font-medium text-text-400", children: time }),
980
+ onNavigate && actionLabel && /* @__PURE__ */ jsx7(
661
981
  "button",
662
982
  {
663
983
  type: "button",
@@ -684,9 +1004,9 @@ var NotificationList = ({
684
1004
  className
685
1005
  }) => {
686
1006
  if (error) {
687
- return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: [
688
- /* @__PURE__ */ jsx4("p", { className: "text-sm text-error-600", children: error }),
689
- onRetry && /* @__PURE__ */ jsx4(
1007
+ return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: [
1008
+ /* @__PURE__ */ jsx7("p", { className: "text-sm text-error-600", children: error }),
1009
+ onRetry && /* @__PURE__ */ jsx7(
690
1010
  "button",
691
1011
  {
692
1012
  type: "button",
@@ -698,8 +1018,8 @@ var NotificationList = ({
698
1018
  ] });
699
1019
  }
700
1020
  if (loading) {
701
- return /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-0 w-full", children: ["skeleton-first", "skeleton-second", "skeleton-third"].map(
702
- (skeletonId) => /* @__PURE__ */ jsx4(
1021
+ return /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-0 w-full", children: ["skeleton-first", "skeleton-second", "skeleton-third"].map(
1022
+ (skeletonId) => /* @__PURE__ */ jsx7(
703
1023
  SkeletonCard,
704
1024
  {
705
1025
  className: "p-4 border-b border-border-200"
@@ -709,59 +1029,303 @@ var NotificationList = ({
709
1029
  ) });
710
1030
  }
711
1031
  if (!groupedNotifications || groupedNotifications.length === 0) {
712
- return renderEmpty ? /* @__PURE__ */ jsx4("div", { className: "w-full", children: renderEmpty() }) : /* @__PURE__ */ jsx4("div", { className: "flex flex-col items-center justify-center gap-4 p-6 w-full", children: /* @__PURE__ */ jsx4("p", { className: "text-sm text-text-400", children: "Nenhuma notifica\xE7\xE3o encontrada" }) });
1032
+ return renderEmpty ? /* @__PURE__ */ jsx7("div", { className: "w-full", children: renderEmpty() }) : /* @__PURE__ */ jsx7(NotificationEmpty, {});
713
1033
  }
714
- return /* @__PURE__ */ jsx4("div", { className: cn("flex flex-col gap-0 w-full", className), children: groupedNotifications.map((group, idx) => /* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
715
- /* @__PURE__ */ jsx4("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ jsx4("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }),
716
- group.notifications.map((notification) => /* @__PURE__ */ jsx4(
1034
+ return /* @__PURE__ */ jsx7("div", { className: cn("flex flex-col gap-0 w-full", className), children: groupedNotifications.map((group, idx) => /* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
1035
+ /* @__PURE__ */ jsx7("div", { className: "flex items-end px-4 py-6 pb-4", children: /* @__PURE__ */ jsx7("h4", { className: "text-lg font-bold text-text-500 flex-grow", children: group.label }) }),
1036
+ group.notifications.map((notification) => /* @__PURE__ */ jsx7(
717
1037
  SingleNotificationCard,
718
1038
  {
719
1039
  title: notification.title,
720
1040
  message: notification.message,
721
- time: notification.time,
1041
+ time: notification.time ?? formatTimeAgo(new Date(notification.createdAt)),
722
1042
  isRead: notification.isRead,
723
1043
  onMarkAsRead: () => onMarkAsReadById?.(notification.id),
724
1044
  onDelete: () => onDeleteById?.(notification.id),
725
1045
  onNavigate: notification.entityType && notification.entityId && onNavigateById ? () => onNavigateById(
726
- notification.entityType,
727
- notification.entityId
1046
+ notification.entityType ?? void 0,
1047
+ notification.entityId ?? void 0
728
1048
  ) : void 0,
729
- actionLabel: getActionLabel?.(notification.entityType)
1049
+ actionLabel: getActionLabel?.(
1050
+ notification.entityType ?? void 0
1051
+ )
730
1052
  },
731
1053
  notification.id
732
1054
  ))
733
1055
  ] }, `${group.label}-${idx}`)) });
734
1056
  };
1057
+ var NotificationCenter = ({
1058
+ isActive,
1059
+ onToggleActive,
1060
+ unreadCount = 0,
1061
+ groupedNotifications = [],
1062
+ loading = false,
1063
+ error = null,
1064
+ onRetry,
1065
+ onMarkAsReadById,
1066
+ onDeleteById,
1067
+ onNavigateById,
1068
+ getActionLabel,
1069
+ onFetchNotifications,
1070
+ onMarkAllAsRead,
1071
+ emptyStateImage,
1072
+ emptyStateTitle,
1073
+ emptyStateDescription,
1074
+ className
1075
+ }) => {
1076
+ const { isMobile } = useMobile();
1077
+ const [isModalOpen, setIsModalOpen] = useState3(false);
1078
+ const handleMobileClick = () => {
1079
+ setIsModalOpen(true);
1080
+ onFetchNotifications?.();
1081
+ };
1082
+ const handleDesktopClick = () => {
1083
+ onToggleActive?.();
1084
+ };
1085
+ useEffect4(() => {
1086
+ if (isActive) {
1087
+ onFetchNotifications?.();
1088
+ }
1089
+ }, [isActive, onFetchNotifications]);
1090
+ const handleNavigate = (entityType, entityId, onCleanup) => {
1091
+ onCleanup?.();
1092
+ onNavigateById?.(entityType, entityId);
1093
+ };
1094
+ const renderEmptyState = () => /* @__PURE__ */ jsx7(
1095
+ NotificationEmpty,
1096
+ {
1097
+ emptyStateImage,
1098
+ emptyStateTitle,
1099
+ emptyStateDescription
1100
+ }
1101
+ );
1102
+ if (isMobile) {
1103
+ return /* @__PURE__ */ jsxs5(Fragment, { children: [
1104
+ /* @__PURE__ */ jsx7(
1105
+ IconButton_default,
1106
+ {
1107
+ active: isModalOpen,
1108
+ onClick: handleMobileClick,
1109
+ icon: /* @__PURE__ */ jsx7(Bell, { size: 24, className: "text-primary" }),
1110
+ className
1111
+ }
1112
+ ),
1113
+ /* @__PURE__ */ jsx7(
1114
+ Modal_default,
1115
+ {
1116
+ isOpen: isModalOpen,
1117
+ onClose: () => setIsModalOpen(false),
1118
+ title: "Notifica\xE7\xF5es",
1119
+ size: "md",
1120
+ hideCloseButton: false,
1121
+ closeOnBackdropClick: true,
1122
+ closeOnEscape: true,
1123
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col h-full max-h-[80vh]", children: [
1124
+ /* @__PURE__ */ jsx7("div", { className: "px-0 pb-3 border-b border-border-200", children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between", children: [
1125
+ /* @__PURE__ */ jsx7(NotificationHeader, { unreadCount, variant: "modal" }),
1126
+ unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ jsx7(
1127
+ "button",
1128
+ {
1129
+ type: "button",
1130
+ onClick: onMarkAllAsRead,
1131
+ className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer",
1132
+ children: "Marcar todas como lidas"
1133
+ }
1134
+ )
1135
+ ] }) }),
1136
+ /* @__PURE__ */ jsx7("div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx7(
1137
+ NotificationList,
1138
+ {
1139
+ groupedNotifications,
1140
+ loading,
1141
+ error,
1142
+ onRetry,
1143
+ onMarkAsReadById,
1144
+ onDeleteById,
1145
+ onNavigateById: (entityType, entityId) => handleNavigate(
1146
+ entityType,
1147
+ entityId,
1148
+ () => setIsModalOpen(false)
1149
+ ),
1150
+ getActionLabel,
1151
+ renderEmpty: renderEmptyState
1152
+ }
1153
+ ) })
1154
+ ] })
1155
+ }
1156
+ )
1157
+ ] });
1158
+ }
1159
+ return /* @__PURE__ */ jsxs5(DropdownMenu_default, { children: [
1160
+ /* @__PURE__ */ jsx7(DropdownMenuTrigger, { className: "text-primary cursor-pointer", children: /* @__PURE__ */ jsx7(
1161
+ IconButton_default,
1162
+ {
1163
+ active: isActive,
1164
+ onClick: handleDesktopClick,
1165
+ icon: /* @__PURE__ */ jsx7(
1166
+ Bell,
1167
+ {
1168
+ size: 24,
1169
+ className: isActive ? "text-primary-950" : "text-primary"
1170
+ }
1171
+ ),
1172
+ className
1173
+ }
1174
+ ) }),
1175
+ /* @__PURE__ */ jsx7(
1176
+ DropdownMenuContent,
1177
+ {
1178
+ className: "min-w-[320px] max-w-[400px] max-h-[500px] overflow-hidden",
1179
+ side: "bottom",
1180
+ align: "end",
1181
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
1182
+ /* @__PURE__ */ jsx7("div", { className: "px-4 py-3 border-b border-border-200", children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between", children: [
1183
+ /* @__PURE__ */ jsx7(
1184
+ NotificationHeader,
1185
+ {
1186
+ unreadCount,
1187
+ variant: "dropdown"
1188
+ }
1189
+ ),
1190
+ unreadCount > 0 && onMarkAllAsRead && /* @__PURE__ */ jsx7(
1191
+ "button",
1192
+ {
1193
+ type: "button",
1194
+ onClick: onMarkAllAsRead,
1195
+ className: "text-sm font-medium text-info-600 hover:text-info-700 cursor-pointer",
1196
+ children: "Marcar todas como lidas"
1197
+ }
1198
+ )
1199
+ ] }) }),
1200
+ /* @__PURE__ */ jsx7("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ jsx7(
1201
+ NotificationList,
1202
+ {
1203
+ groupedNotifications,
1204
+ loading,
1205
+ error,
1206
+ onRetry,
1207
+ onMarkAsReadById,
1208
+ onDeleteById,
1209
+ onNavigateById: (entityType, entityId) => handleNavigate(entityType, entityId, onToggleActive),
1210
+ getActionLabel,
1211
+ renderEmpty: renderEmptyState
1212
+ }
1213
+ ) })
1214
+ ] })
1215
+ }
1216
+ )
1217
+ ] });
1218
+ };
735
1219
  var NotificationCard = (props) => {
1220
+ switch (props.mode) {
1221
+ case "single":
1222
+ return /* @__PURE__ */ jsx7(
1223
+ SingleNotificationCard,
1224
+ {
1225
+ title: props.title,
1226
+ message: props.message,
1227
+ time: props.time,
1228
+ isRead: props.isRead,
1229
+ onMarkAsRead: props.onMarkAsRead,
1230
+ onDelete: props.onDelete,
1231
+ onNavigate: props.onNavigate,
1232
+ actionLabel: props.actionLabel,
1233
+ className: props.className
1234
+ }
1235
+ );
1236
+ case "list":
1237
+ return /* @__PURE__ */ jsx7(
1238
+ NotificationList,
1239
+ {
1240
+ groupedNotifications: props.groupedNotifications ?? (props.notifications ? [
1241
+ {
1242
+ label: "Notifica\xE7\xF5es",
1243
+ notifications: props.notifications
1244
+ }
1245
+ ] : []),
1246
+ loading: props.loading,
1247
+ error: props.error,
1248
+ onRetry: props.onRetry,
1249
+ onMarkAsReadById: props.onMarkAsReadById,
1250
+ onDeleteById: props.onDeleteById,
1251
+ onNavigateById: props.onNavigateById,
1252
+ getActionLabel: props.getActionLabel,
1253
+ renderEmpty: props.renderEmpty,
1254
+ className: props.className
1255
+ }
1256
+ );
1257
+ case "center":
1258
+ return /* @__PURE__ */ jsx7(NotificationCenter, { ...props });
1259
+ default:
1260
+ return /* @__PURE__ */ jsx7("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: /* @__PURE__ */ jsx7("p", { className: "text-sm text-text-600", children: "Modo de notifica\xE7\xE3o n\xE3o reconhecido" }) });
1261
+ }
1262
+ };
1263
+ var LegacyNotificationCard = (props) => {
1264
+ if (props.variant === "center") {
1265
+ const centerProps = {
1266
+ mode: "center",
1267
+ ...props
1268
+ };
1269
+ return /* @__PURE__ */ jsx7(NotificationCenter, { ...centerProps });
1270
+ }
736
1271
  if (props.groupedNotifications !== void 0 || props.notifications !== void 0 || props.loading || props.error) {
737
- return /* @__PURE__ */ jsx4(
1272
+ return /* @__PURE__ */ jsx7(
738
1273
  NotificationList,
739
1274
  {
740
- ...props,
741
- groupedNotifications: props.groupedNotifications ?? (props.notifications ? [{ label: "Notifica\xE7\xF5es", notifications: props.notifications }] : [])
1275
+ groupedNotifications: props.groupedNotifications ?? (props.notifications ? [
1276
+ {
1277
+ label: "Notifica\xE7\xF5es",
1278
+ notifications: props.notifications
1279
+ }
1280
+ ] : []),
1281
+ loading: props.loading,
1282
+ error: props.error,
1283
+ onRetry: props.onRetry,
1284
+ onMarkAsReadById: props.onMarkAsReadById,
1285
+ onDeleteById: props.onDeleteById,
1286
+ onNavigateById: props.onNavigateById,
1287
+ getActionLabel: props.getActionLabel,
1288
+ renderEmpty: props.renderEmpty,
1289
+ className: props.className
742
1290
  }
743
1291
  );
744
1292
  }
745
1293
  if (props.title !== void 0 && props.message !== void 0 && props.time !== void 0 && props.isRead !== void 0 && props.onMarkAsRead && props.onDelete) {
746
- return /* @__PURE__ */ jsx4(
1294
+ const singleProps = {
1295
+ mode: "single",
1296
+ title: props.title,
1297
+ message: props.message,
1298
+ time: props.time,
1299
+ isRead: props.isRead,
1300
+ onMarkAsRead: props.onMarkAsRead,
1301
+ onDelete: props.onDelete,
1302
+ onNavigate: props.onNavigate,
1303
+ actionLabel: props.actionLabel,
1304
+ className: props.className,
1305
+ emptyStateImage: props.emptyStateImage,
1306
+ emptyStateTitle: props.emptyStateTitle,
1307
+ emptyStateDescription: props.emptyStateDescription
1308
+ };
1309
+ return /* @__PURE__ */ jsx7(
747
1310
  SingleNotificationCard,
748
1311
  {
749
- title: props.title,
750
- message: props.message,
751
- time: props.time,
752
- isRead: props.isRead,
753
- onMarkAsRead: props.onMarkAsRead,
754
- onDelete: props.onDelete,
755
- onNavigate: props.onNavigate,
756
- actionLabel: props.actionLabel,
757
- className: props.className
1312
+ title: singleProps.title,
1313
+ message: singleProps.message,
1314
+ time: singleProps.time,
1315
+ isRead: singleProps.isRead,
1316
+ onMarkAsRead: singleProps.onMarkAsRead,
1317
+ onDelete: singleProps.onDelete,
1318
+ onNavigate: singleProps.onNavigate,
1319
+ actionLabel: singleProps.actionLabel,
1320
+ className: singleProps.className
758
1321
  }
759
1322
  );
760
1323
  }
761
- return /* @__PURE__ */ jsx4("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: /* @__PURE__ */ jsx4("p", { className: "text-sm text-text-600", children: "Nenhuma notifica\xE7\xE3o configurada" }) });
1324
+ return /* @__PURE__ */ jsx7("div", { className: "flex flex-col items-center gap-4 p-6 w-full", children: /* @__PURE__ */ jsx7("p", { className: "text-sm text-text-600", children: "Nenhuma notifica\xE7\xE3o configurada" }) });
762
1325
  };
763
1326
  var NotificationCard_default = NotificationCard;
764
1327
  export {
1328
+ LegacyNotificationCard,
765
1329
  NotificationCard_default as default
766
1330
  };
767
1331
  //# sourceMappingURL=index.mjs.map