sea-react-components 1.3.8 → 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/input/index.d.ts +2 -1
- package/dist/components/input/index.d.ts.map +1 -1
- package/dist/components/input/index.js +3 -3
- 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 +4 -1
- package/dist/components/select/index.d.ts.map +1 -1
- package/dist/components/select/index.js +14 -4
- package/dist/components/textarea/index.d.ts +2 -1
- package/dist/components/textarea/index.d.ts.map +1 -1
- package/dist/components/textarea/index.js +3 -3
- 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 +8 -0
- package/dist/middleware/firebase-token-handler/index.d.ts.map +1 -0
- package/dist/middleware/firebase-token-handler/index.js +28 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/firebase/index.d.ts +1 -0
- package/dist/utils/firebase/index.d.ts.map +1 -0
- package/dist/utils/firebase/index.js +0 -0
- package/dist/utils/firebase-client/config.d.ts +1 -0
- package/dist/utils/firebase-client/config.d.ts.map +1 -0
- package/dist/utils/firebase-client/config.js +0 -0
- package/dist/utils/firebase-client/firebase.d.ts +15 -0
- package/dist/utils/firebase-client/firebase.d.ts.map +1 -0
- package/dist/utils/firebase-client/firebase.js +55 -0
- package/dist/utils/firebase-client/index.d.ts +3 -0
- package/dist/utils/firebase-client/index.d.ts.map +1 -0
- package/dist/utils/firebase-client/index.js +2 -0
- package/dist/utils/firebase-client/types.d.ts +17 -0
- package/dist/utils/firebase-client/types.d.ts.map +1 -0
- package/dist/utils/firebase-client/types.js +1 -0
- 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
|
+
}
|
|
@@ -4,6 +4,7 @@ export type Props = {
|
|
|
4
4
|
errorMessage?: string | boolean;
|
|
5
5
|
start?: React.ReactNode | null;
|
|
6
6
|
end?: React.ReactNode | null;
|
|
7
|
+
label?: string;
|
|
7
8
|
} & React.InputHTMLAttributes<HTMLInputElement>;
|
|
8
|
-
export default function Input({ errorMessage, className, start, end, ref, type, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default function Input({ errorMessage, className, start, end, ref, type, label, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC/B,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC/B,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,YAAY,EACZ,SAAS,EACT,KAAY,EACZ,GAAU,EACV,GAAG,EACH,IAAI,EACJ,KAAK,EACL,GAAG,KAAK,EACT,EAAE,KAAK,2CA+DP"}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Icon } from "@iconify/react";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { useState } from "react";
|
|
6
|
-
export default function Input({ errorMessage, className, start = null, end = null, ref, type, ...props }) {
|
|
6
|
+
export default function Input({ errorMessage, className, start = null, end = null, ref, type, label, ...props }) {
|
|
7
7
|
const [isFocused, setIsFocused] = useState(false);
|
|
8
8
|
const [currentType, setCurrentType] = useState(type);
|
|
9
9
|
if (type === "password") {
|
|
@@ -13,9 +13,9 @@ export default function Input({ errorMessage, className, start = null, end = nul
|
|
|
13
13
|
? "mdi:eye-outline"
|
|
14
14
|
: "mdi:eye-off-outline", className: "w-5 h-5 text-primary" }) }));
|
|
15
15
|
}
|
|
16
|
-
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs("div", { className: clsx("flex items-center justify-between gap-2 bg-white px-3 py-2 rounded-xl border-0.5 hover:border-primary", errorMessage
|
|
16
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [label && (_jsx("label", { htmlFor: props.id, className: "pl-1 text-sm text-foreground", children: label })), _jsxs("div", { className: clsx("flex items-center justify-between gap-2 bg-white px-3 py-2 rounded-xl border-0.5 hover:border-primary", errorMessage
|
|
17
17
|
? "border-error"
|
|
18
18
|
: isFocused
|
|
19
19
|
? "border-primary"
|
|
20
|
-
: "border-gray-200"), children: [start, _jsx("input", { ref: ref, type: currentType, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), className: clsx("outline-none text-text flex-1", className), ...props }), end] }), errorMessage && (_jsx("p", { className: "pl-1 text-sm text-error", children: errorMessage }))] }));
|
|
20
|
+
: "border-gray-200"), children: [start, _jsx("input", { ref: ref, id: props.id, type: currentType, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), "aria-invalid": !!errorMessage || undefined, className: clsx("outline-none text-text flex-1", className), ...props }), end] }), errorMessage && (_jsx("p", { className: "pl-1 text-sm text-error", children: typeof errorMessage === "string" ? errorMessage : "Invalid value" }))] }));
|
|
21
21
|
}
|
|
@@ -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)
|
|
@@ -12,6 +12,9 @@ export type Props<T> = {
|
|
|
12
12
|
buttonClassName?: string;
|
|
13
13
|
placeholder?: string;
|
|
14
14
|
multiselect?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
label?: string;
|
|
15
17
|
};
|
|
16
|
-
export default function Select<T>({ name, options, values, setValues, errorMessage, buttonClassName, placeholder, multiselect,
|
|
18
|
+
export default function Select<T>({ name, options, values, setValues, errorMessage, buttonClassName, placeholder, multiselect, disabled, // ✅ default false
|
|
19
|
+
label, }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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;
|
|
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,11 +3,14 @@ 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 = "Select
|
|
6
|
+
export default function Select({ name, options, values, setValues, errorMessage, buttonClassName, placeholder = "Select...", multiselect = false, disabled = false, // ✅ default false
|
|
7
|
+
label, }) {
|
|
7
8
|
const [isOpen, setIsOpen] = useState(false);
|
|
8
9
|
const containerRef = useRef(null);
|
|
9
10
|
const selectedOptions = options.filter((o) => values.some((v) => Object.is(v, o.value)));
|
|
10
11
|
const toggleOption = (option) => {
|
|
12
|
+
if (disabled)
|
|
13
|
+
return; // ✅ prevent selecting if disabled
|
|
11
14
|
if (multiselect) {
|
|
12
15
|
const isSelected = values.some((v) => Object.is(v, option.value));
|
|
13
16
|
const updated = isSelected
|
|
@@ -21,6 +24,8 @@ export default function Select({ name, options, values, setValues, errorMessage,
|
|
|
21
24
|
}
|
|
22
25
|
};
|
|
23
26
|
const removeSelected = (option) => {
|
|
27
|
+
if (disabled)
|
|
28
|
+
return; // ✅ prevent removing if disabled
|
|
24
29
|
setValues(values.filter((v) => !Object.is(v, option.value)));
|
|
25
30
|
};
|
|
26
31
|
const handleClickOutside = (e) => {
|
|
@@ -33,14 +38,19 @@ export default function Select({ name, options, values, setValues, errorMessage,
|
|
|
33
38
|
document.addEventListener("mousedown", handleClickOutside);
|
|
34
39
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
35
40
|
}, []);
|
|
36
|
-
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs("div", { ref: containerRef, className: "relative w-full", children: [_jsxs("div", { onClick: () => setIsOpen((o) => !o), className: clsx("text-text
|
|
41
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [label && (_jsx("label", { htmlFor: name, className: "pl-1 text-sm text-foreground", children: label })), _jsxs("div", { ref: containerRef, className: "relative w-full", children: [_jsxs("div", { onClick: () => !disabled && setIsOpen((o) => !o), className: clsx("text-text flex items-center justify-between gap-2 px-3 py-2 rounded-md border-0.5", disabled
|
|
42
|
+
? "bg-gray-100 text-gray-400 cursor-not-allowed"
|
|
43
|
+
: "bg-white cursor-pointer", errorMessage
|
|
37
44
|
? "border-error"
|
|
38
45
|
: isOpen
|
|
39
46
|
? "border-primary"
|
|
40
|
-
: "border-gray-200", buttonClassName), children: [multiselect ? (selectedOptions.length ? (_jsx("div", { className: "flex flex-wrap gap-2", children: selectedOptions.map((o, i) => (_jsxs("div", { className: "bg-primary bg-opacity-50 px-2 py-1 rounded-2xl flex items-center gap-1", children: [_jsx("div", { className: "text-black text-sm", children: o.label }),
|
|
47
|
+
: "border-gray-200", buttonClassName), children: [multiselect ? (selectedOptions.length ? (_jsx("div", { className: "flex flex-wrap gap-2", id: `${name}`, children: selectedOptions.map((o, i) => (_jsxs("div", { className: "bg-primary bg-opacity-50 px-2 py-1 rounded-2xl flex items-center gap-1", children: [_jsx("div", { className: "text-black text-sm", children: o.label }), !disabled && ( // ✅ hide close button if disabled
|
|
48
|
+
_jsx("button", { type: "button", onClick: (e) => {
|
|
41
49
|
e.stopPropagation();
|
|
42
50
|
removeSelected(o);
|
|
43
|
-
}, children: _jsx(Icon, { icon: "line-md:close-small", className: "w-4 h-4" }) })] }, `${name}-${i}`))) })) : (_jsx("p", { className: "text-gray-500", children: placeholder }))) : selectedOptions[0] ? (_jsx("div", { children: selectedOptions[0].label })) : (_jsx("p", { className: "text-gray-500", children: placeholder })), _jsx(Icon, { icon: "iconamoon:arrow-down-2" })] }), isOpen &&
|
|
51
|
+
}, children: _jsx(Icon, { icon: "line-md:close-small", className: "w-4 h-4" }) }))] }, `${name}-${i}`))) })) : (_jsx("p", { className: "text-gray-500", children: placeholder }))) : selectedOptions[0] ? (_jsx("div", { children: selectedOptions[0].label })) : (_jsx("p", { className: "text-gray-500", children: placeholder })), _jsx(Icon, { icon: "iconamoon:arrow-down-2" })] }), isOpen &&
|
|
52
|
+
!disabled && ( // ✅ prevent opening dropdown when disabled
|
|
53
|
+
_jsx("div", { className: "absolute left-0 mt-1 w-full z-50 bg-white border border-gray-200 rounded-md shadow-lg max-h-64 overflow-auto animate-fade-in", children: options.map((o, i) => {
|
|
44
54
|
const isSelected = selectedOptions.some((s) => Object.is(s.value, o.value));
|
|
45
55
|
return (_jsx("div", { onClick: () => toggleOption(o), className: clsx("px-4 py-2 cursor-pointer custom-animation", isSelected && "bg-primary text-white", !isSelected && "hover:bg-primary hover:bg-opacity-20"), children: o.label }, `${name}-option-${i}`));
|
|
46
56
|
}) }))] }), errorMessage && (_jsx("p", { className: "pl-1 text-sm text-error", children: errorMessage }))] }));
|
|
@@ -2,6 +2,7 @@ import React, { LegacyRef } from "react";
|
|
|
2
2
|
export type Props = {
|
|
3
3
|
ref?: LegacyRef<HTMLTextAreaElement> | undefined;
|
|
4
4
|
errorMessage?: string | boolean;
|
|
5
|
+
label?: string;
|
|
5
6
|
} & React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
6
|
-
export default function Textarea({ errorMessage, className, ref, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default function Textarea({ errorMessage, className, ref, label, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/textarea/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,CAAC,EAAE,SAAS,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;IACjD,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/textarea/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,CAAC,EAAE,SAAS,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;IACjD,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;AAEtD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,YAAY,EACZ,SAAS,EACT,GAAG,EACH,KAAK,EACL,GAAG,KAAK,EACT,EAAE,KAAK,2CAuCP"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useState } from "react";
|
|
5
|
-
export default function Textarea({ errorMessage, className, ref, ...props }) {
|
|
5
|
+
export default function Textarea({ errorMessage, className, ref, label, ...props }) {
|
|
6
6
|
const [isFocused, setIsFocused] = useState(false);
|
|
7
|
-
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("div", { className: clsx("flex items-center justify-between gap-2 bg-white px-3 py-2 rounded-xl border-0.5 hover:border-primary", errorMessage
|
|
7
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [label && (_jsx("label", { htmlFor: props.id, className: "pl-1 text-sm text-foreground", children: label })), _jsx("div", { className: clsx("flex items-center justify-between gap-2 bg-white px-3 py-2 rounded-xl border-0.5 hover:border-primary", errorMessage
|
|
8
8
|
? "border-error"
|
|
9
9
|
: isFocused
|
|
10
10
|
? "border-primary"
|
|
11
|
-
: "border-gray-200"), children: _jsx("textarea", { ref: ref, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), className: clsx("outline-none text-text flex-1", className), ...props }) }), errorMessage && (_jsx("p", { className: "pl-1 text-sm text-error", children: errorMessage }))] }));
|
|
11
|
+
: "border-gray-200"), children: _jsx("textarea", { ref: ref, id: props.id, onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), "aria-invalid": !!errorMessage || undefined, className: clsx("outline-none text-text flex-1", className), ...props }) }), errorMessage && (_jsx("p", { className: "pl-1 text-sm text-error", children: typeof errorMessage === "string" ? errorMessage : "Invalid value" }))] }));
|
|
12
12
|
}
|
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,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAA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,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";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FirebaseConfig, NotificationPayload } from "../../utils/firebase-client";
|
|
2
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, _onForegroundMessage, _onGetToken, }: Readonly<{
|
|
3
|
+
config: FirebaseConfig;
|
|
4
|
+
updateFirebaseTokenUrl: any;
|
|
5
|
+
_onForegroundMessage?: (notification: NotificationPayload) => void;
|
|
6
|
+
_onGetToken?: (token: string) => void;
|
|
7
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
const axiosOptions = {
|
|
9
|
+
headers: {
|
|
10
|
+
Authorization: `Bearer ${getCookie(CONSTANTS.JWT.JWTCookieKey)}`,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default function FirebaseTokenHandler({ config, updateFirebaseTokenUrl, _onForegroundMessage, _onGetToken, }) {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
initFirebase(config);
|
|
16
|
+
requestForToken(config.vapidKey).then((token) => {
|
|
17
|
+
if (token) {
|
|
18
|
+
axios.put(updateFirebaseTokenUrl, { token }, axiosOptions);
|
|
19
|
+
_onGetToken && _onGetToken(token);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
onForegroundMessage((notification) => {
|
|
23
|
+
console.log("Foreground notification:", notification);
|
|
24
|
+
_onForegroundMessage && _onForegroundMessage(notification);
|
|
25
|
+
});
|
|
26
|
+
}, [config]);
|
|
27
|
+
return _jsx(_Fragment, {});
|
|
28
|
+
}
|
|
@@ -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 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/firebase/index.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/firebase-client/config.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Messaging } from "firebase/messaging";
|
|
2
|
+
import { FirebaseConfig, NotificationPayload } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Initialize Firebase and Messaging
|
|
5
|
+
*/
|
|
6
|
+
export declare function initFirebase(config: FirebaseConfig): Messaging;
|
|
7
|
+
/**
|
|
8
|
+
* Get FCM token for this device/browser
|
|
9
|
+
*/
|
|
10
|
+
export declare function requestForToken(vapidKey: string): Promise<string | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Listen for foreground messages
|
|
13
|
+
*/
|
|
14
|
+
export declare function onForegroundMessage(callback: (payload: NotificationPayload) => void): void;
|
|
15
|
+
//# sourceMappingURL=firebase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../../src/utils/firebase-client/firebase.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,SAAS,EACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAK9D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAc9D;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcxB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAC/C,IAAI,CAgBN"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { initializeApp } from "firebase/app";
|
|
2
|
+
import { getMessaging, getToken, onMessage, } from "firebase/messaging";
|
|
3
|
+
let appInstance = null;
|
|
4
|
+
let messagingInstance = null;
|
|
5
|
+
/**
|
|
6
|
+
* Initialize Firebase and Messaging
|
|
7
|
+
*/
|
|
8
|
+
export function initFirebase(config) {
|
|
9
|
+
if (!appInstance) {
|
|
10
|
+
appInstance = initializeApp({
|
|
11
|
+
apiKey: config.apiKey,
|
|
12
|
+
authDomain: config.authDomain,
|
|
13
|
+
projectId: config.projectId,
|
|
14
|
+
storageBucket: config.storageBucket,
|
|
15
|
+
messagingSenderId: config.messagingSenderId,
|
|
16
|
+
appId: config.appId,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
messagingInstance = getMessaging(appInstance);
|
|
20
|
+
return messagingInstance;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get FCM token for this device/browser
|
|
24
|
+
*/
|
|
25
|
+
export async function requestForToken(vapidKey) {
|
|
26
|
+
if (!messagingInstance) {
|
|
27
|
+
throw new Error("[firebase-notifications] Firebase not initialized. Call initFirebase first.");
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const token = await getToken(messagingInstance, { vapidKey });
|
|
31
|
+
return token;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
console.error("[firebase-notifications] Error fetching FCM token:", err);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Listen for foreground messages
|
|
40
|
+
*/
|
|
41
|
+
export function onForegroundMessage(callback) {
|
|
42
|
+
if (!messagingInstance) {
|
|
43
|
+
throw new Error("[firebase-notifications] Firebase not initialized. Call initFirebase first.");
|
|
44
|
+
}
|
|
45
|
+
onMessage(messagingInstance, (payload) => {
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
const notification = {
|
|
48
|
+
title: ((_a = payload.notification) === null || _a === void 0 ? void 0 : _a.title) || "Notification",
|
|
49
|
+
body: ((_b = payload.notification) === null || _b === void 0 ? void 0 : _b.body) || "",
|
|
50
|
+
icon: (_c = payload.notification) === null || _c === void 0 ? void 0 : _c.icon,
|
|
51
|
+
...payload.data,
|
|
52
|
+
};
|
|
53
|
+
callback(notification);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/firebase-client/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface FirebaseConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
authDomain: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
storageBucket: string;
|
|
6
|
+
messagingSenderId: string;
|
|
7
|
+
appId: string;
|
|
8
|
+
vapidKey?: string;
|
|
9
|
+
measurementId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface NotificationPayload {
|
|
12
|
+
title: string;
|
|
13
|
+
body: string;
|
|
14
|
+
icon?: string;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/firebase-client/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
},
|