frontend-plus-react 0.4.1 → 0.4.2
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/CLAUDE.md +2 -1
- package/dist/index.cjs +103 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -58
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4193,7 +4193,7 @@ var GenericDataGrid = ({
|
|
|
4193
4193
|
var GenericDataGrid_default = GenericDataGrid;
|
|
4194
4194
|
|
|
4195
4195
|
// src/App.tsx
|
|
4196
|
-
import
|
|
4196
|
+
import React29, { useEffect as useEffect17, useMemo as useMemo14 } from "react";
|
|
4197
4197
|
import { BrowserRouter, Routes, Route, useLocation as useLocation7, Navigate as Navigate4, Outlet as Outlet2 } from "react-router-dom";
|
|
4198
4198
|
|
|
4199
4199
|
// src/components/MainLayout.tsx
|
|
@@ -4773,7 +4773,6 @@ import { Button as Button8, TextField as TextField2, Typography as Typography13,
|
|
|
4773
4773
|
import { useForm, Controller } from "react-hook-form";
|
|
4774
4774
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4775
4775
|
import * as z from "zod";
|
|
4776
|
-
import { useNavigate as useNavigate4 } from "react-router-dom";
|
|
4777
4776
|
import { useDispatch as useDispatch4 } from "react-redux";
|
|
4778
4777
|
import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4779
4778
|
var loginSchema = z.object({
|
|
@@ -4783,7 +4782,6 @@ var loginSchema = z.object({
|
|
|
4783
4782
|
// Añadir validación básica
|
|
4784
4783
|
});
|
|
4785
4784
|
var LoginPage = () => {
|
|
4786
|
-
const navigate = useNavigate4();
|
|
4787
4785
|
const [loginError, setLoginError] = useState14(null);
|
|
4788
4786
|
const [isSubmitting, setIsSubmitting] = useState14(false);
|
|
4789
4787
|
const { setIsLoggedIn, checkSession } = useApp();
|
|
@@ -4821,7 +4819,6 @@ var LoginPage = () => {
|
|
|
4821
4819
|
setIsLoggedIn(true);
|
|
4822
4820
|
await dispatch(fetchClientContext()).unwrap();
|
|
4823
4821
|
console.log("Login exitoso y clientContext cargado.");
|
|
4824
|
-
navigate("/");
|
|
4825
4822
|
reset();
|
|
4826
4823
|
} catch (error) {
|
|
4827
4824
|
console.error("Error al iniciar sesi\xF3n:", error);
|
|
@@ -5429,10 +5426,10 @@ var PrivateRoute_default = PrivateRoute;
|
|
|
5429
5426
|
|
|
5430
5427
|
// src/components/InitialRedirectHandler.tsx
|
|
5431
5428
|
import { useEffect as useEffect11, useRef as useRef8 } from "react";
|
|
5432
|
-
import { useLocation as useLocation4, useNavigate as
|
|
5429
|
+
import { useLocation as useLocation4, useNavigate as useNavigate4 } from "react-router-dom";
|
|
5433
5430
|
var InitialRedirectHandler = () => {
|
|
5434
5431
|
const location = useLocation4();
|
|
5435
|
-
const navigate =
|
|
5432
|
+
const navigate = useNavigate4();
|
|
5436
5433
|
const dispatch = useAppDispatch();
|
|
5437
5434
|
const redirectPath = useRedirectPath();
|
|
5438
5435
|
const clientContextStatus = useClientContextStatus();
|
|
@@ -5620,7 +5617,7 @@ var MenuTablePage_default = MenuTablePage;
|
|
|
5620
5617
|
|
|
5621
5618
|
// src/puente/PantallaBP.tsx
|
|
5622
5619
|
import { useEffect as useEffect14, useRef as useRef9, useState as useState17 } from "react";
|
|
5623
|
-
import { Navigate as Navigate3, useLocation as useLocation6,
|
|
5620
|
+
import { Navigate as Navigate3, useLocation as useLocation6, useParams as useParams4 } from "react-router-dom";
|
|
5624
5621
|
import { Alert as Alert7, Box as Box24, CircularProgress as CircularProgress8 } from "@mui/material";
|
|
5625
5622
|
|
|
5626
5623
|
// src/puente/clienteBP.ts
|
|
@@ -5655,6 +5652,24 @@ function esperarCargaDeVentana() {
|
|
|
5655
5652
|
if (document.readyState === "complete") return Promise.resolve();
|
|
5656
5653
|
return new Promise((resolver) => window.addEventListener("load", () => resolver(), { once: true }));
|
|
5657
5654
|
}
|
|
5655
|
+
async function sinEscuchasDeVentana(tipos, inyectar) {
|
|
5656
|
+
const original = window.addEventListener;
|
|
5657
|
+
const filtrada = function(tipo, escucha, opciones) {
|
|
5658
|
+
if (tipos.includes(tipo)) return;
|
|
5659
|
+
original.call(this, tipo, escucha, opciones);
|
|
5660
|
+
};
|
|
5661
|
+
window.addEventListener = filtrada;
|
|
5662
|
+
try {
|
|
5663
|
+
return await inyectar();
|
|
5664
|
+
} finally {
|
|
5665
|
+
if (window.addEventListener === filtrada) window.addEventListener = original;
|
|
5666
|
+
}
|
|
5667
|
+
}
|
|
5668
|
+
async function cargarScripts(rutas) {
|
|
5669
|
+
for (const ruta of rutas) {
|
|
5670
|
+
await cargarScript(ruta);
|
|
5671
|
+
}
|
|
5672
|
+
}
|
|
5658
5673
|
var carga = null;
|
|
5659
5674
|
function cargarClienteBP(urlBackend) {
|
|
5660
5675
|
if (!carga) {
|
|
@@ -5683,9 +5698,7 @@ async function cargarSinMemoria(urlBackend) {
|
|
|
5683
5698
|
document.head.appendChild(enlace);
|
|
5684
5699
|
});
|
|
5685
5700
|
await esperarCargaDeVentana();
|
|
5686
|
-
|
|
5687
|
-
await cargarScript(ruta);
|
|
5688
|
-
}
|
|
5701
|
+
await sinEscuchasDeVentana(["popstate"], () => cargarScripts(recursos.scripts));
|
|
5689
5702
|
const myOwn = window.myOwn;
|
|
5690
5703
|
if (!myOwn) throw new Error("El backend no defini\xF3 myOwn.");
|
|
5691
5704
|
window.my = myOwn;
|
|
@@ -5807,47 +5820,6 @@ function resolverPantallaBP(myOwn, nombre, contenedor) {
|
|
|
5807
5820
|
return null;
|
|
5808
5821
|
}
|
|
5809
5822
|
|
|
5810
|
-
// src/puente/capturaDeNavegacion.ts
|
|
5811
|
-
function apiDeNavegacion() {
|
|
5812
|
-
const api = Reflect.get(window, "navigation");
|
|
5813
|
-
return typeof api === "object" && api !== null && "addEventListener" in api && typeof api.addEventListener === "function" ? api : null;
|
|
5814
|
-
}
|
|
5815
|
-
function capturarNavegacionBP(urlBackend, navegar) {
|
|
5816
|
-
const alHacerClick = (evento) => {
|
|
5817
|
-
if (evento.defaultPrevented || evento.button !== 0 || evento.ctrlKey || evento.metaKey || evento.shiftKey) return;
|
|
5818
|
-
const enlace = evento.target instanceof Element ? evento.target.closest("a[href]") : null;
|
|
5819
|
-
if (!enlace || enlace.hasAttribute("download") || (enlace.getAttribute("target") ?? "_self") !== "_self") return;
|
|
5820
|
-
const ruta = rutaDeEnlaceBP(enlace.getAttribute("href") ?? "", document.baseURI, urlBackend);
|
|
5821
|
-
if (ruta) {
|
|
5822
|
-
evento.preventDefault();
|
|
5823
|
-
evento.stopPropagation();
|
|
5824
|
-
navegar(ruta);
|
|
5825
|
-
}
|
|
5826
|
-
};
|
|
5827
|
-
document.addEventListener("click", alHacerClick, true);
|
|
5828
|
-
const navegacion = apiDeNavegacion();
|
|
5829
|
-
const alNavegar = (evento) => {
|
|
5830
|
-
if (!evento.cancelable || evento.destination.sameDocument || evento.downloadRequest !== null) return;
|
|
5831
|
-
const ruta = rutaDeEnlaceBP(evento.destination.url, document.baseURI, urlBackend);
|
|
5832
|
-
if (ruta) {
|
|
5833
|
-
evento.preventDefault();
|
|
5834
|
-
navegar(ruta);
|
|
5835
|
-
}
|
|
5836
|
-
};
|
|
5837
|
-
navegacion?.addEventListener("navigate", alNavegar);
|
|
5838
|
-
const reemplazarOriginal = history.replaceState;
|
|
5839
|
-
const reemplazar = (estado, titulo, url) => {
|
|
5840
|
-
const ruta = url === void 0 || url === null ? null : rutaDeEnlaceBP(String(url), document.baseURI, urlBackend);
|
|
5841
|
-
reemplazarOriginal.call(history, estado, titulo, ruta === null ? url : rutaBase + ruta);
|
|
5842
|
-
};
|
|
5843
|
-
history.replaceState = reemplazar;
|
|
5844
|
-
return () => {
|
|
5845
|
-
if (history.replaceState === reemplazar) history.replaceState = reemplazarOriginal;
|
|
5846
|
-
document.removeEventListener("click", alHacerClick, true);
|
|
5847
|
-
navegacion?.removeEventListener("navigate", alNavegar);
|
|
5848
|
-
};
|
|
5849
|
-
}
|
|
5850
|
-
|
|
5851
5823
|
// src/puente/habilitacion.ts
|
|
5852
5824
|
var habilitado = false;
|
|
5853
5825
|
var habilitarPuenteBP = () => {
|
|
@@ -5868,7 +5840,6 @@ function buscarItemDeMenu(items, tipo) {
|
|
|
5868
5840
|
return void 0;
|
|
5869
5841
|
}
|
|
5870
5842
|
var PantallaBP = ({ nombre, direccion }) => {
|
|
5871
|
-
const navigate = useNavigate6();
|
|
5872
5843
|
const { clientContext } = useApp();
|
|
5873
5844
|
const [cargando, setCargando] = useState17(true);
|
|
5874
5845
|
const [error, setError] = useState17(null);
|
|
@@ -5882,7 +5853,6 @@ var PantallaBP = ({ nombre, direccion }) => {
|
|
|
5882
5853
|
setError(null);
|
|
5883
5854
|
setNoExiste(false);
|
|
5884
5855
|
setCargando(true);
|
|
5885
|
-
const dejarDeCapturar = capturarNavegacionBP(envConfig.backendUrl, navigate);
|
|
5886
5856
|
cargarClienteBP(envConfig.backendUrl).then((myOwn) => {
|
|
5887
5857
|
if (!vigente) return;
|
|
5888
5858
|
setCargando(false);
|
|
@@ -5904,10 +5874,9 @@ var PantallaBP = ({ nombre, direccion }) => {
|
|
|
5904
5874
|
});
|
|
5905
5875
|
return () => {
|
|
5906
5876
|
vigente = false;
|
|
5907
|
-
dejarDeCapturar();
|
|
5908
5877
|
elemento.replaceChildren();
|
|
5909
5878
|
};
|
|
5910
|
-
}, [nombre, direccion, menu
|
|
5879
|
+
}, [nombre, direccion, menu]);
|
|
5911
5880
|
if (noExiste) return /* @__PURE__ */ jsx33(FallbackWScreen, { screenName: nombre });
|
|
5912
5881
|
return (
|
|
5913
5882
|
// el indicador de carga flota: si ocupara lugar, el contenido de backend-plus empezaría más abajo mientras carga y subiría al terminar
|
|
@@ -5986,13 +5955,65 @@ var PaginaGrillaBP = () => {
|
|
|
5986
5955
|
return /* @__PURE__ */ jsx34(GrillaBP, { tabla: tableName }, tableName);
|
|
5987
5956
|
};
|
|
5988
5957
|
|
|
5958
|
+
// src/puente/CapturaBP.tsx
|
|
5959
|
+
import { useEffect as useEffect16 } from "react";
|
|
5960
|
+
import { useNavigate as useNavigate5 } from "react-router-dom";
|
|
5961
|
+
|
|
5962
|
+
// src/puente/capturaDeNavegacion.ts
|
|
5963
|
+
function apiDeNavegacion() {
|
|
5964
|
+
const api = Reflect.get(window, "navigation");
|
|
5965
|
+
return typeof api === "object" && api !== null && "addEventListener" in api && typeof api.addEventListener === "function" ? api : null;
|
|
5966
|
+
}
|
|
5967
|
+
function capturarNavegacionBP(urlBackend, navegar) {
|
|
5968
|
+
const alHacerClick = (evento) => {
|
|
5969
|
+
if (evento.defaultPrevented || evento.button !== 0 || evento.ctrlKey || evento.metaKey || evento.shiftKey) return;
|
|
5970
|
+
const enlace = evento.target instanceof Element ? evento.target.closest("a[href]") : null;
|
|
5971
|
+
if (!enlace || enlace.hasAttribute("download") || (enlace.getAttribute("target") ?? "_self") !== "_self") return;
|
|
5972
|
+
const ruta = rutaDeEnlaceBP(enlace.getAttribute("href") ?? "", document.baseURI, urlBackend);
|
|
5973
|
+
if (ruta) {
|
|
5974
|
+
evento.preventDefault();
|
|
5975
|
+
evento.stopPropagation();
|
|
5976
|
+
navegar(ruta);
|
|
5977
|
+
}
|
|
5978
|
+
};
|
|
5979
|
+
document.addEventListener("click", alHacerClick, true);
|
|
5980
|
+
const navegacion = apiDeNavegacion();
|
|
5981
|
+
const alNavegar = (evento) => {
|
|
5982
|
+
if (!evento.cancelable || evento.destination.sameDocument || evento.downloadRequest !== null) return;
|
|
5983
|
+
const ruta = rutaDeEnlaceBP(evento.destination.url, document.baseURI, urlBackend);
|
|
5984
|
+
if (ruta) {
|
|
5985
|
+
evento.preventDefault();
|
|
5986
|
+
navegar(ruta);
|
|
5987
|
+
}
|
|
5988
|
+
};
|
|
5989
|
+
navegacion?.addEventListener("navigate", alNavegar);
|
|
5990
|
+
const reemplazarOriginal = history.replaceState;
|
|
5991
|
+
const reemplazar = (estado, titulo, url) => {
|
|
5992
|
+
const ruta = url === void 0 || url === null ? null : rutaDeEnlaceBP(String(url), document.baseURI, urlBackend);
|
|
5993
|
+
reemplazarOriginal.call(history, estado, titulo, ruta === null ? url : rutaBase + ruta);
|
|
5994
|
+
};
|
|
5995
|
+
history.replaceState = reemplazar;
|
|
5996
|
+
return () => {
|
|
5997
|
+
if (history.replaceState === reemplazar) history.replaceState = reemplazarOriginal;
|
|
5998
|
+
document.removeEventListener("click", alHacerClick, true);
|
|
5999
|
+
navegacion?.removeEventListener("navigate", alNavegar);
|
|
6000
|
+
};
|
|
6001
|
+
}
|
|
6002
|
+
|
|
6003
|
+
// src/puente/CapturaBP.tsx
|
|
6004
|
+
var CapturaBP = () => {
|
|
6005
|
+
const navigate = useNavigate5();
|
|
6006
|
+
useEffect16(() => capturarNavegacionBP(envConfig.backendUrl, navigate), [navigate]);
|
|
6007
|
+
return null;
|
|
6008
|
+
};
|
|
6009
|
+
|
|
5989
6010
|
// src/App.tsx
|
|
5990
6011
|
import typeStore6 from "type-store";
|
|
5991
6012
|
import { Fragment as Fragment5, jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5992
6013
|
var LocationTracker = () => {
|
|
5993
6014
|
const location = useLocation7();
|
|
5994
6015
|
const dispatch = useAppDispatch();
|
|
5995
|
-
|
|
6016
|
+
useEffect17(() => {
|
|
5996
6017
|
dispatch(setCurrentPath(location.pathname + location.search));
|
|
5997
6018
|
}, [location, dispatch]);
|
|
5998
6019
|
return null;
|
|
@@ -6000,6 +6021,7 @@ var LocationTracker = () => {
|
|
|
6000
6021
|
function FrontendPlusReactRoutes({ myRoutes, myUnloggedRoutes, layout: Layout = MainLayout_default, unloggedLayout: UnloggedLayout }) {
|
|
6001
6022
|
return /* @__PURE__ */ jsxs25(Fragment5, { children: [
|
|
6002
6023
|
/* @__PURE__ */ jsx35(InitialRedirectHandler_default, {}),
|
|
6024
|
+
puenteBPHabilitado() && /* @__PURE__ */ jsx35(CapturaBP, {}),
|
|
6003
6025
|
/* @__PURE__ */ jsxs25(Routes, { children: [
|
|
6004
6026
|
/* @__PURE__ */ jsxs25(Route, { element: UnloggedLayout ? /* @__PURE__ */ jsx35(UnloggedLayout, {}) : /* @__PURE__ */ jsx35(Outlet2, {}), children: [
|
|
6005
6027
|
/* @__PURE__ */ jsx35(Route, { path: "/login", element: /* @__PURE__ */ jsx35(LoginPage_default, {}) }),
|
|
@@ -6066,7 +6088,7 @@ var App = ({
|
|
|
6066
6088
|
habilitarPuenteBP();
|
|
6067
6089
|
}
|
|
6068
6090
|
}, [myClientSides, myResultsOk, myWScreens, myConditions, puenteBP]);
|
|
6069
|
-
|
|
6091
|
+
useEffect17(() => {
|
|
6070
6092
|
typeStore6.messages = typeStore6.i18n.messages.es;
|
|
6071
6093
|
typeStore6.locale = typeStore6.i18n.locale.es;
|
|
6072
6094
|
const link = document.querySelector("link[rel*='icon']") || document.createElement("link");
|
|
@@ -6075,7 +6097,7 @@ var App = ({
|
|
|
6075
6097
|
link.href = `${envConfig.backendUrl}/img/logo-128.png`;
|
|
6076
6098
|
document.getElementsByTagName("head")[0].appendChild(link);
|
|
6077
6099
|
}, []);
|
|
6078
|
-
const safePaths =
|
|
6100
|
+
const safePaths = React29.useMemo(() => {
|
|
6079
6101
|
const extracted = extractPathsFromRoutes(myUnloggedRoutes);
|
|
6080
6102
|
return ["/login", "/logout", ...extracted];
|
|
6081
6103
|
}, [myUnloggedRoutes]);
|