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/Menu/index.d.mts +0 -1
- package/dist/Menu/index.d.ts +0 -1
- package/dist/Menu/index.js +2 -15
- package/dist/Menu/index.js.map +1 -1
- package/dist/Menu/index.mjs +2 -15
- package/dist/Menu/index.mjs.map +1 -1
- package/dist/NotificationCard/index.d.mts +1 -1
- package/dist/NotificationCard/index.d.ts +1 -1
- package/dist/{NotificationCard-IYDURfYp.d.mts → NotificationCard-kGUKNOqT.d.mts} +1 -1
- package/dist/{NotificationCard-IYDURfYp.d.ts → NotificationCard-kGUKNOqT.d.ts} +1 -1
- package/dist/index.d.mts +128 -3
- package/dist/index.d.ts +128 -3
- package/dist/index.js +116 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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,
|
|
@@ -6472,18 +6474,6 @@ var MenuContent = (0, import_react21.forwardRef)(
|
|
|
6472
6474
|
({ className, children, variant = "menu", ...props }, ref) => {
|
|
6473
6475
|
const baseClasses = "w-full flex flex-row items-center gap-2";
|
|
6474
6476
|
const variantClasses = variant === "menu2" ? "overflow-x-auto scroll-smooth" : "";
|
|
6475
|
-
const childrenArray = import_react21.Children.toArray(children);
|
|
6476
|
-
const menuItemCount = childrenArray.filter(
|
|
6477
|
-
(child) => (0, import_react21.isValidElement)(child) && child.type === MenuItem
|
|
6478
|
-
).length;
|
|
6479
|
-
const enhancedChildren = variant === "menu2" ? import_react21.Children.map(children, (child) => {
|
|
6480
|
-
if ((0, import_react21.isValidElement)(child) && child.type === MenuItem) {
|
|
6481
|
-
return (0, import_react21.cloneElement)(child, {
|
|
6482
|
-
itemCount: menuItemCount
|
|
6483
|
-
});
|
|
6484
|
-
}
|
|
6485
|
-
return child;
|
|
6486
|
-
}) : children;
|
|
6487
6477
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
6488
6478
|
"ul",
|
|
6489
6479
|
{
|
|
@@ -6496,7 +6486,7 @@ var MenuContent = (0, import_react21.forwardRef)(
|
|
|
6496
6486
|
`,
|
|
6497
6487
|
style: variant === "menu2" ? { scrollbarWidth: "none", msOverflowStyle: "none" } : void 0,
|
|
6498
6488
|
...props,
|
|
6499
|
-
children
|
|
6489
|
+
children
|
|
6500
6490
|
}
|
|
6501
6491
|
);
|
|
6502
6492
|
}
|
|
@@ -6511,7 +6501,6 @@ var MenuItem = (0, import_react21.forwardRef)(
|
|
|
6511
6501
|
store: externalStore,
|
|
6512
6502
|
variant = "menu",
|
|
6513
6503
|
separator = false,
|
|
6514
|
-
itemCount = 1,
|
|
6515
6504
|
...props
|
|
6516
6505
|
}, ref) => {
|
|
6517
6506
|
const store = useMenuStore(externalStore);
|
|
@@ -6557,7 +6546,7 @@ var MenuItem = (0, import_react21.forwardRef)(
|
|
|
6557
6546
|
{
|
|
6558
6547
|
"data-variant": "menu2",
|
|
6559
6548
|
className: `
|
|
6560
|
-
|
|
6549
|
+
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
|
|
6561
6550
|
focus:outline-none focus:border-indicator-info focus:border-2
|
|
6562
6551
|
${selectedValue === value ? "" : "pb-4"}
|
|
6563
6552
|
`,
|
|
@@ -10888,6 +10877,116 @@ var NotificationCard_default = NotificationCard;
|
|
|
10888
10877
|
var createUseNotificationStore = (apiClient) => {
|
|
10889
10878
|
return createNotificationStore(apiClient);
|
|
10890
10879
|
};
|
|
10880
|
+
|
|
10881
|
+
// src/hooks/useNotifications.ts
|
|
10882
|
+
var import_react31 = require("react");
|
|
10883
|
+
var createUseNotifications = (apiClient) => {
|
|
10884
|
+
const useNotificationStore = createUseNotificationStore(apiClient);
|
|
10885
|
+
return () => {
|
|
10886
|
+
const {
|
|
10887
|
+
notifications,
|
|
10888
|
+
unreadCount,
|
|
10889
|
+
loading,
|
|
10890
|
+
error,
|
|
10891
|
+
hasMore,
|
|
10892
|
+
currentPage,
|
|
10893
|
+
fetchNotifications,
|
|
10894
|
+
markAsRead,
|
|
10895
|
+
markAllAsRead,
|
|
10896
|
+
deleteNotification,
|
|
10897
|
+
clearNotifications,
|
|
10898
|
+
resetError,
|
|
10899
|
+
getGroupedNotifications
|
|
10900
|
+
} = useNotificationStore();
|
|
10901
|
+
const handleNavigate = (0, import_react31.useCallback)(
|
|
10902
|
+
(entityType, entityId) => {
|
|
10903
|
+
if (entityType && entityId) {
|
|
10904
|
+
switch (entityType.toUpperCase()) {
|
|
10905
|
+
case "ACTIVITY" /* ACTIVITY */:
|
|
10906
|
+
window.location.href = `/atividades/${entityId}`;
|
|
10907
|
+
break;
|
|
10908
|
+
case "GOAL" /* GOAL */:
|
|
10909
|
+
window.location.href = `/painel/trilhas/${entityId}`;
|
|
10910
|
+
break;
|
|
10911
|
+
default:
|
|
10912
|
+
break;
|
|
10913
|
+
}
|
|
10914
|
+
}
|
|
10915
|
+
},
|
|
10916
|
+
[]
|
|
10917
|
+
);
|
|
10918
|
+
const getActionLabel = (0, import_react31.useCallback)(
|
|
10919
|
+
(entityType) => {
|
|
10920
|
+
if (!entityType) return void 0;
|
|
10921
|
+
switch (entityType.toUpperCase()) {
|
|
10922
|
+
case "ACTIVITY" /* ACTIVITY */:
|
|
10923
|
+
return "Ver atividade";
|
|
10924
|
+
case "GOAL" /* GOAL */:
|
|
10925
|
+
return "Ver meta";
|
|
10926
|
+
default:
|
|
10927
|
+
return void 0;
|
|
10928
|
+
}
|
|
10929
|
+
},
|
|
10930
|
+
[]
|
|
10931
|
+
);
|
|
10932
|
+
const markAsReadAndNavigate = (0, import_react31.useCallback)(
|
|
10933
|
+
async (id, entityType, entityId) => {
|
|
10934
|
+
await markAsRead(id);
|
|
10935
|
+
if (entityType && entityId) {
|
|
10936
|
+
handleNavigate(entityType, entityId);
|
|
10937
|
+
}
|
|
10938
|
+
},
|
|
10939
|
+
[markAsRead, handleNavigate]
|
|
10940
|
+
);
|
|
10941
|
+
const refreshNotifications = (0, import_react31.useCallback)(async () => {
|
|
10942
|
+
resetError();
|
|
10943
|
+
await fetchNotifications();
|
|
10944
|
+
}, [resetError, fetchNotifications]);
|
|
10945
|
+
const formatNotification = (0, import_react31.useCallback)(
|
|
10946
|
+
(notification) => ({
|
|
10947
|
+
...notification,
|
|
10948
|
+
time: formatTimeAgo(notification.createdAt),
|
|
10949
|
+
entityType: notification.entityType || void 0,
|
|
10950
|
+
entityId: notification.entityId || void 0
|
|
10951
|
+
}),
|
|
10952
|
+
[]
|
|
10953
|
+
);
|
|
10954
|
+
const getFormattedGroupedNotifications = (0, import_react31.useCallback)(() => {
|
|
10955
|
+
const groups = getGroupedNotifications();
|
|
10956
|
+
return groups.map((group) => ({
|
|
10957
|
+
...group,
|
|
10958
|
+
notifications: group.notifications.map(formatNotification)
|
|
10959
|
+
}));
|
|
10960
|
+
}, [getGroupedNotifications, formatNotification]);
|
|
10961
|
+
return {
|
|
10962
|
+
// State
|
|
10963
|
+
notifications,
|
|
10964
|
+
unreadCount,
|
|
10965
|
+
loading,
|
|
10966
|
+
error,
|
|
10967
|
+
hasMore,
|
|
10968
|
+
currentPage,
|
|
10969
|
+
// Actions
|
|
10970
|
+
fetchNotifications,
|
|
10971
|
+
markAsRead,
|
|
10972
|
+
markAllAsRead,
|
|
10973
|
+
deleteNotification,
|
|
10974
|
+
clearNotifications,
|
|
10975
|
+
resetError,
|
|
10976
|
+
markAsReadAndNavigate,
|
|
10977
|
+
refreshNotifications,
|
|
10978
|
+
// Navigation
|
|
10979
|
+
handleNavigate,
|
|
10980
|
+
// Helpers
|
|
10981
|
+
getActionLabel,
|
|
10982
|
+
getGroupedNotifications,
|
|
10983
|
+
getFormattedGroupedNotifications
|
|
10984
|
+
};
|
|
10985
|
+
};
|
|
10986
|
+
};
|
|
10987
|
+
var createNotificationsHook = (apiClient) => {
|
|
10988
|
+
return createUseNotifications(apiClient);
|
|
10989
|
+
};
|
|
10891
10990
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10892
10991
|
0 && (module.exports = {
|
|
10893
10992
|
ANSWER_STATUS,
|
|
@@ -10993,7 +11092,9 @@ var createUseNotificationStore = (apiClient) => {
|
|
|
10993
11092
|
VideoPlayer,
|
|
10994
11093
|
Whiteboard,
|
|
10995
11094
|
createNotificationStore,
|
|
11095
|
+
createNotificationsHook,
|
|
10996
11096
|
createUseNotificationStore,
|
|
11097
|
+
createUseNotifications,
|
|
10997
11098
|
createZustandAuthAdapter,
|
|
10998
11099
|
formatTimeAgo,
|
|
10999
11100
|
getDeviceType,
|