@nocios/crudify-ui 4.1.20 → 4.1.21

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.d.mts CHANGED
@@ -6,6 +6,7 @@ import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './inde
6
6
  export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-BwF68SOh.mjs';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
8
  import { ReactNode } from 'react';
9
+ import { ThemeOptions } from '@mui/material';
9
10
  export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-DEn4aqs6.mjs';
10
11
  export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-C3iWgM1z.mjs';
11
12
 
@@ -69,6 +70,31 @@ declare function useSessionContext(): SessionContextType;
69
70
  */
70
71
  declare function SessionDebugInfo(): react_jsx_runtime.JSX.Element;
71
72
 
73
+ type CrudifyThemeProviderProps = {
74
+ children: ReactNode;
75
+ defaultTheme?: ThemeOptions;
76
+ disableCssBaseline?: boolean;
77
+ };
78
+ /**
79
+ * Provider de tema para aplicaciones Crudify
80
+ * Lee automáticamente la cookie "theme" y aplica el tema a Material-UI
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * <CrudifyThemeProvider>
85
+ * <App />
86
+ * </CrudifyThemeProvider>
87
+ * ```
88
+ *
89
+ * @example Con tema por defecto personalizado
90
+ * ```tsx
91
+ * <CrudifyThemeProvider defaultTheme={{ palette: { mode: 'dark' } }}>
92
+ * <App />
93
+ * </CrudifyThemeProvider>
94
+ * ```
95
+ */
96
+ declare function CrudifyThemeProvider({ children, defaultTheme, disableCssBaseline }: CrudifyThemeProviderProps): react_jsx_runtime.JSX.Element;
97
+
72
98
  interface ProtectedRouteProps {
73
99
  children: ReactNode;
74
100
  /**
@@ -193,4 +219,4 @@ declare const validateInternalRedirect: (path: string, defaultPath?: string) =>
193
219
  */
194
220
  declare const extractSafeRedirectFromUrl: (searchParams: URLSearchParams | string, defaultPath?: string) => string;
195
221
 
196
- export { AuthRoute, type AuthRouteProps, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, TokenData, UseSessionOptions, extractSafeRedirectFromUrl, useSessionContext, validateInternalRedirect };
222
+ export { AuthRoute, type AuthRouteProps, CrudifyThemeProvider, type CrudifyThemeProviderProps, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, TokenData, UseSessionOptions, extractSafeRedirectFromUrl, useSessionContext, validateInternalRedirect };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { U as UseSessionOptions, T as TokenData, L as LoginResult } from './inde
6
6
  export { a as SessionConfig, S as SessionManager, d as SessionState, c as StorageType, b as TokenStorage, j as UseAuthReturn, l as UseDataReturn, g as UseUserDataOptions, f as UseUserDataReturn, h as UserData, i as useAuth, n as useCrudifyWithNotifications, k as useData, u as useSession, e as useUserData, m as useUserProfile } from './index-Fkm9ErmY.js';
7
7
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
8
  import { ReactNode } from 'react';
9
+ import { ThemeOptions } from '@mui/material';
9
10
  export { E as ERROR_CODES, j as ERROR_SEVERITY_MAP, n as ErrorCode, o as ErrorSeverity, q as ErrorTranslationConfig, P as ParsedError, m as createErrorTranslator, d as decodeJwtSafely, a as getCookie, g as getCurrentUserEmail, f as getErrorMessage, h as handleCrudifyError, i as isTokenExpired, p as parseApiError, e as parseJavaScriptError, c as parseTransactionError, b as secureLocalStorage, s as secureSessionStorage, l as translateError, t as translateErrorCode, k as translateErrorCodes } from './errorTranslation-DdqZg8JD.js';
10
11
  export { G as GlobalNotificationProvider, a as GlobalNotificationProviderProps, N as Notification, b as NotificationSeverity, u as useGlobalNotification } from './GlobalNotificationProvider-C3iWgM1z.js';
11
12
 
@@ -69,6 +70,31 @@ declare function useSessionContext(): SessionContextType;
69
70
  */
70
71
  declare function SessionDebugInfo(): react_jsx_runtime.JSX.Element;
71
72
 
73
+ type CrudifyThemeProviderProps = {
74
+ children: ReactNode;
75
+ defaultTheme?: ThemeOptions;
76
+ disableCssBaseline?: boolean;
77
+ };
78
+ /**
79
+ * Provider de tema para aplicaciones Crudify
80
+ * Lee automáticamente la cookie "theme" y aplica el tema a Material-UI
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * <CrudifyThemeProvider>
85
+ * <App />
86
+ * </CrudifyThemeProvider>
87
+ * ```
88
+ *
89
+ * @example Con tema por defecto personalizado
90
+ * ```tsx
91
+ * <CrudifyThemeProvider defaultTheme={{ palette: { mode: 'dark' } }}>
92
+ * <App />
93
+ * </CrudifyThemeProvider>
94
+ * ```
95
+ */
96
+ declare function CrudifyThemeProvider({ children, defaultTheme, disableCssBaseline }: CrudifyThemeProviderProps): react_jsx_runtime.JSX.Element;
97
+
72
98
  interface ProtectedRouteProps {
73
99
  children: ReactNode;
74
100
  /**
@@ -193,4 +219,4 @@ declare const validateInternalRedirect: (path: string, defaultPath?: string) =>
193
219
  */
194
220
  declare const extractSafeRedirectFromUrl: (searchParams: URLSearchParams | string, defaultPath?: string) => string;
195
221
 
196
- export { AuthRoute, type AuthRouteProps, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, TokenData, UseSessionOptions, extractSafeRedirectFromUrl, useSessionContext, validateInternalRedirect };
222
+ export { AuthRoute, type AuthRouteProps, CrudifyThemeProvider, type CrudifyThemeProviderProps, LoginResult, type NotificationOptions, ProtectedRoute, type ProtectedRouteProps, SessionDebugInfo, SessionLoadingScreen, type SessionLoadingScreenProps, SessionProvider, type SessionProviderProps, TokenData, UseSessionOptions, extractSafeRedirectFromUrl, useSessionContext, validateInternalRedirect };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkYQF2FVCXjs = require('./chunk-YQF2FVCX.js');var _chunkX3HSMDZ7js = require('./chunk-X3HSMDZ7.js');var _chunkTLGRXZCSjs = require('./chunk-TLGRXZCS.js');var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkAT74WV5Wjs = require('./chunk-AT74WV5W.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);var _reactrouterdom = require('react-router-dom');var _jsxruntime = require('react/jsx-runtime');var ne={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ae=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkYQF2FVCXjs = require('./chunk-YQF2FVCX.js');var _chunkX3HSMDZ7js = require('./chunk-X3HSMDZ7.js');var _chunkTLGRXZCSjs = require('./chunk-TLGRXZCS.js');var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkAT74WV5Wjs = require('./chunk-AT74WV5W.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var fe=(o={})=>{try{let e=_chunkAT74WV5Wjs.a.call(void 0, "theme");if(e){let r=JSON.parse(decodeURIComponent(e));return{...o,...r}}}catch(e){console.warn("Error parsing theme from cookie:",e)}return o};function de({children:o,defaultTheme:e={},disableCssBaseline:r=!1}){let t=_react.useMemo.call(void 0, ()=>{let i=fe(e);return _material.createTheme.call(void 0, i)},[e]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:t,children:[!r&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),o]})}var _reactrouterdom = require('react-router-dom');var ue={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ge=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
2
2
  @keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
5
5
  }
6
- `});function d({stage:e="loading",message:o}){let t=o||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, ae,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:ne}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var pe=/^[a-zA-Z0-9\-_./\?=&%#]+$/,fe=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],p= exports.validateInternalRedirect =(e,o="/")=>{if(!e||typeof e!="string")return o;let r=e.trim();if(!r)return o;if(!r.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",e),o;if(!pe.test(r))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",e),o;let t=r.toLowerCase();for(let i of fe)if(i.test(t))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",e),o;let s=r.split("?")[0].split("/").filter(Boolean);if(s.length===0)return r;for(let i of s)if(i===".."||i.includes(":")||i.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",i),o;return r},l= exports.extractSafeRedirectFromUrl =(e,o="/")=>{try{let t=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!t)return o;let s=decodeURIComponent(t);return p(s,o)}catch(r){return console.warn("\u{1F6A8} Error parsing redirect parameter:",r),o}};function x({children:e,loadingComponent:o,loginPath:r="/login"}){let{isAuthenticated:t,isLoading:s,isInitialized:i,tokens:n,error:y}=_chunkTLGRXZCSjs.g.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!i||s)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o||_jsxruntime.jsx.call(void 0, d,{stage:"validating-session"})});let P=t&&_optionalChain([n, 'optionalAccess', _2 => _2.accessToken])&&n.accessToken.length>0;if(y||!t||!P){n&&(!n.accessToken||n.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let h=u.pathname+u.search,C=p(h),L=encodeURIComponent(C);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${r}?redirect=${L}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}function S({children:e,redirectTo:o="/"}){let{isAuthenticated:r}=_chunkTLGRXZCSjs.g.call(void 0, ),t=_reactrouterdom.useLocation.call(void 0, );if(r){let s=new URLSearchParams(t.search),i=l(s,o);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:i,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e})}exports.AuthRoute = S; exports.CrudifyLogin = _chunkYQF2FVCXjs.a; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunkTLGRXZCSjs.d; exports.LoginComponent = _chunkYQF2FVCXjs.f; exports.POLICY_ACTIONS = _chunkYQF2FVCXjs.c; exports.PREFERRED_POLICY_ORDER = _chunkYQF2FVCXjs.d; exports.Policies = _chunkYQF2FVCXjs.e; exports.ProtectedRoute = x; exports.SessionDebugInfo = _chunkTLGRXZCSjs.h; exports.SessionLoadingScreen = d; exports.SessionManager = _chunkTLGRXZCSjs.b; exports.SessionProvider = _chunkTLGRXZCSjs.f; exports.SessionStatus = _chunkYQF2FVCXjs.g; exports.TokenStorage = _chunkTLGRXZCSjs.a; exports.UserProfileDisplay = _chunkYQF2FVCXjs.b; exports.createErrorTranslator = _chunkAT74WV5Wjs.e; exports.crudify = _crudifybrowser2.default; exports.decodeJwtSafely = _chunkAT74WV5Wjs.h; exports.extractSafeRedirectFromUrl = l; exports.getCookie = _chunkAT74WV5Wjs.a; exports.getCurrentUserEmail = _chunkAT74WV5Wjs.i; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkAT74WV5Wjs.j; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkAT74WV5Wjs.d; exports.translateErrorCode = _chunkAT74WV5Wjs.b; exports.translateErrorCodes = _chunkAT74WV5Wjs.c; exports.useAuth = _chunkX3HSMDZ7js.b; exports.useCrudifyWithNotifications = _chunkX3HSMDZ7js.d; exports.useData = _chunkX3HSMDZ7js.c; exports.useGlobalNotification = _chunkTLGRXZCSjs.e; exports.useSession = _chunkTLGRXZCSjs.c; exports.useSessionContext = _chunkTLGRXZCSjs.g; exports.useUserData = _chunkX3HSMDZ7js.a; exports.useUserProfile = _chunkTLGRXZCSjs.i; exports.validateInternalRedirect = p;
6
+ `});function m({stage:o="loading",message:e}){let t=e||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[o];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, ge,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:ue}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Re=/^[a-zA-Z0-9\-_./\?=&%#]+$/,ye=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],c= exports.validateInternalRedirect =(o,e="/")=>{if(!o||typeof o!="string")return e;let r=o.trim();if(!r)return e;if(!r.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",o),e;if(!Re.test(r))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",o),e;let t=r.toLowerCase();for(let s of ye)if(s.test(t))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",o),e;let i=r.split("?")[0].split("/").filter(Boolean);if(i.length===0)return r;for(let s of i)if(s===".."||s.includes(":")||s.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",s),e;return r},l= exports.extractSafeRedirectFromUrl =(o,e="/")=>{try{let t=(typeof o=="string"?new URLSearchParams(o):o).get("redirect");if(!t)return e;let i=decodeURIComponent(t);return c(i,e)}catch(r){return console.warn("\u{1F6A8} Error parsing redirect parameter:",r),e}};function R({children:o,loadingComponent:e,loginPath:r="/login"}){let{isAuthenticated:t,isLoading:i,isInitialized:s,tokens:n,error:h}=_chunkTLGRXZCSjs.g.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!s||i)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e||_jsxruntime.jsx.call(void 0, m,{stage:"validating-session"})});let P=t&&_optionalChain([n, 'optionalAccess', _2 => _2.accessToken])&&n.accessToken.length>0;if(h||!t||!P){n&&(!n.accessToken||n.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let C=u.pathname+u.search,v=c(C),T=encodeURIComponent(v);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${r}?redirect=${T}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o})}function S({children:o,redirectTo:e="/"}){let{isAuthenticated:r}=_chunkTLGRXZCSjs.g.call(void 0, ),t=_reactrouterdom.useLocation.call(void 0, );if(r){let i=new URLSearchParams(t.search),s=l(i,e);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:s,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:o})}exports.AuthRoute = S; exports.CrudifyLogin = _chunkYQF2FVCXjs.a; exports.CrudifyThemeProvider = de; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunkTLGRXZCSjs.d; exports.LoginComponent = _chunkYQF2FVCXjs.f; exports.POLICY_ACTIONS = _chunkYQF2FVCXjs.c; exports.PREFERRED_POLICY_ORDER = _chunkYQF2FVCXjs.d; exports.Policies = _chunkYQF2FVCXjs.e; exports.ProtectedRoute = R; exports.SessionDebugInfo = _chunkTLGRXZCSjs.h; exports.SessionLoadingScreen = m; exports.SessionManager = _chunkTLGRXZCSjs.b; exports.SessionProvider = _chunkTLGRXZCSjs.f; exports.SessionStatus = _chunkYQF2FVCXjs.g; exports.TokenStorage = _chunkTLGRXZCSjs.a; exports.UserProfileDisplay = _chunkYQF2FVCXjs.b; exports.createErrorTranslator = _chunkAT74WV5Wjs.e; exports.crudify = _crudifybrowser2.default; exports.decodeJwtSafely = _chunkAT74WV5Wjs.h; exports.extractSafeRedirectFromUrl = l; exports.getCookie = _chunkAT74WV5Wjs.a; exports.getCurrentUserEmail = _chunkAT74WV5Wjs.i; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkAT74WV5Wjs.j; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkAT74WV5Wjs.d; exports.translateErrorCode = _chunkAT74WV5Wjs.b; exports.translateErrorCodes = _chunkAT74WV5Wjs.c; exports.useAuth = _chunkX3HSMDZ7js.b; exports.useCrudifyWithNotifications = _chunkX3HSMDZ7js.d; exports.useData = _chunkX3HSMDZ7js.c; exports.useGlobalNotification = _chunkTLGRXZCSjs.e; exports.useSession = _chunkTLGRXZCSjs.c; exports.useSessionContext = _chunkTLGRXZCSjs.g; exports.useUserData = _chunkX3HSMDZ7js.a; exports.useUserProfile = _chunkTLGRXZCSjs.i; exports.validateInternalRedirect = c;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import{a as J,b as $,c as K,d as Z,e as Q,f as X,g as j}from"./chunk-ZA2SJDMK.mjs";import{a as ee,b as oe,c as re,d as se}from"./chunk-KNEHDX2M.mjs";import{a as E,b as k,c as D,d as I,e as _,f as z,g as a,h as F,i as Y}from"./chunk-CTDQEJAU.mjs";import{a as te,b as ie}from"./chunk-T2CPA46I.mjs";import{a as M,b as G,c as V,d as q,e as H,f as W,g as B}from"./chunk-BJ6PIVZR.mjs";import{a as v,b as A,c as U,d as T,e as b,h as N,i as w,j as O}from"./chunk-5JKS55SE.mjs";import{default as Ie}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";import{Navigate as de,useLocation as le}from"react-router-dom";import{Fragment as ce,jsx as c,jsxs as m}from"react/jsx-runtime";var ne={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ae=()=>c("style",{children:`
1
+ import{a as W,b as $,c as K,d as Z,e as Q,f as X,g as j}from"./chunk-ZA2SJDMK.mjs";import{a as ee,b as oe,c as re,d as se}from"./chunk-KNEHDX2M.mjs";import{a as E,b,c as N,d as I,e as _,f as F,g as a,h as M,i as Y}from"./chunk-CTDQEJAU.mjs";import{a as te,b as ie}from"./chunk-T2CPA46I.mjs";import{a as z,b as G,c as B,d as V,e as q,f as H,g as J}from"./chunk-BJ6PIVZR.mjs";import{a as d,b as L,c as A,d as k,e as U,h as O,i as D,j as w}from"./chunk-5JKS55SE.mjs";import{default as Qe}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";import{useMemo as ne}from"react";import{ThemeProvider as ae,createTheme as pe,CssBaseline as ce}from"@mui/material";import{jsx as me,jsxs as le}from"react/jsx-runtime";var fe=(o={})=>{try{let e=d("theme");if(e){let r=JSON.parse(decodeURIComponent(e));return{...o,...r}}}catch(e){console.warn("Error parsing theme from cookie:",e)}return o};function de({children:o,defaultTheme:e={},disableCssBaseline:r=!1}){let t=ne(()=>{let i=fe(e);return pe(i)},[e]);return le(ae,{theme:t,children:[!r&&me(ce,{}),o]})}import{Navigate as Se,useLocation as he}from"react-router-dom";import{Fragment as xe,jsx as p,jsxs as g}from"react/jsx-runtime";var ue={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},ge=()=>p("style",{children:`
2
2
  @keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
5
5
  }
