@variamosple/variamos-components 0.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.
Files changed (87) hide show
  1. package/README.md +50 -0
  2. package/dist/AbstractModalHeader-UzCRSxIO.js +1690 -0
  3. package/dist/Anchor-DJG5WYYF.js +40 -0
  4. package/dist/Button-DWo2Fl71.js +78 -0
  5. package/dist/Button-GQJKgb76.js +33 -0
  6. package/dist/Common/Events.d.ts +9 -0
  7. package/dist/Common/Events.js +18 -0
  8. package/dist/Common/index.d.ts +1 -0
  9. package/dist/Common/index.js +4 -0
  10. package/dist/Components/AuthWrapper/index.d.ts +7 -0
  11. package/dist/Components/AuthWrapper/index.js +52 -0
  12. package/dist/Components/ConfirmationModal/index.d.ts +12 -0
  13. package/dist/Components/ConfirmationModal/index.js +293 -0
  14. package/dist/Components/Footer/index.d.ts +5 -0
  15. package/dist/Components/Footer/index.js +11 -0
  16. package/dist/Components/Header/HeaderOptions.d.ts +2 -0
  17. package/dist/Components/Header/HeaderOptions.js +39 -0
  18. package/dist/Components/Header/MenuItem.d.ts +3 -0
  19. package/dist/Components/Header/MenuItem.js +51 -0
  20. package/dist/Components/Header/SubHeader.d.ts +2 -0
  21. package/dist/Components/Header/SubHeader.js +12 -0
  22. package/dist/Components/Header/index.d.ts +7 -0
  23. package/dist/Components/Header/index.js +46 -0
  24. package/dist/Components/NotAuthorized/index.d.ts +5 -0
  25. package/dist/Components/NotAuthorized/index.js +18 -0
  26. package/dist/Components/Paginator/index.d.ts +7 -0
  27. package/dist/Components/Paginator/index.js +156 -0
  28. package/dist/Components/ProtectedRoute/index.d.ts +8 -0
  29. package/dist/Components/ProtectedRoute/index.js +32 -0
  30. package/dist/Components/index.d.ts +7 -0
  31. package/dist/Components/index.js +16 -0
  32. package/dist/Container-BLjzOisH.js +22 -0
  33. package/dist/Context/AnalyticsContext.d.ts +9 -0
  34. package/dist/Context/AnalyticsContext.js +23 -0
  35. package/dist/Context/MenuContext.d.ts +15 -0
  36. package/dist/Context/MenuContext.js +61 -0
  37. package/dist/Context/RouterContext.d.ts +15 -0
  38. package/dist/Context/RouterContext.js +18 -0
  39. package/dist/Context/SessionsContext.d.ts +22 -0
  40. package/dist/Context/SessionsContext.js +81 -0
  41. package/dist/Context/index.d.ts +4 -0
  42. package/dist/Context/index.js +18 -0
  43. package/dist/HOC/WithPageVisit.d.ts +2 -0
  44. package/dist/HOC/WithPageVisit.js +12 -0
  45. package/dist/HOC/index.d.ts +1 -0
  46. package/dist/HOC/index.js +4 -0
  47. package/dist/Hooks/index.d.ts +4 -0
  48. package/dist/Hooks/index.js +10 -0
  49. package/dist/Hooks/useDebouncedValue.d.ts +1 -0
  50. package/dist/Hooks/useDebouncedValue.js +19 -0
  51. package/dist/Hooks/usePageVisibility.d.ts +1 -0
  52. package/dist/Hooks/usePageVisibility.js +15 -0
  53. package/dist/Hooks/usePaginatedQuery.d.ts +21 -0
  54. package/dist/Hooks/usePaginatedQuery.js +38 -0
  55. package/dist/Hooks/useQuery.d.ts +15 -0
  56. package/dist/Hooks/useQuery.js +22 -0
  57. package/dist/Model/Credentials.d.ts +5 -0
  58. package/dist/Model/Credentials.js +13 -0
  59. package/dist/Model/Menu.d.ts +28 -0
  60. package/dist/Model/Menu.js +1 -0
  61. package/dist/Model/PagedModel.d.ts +5 -0
  62. package/dist/Model/PagedModel.js +8 -0
  63. package/dist/Model/ResponseModel.d.ts +10 -0
  64. package/dist/Model/ResponseModel.js +14 -0
  65. package/dist/Model/Router.d.ts +3 -0
  66. package/dist/Model/Router.js +9 -0
  67. package/dist/Model/SessionUser.d.ts +8 -0
  68. package/dist/Model/SessionUser.js +1 -0
  69. package/dist/Model/SingInResponse.d.ts +4 -0
  70. package/dist/Model/SingInResponse.js +1 -0
  71. package/dist/Model/UserRegistration.d.ts +6 -0
  72. package/dist/Model/UserRegistration.js +9 -0
  73. package/dist/Model/index.d.ts +8 -0
  74. package/dist/Model/index.js +12 -0
  75. package/dist/Nav-CdxSljzW.js +144 -0
  76. package/dist/NavDropdown-AuV3RgfC.js +1764 -0
  77. package/dist/NavLink-ebvp1HCw.js +173 -0
  78. package/dist/SubHeader-DNc4qWBV.js +481 -0
  79. package/dist/ThemeProvider-Q3gZ4GF2.js +72 -0
  80. package/dist/assets/index.css +1 -0
  81. package/dist/jsx-runtime-Drh4NO5G.js +633 -0
  82. package/dist/main.d.ts +6 -0
  83. package/dist/main.js +54 -0
  84. package/dist/useEventCallback-Bfo0-hwZ.js +16 -0
  85. package/dist/useMergedRefs-BpAaCckn.js +16 -0
  86. package/dist/useWindow-rGE2GXIv.js +118 -0
  87. package/package.json +50 -0
