react-notify-sdk 1.0.3 → 1.0.5
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/NotifyProvider.js +24 -40
- package/dist/index.js +1 -5
- package/dist/supabase/supabaseClient.js +2 -5
- package/dist/types.d.ts +0 -1
- package/dist/types.js +1 -2
- package/package.json +1 -1
- package/src/NotifyProvider.tsx +1 -1
- package/src/types.ts +0 -1
- package/tsconfig.json +4 -4
package/README.md
CHANGED
package/dist/NotifyProvider.js
CHANGED
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.NotifyProvider = void 0;
|
|
16
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
2
|
// src/FeatureMessage.tsx
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const NotifyProvider = ({ projectId,
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useLocation } from 'react-router-dom';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { supabase } from './supabase/supabaseClient';
|
|
7
|
+
export const NotifyProvider = ({ projectId,
|
|
23
8
|
//className,
|
|
24
9
|
//style,
|
|
25
10
|
disableDefaultStyles = false, }) => {
|
|
26
|
-
const [message, setMessage] =
|
|
27
|
-
const location =
|
|
28
|
-
|
|
11
|
+
const [message, setMessage] = useState(null);
|
|
12
|
+
const location = useLocation();
|
|
13
|
+
useEffect(() => {
|
|
29
14
|
if (typeof window === 'undefined')
|
|
30
15
|
return; // Skip on server
|
|
31
|
-
const fetchMessage = () =>
|
|
32
|
-
const { data } =
|
|
16
|
+
const fetchMessage = async () => {
|
|
17
|
+
const { data } = await supabase
|
|
33
18
|
.from('feature_messages')
|
|
34
19
|
.select('*')
|
|
35
20
|
.eq('project_key', projectId)
|
|
@@ -39,9 +24,9 @@ disableDefaultStyles = false, }) => {
|
|
|
39
24
|
.limit(1)
|
|
40
25
|
.single();
|
|
41
26
|
setMessage(data);
|
|
42
|
-
}
|
|
27
|
+
};
|
|
43
28
|
fetchMessage();
|
|
44
|
-
const subscription =
|
|
29
|
+
const subscription = supabase
|
|
45
30
|
.channel('feature_messages_channel')
|
|
46
31
|
.on('postgres_changes', {
|
|
47
32
|
event: '*',
|
|
@@ -55,35 +40,34 @@ disableDefaultStyles = false, }) => {
|
|
|
55
40
|
})
|
|
56
41
|
.subscribe();
|
|
57
42
|
return () => {
|
|
58
|
-
|
|
43
|
+
supabase.removeChannel(subscription);
|
|
59
44
|
};
|
|
60
45
|
}, [location.pathname, projectId]);
|
|
61
46
|
if (!message)
|
|
62
47
|
return null;
|
|
63
|
-
const defaultClasses = `fixed ${message
|
|
64
|
-
return ((
|
|
48
|
+
const defaultClasses = `fixed ${message?.position}-4 left-1/2 transform -translate-x-1/2 z-50 w-[${message?.width}%] px-3 bg-[${message?.backgroundColor}] border border-[${message?.borderColor}] text-[${message?.textColor}] rounded-lg shadow`;
|
|
49
|
+
return (_jsxs("div", { className: clsx(!disableDefaultStyles && defaultClasses), style: disableDefaultStyles ?
|
|
65
50
|
{
|
|
66
51
|
position: 'fixed',
|
|
67
|
-
top:
|
|
68
|
-
bottom:
|
|
52
|
+
top: message?.position === 'top' ? '16px' : undefined,
|
|
53
|
+
bottom: message?.position === 'top' ? undefined : '16px',
|
|
69
54
|
left: '50%',
|
|
70
55
|
transform: 'translateX(-50%)',
|
|
71
56
|
zIndex: 50,
|
|
72
|
-
width: `${message
|
|
57
|
+
width: `${message?.width}%`,
|
|
73
58
|
padding: '1rem', // p-4 = 1rem
|
|
74
|
-
backgroundColor: message
|
|
59
|
+
backgroundColor: message?.backgroundColor,
|
|
75
60
|
border: '1px solid', // Completed border style
|
|
76
61
|
}
|
|
77
62
|
:
|
|
78
|
-
{}, children: [(
|
|
63
|
+
{}, children: [_jsx("strong", { className: `block mb-2 text-lg font-semibold text-[${message?.textColor}]`, style: {
|
|
79
64
|
display: 'block',
|
|
80
65
|
marginBottom: '0.5rem', // mb-2 = 0.5rem
|
|
81
66
|
fontSize: '1.125rem', // text-lg = 18px = 1.125rem
|
|
82
67
|
fontWeight: 600, // font-semibold = 600
|
|
83
|
-
color: `${message
|
|
84
|
-
}, children: message.title }), (
|
|
68
|
+
color: `${message?.backgroundColor}`,
|
|
69
|
+
}, children: message.title }), _jsx("p", { className: `text-sm text-[${message?.textColor}]`, style: {
|
|
85
70
|
fontSize: '0.875rem', // text-sm = 14px = 0.875rem
|
|
86
|
-
color: `${message
|
|
71
|
+
color: `${message?.backgroundColor}`,
|
|
87
72
|
}, children: message.content })] }));
|
|
88
73
|
};
|
|
89
|
-
exports.NotifyProvider = NotifyProvider;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotifyProvider = void 0;
|
|
4
|
-
var NotifyProvider_1 = require("./NotifyProvider");
|
|
5
|
-
Object.defineProperty(exports, "NotifyProvider", { enumerable: true, get: function () { return NotifyProvider_1.NotifyProvider; } });
|
|
1
|
+
export { NotifyProvider } from './NotifyProvider';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.supabase = void 0;
|
|
4
|
-
const supabase_js_1 = require("@supabase/supabase-js");
|
|
1
|
+
import { createClient } from '@supabase/supabase-js';
|
|
5
2
|
const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
|
|
6
3
|
const supabaseKey = process.env.REACT_APP_SUPABASE_KEY;
|
|
7
4
|
// Create a single supabase client for interacting with your database
|
|
8
|
-
|
|
5
|
+
export const supabase = createClient(supabaseUrl, supabaseKey);
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/src/NotifyProvider.tsx
CHANGED
|
@@ -56,7 +56,7 @@ export const NotifyProvider = ({
|
|
|
56
56
|
|
|
57
57
|
if (!message) return null;
|
|
58
58
|
|
|
59
|
-
const defaultClasses = `fixed ${message?.position}-4 left-1/2 transform -translate-x-1/2 z-50 w-[${message?.width}%]
|
|
59
|
+
const defaultClasses = `fixed ${message?.position}-4 left-1/2 transform -translate-x-1/2 z-50 w-[${message?.width}%] px-3 bg-[${message?.backgroundColor}] border border-[${message?.borderColor}] text-[${message?.textColor}] rounded-lg shadow`;
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
62
|
<div
|
package/src/types.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ESNext",
|
|
4
4
|
//"module": "ESNext",
|
|
5
5
|
"declaration": true,
|
|
6
|
-
"outDir": "dist",
|
|
6
|
+
"outDir": "./dist",
|
|
7
7
|
//"strict": true,
|
|
8
8
|
//"esModuleInterop": true,
|
|
9
9
|
"jsx": "react-jsx", // ✅ This is required for React 17+ JSX
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
34
34
|
|
|
35
35
|
/* Modules */
|
|
36
|
-
"module": "
|
|
36
|
+
"module": "ESNext", /* Specify what module code is generated. */
|
|
37
37
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
38
|
-
|
|
38
|
+
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
39
39
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
40
40
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
41
41
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|