6
- `});function d({stage:e="loading",message:o}){let t=o||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[e];return m(ce,{children:[c(ae,{}),m("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[c("div",{style:ne}),c("p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var pe=/^[a-zA-Z0-9\-_./\?=&%#]+$/,fe=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],p=(e,o="/")=>{if(!e||typeof e!="string")return o;let r=e.trim();if(!r)return o;if(!r.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",e),o;if(!pe.test(r))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",e),o;let t=r.toLowerCase();for(let i of fe)if(i.test(t))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",e),o;let s=r.split("?")[0].split("/").filter(Boolean);if(s.length===0)return r;for(let i of s)if(i===".."||i.includes(":")||i.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",i),o;return r},l=(e,o="/")=>{try{let t=(typeof e=="string"?new URLSearchParams(e):e).get("redirect");if(!t)return o;let s=decodeURIComponent(t);return p(s,o)}catch(r){return console.warn("\u{1F6A8} Error parsing redirect parameter:",r),o}};import{Fragment as g,jsx as f}from"react/jsx-runtime";function x({children:e,loadingComponent:o,loginPath:r="/login"}){let{isAuthenticated:t,isLoading:s,isInitialized:i,tokens:n,error:y}=a(),u=le();if(!i||s)return f(g,{children:o||f(d,{stage:"validating-session"})});let P=t&&n?.accessToken&&n.accessToken.length>0;if(y||!t||!P){n&&(!n.accessToken||n.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let h=u.pathname+u.search,C=p(h),L=encodeURIComponent(C);return f(de,{to:`${r}?redirect=${L}`,replace:!0})}return f(g,{children:e})}import{Navigate as ue,useLocation as me}from"react-router-dom";import{Fragment as ge,jsx as R}from"react/jsx-runtime";function S({children:e,redirectTo:o="/"}){let{isAuthenticated:r}=a(),t=me();if(r){let s=new URLSearchParams(t.search),i=l(s,o);return R(ue,{to:i,replace:!0})}return R(ge,{children:e})}export{S as AuthRoute,J as CrudifyLogin,M as ERROR_CODES,G as ERROR_SEVERITY_MAP,I as GlobalNotificationProvider,X as LoginComponent,K as POLICY_ACTIONS,Z as PREFERRED_POLICY_ORDER,Q as Policies,x as ProtectedRoute,F as SessionDebugInfo,d as SessionLoadingScreen,k as SessionManager,z as SessionProvider,j as SessionStatus,E as TokenStorage,$ as UserProfileDisplay,b as createErrorTranslator,Ie as crudify,N as decodeJwtSafely,l as extractSafeRedirectFromUrl,v as getCookie,w as getCurrentUserEmail,H as getErrorMessage,B as handleCrudifyError,O as isTokenExpired,V as parseApiError,W as parseJavaScriptError,q as parseTransactionError,ie as secureLocalStorage,te as secureSessionStorage,T as translateError,A as translateErrorCode,U as translateErrorCodes,oe as useAuth,se as useCrudifyWithNotifications,re as useData,_ as useGlobalNotification,D as useSession,a as useSessionContext,ee as useUserData,Y as useUserProfile,p as validateInternalRedirect};
6
+ `});function m({stage:o="loading",message:e}){let t=e||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[o];return g(xe,{children:[p(ge,{}),g("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[p("div",{style:ue}),p("p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:t})]})]})}var Re=/^[a-zA-Z0-9\-_./\?=&%#]+$/,ye=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],c=(o,e="/")=>{if(!o||typeof o!="string")return e;let r=o.trim();if(!r)return e;if(!r.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",o),e;if(!Re.test(r))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",o),e;let t=r.toLowerCase();for(let s of ye)if(s.test(t))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",o),e;let i=r.split("?")[0].split("/").filter(Boolean);if(i.length===0)return r;for(let s of i)if(s===".."||s.includes(":")||s.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",s),e;return r},l=(o,e="/")=>{try{let t=(typeof o=="string"?new URLSearchParams(o):o).get("redirect");if(!t)return e;let i=decodeURIComponent(t);return c(i,e)}catch(r){return console.warn("\u{1F6A8} Error parsing redirect parameter:",r),e}};import{Fragment as x,jsx as f}from"react/jsx-runtime";function R({children:o,loadingComponent:e,loginPath:r="/login"}){let{isAuthenticated:t,isLoading:i,isInitialized:s,tokens:n,error:h}=a(),u=he();if(!s||i)return f(x,{children:e||f(m,{stage:"validating-session"})});let P=t&&n?.accessToken&&n.accessToken.length>0;if(h||!t||!P){n&&(!n.accessToken||n.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let C=u.pathname+u.search,v=c(C),T=encodeURIComponent(v);return f(Se,{to:`${r}?redirect=${T}`,replace:!0})}return f(x,{children:o})}import{Navigate as Pe,useLocation as Ce}from"react-router-dom";import{Fragment as ve,jsx as y}from"react/jsx-runtime";function S({children:o,redirectTo:e="/"}){let{isAuthenticated:r}=a(),t=Ce();if(r){let i=new URLSearchParams(t.search),s=l(i,e);return y(Pe,{to:s,replace:!0})}return y(ve,{children:o})}export{S as AuthRoute,W as CrudifyLogin,de as CrudifyThemeProvider,z as ERROR_CODES,G as ERROR_SEVERITY_MAP,I as GlobalNotificationProvider,X as LoginComponent,K as POLICY_ACTIONS,Z as PREFERRED_POLICY_ORDER,Q as Policies,R as ProtectedRoute,M as SessionDebugInfo,m as SessionLoadingScreen,b as SessionManager,F as SessionProvider,j as SessionStatus,E as TokenStorage,$ as UserProfileDisplay,U as createErrorTranslator,Qe as crudify,O as decodeJwtSafely,l as extractSafeRedirectFromUrl,d as getCookie,D as getCurrentUserEmail,q as getErrorMessage,J as handleCrudifyError,w as isTokenExpired,B as parseApiError,H as parseJavaScriptError,V as parseTransactionError,ie as secureLocalStorage,te as secureSessionStorage,k as translateError,L as translateErrorCode,A as translateErrorCodes,oe as useAuth,se as useCrudifyWithNotifications,re as useData,_ as useGlobalNotification,N as useSession,a as useSessionContext,ee as useUserData,Y as useUserProfile,c as validateInternalRedirect};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocios/crudify-ui",
3
- "version": "4.1.20",
3
+ "version": "4.1.21",
4
4
  "description": "Biblioteca de componentes UI para Crudify",
5
5
  "author": "Nocios",
6
6
  "license": "MIT",