@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,10 @@
1
+ import { useDebouncedValue as o } from "./useDebouncedValue.js";
2
+ import { usePageVisibility as t } from "./usePageVisibility.js";
3
+ import { usePaginatedQuery as s } from "./usePaginatedQuery.js";
4
+ import { useQuery as f } from "./useQuery.js";
5
+ export {
6
+ o as useDebouncedValue,
7
+ t as usePageVisibility,
8
+ s as usePaginatedQuery,
9
+ f as useQuery
10
+ };
@@ -0,0 +1 @@
1
+ export declare function useDebouncedValue<T>(value: T, delay: number): [T, (value: T) => void];
@@ -0,0 +1,19 @@
1
+ import { useState as r, useEffect as i, useCallback as m } from "react";
2
+ let e;
3
+ function l(t, u) {
4
+ const [c, o] = r(t);
5
+ i(() => (e = setTimeout(() => {
6
+ o(t);
7
+ }, u), () => {
8
+ clearTimeout(e);
9
+ }), [t, u]);
10
+ const s = m((n) => {
11
+ clearTimeout(e), e = setTimeout(() => {
12
+ o(n);
13
+ }, u);
14
+ }, []);
15
+ return [c, s];
16
+ }
17
+ export {
18
+ l as useDebouncedValue
19
+ };
@@ -0,0 +1 @@
1
+ export declare const usePageVisibility: () => boolean;
@@ -0,0 +1,15 @@
1
+ import { useState as n, useEffect as s } from "react";
2
+ const o = () => {
3
+ const [i, t] = n(!document.hidden);
4
+ return s(() => {
5
+ const e = () => {
6
+ t(!document.hidden);
7
+ };
8
+ return document.addEventListener("visibilitychange", e), () => {
9
+ document.removeEventListener("visibilitychange", e);
10
+ };
11
+ }, []), i;
12
+ };
13
+ export {
14
+ o as usePageVisibility
15
+ };
@@ -0,0 +1,21 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { PagedModel, ResponseModel } from '../Model';
3
+ interface UsePaginatedQueryProps<Filter extends PagedModel, Response> {
4
+ queryFunction: (filter: Filter) => Promise<ResponseModel<Response[]>>;
5
+ initialFilter: Filter;
6
+ initialPage?: number;
7
+ }
8
+ interface PaginatedQueryResult<Filter extends PagedModel, Response> {
9
+ data: Response[];
10
+ loadData: (filter: Filter) => Promise<ResponseModel<Response[]>>;
11
+ filter: Filter | null;
12
+ currentPage: number;
13
+ totalItems: number;
14
+ totalPages: number;
15
+ isLoading: boolean;
16
+ error: string | null;
17
+ onPageChange: (page: number) => void;
18
+ setCurrentPage: Dispatch<SetStateAction<number>>;
19
+ }
20
+ export declare function usePaginatedQuery<Filter extends PagedModel, Response>({ queryFunction, initialPage, }: UsePaginatedQueryProps<Filter, Response>): PaginatedQueryResult<Filter, Response>;
21
+ export {};
@@ -0,0 +1,38 @@
1
+ import { useState as t, useCallback as u } from "react";
2
+ function T({
3
+ queryFunction: s,
4
+ initialPage: c = 1
5
+ }) {
6
+ const [g, i] = t([]), [n, d] = t(null), [P, l] = t(c), [m, C] = t(1), [b, f] = t(1), [h, r] = t(!1), [I] = t(null), o = u(
7
+ (a) => (d(a), r(!0), l(a.pageNumber || 1), s(a).then((e) => (i(e.data ?? []), C(e.totalCount || 0), f(
8
+ Math.ceil((e.totalCount || 0) / a.pageSize)
9
+ ), e)).finally(() => {
10
+ r(!1);
11
+ })),
12
+ [s]
13
+ ), D = u(
14
+ (a) => {
15
+ o(
16
+ Object.assign(n, {
17
+ pageNumber: a
18
+ })
19
+ );
20
+ },
21
+ [n, o]
22
+ );
23
+ return {
24
+ data: g,
25
+ loadData: o,
26
+ filter: n,
27
+ currentPage: P,
28
+ totalItems: m,
29
+ totalPages: b,
30
+ isLoading: h,
31
+ error: I,
32
+ onPageChange: D,
33
+ setCurrentPage: l
34
+ };
35
+ }
36
+ export {
37
+ T as usePaginatedQuery
38
+ };
@@ -0,0 +1,15 @@
1
+ import { ResponseModel } from '../Model';
2
+ interface UseQueryProps<Filter, Response> {
3
+ queryFunction: (filter: Filter) => Promise<ResponseModel<Response>>;
4
+ initialFilter: Filter;
5
+ }
6
+ interface QueryResult<Filter, Response> {
7
+ data?: Response;
8
+ loadData: (filter: Filter) => Promise<ResponseModel<Response>>;
9
+ filter: Filter | null;
10
+ isLoading: boolean;
11
+ isLoaded: boolean;
12
+ error: string | null;
13
+ }
14
+ export declare function useQuery<Filter, Response>({ queryFunction, }: UseQueryProps<Filter, Response>): QueryResult<Filter, Response>;
15
+ export {};
@@ -0,0 +1,22 @@
1
+ import { useState as t, useCallback as g } from "react";
2
+ function D({
3
+ queryFunction: a
4
+ }) {
5
+ const [n, o] = t(), [r, u] = t(null), [d, e] = t(!1), [c, i] = t(!1), [f] = t(null), L = g(
6
+ (s) => (u(s), e(!0), a(s).then((l) => (o(l.data), l)).finally(() => {
7
+ e(!1), i(!0);
8
+ })),
9
+ [a]
10
+ );
11
+ return {
12
+ data: n,
13
+ loadData: L,
14
+ filter: r,
15
+ isLoading: d,
16
+ isLoaded: c,
17
+ error: f
18
+ };
19
+ }
20
+ export {
21
+ D as useQuery
22
+ };
@@ -0,0 +1,5 @@
1
+ export declare class Credentials {
2
+ email: string;
3
+ password: string;
4
+ constructor(email: string, password: string);
5
+ }
@@ -0,0 +1,13 @@
1
+ var e = Object.defineProperty;
2
+ var i = (a, s, r) => s in a ? e(a, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[s] = r;
3
+ var t = (a, s, r) => i(a, typeof s != "symbol" ? s + "" : s, r);
4
+ class l {
5
+ constructor(s, r) {
6
+ t(this, "email");
7
+ t(this, "password");
8
+ this.email = s, this.password = r;
9
+ }
10
+ }
11
+ export {
12
+ l as Credentials
13
+ };
@@ -0,0 +1,28 @@
1
+ import { NavigationTarget } from './Router';
2
+ export interface MenuItemBase {
3
+ title: string;
4
+ allowedRoles?: string[];
5
+ allowedPermissions?: string[];
6
+ target?: NavigationTarget;
7
+ }
8
+ export interface MenuSubItem extends MenuItemBase {
9
+ location: string;
10
+ }
11
+ export interface SubMenu {
12
+ accessibleFrom: string;
13
+ items: MenuSubItem[];
14
+ }
15
+ export interface MenuItem extends MenuItemBase {
16
+ type: "location" | "dropdown";
17
+ location?: string;
18
+ children?: MenuSubItem[];
19
+ }
20
+ export interface MenuOption extends MenuItemBase {
21
+ accessibleFrom?: string;
22
+ location: string;
23
+ }
24
+ export interface Menu {
25
+ items: MenuItem[];
26
+ subMenu: SubMenu[];
27
+ options: MenuOption[];
28
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,5 @@
1
+ export declare class PagedModel {
2
+ pageNumber: number;
3
+ pageSize: number;
4
+ constructor(pageNumber?: number, pageSize?: number);
5
+ }
@@ -0,0 +1,8 @@
1
+ class a {
2
+ constructor(e = 1, s = 20) {
3
+ this.pageNumber = e, this.pageSize = s;
4
+ }
5
+ }
6
+ export {
7
+ a as PagedModel
8
+ };
@@ -0,0 +1,10 @@
1
+ export declare class ResponseModel<Type> {
2
+ transactionId?: string | undefined;
3
+ errorCode?: number | undefined;
4
+ message?: string | undefined;
5
+ totalCount?: number | undefined;
6
+ data?: Type | undefined;
7
+ constructor(transactionId?: string | undefined, errorCode?: number | undefined, message?: string | undefined, totalCount?: number | undefined, data?: Type | undefined);
8
+ withData(data: Type): this;
9
+ withError(errorCode: number, errorMessage: string): this;
10
+ }
@@ -0,0 +1,14 @@
1
+ class a {
2
+ constructor(t, s, r, e, i) {
3
+ this.transactionId = t, this.errorCode = s, this.message = r, this.totalCount = e, this.data = i;
4
+ }
5
+ withData(t) {
6
+ return this.data = t, this;
7
+ }
8
+ withError(t, s) {
9
+ return this.errorCode = t, this.message = s, this;
10
+ }
11
+ }
12
+ export {
13
+ a as ResponseModel
14
+ };
@@ -0,0 +1,3 @@
1
+ export type Target = "_blank" | "_self" | "_parent" | "_top";
2
+ export type NavigationTarget = "newWindow" | "sameWindow" | "parentContainer" | "rootContainer";
3
+ export declare const mapToWebTarget: (target?: NavigationTarget) => "_blank" | "_self" | "_parent" | "_top";
@@ -0,0 +1,9 @@
1
+ const e = {
2
+ newWindow: "_blank",
3
+ sameWindow: "_self",
4
+ parentContainer: "_parent",
5
+ rootContainer: "_top"
6
+ }, o = (n) => n && e[n] || "_self";
7
+ export {
8
+ o as mapToWebTarget
9
+ };
@@ -0,0 +1,8 @@
1
+ export interface SessionUser {
2
+ id: string;
3
+ user: string;
4
+ name: string;
5
+ email: string;
6
+ roles: string[];
7
+ permissions: string[];
8
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,4 @@
1
+ export interface singInResponse {
2
+ id?: string;
3
+ redirect: string;
4
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,6 @@
1
+ import { Credentials } from './Credentials';
2
+ export declare class UserRegistration extends Credentials {
3
+ name: string;
4
+ passwordConfirmation: string;
5
+ constructor(name: string, email: string, password: string, passwordConfirmation: string);
6
+ }
@@ -0,0 +1,9 @@
1
+ import { Credentials as o } from "./Credentials.js";
2
+ class a extends o {
3
+ constructor(s, r, t, e) {
4
+ super(r, t), this.name = s, this.passwordConfirmation = e;
5
+ }
6
+ }
7
+ export {
8
+ a as UserRegistration
9
+ };
@@ -0,0 +1,8 @@
1
+ export * from './Credentials';
2
+ export * from './Menu';
3
+ export * from './PagedModel';
4
+ export * from './ResponseModel';
5
+ export * from './Router';
6
+ export * from './SessionUser';
7
+ export * from './SingInResponse';
8
+ export * from './UserRegistration';
@@ -0,0 +1,12 @@
1
+ import { Credentials as r } from "./Credentials.js";
2
+ import { PagedModel as p } from "./PagedModel.js";
3
+ import { ResponseModel as a } from "./ResponseModel.js";
4
+ import { mapToWebTarget as s } from "./Router.js";
5
+ import { UserRegistration as d } from "./UserRegistration.js";
6
+ export {
7
+ r as Credentials,
8
+ p as PagedModel,
9
+ a as ResponseModel,
10
+ d as UserRegistration,
11
+ s as mapToWebTarget
12
+ };
@@ -0,0 +1,144 @@
1
+ import { u as A, c as E } from "./ThemeProvider-Q3gZ4GF2.js";
2
+ import * as K from "react";
3
+ import { useRef as I, useContext as w, useEffect as L } from "react";
4
+ import { N as q, u as U, S as R, T as H, a as _, m as F, b as M, c as V, d as W } from "./NavLink-ebvp1HCw.js";
5
+ import { d as Y, a as z, q as G } from "./useWindow-rGE2GXIv.js";
6
+ import { u as J } from "./useMergedRefs-BpAaCckn.js";
7
+ import { j as p } from "./jsx-runtime-Drh4NO5G.js";
8
+ const O = /* @__PURE__ */ K.createContext(null);
9
+ O.displayName = "CardHeaderContext";
10
+ const Q = ["as", "onSelect", "activeKey", "role", "onKeyDown"];
11
+ function X(t, n) {
12
+ if (t == null) return {};
13
+ var o = {};
14
+ for (var r in t) if ({}.hasOwnProperty.call(t, r)) {
15
+ if (n.indexOf(r) >= 0) continue;
16
+ o[r] = t[r];
17
+ }
18
+ return o;
19
+ }
20
+ const P = () => {
21
+ }, S = Y("event-key"), D = /* @__PURE__ */ K.forwardRef((t, n) => {
22
+ let {
23
+ // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
24
+ as: o = "div",
25
+ onSelect: r,
26
+ activeKey: s,
27
+ role: u,
28
+ onKeyDown: N
29
+ } = t, y = X(t, Q);
30
+ const $ = U(), v = I(!1), C = w(R), c = w(H);
31
+ let i, f;
32
+ c && (u = u || "tablist", s = c.activeKey, i = c.getControlledId, f = c.getControllerId);
33
+ const l = I(null), d = (e) => {
34
+ const a = l.current;
35
+ if (!a) return null;
36
+ const g = G(a, `[${S}]:not([aria-disabled=true])`), h = a.querySelector("[aria-selected=true]");
37
+ if (!h || h !== document.activeElement) return null;
38
+ const j = g.indexOf(h);
39
+ if (j === -1) return null;
40
+ let x = j + e;
41
+ return x >= g.length && (x = 0), x < 0 && (x = g.length - 1), g[x];
42
+ }, m = (e, a) => {
43
+ e != null && (r == null || r(e, a), C == null || C(e, a));
44
+ }, b = (e) => {
45
+ if (N == null || N(e), !c)
46
+ return;
47
+ let a;
48
+ switch (e.key) {
49
+ case "ArrowLeft":
50
+ case "ArrowUp":
51
+ a = d(-1);
52
+ break;
53
+ case "ArrowRight":
54
+ case "ArrowDown":
55
+ a = d(1);
56
+ break;
57
+ default:
58
+ return;
59
+ }
60
+ a && (e.preventDefault(), m(a.dataset[z("EventKey")] || null, e), v.current = !0, $());
61
+ };
62
+ L(() => {
63
+ if (l.current && v.current) {
64
+ const e = l.current.querySelector(`[${S}][aria-selected=true]`);
65
+ e == null || e.focus();
66
+ }
67
+ v.current = !1;
68
+ });
69
+ const B = J(n, l);
70
+ return /* @__PURE__ */ p.jsx(R.Provider, {
71
+ value: m,
72
+ children: /* @__PURE__ */ p.jsx(_.Provider, {
73
+ value: {
74
+ role: u,
75
+ // used by NavLink to determine it's role
76
+ activeKey: F(s),
77
+ getControlledId: i || P,
78
+ getControllerId: f || P
79
+ },
80
+ children: /* @__PURE__ */ p.jsx(o, Object.assign({}, y, {
81
+ onKeyDown: b,
82
+ ref: B,
83
+ role: u
84
+ }))
85
+ })
86
+ });
87
+ });
88
+ D.displayName = "Nav";
89
+ const Z = Object.assign(D, {
90
+ Item: q
91
+ }), T = /* @__PURE__ */ K.forwardRef(({
92
+ className: t,
93
+ bsPrefix: n,
94
+ as: o = "div",
95
+ ...r
96
+ }, s) => (n = A(n, "nav-item"), /* @__PURE__ */ p.jsx(o, {
97
+ ref: s,
98
+ className: E(t, n),
99
+ ...r
100
+ })));
101
+ T.displayName = "NavItem";
102
+ const k = /* @__PURE__ */ K.forwardRef((t, n) => {
103
+ const {
104
+ as: o = "div",
105
+ bsPrefix: r,
106
+ variant: s,
107
+ fill: u = !1,
108
+ justify: N = !1,
109
+ navbar: y,
110
+ navbarScroll: $,
111
+ className: v,
112
+ activeKey: C,
113
+ ...c
114
+ } = V(t, {
115
+ activeKey: "onSelect"
116
+ }), i = A(r, "nav");
117
+ let f, l, d = !1;
118
+ const m = w(W), b = w(O);
119
+ return m ? (f = m.bsPrefix, d = y ?? !0) : b && ({
120
+ cardHeaderBsPrefix: l
121
+ } = b), /* @__PURE__ */ p.jsx(Z, {
122
+ as: o,
123
+ ref: n,
124
+ activeKey: C,
125
+ className: E(v, {
126
+ [i]: !d,
127
+ [`${f}-nav`]: d,
128
+ [`${f}-nav-scroll`]: d && $,
129
+ [`${l}-${s}`]: !!l,
130
+ [`${i}-${s}`]: !!s,
131
+ [`${i}-fill`]: u,
132
+ [`${i}-justified`]: N
133
+ }),
134
+ ...c
135
+ });
136
+ });
137
+ k.displayName = "Nav";
138
+ const se = Object.assign(k, {
139
+ Item: T,
140
+ Link: M
141
+ });
142
+ export {
143
+ se as N
144
+ };