sea-react-components 1.3.9 → 1.3.10
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/README.md +1 -1
- package/dist/components/firebase-token-handler/index.d.ts +10 -0
- package/dist/components/firebase-token-handler/index.d.ts.map +1 -0
- package/dist/components/firebase-token-handler/index.js +30 -0
- package/dist/components/notifications-menu/index.d.ts.map +1 -1
- package/dist/components/notifications-menu/index.js +26 -3
- package/dist/components/select/index.d.ts.map +1 -1
- package/dist/components/select/index.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/middleware/firebase-token-handler/index.d.ts +2 -1
- package/dist/middleware/firebase-token-handler/index.d.ts.map +1 -1
- package/dist/middleware/firebase-token-handler/index.js +10 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/notification-localstorage/index.d.ts +5 -0
- package/dist/utils/notification-localstorage/index.d.ts.map +1 -0
- package/dist/utils/notification-localstorage/index.js +24 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# sea-react-components
|
|
1
|
+
# sea-react-components
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CONSTANTS } from "sea-platform-helpers";
|
|
2
|
+
import { FirebaseConfig, NotificationPayload } from "../../utils/firebase-client";
|
|
3
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, _onForegroundMessage, _onGetToken, }: Readonly<{
|
|
4
|
+
config: FirebaseConfig;
|
|
5
|
+
updateFirebaseTokenUrl: string;
|
|
6
|
+
applicationKey: CONSTANTS.Application.ApplicationKeys;
|
|
7
|
+
_onForegroundMessage?: (notification: NotificationPayload) => void;
|
|
8
|
+
_onGetToken?: (token: string) => void;
|
|
9
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/firebase-token-handler/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAS,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAIL,cAAc,EACd,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AASrC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,WAAW,GACZ,EAAE,QAAQ,CAAC;IACV,MAAM,EAAE,cAAc,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC;IACtD,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC,2CAwBD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
import { CONSTANTS } from "sea-platform-helpers";
|
|
6
|
+
import { getCookie } from "../../utils/cookie";
|
|
7
|
+
import { initFirebase, requestForToken, onForegroundMessage, } from "../../utils/firebase-client";
|
|
8
|
+
import * as NotificationLocalStorageUtils from "../../utils/notification-localstorage";
|
|
9
|
+
const axiosOptions = {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${getCookie(CONSTANTS.JWT.JWTCookieKey)}`,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, applicationKey, _onForegroundMessage, _onGetToken, }) {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
initFirebase(config);
|
|
17
|
+
requestForToken(config.vapidKey).then((token) => {
|
|
18
|
+
if (token) {
|
|
19
|
+
axios.put(updateFirebaseTokenUrl, { token, applicationKey }, axiosOptions);
|
|
20
|
+
_onGetToken && _onGetToken(token);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
onForegroundMessage((notification) => {
|
|
24
|
+
console.log("Foreground notification:", notification);
|
|
25
|
+
NotificationLocalStorageUtils.pushNewNotificationId(notification.id);
|
|
26
|
+
_onForegroundMessage && _onForegroundMessage(notification);
|
|
27
|
+
});
|
|
28
|
+
}, [config]);
|
|
29
|
+
return _jsx(_Fragment, {});
|
|
30
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications-menu/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/notifications-menu/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;AAoB7D,MAAM,MAAM,KAAK,GAAG;IAClB,cAAc,EACV,SAAS,CAAC,WAAW,CAAC,eAAe,GACrC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,OAAO,CAC3B,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,CACtD,CAAC;IACF,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AACF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,cAAc,EACd,mBAAmB,EACnB,KAAyC,EACzC,oBAAoB,EACpB,QAAQ,GACT,EAAE,KAAK,2CA8UP"}
|
|
@@ -9,15 +9,14 @@ import NativeMenuItem from "../native-menu/native-menu-item";
|
|
|
9
9
|
import { getCookie } from "../../utils/cookie";
|
|
10
10
|
import axios from "axios";
|
|
11
11
|
import Skeleton from "../skeleton";
|
|
12
|
+
import * as NotificationLocalStorageUtils from "../../utils/notification-localstorage";
|
|
12
13
|
const DEFAULT_FETCH_NOTIFICATIONS_LIMIT = 50;
|
|
13
14
|
const axiosOptions = {
|
|
14
15
|
headers: {
|
|
15
16
|
Authorization: `Bearer ${getCookie(CONSTANTS.JWT.JWTCookieKey)}`,
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
|
-
export default function NotificationMenu({ applicationKey, notificationBaseUrl,
|
|
19
|
-
// fetchNotifications,
|
|
20
|
-
limit = DEFAULT_FETCH_NOTIFICATIONS_LIMIT, applicationsBaseUrls, navigate, }) {
|
|
19
|
+
export default function NotificationMenu({ applicationKey, notificationBaseUrl, limit = DEFAULT_FETCH_NOTIFICATIONS_LIMIT, applicationsBaseUrls, navigate, }) {
|
|
21
20
|
const [loading, setLoading] = useState(false);
|
|
22
21
|
const [page, setPage] = useState(1);
|
|
23
22
|
const [totalCount, setTotalCount] = useState(0);
|
|
@@ -43,6 +42,30 @@ limit = DEFAULT_FETCH_NOTIFICATIONS_LIMIT, applicationsBaseUrls, navigate, }) {
|
|
|
43
42
|
setLoading(false);
|
|
44
43
|
});
|
|
45
44
|
}, [applicationKey, notificationBaseUrl, limit, page]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const handler = () => {
|
|
47
|
+
const notificationIds = NotificationLocalStorageUtils.getNewNotificationIds();
|
|
48
|
+
notificationIds.forEach((id) => {
|
|
49
|
+
handleNewNotificationCome(id);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
handler();
|
|
53
|
+
window.addEventListener(NotificationLocalStorageUtils.NEW_NOTIFICATION_EVENT_NAME, handler);
|
|
54
|
+
return () => window.removeEventListener(NotificationLocalStorageUtils.NEW_NOTIFICATION_EVENT_NAME, handler);
|
|
55
|
+
}, []);
|
|
56
|
+
const handleNewNotificationCome = (notificationId) => {
|
|
57
|
+
const exist = notifications.find((n) => n.id === notificationId);
|
|
58
|
+
if (!exist) {
|
|
59
|
+
axios
|
|
60
|
+
.get(`${notificationBaseUrl}/${notificationId}`, axiosOptions)
|
|
61
|
+
.then((response) => {
|
|
62
|
+
setUnreadCount((prev) => prev + 1);
|
|
63
|
+
setTotalCount((prev) => prev + 1);
|
|
64
|
+
setNotifications((prev) => [response.data, ...prev]);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
NotificationLocalStorageUtils.removeNotificationId(notificationId);
|
|
68
|
+
};
|
|
46
69
|
const markAsRead = (notification) => {
|
|
47
70
|
axios
|
|
48
71
|
.put(`${notificationBaseUrl}/${notification.id}/read`, {}, axiosOptions)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/select/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,EAChC,IAAI,EACJ,OAAO,EACP,MAAM,EACN,SAAS,EACT,YAAY,EACZ,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/select/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,EAChC,IAAI,EACJ,OAAO,EACP,MAAM,EACN,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAyB,EACzB,WAAmB,EACnB,QAAgB,EAAE,kBAAkB;AACpC,KAAK,GACN,EAAE,KAAK,CAAC,CAAC,CAAC,2CAkIV"}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState, useRef, useEffect } from "react";
|
|
4
4
|
import { Icon } from "@iconify/react";
|
|
5
5
|
import clsx from "clsx";
|
|
6
|
-
export default function Select({ name, options, values, setValues, errorMessage, buttonClassName, placeholder = "", multiselect = false, disabled = false, // ✅ default false
|
|
6
|
+
export default function Select({ name, options, values, setValues, errorMessage, buttonClassName, placeholder = "Select...", multiselect = false, disabled = false, // ✅ default false
|
|
7
7
|
label, }) {
|
|
8
8
|
const [isOpen, setIsOpen] = useState(false);
|
|
9
9
|
const containerRef = useRef(null);
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * as ColorUtils from "./utils/color";
|
|
|
5
5
|
export * as AxiosUtils from "./utils/axios";
|
|
6
6
|
export * as FileUtils from "./utils/file";
|
|
7
7
|
export * as CookieUtils from "./utils/cookie";
|
|
8
|
+
export * as FirebaseUtils from "./utils/firebase-client";
|
|
8
9
|
export { default as MustAuth } from "./middleware/must-auth";
|
|
9
10
|
export { useHasApplicationAccess } from "./hooks/user-has-application-access";
|
|
10
11
|
export { useHasOneOfPermissions, useHasPermission, } from "./hooks/use-has-permission-access";
|
|
@@ -58,4 +59,5 @@ export { default as NotificationsMenu, Props as NotificationsMenuProps, } from "
|
|
|
58
59
|
export { default as ActivityMessage } from "./components/activity-message";
|
|
59
60
|
export { default as WithAuthorization, Props as WithAuthorizationProps, } from "./HOC/with-authorization";
|
|
60
61
|
export { default as CanAccessApplication, Props as CanAccessApplicationProps, } from "./HOC/can-access-application";
|
|
62
|
+
export { default as FirebaseTokenHandler } from "./components/firebase-token-handler";
|
|
61
63
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAGzC,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,eAAe,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BAAiB,GAC3B,MAAM,6BAA6B,CAAC;AAErC,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EACL,OAAO,IAAI,iBAAiB,EAC5B,KAAK,IAAI,sBAAsB,GAChC,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EACL,OAAO,IAAI,iBAAiB,EAC5B,KAAK,IAAI,sBAAsB,GAChC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,OAAO,IAAI,oBAAoB,EAC/B,KAAK,IAAI,yBAAyB,GACnC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,qCAAqC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * as ColorUtils from "./utils/color";
|
|
|
7
7
|
export * as AxiosUtils from "./utils/axios";
|
|
8
8
|
export * as FileUtils from "./utils/file";
|
|
9
9
|
export * as CookieUtils from "./utils/cookie";
|
|
10
|
+
export * as FirebaseUtils from "./utils/firebase-client";
|
|
10
11
|
// middleware
|
|
11
12
|
export { default as MustAuth } from "./middleware/must-auth";
|
|
12
13
|
// hooks
|
|
@@ -63,3 +64,4 @@ export { default as NotificationsMenu, } from "./components/notifications-menu";
|
|
|
63
64
|
export { default as ActivityMessage } from "./components/activity-message";
|
|
64
65
|
export { default as WithAuthorization, } from "./HOC/with-authorization";
|
|
65
66
|
export { default as CanAccessApplication, } from "./HOC/can-access-application";
|
|
67
|
+
export { default as FirebaseTokenHandler } from "./components/firebase-token-handler";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FirebaseConfig, NotificationPayload } from "../../utils/firebase-client";
|
|
2
|
-
export default function FirebaseTokenHandler({ config, _onForegroundMessage, _onGetToken, }: Readonly<{
|
|
2
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, _onForegroundMessage, _onGetToken, }: Readonly<{
|
|
3
3
|
config: FirebaseConfig;
|
|
4
|
+
updateFirebaseTokenUrl: any;
|
|
4
5
|
_onForegroundMessage?: (notification: NotificationPayload) => void;
|
|
5
6
|
_onGetToken?: (token: string) => void;
|
|
6
7
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/firebase-token-handler/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAIL,cAAc,EACd,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/firebase-token-handler/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAIL,cAAc,EACd,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AAQrC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,GACZ,EAAE,QAAQ,CAAC;IACV,MAAM,EAAE,cAAc,CAAC;IACvB,sBAAsB,MAAC;IACvB,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC,2CAiBD"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
import { CONSTANTS } from "sea-platform-helpers";
|
|
6
|
+
import { getCookie } from "../../utils/cookie";
|
|
4
7
|
import { initFirebase, requestForToken, onForegroundMessage, } from "../../utils/firebase-client";
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
const axiosOptions = {
|
|
9
|
+
headers: {
|
|
10
|
+
Authorization: `Bearer ${getCookie(CONSTANTS.JWT.JWTCookieKey)}`,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, _onForegroundMessage, _onGetToken, }) {
|
|
7
14
|
useEffect(() => {
|
|
8
|
-
console.log("Init ...");
|
|
9
15
|
initFirebase(config);
|
|
10
16
|
requestForToken(config.vapidKey).then((token) => {
|
|
11
17
|
if (token) {
|
|
12
|
-
|
|
18
|
+
axios.put(updateFirebaseTokenUrl, { token }, axiosOptions);
|
|
13
19
|
_onGetToken && _onGetToken(token);
|
|
14
20
|
}
|
|
15
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/hoc/can-access-application/index.tsx","../src/hoc/with-authorization/index.tsx","../src/components/accordion/index.tsx","../src/components/activity-message/index.tsx","../src/components/alert/index.tsx","../src/components/auto-complete-input/index.tsx","../src/components/avatar/index.tsx","../src/components/badge/index.tsx","../src/components/breadcrumb/index.tsx","../src/components/button/index.tsx","../src/components/calendar/index.tsx","../src/components/cards-list/index.tsx","../src/components/carousel/index.tsx","../src/components/checkbox/index.tsx","../src/components/color-picker/index.tsx","../src/components/count-down/index.tsx","../src/components/day-calendar/index.tsx","../src/components/drawer/index.tsx","../src/components/editable-text/index.tsx","../src/components/expandable-text/index.tsx","../src/components/file-input/index.tsx","../src/components/file-input/components/file-item/index.tsx","../src/components/icon/index.tsx","../src/components/input/index.tsx","../src/components/item-not-found/index.tsx","../src/components/list-item/index.tsx","../src/components/list-item/components/page-button/index.tsx","../src/components/list-item/components/pagination/index.tsx","../src/components/loader/index.tsx","../src/components/menu/index.tsx","../src/components/menu/menu-item/index.tsx","../src/components/modal/index.tsx","../src/components/month-calendar/index.tsx","../src/components/native-menu/index.tsx","../src/components/native-menu/native-menu-item/index.tsx","../src/components/not-authorized/index.tsx","../src/components/notifications-menu/index.tsx","../src/components/otp-input/index.tsx","../src/components/paper/index.tsx","../src/components/progress-bar/index.tsx","../src/components/radio-button/index.tsx","../src/components/search-input/index.tsx","../src/components/select/index.tsx","../src/components/skeleton/index.tsx","../src/components/stacked-avatars/index.tsx","../src/components/tab/index.tsx","../src/components/table/index.tsx","../src/components/text-editor/index.tsx","../src/components/text-editor/components/toolbar/index.tsx","../src/components/text-editor/utils/index.ts","../src/components/textarea/index.tsx","../src/components/toggle/index.tsx","../src/components/tooltip/index.tsx","../src/components/tree-checkbox/index.tsx","../src/components/tree-checkbox/components/tree-checkbox-item/index.tsx","../src/components/tree-checkbox/utils/index.ts","../src/components/week-calendar/index.tsx","../src/constants/index.ts","../src/hooks/list-items-hook/types.ts","../src/hooks/list-items-hook/usebulkactions.ts","../src/hooks/list-items-hook/usefilters.ts","../src/hooks/list-items-hook/usepagination.ts","../src/hooks/use-has-permission-access/index.ts","../src/hooks/user-has-application-access/index.ts","../src/middleware/must-auth/index.tsx","../src/utils/axios/index.ts","../src/utils/color/index.ts","../src/utils/cookie/index.ts","../src/utils/file/index.ts","../src/utils/jwt/index.ts","../src/utils/validation/index.ts"],"version":"5.6.3"}
|
|
1
|
+
{"root":["../src/index.ts","../src/hoc/can-access-application/index.tsx","../src/hoc/with-authorization/index.tsx","../src/components/accordion/index.tsx","../src/components/activity-message/index.tsx","../src/components/alert/index.tsx","../src/components/auto-complete-input/index.tsx","../src/components/avatar/index.tsx","../src/components/badge/index.tsx","../src/components/breadcrumb/index.tsx","../src/components/button/index.tsx","../src/components/calendar/index.tsx","../src/components/cards-list/index.tsx","../src/components/carousel/index.tsx","../src/components/checkbox/index.tsx","../src/components/color-picker/index.tsx","../src/components/count-down/index.tsx","../src/components/day-calendar/index.tsx","../src/components/drawer/index.tsx","../src/components/editable-text/index.tsx","../src/components/expandable-text/index.tsx","../src/components/file-input/index.tsx","../src/components/file-input/components/file-item/index.tsx","../src/components/firebase-token-handler/index.tsx","../src/components/icon/index.tsx","../src/components/input/index.tsx","../src/components/item-not-found/index.tsx","../src/components/list-item/index.tsx","../src/components/list-item/components/page-button/index.tsx","../src/components/list-item/components/pagination/index.tsx","../src/components/loader/index.tsx","../src/components/menu/index.tsx","../src/components/menu/menu-item/index.tsx","../src/components/modal/index.tsx","../src/components/month-calendar/index.tsx","../src/components/native-menu/index.tsx","../src/components/native-menu/native-menu-item/index.tsx","../src/components/not-authorized/index.tsx","../src/components/notifications-menu/index.tsx","../src/components/otp-input/index.tsx","../src/components/paper/index.tsx","../src/components/progress-bar/index.tsx","../src/components/radio-button/index.tsx","../src/components/search-input/index.tsx","../src/components/select/index.tsx","../src/components/skeleton/index.tsx","../src/components/stacked-avatars/index.tsx","../src/components/tab/index.tsx","../src/components/table/index.tsx","../src/components/text-editor/index.tsx","../src/components/text-editor/components/toolbar/index.tsx","../src/components/text-editor/utils/index.ts","../src/components/textarea/index.tsx","../src/components/toggle/index.tsx","../src/components/tooltip/index.tsx","../src/components/tree-checkbox/index.tsx","../src/components/tree-checkbox/components/tree-checkbox-item/index.tsx","../src/components/tree-checkbox/utils/index.ts","../src/components/week-calendar/index.tsx","../src/constants/index.ts","../src/hooks/list-items-hook/types.ts","../src/hooks/list-items-hook/usebulkactions.ts","../src/hooks/list-items-hook/usefilters.ts","../src/hooks/list-items-hook/usepagination.ts","../src/hooks/use-has-permission-access/index.ts","../src/hooks/user-has-application-access/index.ts","../src/middleware/must-auth/index.tsx","../src/utils/axios/index.ts","../src/utils/color/index.ts","../src/utils/cookie/index.ts","../src/utils/file/index.ts","../src/utils/firebase-client/firebase.ts","../src/utils/firebase-client/index.ts","../src/utils/firebase-client/types.ts","../src/utils/jwt/index.ts","../src/utils/notification-localstorage/index.ts","../src/utils/validation/index.ts"],"version":"5.6.3"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const NEW_NOTIFICATION_EVENT_NAME = "new-notification";
|
|
2
|
+
export declare const getNewNotificationIds: () => string[];
|
|
3
|
+
export declare const pushNewNotificationId: (notificationId: string) => void;
|
|
4
|
+
export declare const removeNotificationId: (notificationId: string) => void;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/notification-localstorage/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAE9D,eAAO,MAAM,qBAAqB,QAAO,MAAM,EAG9C,CAAC;AAEF,eAAO,MAAM,qBAAqB,mBAAoB,MAAM,SAkB3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,mBAAoB,MAAM,SAY1D,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Utils } from "sea-platform-helpers";
|
|
2
|
+
const NEW_NOTIFICATION_IDS_KEY = "new-notification-ids";
|
|
3
|
+
export const NEW_NOTIFICATION_EVENT_NAME = "new-notification";
|
|
4
|
+
export const getNewNotificationIds = () => {
|
|
5
|
+
const data = window.localStorage.getItem(NEW_NOTIFICATION_IDS_KEY);
|
|
6
|
+
return data ? JSON.parse(data) : [];
|
|
7
|
+
};
|
|
8
|
+
export const pushNewNotificationId = (notificationId) => {
|
|
9
|
+
console.log("pushNewNotificationId: ", notificationId);
|
|
10
|
+
if (!window.localStorage)
|
|
11
|
+
return;
|
|
12
|
+
let newNotificationIds = getNewNotificationIds();
|
|
13
|
+
newNotificationIds = Utils.Array.concatWithoutDuplicates(newNotificationIds, [notificationId], (a, b) => a === b);
|
|
14
|
+
window.localStorage.setItem(NEW_NOTIFICATION_IDS_KEY, JSON.stringify(newNotificationIds));
|
|
15
|
+
window.dispatchEvent(new Event(NEW_NOTIFICATION_EVENT_NAME));
|
|
16
|
+
};
|
|
17
|
+
export const removeNotificationId = (notificationId) => {
|
|
18
|
+
console.log("removeNotificationId: ", notificationId);
|
|
19
|
+
if (!window.localStorage)
|
|
20
|
+
return;
|
|
21
|
+
let newNotificationIds = getNewNotificationIds();
|
|
22
|
+
newNotificationIds = newNotificationIds.filter((id) => id !== notificationId);
|
|
23
|
+
window.localStorage.setItem(NEW_NOTIFICATION_IDS_KEY, JSON.stringify(newNotificationIds));
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-react-components",
|
|
3
3
|
"description": "SEA react components library",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.10",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc --build && npx postcss src/styles.css -o dist/styles.css && npx postcss src/components/text-editor/style.css -o dist/components/text-editor/style.css",
|
|
@@ -42,10 +42,11 @@
|
|
|
42
42
|
"@tiptap/starter-kit": "^2.11.2",
|
|
43
43
|
"axios": "^1.7.9",
|
|
44
44
|
"clsx": "^2.1.1",
|
|
45
|
+
"firebase": "^12.3.0",
|
|
45
46
|
"jwt-decode": "^4.0.0",
|
|
46
47
|
"lowlight": "^3.3.0",
|
|
47
48
|
"react-dom": "^18.3.1",
|
|
48
|
-
"sea-platform-helpers": "^1.5.
|
|
49
|
+
"sea-platform-helpers": "^1.5.9",
|
|
49
50
|
"sea-react-components": "file:",
|
|
50
51
|
"yup": "^1.5.0"
|
|
51
52
|
},
|