@variamosple/variamos-components 0.2.5 → 0.4.0
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 +29 -42
- package/dist/Common/Events.d.ts +3 -2
- package/dist/Common/Events.js +18 -11
- package/dist/Common/fieldOf.d.ts +2 -0
- package/dist/Common/fieldOf.js +7 -0
- package/dist/Common/isAllowedFor.d.ts +7 -0
- package/dist/Common/isAllowedFor.js +9 -0
- package/dist/Components/AuthWrapper/index.js +6 -6
- package/dist/Components/ConfirmationModal/index.js +3 -3
- package/dist/Components/Footer/index.js +1 -1
- package/dist/Components/Header/BugFormModal.d.ts +2 -0
- package/dist/Components/Header/BugFormModal.js +39 -37
- package/dist/Components/Header/HeaderOptions.js +79 -86
- package/dist/Components/Header/MenuItem.js +24 -34
- package/dist/Components/Header/SubHeader.js +17 -29
- package/dist/Components/Header/index.js +25 -13
- package/dist/Components/Header/submitBugReport.d.ts +14 -0
- package/dist/Components/Header/submitBugReport.js +22 -0
- package/dist/Components/NotAuthorized/index.js +1 -1
- package/dist/Components/Notifications/NotificationBell.js +10 -10
- package/dist/Components/Notifications/NotificationCard.d.ts +9 -0
- package/dist/Components/Notifications/NotificationCard.js +81 -0
- package/dist/Components/Notifications/NotificationDrawer.js +139 -191
- package/dist/Components/Notifications/NotificationSettings.js +32 -28
- package/dist/Components/Notifications/mutedEventTypes.js +9 -9
- package/dist/Components/Notifications/notificationText.d.ts +7 -0
- package/dist/Components/Notifications/notificationText.js +38 -0
- package/dist/Components/Paginator/index.js +22 -22
- package/dist/Components/ProtectedRoute/index.js +18 -18
- package/dist/Components/index.d.ts +1 -1
- package/dist/Components/index.js +10 -10
- package/dist/Context/AnalyticsContext.d.ts +2 -2
- package/dist/Context/AnalyticsContext.js +15 -15
- package/dist/Context/MenuContext.js +39 -47
- package/dist/Context/NotificationContext.d.ts +2 -14
- package/dist/Context/NotificationContext.js +393 -458
- package/dist/Context/SessionContext.js +72 -78
- package/dist/Context/index.d.ts +1 -1
- package/dist/Context/index.js +11 -11
- package/dist/Context/notificationAccessToken.d.ts +1 -3
- package/dist/Context/notificationAccessToken.js +15 -19
- package/dist/Context/notificationApi.d.ts +43 -0
- package/dist/Context/notificationApi.js +83 -0
- package/dist/Context/storedSessionToken.d.ts +8 -0
- package/dist/Context/storedSessionToken.js +11 -0
- package/dist/Context/useNotificationState.d.ts +35 -0
- package/dist/Context/useNotificationState.js +92 -0
- package/dist/Hooks/useDebouncedValue.js +20 -16
- package/dist/Hooks/usePaginatedQuery.js +14 -20
- package/dist/Hooks/useQuery.js +6 -6
- package/dist/Model/ResponseModel.d.ts +2 -2
- package/dist/Model/ResponseModel.js +9 -4
- package/dist/Model/SessionInfoResponse.d.ts +0 -1
- package/dist/main.js +21 -21
- package/package.json +19 -17
|
@@ -2,32 +2,32 @@ import { jsx as f, Fragment as u } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect as g } from "react";
|
|
3
3
|
import "../../Context/AnalyticsContext.js";
|
|
4
4
|
import "../../Context/MenuContext.js";
|
|
5
|
-
import { useRouter as h } from "../../Context/RouterContext.js";
|
|
6
|
-
import { useSession as d } from "../../Context/SessionContext.js";
|
|
7
5
|
import "../../Context/NotificationContext.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import { useRouter as R } from "../../Context/RouterContext.js";
|
|
7
|
+
import { useSession as E } from "../../Context/SessionContext.js";
|
|
8
|
+
const h = [], j = ({
|
|
9
|
+
notAuthorizedPath: n,
|
|
10
|
+
allowedPermissions: o = h,
|
|
11
|
+
children: c
|
|
12
12
|
}) => {
|
|
13
|
-
var
|
|
14
|
-
const { isAuthenticated:
|
|
13
|
+
var m;
|
|
14
|
+
const { isAuthenticated: r, isLoading: e, user: t } = E(), { navigate: s } = R();
|
|
15
15
|
return g(() => {
|
|
16
|
-
if (!
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
if (!e && r) {
|
|
17
|
+
const i = (t == null ? void 0 : t.permissions) ?? [];
|
|
18
|
+
o.length === 0 || i.some((p) => o.includes(p)) || s(n);
|
|
19
19
|
}
|
|
20
20
|
}, [
|
|
21
|
-
n,
|
|
22
21
|
e,
|
|
23
22
|
r,
|
|
24
|
-
|
|
23
|
+
n,
|
|
24
|
+
s,
|
|
25
25
|
t,
|
|
26
|
-
|
|
27
|
-
]),
|
|
28
|
-
(
|
|
29
|
-
)) ? null : /* @__PURE__ */ f(u, { children:
|
|
26
|
+
o
|
|
27
|
+
]), o.length > 0 && !((m = t == null ? void 0 : t.permissions) != null && m.some(
|
|
28
|
+
(i) => o.includes(i)
|
|
29
|
+
)) ? null : /* @__PURE__ */ f(u, { children: c });
|
|
30
30
|
};
|
|
31
31
|
export {
|
|
32
|
-
|
|
32
|
+
j as ProtectedRoute
|
|
33
33
|
};
|
package/dist/Components/index.js
CHANGED
|
@@ -3,20 +3,20 @@ import { confirmationModalDefaultProps as f } from "./ConfirmationModal/index.js
|
|
|
3
3
|
import { Footer as p } from "./Footer/index.js";
|
|
4
4
|
import { Header as m } from "./Header/index.js";
|
|
5
5
|
import { NotAuthorized as n } from "./NotAuthorized/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { NotificationBell as d } from "./Notifications/NotificationBell.js";
|
|
7
|
+
import { NotificationDrawer as u } from "./Notifications/NotificationDrawer.js";
|
|
8
|
+
import { NotificationSettings as P } from "./Notifications/NotificationSettings.js";
|
|
9
|
+
import { Paginator as h } from "./Paginator/index.js";
|
|
10
|
+
import { ProtectedRoute as A } from "./ProtectedRoute/index.js";
|
|
11
11
|
export {
|
|
12
12
|
t as AuthWrapper,
|
|
13
13
|
p as Footer,
|
|
14
14
|
m as Header,
|
|
15
15
|
n as NotAuthorized,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
d as NotificationBell,
|
|
17
|
+
u as NotificationDrawer,
|
|
18
|
+
P as NotificationSettings,
|
|
19
|
+
h as Paginator,
|
|
20
|
+
A as ProtectedRoute,
|
|
21
21
|
f as confirmationModalDefaultProps
|
|
22
22
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { ResponseModel } from '../Model';
|
|
3
3
|
export declare const AnalyticsContext: import('react').Context<unknown>;
|
|
4
4
|
export declare const PAGE_VISIT_EVENT = "page-visit";
|
|
5
5
|
export interface AnalyticsProviderProps {
|
|
6
6
|
onVisit: (pageId: string) => Promise<ResponseModel<void>>;
|
|
7
|
-
children?:
|
|
7
|
+
children?: ReactNode;
|
|
8
8
|
}
|
|
9
9
|
export declare const AnalyticsProvider: FC<AnalyticsProviderProps>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { Events as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as d, useEffect as s } from "react";
|
|
3
|
+
import { Events as i } from "../Common/Events.js";
|
|
4
4
|
import { useDebouncedValue as m } from "../Hooks/useDebouncedValue.js";
|
|
5
|
-
const
|
|
5
|
+
const f = d({}), n = "page-visit", E = ({
|
|
6
6
|
onVisit: t,
|
|
7
|
-
children:
|
|
7
|
+
children: c
|
|
8
8
|
}) => {
|
|
9
9
|
const [e, o] = m(null, 1e4);
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
o(
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, [e, t]), /* @__PURE__ */
|
|
10
|
+
return s(() => {
|
|
11
|
+
const r = (u) => {
|
|
12
|
+
o(u.detail.id);
|
|
13
|
+
};
|
|
14
|
+
return i.subscribe(n, r), () => i.unsubscribe(n, r);
|
|
15
|
+
}, [o]), s(() => {
|
|
16
|
+
e && t(e);
|
|
17
|
+
}, [e, t]), /* @__PURE__ */ a(f.Provider, { value: {}, children: c });
|
|
18
18
|
};
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
f as AnalyticsContext,
|
|
21
21
|
E as AnalyticsProvider,
|
|
22
|
-
|
|
22
|
+
n as PAGE_VISIT_EVENT
|
|
23
23
|
};
|
|
@@ -1,61 +1,53 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as v, useMemo as n, useEffect as x, useContext as M } from "react";
|
|
3
|
+
import { isAllowedFor as F } from "../Common/isAllowedFor.js";
|
|
4
|
+
import { useQuery as h } from "../Hooks/useQuery.js";
|
|
5
|
+
import { useRouter as w } from "./RouterContext.js";
|
|
6
|
+
import { useSession as C } from "./SessionContext.js";
|
|
7
|
+
const d = v({
|
|
7
8
|
items: [],
|
|
8
9
|
isLoading: !0
|
|
9
|
-
}),
|
|
10
|
-
requestMenu:
|
|
11
|
-
children:
|
|
10
|
+
}), j = ({
|
|
11
|
+
requestMenu: s,
|
|
12
|
+
children: f
|
|
12
13
|
}) => {
|
|
13
|
-
const { user:
|
|
14
|
+
const { user: c } = C(), { basePath: r } = w(), {
|
|
14
15
|
data: o,
|
|
15
|
-
loadData:
|
|
16
|
-
isLoading:
|
|
17
|
-
isLoaded:
|
|
18
|
-
} =
|
|
19
|
-
queryFunction:
|
|
20
|
-
}),
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var v, x;
|
|
25
|
-
if (!((v = s == null ? void 0 : s.allowedPermissions) != null && v.length) && !((x = s == null ? void 0 : s.allowedRoles) != null && x.length))
|
|
26
|
-
return !0;
|
|
27
|
-
let t = !0;
|
|
28
|
-
return s.allowedRoles && (t = t && s.allowedRoles.some((a) => c.includes(a))), s.allowedPermissions && (t = t && s.allowedPermissions.some(
|
|
29
|
-
(a) => i.includes(a)
|
|
30
|
-
)), t;
|
|
31
|
-
}) : [];
|
|
32
|
-
}, [o == null ? void 0 : o.items, r]), C = d(() => {
|
|
16
|
+
loadData: u,
|
|
17
|
+
isLoading: e,
|
|
18
|
+
isLoaded: a
|
|
19
|
+
} = h({
|
|
20
|
+
queryFunction: s
|
|
21
|
+
}), p = n(() => {
|
|
22
|
+
var t;
|
|
23
|
+
return (t = o == null ? void 0 : o.items) != null && t.length ? o.items.filter((i) => F(i, c)) : [];
|
|
24
|
+
}, [o == null ? void 0 : o.items, c]), l = n(() => {
|
|
33
25
|
if (!(o != null && o.subMenu))
|
|
34
26
|
return;
|
|
35
|
-
const
|
|
36
|
-
(
|
|
27
|
+
const t = o == null ? void 0 : o.subMenu.find(
|
|
28
|
+
(i) => r === i.accessibleFrom
|
|
37
29
|
);
|
|
38
|
-
return (
|
|
39
|
-
}, [o == null ? void 0 : o.subMenu,
|
|
40
|
-
(
|
|
41
|
-
) : [], [o == null ? void 0 : o.options,
|
|
42
|
-
return
|
|
43
|
-
!
|
|
44
|
-
}, [
|
|
45
|
-
|
|
30
|
+
return (t == null ? void 0 : t.items) || void 0;
|
|
31
|
+
}, [o == null ? void 0 : o.subMenu, r]), b = n(() => o != null && o.options ? o == null ? void 0 : o.options.filter(
|
|
32
|
+
(t) => !t.accessibleFrom || r === t.accessibleFrom
|
|
33
|
+
) : [], [o == null ? void 0 : o.options, r]);
|
|
34
|
+
return x(() => {
|
|
35
|
+
!e && !a && u({});
|
|
36
|
+
}, [e, a, u]), /* @__PURE__ */ m(
|
|
37
|
+
d.Provider,
|
|
46
38
|
{
|
|
47
|
-
value: { items:
|
|
48
|
-
children:
|
|
39
|
+
value: { items: p, subMenu: l, options: b, isLoading: e },
|
|
40
|
+
children: f
|
|
49
41
|
}
|
|
50
42
|
);
|
|
51
|
-
},
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
43
|
+
}, q = () => {
|
|
44
|
+
const s = M(d);
|
|
45
|
+
if (s === void 0)
|
|
54
46
|
throw new Error("useSession must be used within a SessionProvider");
|
|
55
|
-
return
|
|
47
|
+
return s;
|
|
56
48
|
};
|
|
57
49
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
d as MenuContext,
|
|
51
|
+
j as MenuContextProvider,
|
|
52
|
+
q as useMenu
|
|
61
53
|
};
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
templateKey: string;
|
|
5
|
-
variables: Record<string, any>;
|
|
6
|
-
metadata: Record<string, any>;
|
|
7
|
-
isRead: boolean;
|
|
8
|
-
createdAt: string;
|
|
9
|
-
}
|
|
10
|
-
export interface UserNotificationPreferences {
|
|
11
|
-
emailEnabled: boolean;
|
|
12
|
-
inAppEnabled: boolean;
|
|
13
|
-
mutedEventTypes: string[];
|
|
14
|
-
}
|
|
2
|
+
import { NotificationItem, UserNotificationPreferences } from './notificationApi';
|
|
3
|
+
export type { NotificationItem, UserNotificationPreferences, } from './notificationApi';
|
|
15
4
|
interface NotificationContextType {
|
|
16
5
|
notifications: NotificationItem[];
|
|
17
6
|
unreadCount: number;
|
|
@@ -36,4 +25,3 @@ export interface NotificationProviderProps {
|
|
|
36
25
|
}
|
|
37
26
|
export declare const NotificationProvider: FC<NotificationProviderProps>;
|
|
38
27
|
export declare const useNotifications: () => NotificationContextType;
|
|
39
|
-
export {};
|