analytica-frontend-lib 1.1.45 → 1.1.47

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.js CHANGED
@@ -133,7 +133,9 @@ __export(src_exports, {
133
133
  VideoPlayer: () => VideoPlayer_default,
134
134
  Whiteboard: () => Whiteboard_default,
135
135
  createNotificationStore: () => createNotificationStore,
136
+ createNotificationsHook: () => createNotificationsHook,
136
137
  createUseNotificationStore: () => createUseNotificationStore,
138
+ createUseNotifications: () => createUseNotifications,
137
139
  createZustandAuthAdapter: () => createZustandAuthAdapter,
138
140
  formatTimeAgo: () => formatTimeAgo,
139
141
  getDeviceType: () => getDeviceType,
@@ -6431,6 +6433,7 @@ var useMenuStore = (externalStore) => {
6431
6433
  var VARIANT_CLASSES5 = {
6432
6434
  menu: "bg-background shadow-soft-shadow-1 px-6",
6433
6435
  menu2: "",
6436
+ "menu-overflow": "",
6434
6437
  breadcrumb: "bg-transparent shadow-none !px-0"
6435
6438
  };
6436
6439
  var Menu = (0, import_react21.forwardRef)(
@@ -6450,7 +6453,7 @@ var Menu = (0, import_react21.forwardRef)(
6450
6453
  (0, import_react21.useEffect)(() => {
6451
6454
  setValue(propValue ?? defaultValue);
6452
6455
  }, [defaultValue, propValue, setValue]);
6453
- const baseClasses = "w-full py-2 flex flex-row items-center justify-center";
6456
+ const baseClasses = variant === "menu-overflow" ? "w-fit py-2 flex flex-row items-center justify-center" : "w-full py-2 flex flex-row items-center justify-center";
6454
6457
  const variantClasses = VARIANT_CLASSES5[variant];
6455
6458
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6456
6459
  "div",
@@ -6471,7 +6474,7 @@ Menu.displayName = "Menu";
6471
6474
  var MenuContent = (0, import_react21.forwardRef)(
6472
6475
  ({ className, children, variant = "menu", ...props }, ref) => {
6473
6476
  const baseClasses = "w-full flex flex-row items-center gap-2";
6474
- const variantClasses = variant === "menu2" ? "overflow-x-auto scroll-smooth" : "";
6477
+ const variantClasses = variant === "menu2" || variant === "menu-overflow" ? "overflow-x-auto scroll-smooth" : "";
6475
6478
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6476
6479
  "ul",
6477
6480
  {
@@ -6482,7 +6485,7 @@ var MenuContent = (0, import_react21.forwardRef)(
6482
6485
  ${variant == "breadcrumb" ? "flex-wrap" : ""}
6483
6486
  ${className ?? ""}
6484
6487
  `,
6485
- style: variant === "menu2" ? { scrollbarWidth: "none", msOverflowStyle: "none" } : void 0,
6488
+ style: variant === "menu2" || variant === "menu-overflow" ? { scrollbarWidth: "none", msOverflowStyle: "none" } : void 0,
6486
6489
  ...props,
6487
6490
  children
6488
6491
  }
@@ -6564,6 +6567,31 @@ var MenuItem = (0, import_react21.forwardRef)(
6564
6567
  ]
6565
6568
  }
6566
6569
  ),
6570
+ "menu-overflow": /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6571
+ "li",
6572
+ {
6573
+ "data-variant": "menu-overflow",
6574
+ className: `
6575
+ w-fit flex flex-col items-center px-2 pt-4 gap-3 cursor-pointer focus:rounded-sm justify-center hover:bg-background-100 rounded-lg
6576
+ focus:outline-none focus:border-indicator-info focus:border-2
6577
+ ${selectedValue === value ? "" : "pb-4"}
6578
+ `,
6579
+ ...commonProps,
6580
+ children: [
6581
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6582
+ "span",
6583
+ {
6584
+ className: cn(
6585
+ "flex flex-row items-center gap-2 px-4 text-text-950 text-xs font-bold",
6586
+ className
6587
+ ),
6588
+ children
6589
+ }
6590
+ ),
6591
+ selectedValue === value && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "h-1 w-full bg-primary-950 rounded-lg" })
6592
+ ]
6593
+ }
6594
+ ),
6567
6595
  breadcrumb: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
6568
6596
  "li",
6569
6597
  {
@@ -10875,6 +10903,116 @@ var NotificationCard_default = NotificationCard;
10875
10903
  var createUseNotificationStore = (apiClient) => {
10876
10904
  return createNotificationStore(apiClient);
10877
10905
  };
10906
+
10907
+ // src/hooks/useNotifications.ts
10908
+ var import_react31 = require("react");
10909
+ var createUseNotifications = (apiClient) => {
10910
+ const useNotificationStore = createUseNotificationStore(apiClient);
10911
+ return () => {
10912
+ const {
10913
+ notifications,
10914
+ unreadCount,
10915
+ loading,
10916
+ error,
10917
+ hasMore,
10918
+ currentPage,
10919
+ fetchNotifications,
10920
+ markAsRead,
10921
+ markAllAsRead,
10922
+ deleteNotification,
10923
+ clearNotifications,
10924
+ resetError,
10925
+ getGroupedNotifications
10926
+ } = useNotificationStore();
10927
+ const handleNavigate = (0, import_react31.useCallback)(
10928
+ (entityType, entityId) => {
10929
+ if (entityType && entityId) {
10930
+ switch (entityType.toUpperCase()) {
10931
+ case "ACTIVITY" /* ACTIVITY */:
10932
+ window.location.href = `/atividades/${entityId}`;
10933
+ break;
10934
+ case "GOAL" /* GOAL */:
10935
+ window.location.href = `/painel/trilhas/${entityId}`;
10936
+ break;
10937
+ default:
10938
+ break;
10939
+ }
10940
+ }
10941
+ },
10942
+ []
10943
+ );
10944
+ const getActionLabel = (0, import_react31.useCallback)(
10945
+ (entityType) => {
10946
+ if (!entityType) return void 0;
10947
+ switch (entityType.toUpperCase()) {
10948
+ case "ACTIVITY" /* ACTIVITY */:
10949
+ return "Ver atividade";
10950
+ case "GOAL" /* GOAL */:
10951
+ return "Ver meta";
10952
+ default:
10953
+ return void 0;
10954
+ }
10955
+ },
10956
+ []
10957
+ );
10958
+ const markAsReadAndNavigate = (0, import_react31.useCallback)(
10959
+ async (id, entityType, entityId) => {
10960
+ await markAsRead(id);
10961
+ if (entityType && entityId) {
10962
+ handleNavigate(entityType, entityId);
10963
+ }
10964
+ },
10965
+ [markAsRead, handleNavigate]
10966
+ );
10967
+ const refreshNotifications = (0, import_react31.useCallback)(async () => {
10968
+ resetError();
10969
+ await fetchNotifications();
10970
+ }, [resetError, fetchNotifications]);
10971
+ const formatNotification = (0, import_react31.useCallback)(
10972
+ (notification) => ({
10973
+ ...notification,
10974
+ time: formatTimeAgo(notification.createdAt),
10975
+ entityType: notification.entityType || void 0,
10976
+ entityId: notification.entityId || void 0
10977
+ }),
10978
+ []
10979
+ );
10980
+ const getFormattedGroupedNotifications = (0, import_react31.useCallback)(() => {
10981
+ const groups = getGroupedNotifications();
10982
+ return groups.map((group) => ({
10983
+ ...group,
10984
+ notifications: group.notifications.map(formatNotification)
10985
+ }));
10986
+ }, [getGroupedNotifications, formatNotification]);
10987
+ return {
10988
+ // State
10989
+ notifications,
10990
+ unreadCount,
10991
+ loading,
10992
+ error,
10993
+ hasMore,
10994
+ currentPage,
10995
+ // Actions
10996
+ fetchNotifications,
10997
+ markAsRead,
10998
+ markAllAsRead,
10999
+ deleteNotification,
11000
+ clearNotifications,
11001
+ resetError,
11002
+ markAsReadAndNavigate,
11003
+ refreshNotifications,
11004
+ // Navigation
11005
+ handleNavigate,
11006
+ // Helpers
11007
+ getActionLabel,
11008
+ getGroupedNotifications,
11009
+ getFormattedGroupedNotifications
11010
+ };
11011
+ };
11012
+ };
11013
+ var createNotificationsHook = (apiClient) => {
11014
+ return createUseNotifications(apiClient);
11015
+ };
10878
11016
  // Annotate the CommonJS export names for ESM import in node:
10879
11017
  0 && (module.exports = {
10880
11018
  ANSWER_STATUS,
@@ -10980,7 +11118,9 @@ var createUseNotificationStore = (apiClient) => {
10980
11118
  VideoPlayer,
10981
11119
  Whiteboard,
10982
11120
  createNotificationStore,
11121
+ createNotificationsHook,
10983
11122
  createUseNotificationStore,
11123
+ createUseNotifications,
10984
11124
  createZustandAuthAdapter,
10985
11125
  formatTimeAgo,
10986
11126
  getDeviceType,