analytica-frontend-lib 1.1.44 → 1.1.46

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/index.mjs CHANGED
@@ -6408,18 +6408,6 @@ var MenuContent = forwardRef17(
6408
6408
  ({ className, children, variant = "menu", ...props }, ref) => {
6409
6409
  const baseClasses = "w-full flex flex-row items-center gap-2";
6410
6410
  const variantClasses = variant === "menu2" ? "overflow-x-auto scroll-smooth" : "";
6411
- const childrenArray = Children5.toArray(children);
6412
- const menuItemCount = childrenArray.filter(
6413
- (child) => isValidElement5(child) && child.type === MenuItem
6414
- ).length;
6415
- const enhancedChildren = variant === "menu2" ? Children5.map(children, (child) => {
6416
- if (isValidElement5(child) && child.type === MenuItem) {
6417
- return cloneElement5(child, {
6418
- itemCount: menuItemCount
6419
- });
6420
- }
6421
- return child;
6422
- }) : children;
6423
6411
  return /* @__PURE__ */ jsx33(
6424
6412
  "ul",
6425
6413
  {
@@ -6432,7 +6420,7 @@ var MenuContent = forwardRef17(
6432
6420
  `,
6433
6421
  style: variant === "menu2" ? { scrollbarWidth: "none", msOverflowStyle: "none" } : void 0,
6434
6422
  ...props,
6435
- children: enhancedChildren
6423
+ children
6436
6424
  }
6437
6425
  );
6438
6426
  }
@@ -6447,7 +6435,6 @@ var MenuItem = forwardRef17(
6447
6435
  store: externalStore,
6448
6436
  variant = "menu",
6449
6437
  separator = false,
6450
- itemCount = 1,
6451
6438
  ...props
6452
6439
  }, ref) => {
6453
6440
  const store = useMenuStore(externalStore);
@@ -6493,7 +6480,7 @@ var MenuItem = forwardRef17(
6493
6480
  {
6494
6481
  "data-variant": "menu2",
6495
6482
  className: `
6496
- ${itemCount === 1 ? "w-fit" : "w-full"} flex flex-col items-center px-2 pt-4 gap-3 cursor-pointer focus:rounded-sm justify-center hover:bg-background-100 rounded-lg
6483
+ w-full flex flex-col items-center px-2 pt-4 gap-3 cursor-pointer focus:rounded-sm justify-center hover:bg-background-100 rounded-lg
6497
6484
  focus:outline-none focus:border-indicator-info focus:border-2
6498
6485
  ${selectedValue === value ? "" : "pb-4"}
6499
6486
  `,
@@ -10861,6 +10848,116 @@ var NotificationCard_default = NotificationCard;
10861
10848
  var createUseNotificationStore = (apiClient) => {
10862
10849
  return createNotificationStore(apiClient);
10863
10850
  };
10851
+
10852
+ // src/hooks/useNotifications.ts
10853
+ import { useCallback as useCallback5 } from "react";
10854
+ var createUseNotifications = (apiClient) => {
10855
+ const useNotificationStore = createUseNotificationStore(apiClient);
10856
+ return () => {
10857
+ const {
10858
+ notifications,
10859
+ unreadCount,
10860
+ loading,
10861
+ error,
10862
+ hasMore,
10863
+ currentPage,
10864
+ fetchNotifications,
10865
+ markAsRead,
10866
+ markAllAsRead,
10867
+ deleteNotification,
10868
+ clearNotifications,
10869
+ resetError,
10870
+ getGroupedNotifications
10871
+ } = useNotificationStore();
10872
+ const handleNavigate = useCallback5(
10873
+ (entityType, entityId) => {
10874
+ if (entityType && entityId) {
10875
+ switch (entityType.toUpperCase()) {
10876
+ case "ACTIVITY" /* ACTIVITY */:
10877
+ window.location.href = `/atividades/${entityId}`;
10878
+ break;
10879
+ case "GOAL" /* GOAL */:
10880
+ window.location.href = `/painel/trilhas/${entityId}`;
10881
+ break;
10882
+ default:
10883
+ break;
10884
+ }
10885
+ }
10886
+ },
10887
+ []
10888
+ );
10889
+ const getActionLabel = useCallback5(
10890
+ (entityType) => {
10891
+ if (!entityType) return void 0;
10892
+ switch (entityType.toUpperCase()) {
10893
+ case "ACTIVITY" /* ACTIVITY */:
10894
+ return "Ver atividade";
10895
+ case "GOAL" /* GOAL */:
10896
+ return "Ver meta";
10897
+ default:
10898
+ return void 0;
10899
+ }
10900
+ },
10901
+ []
10902
+ );
10903
+ const markAsReadAndNavigate = useCallback5(
10904
+ async (id, entityType, entityId) => {
10905
+ await markAsRead(id);
10906
+ if (entityType && entityId) {
10907
+ handleNavigate(entityType, entityId);
10908
+ }
10909
+ },
10910
+ [markAsRead, handleNavigate]
10911
+ );
10912
+ const refreshNotifications = useCallback5(async () => {
10913
+ resetError();
10914
+ await fetchNotifications();
10915
+ }, [resetError, fetchNotifications]);
10916
+ const formatNotification = useCallback5(
10917
+ (notification) => ({
10918
+ ...notification,
10919
+ time: formatTimeAgo(notification.createdAt),
10920
+ entityType: notification.entityType || void 0,
10921
+ entityId: notification.entityId || void 0
10922
+ }),
10923
+ []
10924
+ );
10925
+ const getFormattedGroupedNotifications = useCallback5(() => {
10926
+ const groups = getGroupedNotifications();
10927
+ return groups.map((group) => ({
10928
+ ...group,
10929
+ notifications: group.notifications.map(formatNotification)
10930
+ }));
10931
+ }, [getGroupedNotifications, formatNotification]);
10932
+ return {
10933
+ // State
10934
+ notifications,
10935
+ unreadCount,
10936
+ loading,
10937
+ error,
10938
+ hasMore,
10939
+ currentPage,
10940
+ // Actions
10941
+ fetchNotifications,
10942
+ markAsRead,
10943
+ markAllAsRead,
10944
+ deleteNotification,
10945
+ clearNotifications,
10946
+ resetError,
10947
+ markAsReadAndNavigate,
10948
+ refreshNotifications,
10949
+ // Navigation
10950
+ handleNavigate,
10951
+ // Helpers
10952
+ getActionLabel,
10953
+ getGroupedNotifications,
10954
+ getFormattedGroupedNotifications
10955
+ };
10956
+ };
10957
+ };
10958
+ var createNotificationsHook = (apiClient) => {
10959
+ return createUseNotifications(apiClient);
10960
+ };
10864
10961
  export {
10865
10962
  ANSWER_STATUS,
10866
10963
  Alert_default as Alert,
@@ -10965,7 +11062,9 @@ export {
10965
11062
  VideoPlayer_default as VideoPlayer,
10966
11063
  Whiteboard_default as Whiteboard,
10967
11064
  createNotificationStore,
11065
+ createNotificationsHook,
10968
11066
  createUseNotificationStore,
11067
+ createUseNotifications,
10969
11068
  createZustandAuthAdapter,
10970
11069
  formatTimeAgo,
10971
11070
  getDeviceType,