@pagamio/frontend-commons-lib 0.8.295 → 0.8.297
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.
|
@@ -24,8 +24,9 @@ export class TokenManager {
|
|
|
24
24
|
baseUrl;
|
|
25
25
|
refreshEndpoint;
|
|
26
26
|
constructor(config) {
|
|
27
|
+
const isSecureContext = typeof window !== 'undefined' && window.location.protocol === 'https:';
|
|
27
28
|
this.cookieOptions = {
|
|
28
|
-
secure:
|
|
29
|
+
secure: isSecureContext,
|
|
29
30
|
sameSite: 'lax',
|
|
30
31
|
path: '/',
|
|
31
32
|
...config.cookieOptions,
|
|
@@ -5,6 +5,8 @@ export interface PartialToastData {
|
|
|
5
5
|
title?: string;
|
|
6
6
|
message: string;
|
|
7
7
|
variant: ToastVariant;
|
|
8
|
+
/** Auto-dismiss duration in ms. Defaults to 3000 for success, 5000 for error/info. */
|
|
9
|
+
duration?: number;
|
|
8
10
|
}
|
|
9
11
|
interface ToastContextProps {
|
|
10
12
|
addToast: (props: PartialToastData) => void;
|
|
@@ -15,13 +15,13 @@ export const ToastProvider = ({ children }) => {
|
|
|
15
15
|
setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));
|
|
16
16
|
}, []);
|
|
17
17
|
const addToast = useCallback((props) => {
|
|
18
|
-
const { message, title = '', variant = 'info' } = props;
|
|
18
|
+
const { message, title = '', variant = 'info', duration } = props;
|
|
19
19
|
const id = Date.now();
|
|
20
20
|
setToasts((prevToasts) => [...prevToasts, { id, title, message, variant }]);
|
|
21
|
-
|
|
21
|
+
const autoDismissMs = duration ?? (variant === 'success' ? 3000 : 5000);
|
|
22
22
|
setTimeout(() => {
|
|
23
23
|
removeToast(id);
|
|
24
|
-
},
|
|
24
|
+
}, autoDismissMs);
|
|
25
25
|
}, [removeToast]);
|
|
26
26
|
// Wrap the value in useMemo so it remains stable unless addToast changes
|
|
27
27
|
const contextValue = useMemo(() => ({ addToast }), [addToast]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.297",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|