ptechcore_ui 1.0.3 → 1.0.4
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/dist/index.cjs +13 -2
- package/dist/index.d.cts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +10 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,9 @@ __export(index_exports, {
|
|
|
36
36
|
SessionProvider: () => SessionProvider,
|
|
37
37
|
ThemeProvider: () => ThemeContext_default,
|
|
38
38
|
ToastContainer: () => Toast_default,
|
|
39
|
-
ToastProvider: () => ToastProvider
|
|
39
|
+
ToastProvider: () => ToastProvider,
|
|
40
|
+
useSession: () => useSession,
|
|
41
|
+
useToast: () => useToast
|
|
40
42
|
});
|
|
41
43
|
module.exports = __toCommonJS(index_exports);
|
|
42
44
|
|
|
@@ -1267,6 +1269,13 @@ var AuthServices = {
|
|
|
1267
1269
|
// src/contexts/SessionContext.tsx
|
|
1268
1270
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1269
1271
|
var SessionContext = (0, import_react5.createContext)(void 0);
|
|
1272
|
+
var useSession = () => {
|
|
1273
|
+
const context = (0, import_react5.useContext)(SessionContext);
|
|
1274
|
+
if (!context) {
|
|
1275
|
+
throw new Error("useSession must be used within a SessionProvider");
|
|
1276
|
+
}
|
|
1277
|
+
return context;
|
|
1278
|
+
};
|
|
1270
1279
|
var SessionProvider = ({ children }) => {
|
|
1271
1280
|
const [token, setToken] = (0, import_react5.useState)(localStorage.getItem("token"));
|
|
1272
1281
|
const [loggedUser, setLoggedUser] = (0, import_react5.useState)(null);
|
|
@@ -1392,5 +1401,7 @@ var Pages_default = Pages;
|
|
|
1392
1401
|
SessionProvider,
|
|
1393
1402
|
ThemeProvider,
|
|
1394
1403
|
ToastContainer,
|
|
1395
|
-
ToastProvider
|
|
1404
|
+
ToastProvider,
|
|
1405
|
+
useSession,
|
|
1406
|
+
useToast
|
|
1396
1407
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,36 @@ declare const RewiseLayout: React.FC<PrivateLayoutProps>;
|
|
|
29
29
|
|
|
30
30
|
declare const ToastContainer: React.FC;
|
|
31
31
|
|
|
32
|
+
interface User {
|
|
33
|
+
id: number;
|
|
34
|
+
last_login: string | null;
|
|
35
|
+
is_superuser: boolean;
|
|
36
|
+
username: string;
|
|
37
|
+
first_name: string;
|
|
38
|
+
last_name: string;
|
|
39
|
+
email: string;
|
|
40
|
+
is_staff: boolean;
|
|
41
|
+
is_active: boolean;
|
|
42
|
+
date_joined: string;
|
|
43
|
+
is_deleted: boolean;
|
|
44
|
+
deleted_at: string | null;
|
|
45
|
+
phonenumber: string | null;
|
|
46
|
+
groups: any[];
|
|
47
|
+
user_permissions: any[];
|
|
48
|
+
centers_access?: Array<{
|
|
49
|
+
id: number;
|
|
50
|
+
permissions?: number[];
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface SessionContextType {
|
|
55
|
+
isAuthenticated: boolean;
|
|
56
|
+
token: string | null;
|
|
57
|
+
loggedUser: User | null;
|
|
58
|
+
login: (token: string) => void;
|
|
59
|
+
logout: () => void;
|
|
60
|
+
}
|
|
61
|
+
declare const useSession: () => SessionContextType;
|
|
32
62
|
declare const SessionProvider: ({ children }: {
|
|
33
63
|
children: ReactNode;
|
|
34
64
|
}) => react_jsx_runtime.JSX.Element;
|
|
@@ -38,6 +68,22 @@ interface ThemeProviderProps {
|
|
|
38
68
|
}
|
|
39
69
|
declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
40
70
|
|
|
71
|
+
interface Toast {
|
|
72
|
+
id: string;
|
|
73
|
+
message: string;
|
|
74
|
+
type: 'success' | 'error' | 'warning' | 'info';
|
|
75
|
+
duration?: number;
|
|
76
|
+
}
|
|
77
|
+
interface ToastContextType {
|
|
78
|
+
toasts: Toast[];
|
|
79
|
+
addToast: (toast: Omit<Toast, 'id'>) => void;
|
|
80
|
+
removeToast: (id: string) => void;
|
|
81
|
+
success: (message: string, duration?: number) => void;
|
|
82
|
+
error: (message: string, duration?: number) => void;
|
|
83
|
+
warning: (message: string, duration?: number) => void;
|
|
84
|
+
info: (message: string, duration?: number) => void;
|
|
85
|
+
}
|
|
86
|
+
declare const useToast: () => ToastContextType;
|
|
41
87
|
interface ToastProviderProps {
|
|
42
88
|
children: ReactNode;
|
|
43
89
|
}
|
|
@@ -59,4 +105,4 @@ interface PagesProps {
|
|
|
59
105
|
}
|
|
60
106
|
declare const Pages: React.FC<PagesProps>;
|
|
61
107
|
|
|
62
|
-
export { type MenuItem, Pages, PrimaryButton, RewiseLayout, SecondaryButton, SessionProvider, ThemeProvider, ToastContainer, ToastProvider };
|
|
108
|
+
export { type MenuItem, Pages, PrimaryButton, RewiseLayout, SecondaryButton, SessionProvider, ThemeProvider, ToastContainer, ToastProvider, useSession, useToast };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,36 @@ declare const RewiseLayout: React.FC<PrivateLayoutProps>;
|
|
|
29
29
|
|
|
30
30
|
declare const ToastContainer: React.FC;
|
|
31
31
|
|
|
32
|
+
interface User {
|
|
33
|
+
id: number;
|
|
34
|
+
last_login: string | null;
|
|
35
|
+
is_superuser: boolean;
|
|
36
|
+
username: string;
|
|
37
|
+
first_name: string;
|
|
38
|
+
last_name: string;
|
|
39
|
+
email: string;
|
|
40
|
+
is_staff: boolean;
|
|
41
|
+
is_active: boolean;
|
|
42
|
+
date_joined: string;
|
|
43
|
+
is_deleted: boolean;
|
|
44
|
+
deleted_at: string | null;
|
|
45
|
+
phonenumber: string | null;
|
|
46
|
+
groups: any[];
|
|
47
|
+
user_permissions: any[];
|
|
48
|
+
centers_access?: Array<{
|
|
49
|
+
id: number;
|
|
50
|
+
permissions?: number[];
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface SessionContextType {
|
|
55
|
+
isAuthenticated: boolean;
|
|
56
|
+
token: string | null;
|
|
57
|
+
loggedUser: User | null;
|
|
58
|
+
login: (token: string) => void;
|
|
59
|
+
logout: () => void;
|
|
60
|
+
}
|
|
61
|
+
declare const useSession: () => SessionContextType;
|
|
32
62
|
declare const SessionProvider: ({ children }: {
|
|
33
63
|
children: ReactNode;
|
|
34
64
|
}) => react_jsx_runtime.JSX.Element;
|
|
@@ -38,6 +68,22 @@ interface ThemeProviderProps {
|
|
|
38
68
|
}
|
|
39
69
|
declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
40
70
|
|
|
71
|
+
interface Toast {
|
|
72
|
+
id: string;
|
|
73
|
+
message: string;
|
|
74
|
+
type: 'success' | 'error' | 'warning' | 'info';
|
|
75
|
+
duration?: number;
|
|
76
|
+
}
|
|
77
|
+
interface ToastContextType {
|
|
78
|
+
toasts: Toast[];
|
|
79
|
+
addToast: (toast: Omit<Toast, 'id'>) => void;
|
|
80
|
+
removeToast: (id: string) => void;
|
|
81
|
+
success: (message: string, duration?: number) => void;
|
|
82
|
+
error: (message: string, duration?: number) => void;
|
|
83
|
+
warning: (message: string, duration?: number) => void;
|
|
84
|
+
info: (message: string, duration?: number) => void;
|
|
85
|
+
}
|
|
86
|
+
declare const useToast: () => ToastContextType;
|
|
41
87
|
interface ToastProviderProps {
|
|
42
88
|
children: ReactNode;
|
|
43
89
|
}
|
|
@@ -59,4 +105,4 @@ interface PagesProps {
|
|
|
59
105
|
}
|
|
60
106
|
declare const Pages: React.FC<PagesProps>;
|
|
61
107
|
|
|
62
|
-
export { type MenuItem, Pages, PrimaryButton, RewiseLayout, SecondaryButton, SessionProvider, ThemeProvider, ToastContainer, ToastProvider };
|
|
108
|
+
export { type MenuItem, Pages, PrimaryButton, RewiseLayout, SecondaryButton, SessionProvider, ThemeProvider, ToastContainer, ToastProvider, useSession, useToast };
|
package/dist/index.js
CHANGED
|
@@ -1238,6 +1238,13 @@ var AuthServices = {
|
|
|
1238
1238
|
// src/contexts/SessionContext.tsx
|
|
1239
1239
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1240
1240
|
var SessionContext = createContext3(void 0);
|
|
1241
|
+
var useSession = () => {
|
|
1242
|
+
const context = useContext3(SessionContext);
|
|
1243
|
+
if (!context) {
|
|
1244
|
+
throw new Error("useSession must be used within a SessionProvider");
|
|
1245
|
+
}
|
|
1246
|
+
return context;
|
|
1247
|
+
};
|
|
1241
1248
|
var SessionProvider = ({ children }) => {
|
|
1242
1249
|
const [token, setToken] = useState5(localStorage.getItem("token"));
|
|
1243
1250
|
const [loggedUser, setLoggedUser] = useState5(null);
|
|
@@ -1362,5 +1369,7 @@ export {
|
|
|
1362
1369
|
SessionProvider,
|
|
1363
1370
|
ThemeContext_default as ThemeProvider,
|
|
1364
1371
|
Toast_default as ToastContainer,
|
|
1365
|
-
ToastProvider
|
|
1372
|
+
ToastProvider,
|
|
1373
|
+
useSession,
|
|
1374
|
+
useToast
|
|
1366
1375
|
};
|