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