react-notify-sdk 1.0.17 → 1.0.19

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.
@@ -5,7 +5,7 @@ opacity: ${(props) => (props.visible ? 1 : 0)};
5
5
  animation: ${(props) => (props.visible ? fadeIn : fadeOut)} 0.3s ease forwards;
6
6
  transition: opacity 0.3s ease;
7
7
  position: absolute;
8
- width: ${(props) => props.device === 'Mobile' ? '100%' : props.device === 'Tablet' ? '80%' : `${props.message?.width}%`};
8
+ width: ${(props) => props.device === 'Mobile' ? '95%' : props.device === 'Tablet' ? '420px' : '420px'};
9
9
  top: ${(props) => props.message?.position === 'top' ? '24px' : ''};
10
10
  bottom: ${(props) => props.message?.position === 'bottom' ? '24px' : ''};
11
11
  left: 50%;
@@ -1,4 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import InfoOutlineIcon from '@mui/icons-material/InfoOutline';
3
+ import WarningAmberIcon from '@mui/icons-material/WarningAmber';
4
+ import HighlightOffIcon from '@mui/icons-material/HighlightOff';
2
5
  const NotificationMessage = ({ message }) => {
3
6
  return (_jsxs("div", { style: {
4
7
  width: '100%',
@@ -9,11 +12,16 @@ const NotificationMessage = ({ message }) => {
9
12
  backgroundColor: message?.backgroundColor,
10
13
  border: `1px solid ${message?.textColor}`, // Completed border style
11
14
  borderRadius: "8px"
12
- }, children: [_jsx("p", { className: `text-lg font-semibold text-[${message?.textColor}]`, style: {
13
- fontSize: '1.125rem', // text-lg = 18px = 1.125rem
14
- fontWeight: 600, // font-semibold = 600
15
- color: `${message?.textColor}`,
16
- }, children: message.title }), _jsx("p", { className: `text-sm text-[${message?.textColor}]`, style: {
15
+ }, children: [_jsxs("div", { className: 'w-full flex flex-row', style: {
16
+ width: '100%',
17
+ display: 'flex',
18
+ flexDirection: 'row'
19
+ }, children: [message?.type === 'Information' && _jsx(InfoOutlineIcon, { fontSize: 'medium', sx: { color: '#4983c9' } }), message?.type === 'Warning' && _jsx(WarningAmberIcon, { fontSize: 'medium', sx: { color: '#ffbf00' } }), message?.type === 'Error' && _jsx(HighlightOffIcon, { fontSize: 'medium', sx: { color: '#d0342c' } }), _jsx("p", { className: `text-lg font-semibold text-[${message?.textColor}] ml-3`, style: {
20
+ fontSize: '1.125rem', // text-lg = 18px = 1.125rem
21
+ fontWeight: 600, // font-semibold = 600
22
+ color: `${message?.textColor}`,
23
+ marginLeft: '12px'
24
+ }, children: message.title })] }), _jsx("p", { className: `text-sm text-[${message?.textColor}]`, style: {
17
25
  marginTop: '8px',
18
26
  fontSize: '0.875rem', // text-sm = 14px = 0.875rem
19
27
  color: `${message?.textColor}`,
@@ -6,6 +6,19 @@ import NotificationMessage from './NotifyMessage';
6
6
  import { supabase } from './supabase/supabaseClient';
7
7
  import useDeviceDetection from './UseDeviceDetection';
8
8
  import FadeWrapper from './FadeWrapper';
9
+ // Wildcard route matching utility
10
+ const routeMatches = (pattern, path) => {
11
+ if (pattern === path)
12
+ return true;
13
+ const escapeRegex = (str) => str.replace(/([.+^=!:${}()|[\]/\\])/g, "\\$1");
14
+ const regexPattern = "^" + pattern.split("*").map(escapeRegex).join(".*") + "$";
15
+ try {
16
+ return new RegExp(regexPattern).test(path);
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ };
9
22
  export const NotifyProvider = ({ projectId,
10
23
  //className,
11
24
  //style,
@@ -25,11 +38,12 @@ export const NotifyProvider = ({ projectId,
25
38
  .eq('project_key', projectId)
26
39
  .eq('route', location.pathname)
27
40
  .eq('is_active', true)
28
- .order('created_at', { ascending: false })
29
- .limit(1)
30
- .single();
31
- if (data) {
32
- setMessage(data);
41
+ .order('created_at', { ascending: false });
42
+ //.limit(1)
43
+ //.single();
44
+ const match = data?.find((msg) => routeMatches(msg.route, location.pathname));
45
+ if (match) {
46
+ setMessage(match);
33
47
  setVisible(true); // Fade in
34
48
  }
35
49
  else {
@@ -47,7 +61,7 @@ export const NotifyProvider = ({ projectId,
47
61
  table: 'feature_messages',
48
62
  }, (payload) => {
49
63
  const msg = payload.new;
50
- if (msg.project_key === projectId && msg.route === location.pathname && msg.is_active) {
64
+ if (msg.project_key === projectId && msg.is_active && routeMatches(msg.route, location.pathname)) {
51
65
  setMessage(msg);
52
66
  setVisible(true);
53
67
  }
package/dist/types.d.ts CHANGED
@@ -13,6 +13,7 @@ export type NotifyMessage = {
13
13
  borderWidth: number;
14
14
  is_active: boolean;
15
15
  created_at: string;
16
+ type: string;
16
17
  };
17
18
  export type NotifyMessageProviderProps = {
18
19
  projectId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-notify-sdk",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "SDK for displaying real-time route-specific messages in React apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,9 +15,11 @@
15
15
  "author": "",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
+ "@mui/icons-material": "^7.2.0",
18
19
  "@supabase/supabase-js": "^2.50.0",
19
20
  "clsx": "^2.1.1",
20
- "goober": "^2.1.16"
21
+ "goober": "^2.1.16",
22
+ "heroicons": "^1.0.6"
21
23
  },
22
24
  "devDependencies": {
23
25
  "@types/react": "^19.1.8",