sea-react-components 1.3.8 → 1.3.9

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.
@@ -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;CAC9B,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAChD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,YAAY,EACZ,SAAS,EACT,KAAY,EACZ,GAAU,EACV,GAAG,EACH,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,KAAK,2CAoDP"}
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
  }
@@ -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, }: Props<T>): import("react/jsx-runtime").JSX.Element;
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;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,EAChC,IAAI,EACJ,OAAO,EACP,MAAM,EACN,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAgC,EAChC,WAAmB,GACpB,EAAE,KAAK,CAAC,CAAC,CAAC,2CAoHV"}
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,WAAgB,EAChB,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 an option", multiselect = false, }) {
6
+ export default function Select({ name, options, values, setValues, errorMessage, buttonClassName, placeholder = "", 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 cursor-pointer flex items-center justify-between gap-2 bg-white px-3 py-2 rounded-md border-0.5", errorMessage
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 }), _jsx("button", { type: "button", onClick: (e) => {
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 && (_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) => {
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;CACjC,GAAG,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;AACtD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,YAAY,EACZ,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,KAAK,2CA4BP"}
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
  }
@@ -0,0 +1,7 @@
1
+ import { FirebaseConfig, NotificationPayload } from "../../utils/firebase-client";
2
+ export default function FirebaseTokenHandler({ config, _onForegroundMessage, _onGetToken, }: Readonly<{
3
+ config: FirebaseConfig;
4
+ _onForegroundMessage?: (notification: NotificationPayload) => void;
5
+ _onGetToken?: (token: string) => void;
6
+ }>): import("react/jsx-runtime").JSX.Element;
7
+ //# 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;AAErC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,oBAAoB,EACpB,WAAW,GACZ,EAAE,QAAQ,CAAC;IACV,MAAM,EAAE,cAAc,CAAC;IACvB,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC,2CAmBD"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect } from "react";
4
+ import { initFirebase, requestForToken, onForegroundMessage, } from "../../utils/firebase-client";
5
+ export default function FirebaseTokenHandler({ config, _onForegroundMessage, _onGetToken, }) {
6
+ console.log("FirebaseTokenHandler");
7
+ useEffect(() => {
8
+ console.log("Init ...");
9
+ initFirebase(config);
10
+ requestForToken(config.vapidKey).then((token) => {
11
+ if (token) {
12
+ console.log("FCM Token:", token);
13
+ _onGetToken && _onGetToken(token);
14
+ }
15
+ });
16
+ onForegroundMessage((notification) => {
17
+ console.log("Foreground notification:", notification);
18
+ _onForegroundMessage && _onForegroundMessage(notification);
19
+ });
20
+ }, [config]);
21
+ return _jsx(_Fragment, {});
22
+ }
@@ -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,3 @@
1
+ export * from "./types";
2
+ export * from "./firebase";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,2 @@
1
+ export * from "./types";
2
+ export * from "./firebase";
@@ -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 {};
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.8",
4
+ "version": "1.3.9",
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",