@@ -0,0 +1,12 @@
1
+ import "../../jsx-runtime-Drh4NO5G.js";
2
+ import "react";
3
+ import "../../Context/AnalyticsContext.js";
4
+ import "../../Context/MenuContext.js";
5
+ import "../../Context/RouterContext.js";
6
+ import "../../Context/SessionsContext.js";
7
+ import { S as d } from "../../SubHeader-DNc4qWBV.js";
8
+ import "../../Container-BLjzOisH.js";
9
+ import "../../Nav-CdxSljzW.js";
10
+ export {
11
+ d as SubHeader
12
+ };
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ export interface HeaderProps {
3
+ logoUrl?: string;
4
+ logoAlt?: string;
5
+ signInUrl: string;
6
+ }
7
+ export declare const Header: FC<HeaderProps>;
@@ -0,0 +1,46 @@
1
+ import { j as s } from "../../jsx-runtime-Drh4NO5G.js";
2
+ import "../../Context/AnalyticsContext.js";
3
+ import { useMenu as d } from "../../Context/MenuContext.js";
4
+ import { useRouter as x } from "../../Context/RouterContext.js";
5
+ import { useSession as j } from "../../Context/SessionsContext.js";
6
+ import { HeaderOptions as u } from "./HeaderOptions.js";
7
+ import { MenuItemComponent as o } from "./MenuItem.js";
8
+ import { N as r, S as f } from "../../SubHeader-DNc4qWBV.js";
9
+ import { C as h } from "../../Container-BLjzOisH.js";
10
+ import { N as t } from "../../Nav-CdxSljzW.js";
11
+ const I = ({
12
+ logoUrl: i,
13
+ logoAlt: a = "App logo",
14
+ signInUrl: n
15
+ }) => {
16
+ const { items: m } = d(), { navigate: c } = x(), { isAuthenticated: l, isLoading: p } = j();
17
+ return /* @__PURE__ */ s.jsxs("header", { className: "sticky-top", children: [
18
+ /* @__PURE__ */ s.jsx(r, { bg: "dark", variant: "dark", children: /* @__PURE__ */ s.jsxs(h, { fluid: !0, children: [
19
+ /* @__PURE__ */ s.jsx(r.Brand, { onClick: () => c("/"), children: /* @__PURE__ */ s.jsx(
20
+ "img",
21
+ {
22
+ src: i,
23
+ height: "30",
24
+ className: "d-inline-block align-top",
25
+ alt: a
26
+ }
27
+ ) }),
28
+ /* @__PURE__ */ s.jsx(t, { className: "me-auto", children: m.map((e) => /* @__PURE__ */ s.jsx(o, { ...e }, e.title)) }),
29
+ /* @__PURE__ */ s.jsxs(t, { className: "me-5 pe-5", children: [
30
+ /* @__PURE__ */ s.jsx(u, {}),
31
+ !p && !l && /* @__PURE__ */ s.jsx(
32
+ o,
33
+ {
34
+ title: "Sign In",
35
+ type: "location",
36
+ location: n
37
+ }
38
+ )
39
+ ] })
40
+ ] }) }),
41
+ /* @__PURE__ */ s.jsx(f, {})
42
+ ] });
43
+ };
44
+ export {
45
+ I as Header
46
+ };
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+ export interface NotAuthorizedProps {
3
+ homePath: string;
4
+ }
5
+ export declare const NotAuthorized: React.FC<NotAuthorizedProps>;
@@ -0,0 +1,18 @@
1
+ import { j as t } from "../../jsx-runtime-Drh4NO5G.js";
2
+ import "../../Context/AnalyticsContext.js";
3
+ import "../../Context/MenuContext.js";
4
+ import { useRouter as o } from "../../Context/RouterContext.js";
5
+ import "../../Context/SessionsContext.js";
6
+ import { C as s } from "../../Container-BLjzOisH.js";
7
+ import { B as i } from "../../Button-GQJKgb76.js";
8
+ const d = ({ homePath: e }) => {
9
+ const { navigate: r } = o();
10
+ return /* @__PURE__ */ t.jsxs(s, { className: "d-flex flex-column justify-content-center align-items-center vh-100 text-center", children: [
11
+ /* @__PURE__ */ t.jsx("h1", { className: "display-1 fw-bold text-danger", children: "403" }),
12
+ /* @__PURE__ */ t.jsx("p", { className: "fs-4 text-muted", children: "You are not authorized to access this page." }),
13
+ /* @__PURE__ */ t.jsx(i, { variant: "primary", onClick: () => r(e), children: "Go Home" })
14
+ ] });
15
+ };
16
+ export {
17
+ d as NotAuthorized
18
+ };
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ export interface PaginatorProps {
3
+ currentPage: number;
4
+ totalPages: number;
5
+ onPageChange: (newPage: number) => void;
6
+ }
7
+ export declare const Paginator: FC<PaginatorProps>;
@@ -0,0 +1,156 @@
1
+ import { j as l } from "../../jsx-runtime-Drh4NO5G.js";
2
+ import * as p from "react";
3
+ import { useMemo as y } from "react";
4
+ import { c as x, u as I } from "../../ThemeProvider-Q3gZ4GF2.js";
5
+ import { A as v } from "../../Anchor-DJG5WYYF.js";
6
+ const j = /* @__PURE__ */ p.forwardRef(({
7
+ active: i = !1,
8
+ disabled: s = !1,
9
+ className: r,
10
+ style: e,
11
+ activeLabel: n = "(current)",
12
+ children: o,
13
+ linkStyle: d,
14
+ linkClassName: N,
15
+ as: u = v,
16
+ ...a
17
+ }, M) => {
18
+ const k = i || s ? "span" : u;
19
+ return /* @__PURE__ */ l.jsx("li", {
20
+ ref: M,
21
+ style: e,
22
+ className: x(r, "page-item", {
23
+ active: i,
24
+ disabled: s
25
+ }),
26
+ children: /* @__PURE__ */ l.jsxs(k, {
27
+ className: x("page-link", N),
28
+ style: d,
29
+ ...a,
30
+ children: [o, i && n && /* @__PURE__ */ l.jsx("span", {
31
+ className: "visually-hidden",
32
+ children: n
33
+ })]
34
+ })
35
+ });
36
+ });
37
+ j.displayName = "PageItem";
38
+ function t(i, s, r = i) {
39
+ const e = /* @__PURE__ */ p.forwardRef(({
40
+ children: n,
41
+ ...o
42
+ }, d) => /* @__PURE__ */ l.jsxs(j, {
43
+ ...o,
44
+ ref: d,
45
+ children: [/* @__PURE__ */ l.jsx("span", {
46
+ "aria-hidden": "true",
47
+ children: n || s
48
+ }), /* @__PURE__ */ l.jsx("span", {
49
+ className: "visually-hidden",
50
+ children: r
51
+ })]
52
+ }));
53
+ return e.displayName = i, e;
54
+ }
55
+ const E = t("First", "«"), R = t("Prev", "‹", "Previous"), B = t("Ellipsis", "…", "More"), b = t("Next", "›"), w = t("Last", "»"), h = /* @__PURE__ */ p.forwardRef(({
56
+ bsPrefix: i,
57
+ className: s,
58
+ size: r,
59
+ ...e
60
+ }, n) => {
61
+ const o = I(i, "pagination");
62
+ return /* @__PURE__ */ l.jsx("ul", {
63
+ ref: n,
64
+ ...e,
65
+ className: x(s, o, r && `${o}-${r}`)
66
+ });
67
+ });
68
+ h.displayName = "Pagination";
69
+ const c = Object.assign(h, {
70
+ First: E,
71
+ Prev: R,
72
+ Ellipsis: B,
73
+ Item: j,
74
+ Next: b,
75
+ Last: w
76
+ }), f = (i, s) => {
77
+ const r = [];
78
+ for (let e = i; e <= s; e++)
79
+ r.push(e);
80
+ return r;
81
+ }, m = 5, L = ({
82
+ currentPage: i,
83
+ totalPages: s,
84
+ onPageChange: r
85
+ }) => {
86
+ const e = y(() => {
87
+ if (i === 1 && s === 1)
88
+ return [];
89
+ if (i === 1)
90
+ return f(2, Math.min(s - 1, m + 1));
91
+ if (s - m <= 0)
92
+ return f(2, s - 1);
93
+ let n, o;
94
+ return i <= Math.ceil(m / 2) ? (n = 2, o = Math.min(m + 1, s - 1)) : i + Math.floor(m / 2) >= s ? (n = Math.max(s - m, 2), o = s - 1) : (n = i - Math.floor(m / 2), o = i + Math.floor(m / 2)), o = Math.min(o, s - 1), n = Math.max(n, 2), f(n, o);
95
+ }, [i, s]);
96
+ return /* @__PURE__ */ l.jsxs(c, { className: "d-flex justify-content-end", children: [
97
+ /* @__PURE__ */ l.jsx(
98
+ c.First,
99
+ {
100
+ onClick: () => r(1),
101
+ disabled: i === 1
102
+ }
103
+ ),
104
+ /* @__PURE__ */ l.jsx(
105
+ c.Prev,
106
+ {
107
+ onClick: () => r(i - 1),
108
+ disabled: i === 1
109
+ }
110
+ ),
111
+ /* @__PURE__ */ l.jsx(
112
+ c.Item,
113
+ {
114
+ active: i === 1,
115
+ onClick: () => r(1),
116
+ children: "1"
117
+ }
118
+ ),
119
+ s > 2 && !e.includes(2) && /* @__PURE__ */ l.jsx(c.Ellipsis, {}),
120
+ e.map((n) => /* @__PURE__ */ l.jsx(
121
+ c.Item,
122
+ {
123
+ active: i === n,
124
+ onClick: () => r(n),
125
+ children: n
126
+ },
127
+ n
128
+ )),
129
+ s > m && !e.includes(s - 1) && /* @__PURE__ */ l.jsx(c.Ellipsis, {}),
130
+ s > 1 && /* @__PURE__ */ l.jsx(
131
+ c.Item,
132
+ {
133
+ active: i === s,
134
+ onClick: () => r(s),
135
+ children: s
136
+ }
137
+ ),
138
+ /* @__PURE__ */ l.jsx(
139
+ c.Next,
140
+ {
141
+ onClick: () => r(i + 1),
142
+ disabled: i === s
143
+ }
144
+ ),
145
+ /* @__PURE__ */ l.jsx(
146
+ c.Last,
147
+ {
148
+ onClick: () => r(s),
149
+ disabled: i === s
150
+ }
151
+ )
152
+ ] });
153
+ };
154
+ export {
155
+ L as Paginator
156
+ };
@@ -0,0 +1,8 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ interface ProtectedRouteProps {
3
+ allowedPermissions?: string[];
4
+ notAuthorizedPath: string;
5
+ children?: ReactNode;
6
+ }
7
+ export declare const ProtectedRoute: React.FC<ProtectedRouteProps>;
8
+ export {};
@@ -0,0 +1,32 @@
1
+ import { j as p } from "../../jsx-runtime-Drh4NO5G.js";
2
+ import { useEffect as f } from "react";
3
+ import "../../Context/AnalyticsContext.js";
4
+ import "../../Context/MenuContext.js";
5
+ import { useRouter as g } from "../../Context/RouterContext.js";
6
+ import { useSession as x } from "../../Context/SessionsContext.js";
7
+ const v = ({
8
+ notAuthorizedPath: e,
9
+ allowedPermissions: i = [],
10
+ children: c
11
+ }) => {
12
+ var m;
13
+ const { isAuthenticated: n, isLoading: r, user: t } = x(), { navigate: s } = g();
14
+ return f(() => {
15
+ if (!r && n) {
16
+ const o = (t == null ? void 0 : t.permissions) || [];
17
+ !i.length || o.some((u) => i.includes(u)) || s(e);
18
+ }
19
+ }, [
20
+ r,
21
+ n,
22
+ e,
23
+ s,
24
+ t,
25
+ i
26
+ ]), i.length > 0 && !((m = t == null ? void 0 : t.permissions) != null && m.some(
27
+ (o) => i.includes(o)
28
+ )) ? null : /* @__PURE__ */ p.jsx(p.Fragment, { children: c });
29
+ };
30
+ export {
31
+ v as ProtectedRoute
32
+ };
@@ -0,0 +1,7 @@
1
+ export * from './AuthWrapper';
2
+ export * from './ConfirmationModal';
3
+ export * from './Footer';
4
+ export * from './Header';
5
+ export * from './NotAuthorized';
6
+ export * from './Paginator';
7
+ export * from './ProtectedRoute';
@@ -0,0 +1,16 @@
1
+ import { AuthWrapper as t } from "./AuthWrapper/index.js";
2
+ import { confirmationModalDefaultProps as p } from "./ConfirmationModal/index.js";
3
+ import { Footer as m } from "./Footer/index.js";
4
+ import { Header as x } from "./Header/index.js";
5
+ import { NotAuthorized as i } from "./NotAuthorized/index.js";
6
+ import { Paginator as n } from "./Paginator/index.js";
7
+ import { ProtectedRoute as c } from "./ProtectedRoute/index.js";
8
+ export {
9
+ t as AuthWrapper,
10
+ m as Footer,
11
+ x as Header,
12
+ i as NotAuthorized,
13
+ n as Paginator,
14
+ c as ProtectedRoute,
15
+ p as confirmationModalDefaultProps
16
+ };
@@ -0,0 +1,22 @@
1
+ import { u as f, c as m } from "./ThemeProvider-Q3gZ4GF2.js";
2
+ import * as p from "react";
3
+ import { j as c } from "./jsx-runtime-Drh4NO5G.js";
4
+ const x = /* @__PURE__ */ p.forwardRef(({
5
+ bsPrefix: a,
6
+ fluid: s = !1,
7
+ // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
8
+ as: o = "div",
9
+ className: t,
10
+ ...e
11
+ }, i) => {
12
+ const r = f(a, "container"), n = typeof s == "string" ? `-${s}` : "-fluid";
13
+ return /* @__PURE__ */ c.jsx(o, {
14
+ ref: i,
15
+ ...e,
16
+ className: m(t, s ? `${r}${n}` : r)
17
+ });
18
+ });
19
+ x.displayName = "Container";
20
+ export {
21
+ x as C
22
+ };
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { ResponseModel } from '../Model';
3
+ export declare const AnalyticsContext: import('react').Context<unknown>;
4
+ export declare const PAGE_VISIT_EVENT = "page-visit";
5
+ export interface AnalyticsProviderProps {
6
+ onVisit: (pageId: string) => Promise<ResponseModel<void>>;
7
+ children?: React.ReactNode;
8
+ }
9
+ export declare const AnalyticsProvider: FC<AnalyticsProviderProps>;
@@ -0,0 +1,23 @@
1
+ import { j as n } from "../jsx-runtime-Drh4NO5G.js";
2
+ import { createContext as a, useEffect as r } from "react";
3
+ import { Events as c } from "../Common/Events.js";
4
+ import { useDebouncedValue as m } from "../Hooks/useDebouncedValue.js";
5
+ const u = a({}), p = "page-visit", E = ({
6
+ onVisit: t,
7
+ children: s
8
+ }) => {
9
+ const [e, o] = m(null, 1e4);
10
+ return r(() => {
11
+ c.subscribe(p, (i) => {
12
+ o(i.detail.id);
13
+ });
14
+ }, [o]), r(() => {
15
+ e && t(e).then(() => {
16
+ });
17
+ }, [e, t]), /* @__PURE__ */ n.jsx(u.Provider, { value: {}, children: s });
18
+ };
19
+ export {
20
+ u as AnalyticsContext,
21
+ E as AnalyticsProvider,
22
+ p as PAGE_VISIT_EVENT
23
+ };
@@ -0,0 +1,15 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { Menu, MenuItem, MenuSubItem, ResponseModel } from '../Model';
3
+ export interface MenuContext {
4
+ items: MenuItem[];
5
+ subMenu?: MenuSubItem[];
6
+ options?: MenuSubItem[];
7
+ isLoading: boolean;
8
+ }
9
+ export declare const MenuContext: import('react').Context<MenuContext>;
10
+ export interface MenuContextProviderProps {
11
+ requestMenu: () => Promise<ResponseModel<Menu>>;
12
+ children?: ReactNode;
13
+ }
14
+ export declare const MenuContextProvider: FC<MenuContextProviderProps>;
15
+ export declare const useMenu: () => MenuContext;
@@ -0,0 +1,61 @@
1
+ import { j as F } from "../jsx-runtime-Drh4NO5G.js";
2
+ import { createContext as j, useMemo as d, useEffect as E, useContext as L } from "react";
3
+ import { useQuery as S } from "../Hooks/useQuery.js";
4
+ import { useRouter as y } from "./RouterContext.js";
5
+ import { useSession as m } from "./SessionsContext.js";
6
+ const P = j({
7
+ items: [],
8
+ isLoading: !0
9
+ }), A = ({
10
+ requestMenu: e,
11
+ children: h
12
+ }) => {
13
+ const { user: r } = m(), { basePath: l } = y(), {
14
+ data: o,
15
+ loadData: f,
16
+ isLoading: n,
17
+ isLoaded: p
18
+ } = S({
19
+ queryFunction: e
20
+ }), g = d(() => {
21
+ var w;
22
+ const i = (r == null ? void 0 : r.permissions) || [], c = (r == null ? void 0 : r.roles) || [];
23
+ return (w = o == null ? void 0 : o.items) != null && w.length ? o.items.filter((s) => {
24
+ var x, v;
25
+ if (!((x = s == null ? void 0 : s.allowedPermissions) != null && x.length) && !((v = s == null ? void 0 : s.allowedRoles) != null && v.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]), R = d(() => {
33
+ if (!(o != null && o.subMenu))
34
+ return;
35
+ const i = o == null ? void 0 : o.subMenu.find(
36
+ (c) => l === c.accessibleFrom
37
+ );
38
+ return (i == null ? void 0 : i.items) || void 0;
39
+ }, [o == null ? void 0 : o.subMenu, l]), C = d(() => o != null && o.options ? o == null ? void 0 : o.options.filter(
40
+ (i) => !i.accessibleFrom || l === i.accessibleFrom
41
+ ) : [], [o == null ? void 0 : o.options, l]);
42
+ return E(() => {
43
+ !n && !p && f({});
44
+ }, [n, p, f]), /* @__PURE__ */ F.jsx(
45
+ P.Provider,
46
+ {
47
+ value: { items: g, subMenu: R, options: C, isLoading: n },
48
+ children: h
49
+ }
50
+ );
51
+ }, B = () => {
52
+ const e = L(P);
53
+ if (e === void 0)
54
+ throw new Error("useSession must be used within a SessionProvider");
55
+ return e;
56
+ };
57
+ export {
58
+ P as MenuContext,
59
+ A as MenuContextProvider,
60
+ B as useMenu
61
+ };
@@ -0,0 +1,15 @@
1
+ import { Target } from '../Model';
2
+ export interface RouterContextProps {
3
+ navigate: (path: string, options?: {
4
+ replace?: boolean;
5
+ target?: Target;
6
+ }) => void;
7
+ params: Record<string, string | undefined>;
8
+ queryParams: URLSearchParams;
9
+ pathname: string;
10
+ basePath: string;
11
+ }
12
+ export declare const RouterContext: import('react').Context<RouterContextProps | undefined>;
13
+ export declare const getBasePath: () => string;
14
+ export declare const isAbsoluteUrl: (url: string) => boolean;
15
+ export declare const useRouter: () => RouterContextProps;
@@ -0,0 +1,18 @@
1
+ import { createContext as e, useContext as o } from "react";
2
+ const r = e(
3
+ void 0
4
+ ), u = () => {
5
+ var t;
6
+ return ((t = document.querySelector("base")) == null ? void 0 : t.getAttribute("href")) || "/";
7
+ }, n = (t) => /^[a-z]+:\/\/[^/]+/i.test(t), c = () => {
8
+ const t = o(r);
9
+ if (!t)
10
+ throw new Error("useRouter must be used within a RouterProvider");
11
+ return t;
12
+ };
13
+ export {
14
+ r as RouterContext,
15
+ u as getBasePath,
16
+ n as isAbsoluteUrl,
17
+ c as useRouter
18
+ };
@@ -0,0 +1,22 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { Credentials, ResponseModel, SessionUser, singInResponse, UserRegistration } from '../Model';
3
+ interface SessionContextType {
4
+ user: SessionUser | null;
5
+ isLoading: boolean;
6
+ isAuthenticated: boolean;
7
+ signIn: (credentials: Credentials) => Promise<ResponseModel<singInResponse>>;
8
+ signInAsGuest: () => Promise<ResponseModel<singInResponse>>;
9
+ signUp: (registration: UserRegistration) => Promise<ResponseModel<unknown> | null>;
10
+ logout: () => void;
11
+ }
12
+ export interface SessionProviderProps {
13
+ getSessionInfo: () => Promise<ResponseModel<SessionUser>>;
14
+ requestLogout: () => Promise<ResponseModel<void>>;
15
+ requestSignIn?: (request: Credentials) => Promise<ResponseModel<singInResponse>>;
16
+ requestSignInAsGuest?: (guestId?: string | null) => Promise<ResponseModel<singInResponse>>;
17
+ requestSignUp?: (request: UserRegistration) => Promise<ResponseModel<unknown>>;
18
+ children: ReactNode;
19
+ }
20
+ export declare const SessionProvider: FC<SessionProviderProps>;
21
+ export declare const useSession: () => SessionContextType;
22
+ export {};
@@ -0,0 +1,81 @@
1
+ import { j } from "../jsx-runtime-Drh4NO5G.js";
2
+ import { createContext as A, useState as w, useEffect as m, useContext as b } from "react";
3
+ import { usePageVisibility as L } from "../Hooks/usePageVisibility.js";
4
+ const C = A(void 0), u = "guestId", K = ({
5
+ getSessionInfo: o,
6
+ requestSignUp: d,
7
+ requestSignIn: f,
8
+ requestSignInAsGuest: h,
9
+ requestLogout: v,
10
+ children: E
11
+ }) => {
12
+ const [l, r] = w(null), [x, a] = w(!0), c = !!l, g = L();
13
+ m(() => {
14
+ a(!0), o().then((i) => {
15
+ i != null && i.errorCode ? r(null) : r((i == null ? void 0 : i.data) ?? null);
16
+ }).catch(() => {
17
+ r(null);
18
+ }).finally(() => a(!1));
19
+ }, [o]), m(() => {
20
+ if (c && g) {
21
+ const i = () => {
22
+ o().then((t) => {
23
+ t != null && t.errorCode ? r(null) : r((t == null ? void 0 : t.data) ?? null);
24
+ }).catch(() => {
25
+ r(null);
26
+ });
27
+ };
28
+ i();
29
+ const n = setInterval(() => {
30
+ i();
31
+ }, 6e4);
32
+ return () => clearInterval(n);
33
+ }
34
+ }, [c, g, o]);
35
+ const y = (i) => {
36
+ if (!d)
37
+ throw new Error("requestSignUp is not defined.");
38
+ return a(!0), d(i).finally(() => a(!1));
39
+ }, I = (i) => {
40
+ if (!f)
41
+ throw new Error("requestSignIn is not defined.");
42
+ return a(!0), f(i).then((n) => n != null && n.errorCode ? n : o().then((t) => (t != null && t.errorCode ? (r(null), n.withError(t.errorCode, t.message)) : r((t == null ? void 0 : t.data) ?? null), n)).catch(() => (r(null), n.withError(500, "Sign in error.")))).finally(() => a(!1));
43
+ }, S = () => {
44
+ if (!h)
45
+ throw new Error("requestSignInAsGuest is not defined.");
46
+ a(!0);
47
+ const i = localStorage.getItem(u);
48
+ return h(i).then((n) => {
49
+ var t;
50
+ return n != null && n.errorCode ? n : (localStorage.setItem(u, ((t = n == null ? void 0 : n.data) == null ? void 0 : t.id) || ""), o().then((e) => (e != null && e.errorCode ? (r(null), n.withError(e.errorCode, e.message)) : r((e == null ? void 0 : e.data) ?? null), n)).catch(() => (r(null), n.withError(500, "Sign in error."))));
51
+ }).finally(() => a(!1));
52
+ }, P = () => {
53
+ v().then(() => {
54
+ r(null);
55
+ });
56
+ };
57
+ return /* @__PURE__ */ j.jsx(
58
+ C.Provider,
59
+ {
60
+ value: {
61
+ user: l,
62
+ isAuthenticated: c,
63
+ logout: P,
64
+ signUp: y,
65
+ signIn: I,
66
+ signInAsGuest: S,
67
+ isLoading: x
68
+ },
69
+ children: E
70
+ }
71
+ );
72
+ }, R = () => {
73
+ const o = b(C);
74
+ if (o === void 0)
75
+ throw new Error("useSession must be used within a SessionProvider");
76
+ return o;
77
+ };
78
+ export {
79
+ K as SessionProvider,
80
+ R as useSession
81
+ };
@@ -0,0 +1,4 @@
1
+ export * from './AnalyticsContext';
2
+ export * from './MenuContext';
3
+ export * from './RouterContext';
4
+ export * from './SessionsContext';
@@ -0,0 +1,18 @@
1
+ import { AnalyticsContext as t, AnalyticsProvider as r, PAGE_VISIT_EVENT as s } from "./AnalyticsContext.js";
2
+ import { MenuContext as u, MenuContextProvider as i, useMenu as x } from "./MenuContext.js";
3
+ import { RouterContext as a, getBasePath as f, isAbsoluteUrl as l, useRouter as m } from "./RouterContext.js";
4
+ import { SessionProvider as A, useSession as C } from "./SessionsContext.js";
5
+ export {
6
+ t as AnalyticsContext,
7
+ r as AnalyticsProvider,
8
+ u as MenuContext,
9
+ i as MenuContextProvider,
10
+ s as PAGE_VISIT_EVENT,
11
+ a as RouterContext,
12
+ A as SessionProvider,
13
+ f as getBasePath,
14
+ l as isAbsoluteUrl,
15
+ x as useMenu,
16
+ m as useRouter,
17
+ C as useSession
18
+ };
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare function withPageVisit<T extends object>(WrappedComponent: React.ComponentType<T>, id: string): (props: T) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { j as e } from "../jsx-runtime-Drh4NO5G.js";
2
+ import i from "react";
3
+ import { Events as m } from "../Common/Events.js";
4
+ import { PAGE_VISIT_EVENT as f } from "../Context/AnalyticsContext.js";
5
+ function E(t, r) {
6
+ return (o) => (i.useEffect(() => {
7
+ m.publish(f, { id: r });
8
+ }, []), /* @__PURE__ */ e.jsx(t, { ...o }));
9
+ }
10
+ export {
11
+ E as withPageVisit
12
+ };
@@ -0,0 +1 @@
1
+ export * from './WithPageVisit';
@@ -0,0 +1,4 @@
1
+ import { withPageVisit as e } from "./WithPageVisit.js";
2
+ export {
3
+ e as withPageVisit
4
+ };
@@ -0,0 +1,4 @@
1
+ export * from './useDebouncedValue';
2
+ export * from './usePageVisibility';
3
+ export * from './usePaginatedQuery';
4
+ export * from './useQuery';