react-ecosistema-unp 1.4.9 → 1.5.1
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/cards/tarjeta/nuevo-elemento/NuevoElemento.js +1 -1
- package/dist/cards/tarjeta-info/TarjetaInfo.js +1 -1
- package/dist/{index-pCr0mQ1L.js → index-CZLknVmR.js} +2 -2
- package/dist/lib/utils/captcha/CaptchaEcosistema.d.ts +10 -0
- package/dist/lib/utils/validations/useFormValidation.d.ts +15 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/shared/app-list/AppList.js +1 -1
- package/dist/tables/tabla-registros/buscador/Buscador.js +1 -1
- package/dist/tables/tabla-registros/tabla/Tabla.js +1 -1
- package/dist/ui/contenido-modal/ContenidoModal.js +1 -1
- package/dist/ui/contenido-modal/ContenidoModalv0.1.js +1 -1
- package/dist/ui/icono-tooltip/IconoTooltip.js +35 -29
- package/dist/ui/items-modal/ItemsModal.js +1 -1
- package/dist/utils/captcha/CaptchaEcosistema.js +141 -0
- package/dist/utils/validations/useFormValidation.js +192 -0
- package/dist/utils.js +12 -8
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as n, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { o as s } from "../../../index-
|
|
2
|
+
import { o as s } from "../../../index-CZLknVmR.js";
|
|
3
3
|
import '../../../assets/Bootstrap.css';/* empty css */
|
|
4
4
|
import { B as a } from "../../../Button-B87TJYml.js";
|
|
5
5
|
const d = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useState as r, useRef as d, useEffect as u } from "react";
|
|
3
|
-
import { t as j, u as N } from "../../index-
|
|
3
|
+
import { t as j, u as N } from "../../index-CZLknVmR.js";
|
|
4
4
|
import '../../assets/UnpHistorico.css';const C = ({ icon: c, label: l, show: h = !1, children: o }) => {
|
|
5
5
|
const [e, i] = r(h), [f, s] = r(0), a = d(null);
|
|
6
6
|
return u(() => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
type Dependencia = 'ser' | 'sesp' | 'otra';
|
|
3
|
+
interface CaptchaEcosistemaProps {
|
|
4
|
+
dependencia?: Dependencia;
|
|
5
|
+
onTokenChange: (token: string) => void;
|
|
6
|
+
onLoadingChange?: (loading: boolean) => void;
|
|
7
|
+
captchaRef: any;
|
|
8
|
+
}
|
|
9
|
+
export declare const CaptchaEcosistema: React.FC<CaptchaEcosistemaProps>;
|
|
10
|
+
export default CaptchaEcosistema;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const useFormValidation: () => {
|
|
2
|
+
handleChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => string;
|
|
3
|
+
handleBlur: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => string;
|
|
4
|
+
handleKeyPress: (e: React.KeyboardEvent<HTMLInputElement>, type: string) => void;
|
|
5
|
+
errors: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
counter: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export { useFormValidation };
|
|
13
|
+
export declare const IsInvalidStyles: (isInvalid: any, datos: any, field: string | number) => {
|
|
14
|
+
control: (base: any) => any;
|
|
15
|
+
};
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { AuthProvider } from './auth/contexts/AuthContex.js';
|
|
|
2
2
|
export { ProtectedRoute } from './utils/components/ProtectedRoute.js';
|
|
3
3
|
export { UserRoute } from './utils/components/UserRoute.js';
|
|
4
4
|
export { UnpHistorico } from './utils/unp-historico/UnpHistorico.js';
|
|
5
|
+
export { useFormValidation } from './utils/validations/useFormValidation.js';
|
|
6
|
+
export { CaptchaEcosistema } from './utils/captcha/CaptchaEcosistema.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a, jsxs as s } from "react/jsx-runtime";
|
|
2
2
|
import { useState as p, useEffect as m } from "react";
|
|
3
3
|
import { F as l, e as d, f as h, g as f, h as v } from "../../index-CgSyrJ_X.js";
|
|
4
|
-
import { v as g } from "../../index-
|
|
4
|
+
import { v as g } from "../../index-CZLknVmR.js";
|
|
5
5
|
import { G as u } from "../../iconBase-LROS5hdG.js";
|
|
6
6
|
import { j as z } from "../../index-CuHybtft.js";
|
|
7
7
|
import '../../assets/Modal.css';import '../../assets/ContenedorVentana.css';import '../../assets/IconoTooltip.css';import '../../assets/ItemsModal.css';import '../../assets/Bootstrap.css';import '../../assets/Paginador.css';import '../../assets/ContenidoModal.css';import '../../assets/Encabezado.css';import '../../assets/Logo.css';import '../../assets/AppList.css';/* empty css */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as a, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import { s as t } from "../../../index-
|
|
2
|
+
import { s as t } from "../../../index-CZLknVmR.js";
|
|
3
3
|
import { F as i, a as l } from "../../../FormGroup-BLpFcIN5.js";
|
|
4
4
|
import '../../../assets/Buscador.css';const d = ({ onSearch: r }) => {
|
|
5
5
|
const n = (e) => e.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r, jsxs as d } from "react/jsx-runtime";
|
|
2
2
|
import _, { useState as j } from "react";
|
|
3
|
-
import { r as A } from "../../../index-
|
|
3
|
+
import { r as A } from "../../../index-CZLknVmR.js";
|
|
4
4
|
import { a as G, b as R, c as E } from "../../../index-CgSyrJ_X.js";
|
|
5
5
|
import { T as z } from "../../../Table-C5ydZooy.js";
|
|
6
6
|
import { F as M, a as O } from "../../../FormGroup-BLpFcIN5.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as s, Fragment as N, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import p, { useState as o } from "react";
|
|
3
|
-
import { n as v } from "../../index-
|
|
3
|
+
import { n as v } from "../../index-CZLknVmR.js";
|
|
4
4
|
import '../../assets/ContenidoModal.css';/* empty css */
|
|
5
5
|
const x = ({ title: u, modalContent: i, children: d }) => {
|
|
6
6
|
const [a, l] = o(0), [m, c] = o(!0), [r, n] = o(!1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as t, Fragment as N, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useState as m, useEffect as p } from "react";
|
|
3
|
-
import { n as v } from "../../index-
|
|
3
|
+
import { n as v } from "../../index-CZLknVmR.js";
|
|
4
4
|
import '../../assets/ContenidoModal.css';/* empty css */
|
|
5
5
|
const y = ({ title: d, children: h, buttons: s, isShowing: i, setIsShowing: u = () => {
|
|
6
6
|
} }) => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as L, jsx as
|
|
1
|
+
import { jsxs as L, jsx as u } from "react/jsx-runtime";
|
|
2
2
|
import { useState as M } from "react";
|
|
3
|
-
import { F as A, a as U, b as j, c as B, d as J, e as W, f as z, g as P, h as Y, i as q, j as
|
|
3
|
+
import { F as A, a as U, b as j, c as B, d as J, e as W, f as z, g as P, h as Y, i as q, j as g, k as h, l as G, m as H } from "../../index-CZLknVmR.js";
|
|
4
4
|
import '../../assets/IconoTooltip.css';/* empty css */
|
|
5
5
|
const _ = ({ recordType: x, taken: o = !0, customIcon: l }) => {
|
|
6
|
-
const [a,
|
|
6
|
+
const [a, b] = M(!1);
|
|
7
7
|
let c = "", r = {}, e = null, I = { color: o ? "#287cd1" : "#c8c8c8" };
|
|
8
|
-
const f = "#28a19d", n = "#ed7e3e",
|
|
9
|
-
const
|
|
10
|
-
return 0.2126 *
|
|
8
|
+
const f = "#28a19d", n = "#ed7e3e", d = "#3e52ed", C = "#ed3e49", v = "#edd958", w = "#18a871", p = "#db493b", m = "#6845e6", F = "#c2e545", R = "#43b1dd", y = "#de6f43", N = "#6b6e6e", i = "#666666f4", s = (E) => {
|
|
9
|
+
const t = E.replace(/^#/, ""), T = parseInt(t.slice(0, 2), 16) / 255, D = parseInt(t.slice(2, 4), 16) / 255, S = parseInt(t.slice(4, 6), 16) / 255;
|
|
10
|
+
return 0.2126 * T + 0.7152 * D + 0.0722 * S;
|
|
11
11
|
};
|
|
12
12
|
if (l)
|
|
13
13
|
c = o ? l.tooltipText : "Nuevo registro", r = {
|
|
@@ -33,7 +33,7 @@ const _ = ({ recordType: x, taken: o = !0, customIcon: l }) => {
|
|
|
33
33
|
c = o ? "Formulario en línea" : "Nuevo registro", r = {
|
|
34
34
|
backgroundColor: o ? f : i,
|
|
35
35
|
color: "#fcfcfc"
|
|
36
|
-
}, e =
|
|
36
|
+
}, e = g;
|
|
37
37
|
break;
|
|
38
38
|
case "Digitador Formulario Individual":
|
|
39
39
|
c = o ? "Digitador" : "Nuevo registro", r = {
|
|
@@ -46,7 +46,7 @@ const _ = ({ recordType: x, taken: o = !0, customIcon: l }) => {
|
|
|
46
46
|
c = o ? "Formulario en línea" : "Nuevo registro", r = {
|
|
47
47
|
backgroundColor: o ? f : i,
|
|
48
48
|
color: "#fcfcfc"
|
|
49
|
-
}, e =
|
|
49
|
+
}, e = g;
|
|
50
50
|
break;
|
|
51
51
|
case "Digitador Formulario Colectivo":
|
|
52
52
|
c = o ? "Digitador" : "Nuevo registro", r = {
|
|
@@ -54,22 +54,28 @@ const _ = ({ recordType: x, taken: o = !0, customIcon: l }) => {
|
|
|
54
54
|
color: "#fcfcfc"
|
|
55
55
|
}, e = h;
|
|
56
56
|
break;
|
|
57
|
+
case "Formularios en linea Recurso Reposicion":
|
|
58
|
+
c = o ? "Recurso de reposición" : "Nuevo registro", r = {
|
|
59
|
+
backgroundColor: o ? d : i,
|
|
60
|
+
color: "#fcfcfc"
|
|
61
|
+
}, e = g;
|
|
62
|
+
break;
|
|
57
63
|
case "Jurídico":
|
|
58
64
|
c = o ? "Jurídico" : "Nuevo registro", r = {
|
|
59
|
-
backgroundColor: o ?
|
|
60
|
-
color: o && s(
|
|
65
|
+
backgroundColor: o ? d : i,
|
|
66
|
+
color: o && s(d) > 0.5 ? "#141414" : "#fcfcfc"
|
|
61
67
|
}, e = q;
|
|
62
68
|
break;
|
|
63
69
|
case "Emergencia":
|
|
64
70
|
c = o ? "Emergencia" : "Nuevo registro", r = {
|
|
65
|
-
backgroundColor: o ?
|
|
66
|
-
color: o && s(
|
|
71
|
+
backgroundColor: o ? C : i,
|
|
72
|
+
color: o && s(C) > 0.5 ? "#141414" : "#fcfcfc"
|
|
67
73
|
}, e = Y;
|
|
68
74
|
break;
|
|
69
75
|
case "Reasignación":
|
|
70
76
|
c = o ? "Reasignación" : "Nuevo registro", r = {
|
|
71
|
-
backgroundColor: o ?
|
|
72
|
-
color: o && s(
|
|
77
|
+
backgroundColor: o ? v : i,
|
|
78
|
+
color: o && s(v) > 0.5 ? "#141414" : "#fcfcfc"
|
|
73
79
|
}, e = P;
|
|
74
80
|
break;
|
|
75
81
|
case "CTAR":
|
|
@@ -80,55 +86,55 @@ const _ = ({ recordType: x, taken: o = !0, customIcon: l }) => {
|
|
|
80
86
|
break;
|
|
81
87
|
case "Inactivaciones":
|
|
82
88
|
c = o ? "Inactivaciones" : "Nuevo registro", r = {
|
|
83
|
-
backgroundColor: o ?
|
|
84
|
-
color: o && s(
|
|
89
|
+
backgroundColor: o ? p : i,
|
|
90
|
+
color: o && s(p) > 0.5 ? "#141414" : "#fcfcfc"
|
|
85
91
|
}, e = W;
|
|
86
92
|
break;
|
|
87
93
|
case "Desmonte":
|
|
88
94
|
c = o ? "Desmonte" : "Nuevo registro", r = {
|
|
89
|
-
backgroundColor: o ?
|
|
90
|
-
color: o && s(
|
|
95
|
+
backgroundColor: o ? m : i,
|
|
96
|
+
color: o && s(m) > 0.5 ? "#141414" : "#fcfcfc"
|
|
91
97
|
}, e = J;
|
|
92
98
|
break;
|
|
93
99
|
case "Implementación":
|
|
94
100
|
c = o ? "Implementación" : "Nuevo registro", r = {
|
|
95
|
-
backgroundColor: o ?
|
|
96
|
-
color: o && s(
|
|
101
|
+
backgroundColor: o ? F : i,
|
|
102
|
+
color: o && s(F) > 0.5 ? "#141414" : "#fcfcfc"
|
|
97
103
|
}, e = B;
|
|
98
104
|
break;
|
|
99
105
|
case "Correspondencia":
|
|
100
106
|
c = o ? "Correspondencia" : "Nuevo registro", r = {
|
|
101
|
-
backgroundColor: o ?
|
|
107
|
+
backgroundColor: o ? R : i,
|
|
102
108
|
color: "#fcfcfc"
|
|
103
109
|
}, e = j;
|
|
104
110
|
break;
|
|
105
111
|
case "Uso indebido":
|
|
106
112
|
c = o ? "Uso indebido" : "Nuevo registro", r = {
|
|
107
|
-
backgroundColor: o ?
|
|
113
|
+
backgroundColor: o ? y : i,
|
|
108
114
|
color: "#fcfcfc"
|
|
109
115
|
}, e = U;
|
|
110
116
|
break;
|
|
111
117
|
default:
|
|
112
118
|
c = o ? "Registro" : "Nuevo registro", r = {
|
|
113
|
-
backgroundColor: o ?
|
|
114
|
-
color: o && s(
|
|
119
|
+
backgroundColor: o ? N : i,
|
|
120
|
+
color: o && s(N) > 0.5 ? "#141414" : "#fcfcfc"
|
|
115
121
|
}, e = A;
|
|
116
122
|
break;
|
|
117
123
|
}
|
|
118
124
|
return /* @__PURE__ */ L("div", { style: { position: "relative", display: "inline-block" }, children: [
|
|
119
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ u(
|
|
120
126
|
"div",
|
|
121
127
|
{
|
|
122
|
-
onMouseEnter: () =>
|
|
123
|
-
onMouseLeave: () =>
|
|
128
|
+
onMouseEnter: () => b(!0),
|
|
129
|
+
onMouseLeave: () => b(!1),
|
|
124
130
|
style: {
|
|
125
131
|
...I
|
|
126
132
|
},
|
|
127
133
|
className: "icon-solicitud",
|
|
128
|
-
children: /* @__PURE__ */
|
|
134
|
+
children: /* @__PURE__ */ u(e, {})
|
|
129
135
|
}
|
|
130
136
|
),
|
|
131
|
-
a && /* @__PURE__ */
|
|
137
|
+
a && /* @__PURE__ */ u(
|
|
132
138
|
"div",
|
|
133
139
|
{
|
|
134
140
|
style: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { useNavigate as s } from "react-router-dom";
|
|
3
|
-
import { p as i, q as n } from "../../index-
|
|
3
|
+
import { p as i, q as n } from "../../index-CZLknVmR.js";
|
|
4
4
|
import { G as c } from "../../iconBase-LROS5hdG.js";
|
|
5
5
|
import '../../assets/ItemsModal.css';/* empty css */
|
|
6
6
|
function m(l) {
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as B } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as M, useCallback as z, useState as I, useRef as R, useMemo as te, useEffect as b, useImperativeHandle as ne } from "react";
|
|
3
|
+
var oe = ({ as: t = "div", ...a }, o) => B(t, { ...a, ref: o }), ae = M(oe), ie = "https://challenges.cloudflare.com/turnstile/v0/api.js", C = "cf-turnstile-script", ce = "cf-turnstile", F = "onloadTurnstileCallback", Q = (t) => !!document.getElementById(t), se = ({ render: t = "explicit", onLoadCallbackName: a = F, scriptOptions: { nonce: o = "", defer: e = !0, async: l = !0, id: s = "", appendTo: f, onError: g, crossOrigin: E = "" } = {} }) => {
|
|
4
|
+
let k = s || C;
|
|
5
|
+
if (Q(k)) return;
|
|
6
|
+
let i = document.createElement("script");
|
|
7
|
+
i.id = k, i.src = `${ie}?onload=${a}&render=${t}`, !document.querySelector(`script[src="${i.src}"]`) && (i.defer = !!e, i.async = !!l, o && (i.nonce = o), E && (i.crossOrigin = E), g && (i.onerror = g, delete window[a]), (f === "body" ? document.body : document.getElementsByTagName("head")[0]).appendChild(i));
|
|
8
|
+
}, h = { normal: { width: 300, height: 65 }, compact: { width: 150, height: 140 }, invisible: { width: 0, height: 0, overflow: "hidden" }, flexible: { minWidth: 300, width: "100%", height: 65 }, interactionOnly: { width: "fit-content", height: "auto", display: "flex" } };
|
|
9
|
+
function ue(t) {
|
|
10
|
+
if (t !== "invisible" && t !== "interactionOnly") return t;
|
|
11
|
+
}
|
|
12
|
+
function le(t = C) {
|
|
13
|
+
let [a, o] = I(!1);
|
|
14
|
+
return b(() => {
|
|
15
|
+
let e = () => {
|
|
16
|
+
Q(t) && o(!0);
|
|
17
|
+
}, l = new MutationObserver(e);
|
|
18
|
+
return l.observe(document, { childList: !0, subtree: !0 }), e(), () => {
|
|
19
|
+
l.disconnect();
|
|
20
|
+
};
|
|
21
|
+
}, [t]), a;
|
|
22
|
+
}
|
|
23
|
+
var T = "unloaded", U, de = new Promise((t, a) => {
|
|
24
|
+
U = { resolve: t, reject: a }, T === "ready" && t(void 0);
|
|
25
|
+
}), pe = (t = F) => (T === "unloaded" && (T = "loading", window[t] = () => {
|
|
26
|
+
U.resolve(), T = "ready", delete window[t];
|
|
27
|
+
}), de), q = M((t, a) => {
|
|
28
|
+
let { scriptOptions: o, options: e = {}, siteKey: l, onWidgetLoad: s, onSuccess: f, onExpire: g, onError: E, onBeforeInteractive: k, onAfterInteractive: i, onUnsupported: H, onTimeout: J, onLoadScript: L, id: _, style: G, as: V = "div", injectScript: $ = !0, ...Y } = t, c = e.size, j = z(() => typeof c > "u" ? {} : e.execution === "execute" ? h.invisible : e.appearance === "interaction-only" ? h.interactionOnly : h[c], [e.execution, c, e.appearance]), [Z, x] = I(j()), u = R(null), [m, D] = I(!1), n = R(), v = R(!1), P = _ || ce, S = (o == null ? void 0 : o.id) || C, O = le(S), W = (o == null ? void 0 : o.onLoadCallbackName) || F, X = e.appearance || "always", A = te(() => ({ sitekey: l, action: e.action, cData: e.cData, callback: (r) => {
|
|
29
|
+
v.current = !0, f == null || f(r);
|
|
30
|
+
}, "error-callback": E, "expired-callback": g, "before-interactive-callback": k, "after-interactive-callback": i, "unsupported-callback": H, theme: e.theme || "auto", language: e.language || "auto", tabindex: e.tabIndex, "response-field": e.responseField, "response-field-name": e.responseFieldName, size: ue(c), retry: e.retry || "auto", "retry-interval": e.retryInterval || 8e3, "refresh-expired": e.refreshExpired || "auto", "refresh-timeout": e.refreshTimeout || "auto", execution: e.execution || "render", appearance: e.appearance || "always", "feedback-enabled": e.feedbackEnabled || !0, "timeout-callback": J }), [e.action, e.appearance, e.cData, e.execution, e.language, e.refreshExpired, e.responseField, e.responseFieldName, e.retry, e.retryInterval, e.tabIndex, e.theme, e.feedbackEnabled, e.refreshTimeout, l, c]), w = z(() => typeof window < "u" && !!window.turnstile, []);
|
|
31
|
+
return b(function() {
|
|
32
|
+
$ && !m && se({ onLoadCallbackName: W, scriptOptions: { ...o, id: S } });
|
|
33
|
+
}, [$, m, o, S]), b(function() {
|
|
34
|
+
T !== "ready" && pe(W).then(() => D(!0)).catch(console.error);
|
|
35
|
+
}, []), b(function() {
|
|
36
|
+
if (!u.current || !m) return;
|
|
37
|
+
let r = !1;
|
|
38
|
+
return (async () => {
|
|
39
|
+
if (r || !u.current) return;
|
|
40
|
+
let d = window.turnstile.render(u.current, A);
|
|
41
|
+
n.current = d, n.current && (s == null || s(n.current));
|
|
42
|
+
})(), () => {
|
|
43
|
+
r = !0, n.current && (window.turnstile.remove(n.current), v.current = !1);
|
|
44
|
+
};
|
|
45
|
+
}, [P, m, A]), ne(a, () => {
|
|
46
|
+
let { turnstile: r } = window;
|
|
47
|
+
return { getResponse() {
|
|
48
|
+
if (!(r != null && r.getResponse) || !n.current || !w()) {
|
|
49
|
+
console.warn("Turnstile has not been loaded");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
return r.getResponse(n.current);
|
|
53
|
+
}, async getResponsePromise(d = 3e4, ee = 100) {
|
|
54
|
+
return new Promise((re, N) => {
|
|
55
|
+
let p, K = async () => {
|
|
56
|
+
if (v.current && window.turnstile && n.current) try {
|
|
57
|
+
let y = window.turnstile.getResponse(n.current);
|
|
58
|
+
return p && clearTimeout(p), y ? re(y) : N(new Error("No response received"));
|
|
59
|
+
} catch (y) {
|
|
60
|
+
return p && clearTimeout(p), console.warn("Failed to get response", y), N(new Error("Failed to get response"));
|
|
61
|
+
}
|
|
62
|
+
p || (p = setTimeout(() => {
|
|
63
|
+
p && clearTimeout(p), N(new Error("Timeout"));
|
|
64
|
+
}, d)), await new Promise((y) => setTimeout(y, ee)), await K();
|
|
65
|
+
};
|
|
66
|
+
K();
|
|
67
|
+
});
|
|
68
|
+
}, reset() {
|
|
69
|
+
if (!(r != null && r.reset) || !n.current || !w()) {
|
|
70
|
+
console.warn("Turnstile has not been loaded");
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
e.execution === "execute" && x(h.invisible);
|
|
74
|
+
try {
|
|
75
|
+
v.current = !1, r.reset(n.current);
|
|
76
|
+
} catch (d) {
|
|
77
|
+
console.warn(`Failed to reset Turnstile widget ${n}`, d);
|
|
78
|
+
}
|
|
79
|
+
}, remove() {
|
|
80
|
+
if (!(r != null && r.remove) || !n.current || !w()) {
|
|
81
|
+
console.warn("Turnstile has not been loaded");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
x(h.invisible), v.current = !1, r.remove(n.current), n.current = null;
|
|
85
|
+
}, render() {
|
|
86
|
+
if (!(r != null && r.render) || !u.current || !w() || n.current) {
|
|
87
|
+
console.warn("Turnstile has not been loaded or container not found");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
let d = r.render(u.current, A);
|
|
91
|
+
return n.current = d, n.current && (s == null || s(n.current)), e.execution !== "execute" && x(c ? h[c] : {}), d;
|
|
92
|
+
}, execute() {
|
|
93
|
+
if (e.execution !== "execute") {
|
|
94
|
+
console.warn('Execution mode is not set to "execute"');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!(r != null && r.execute) || !u.current || !n.current || !w()) {
|
|
98
|
+
console.warn("Turnstile has not been loaded or container not found");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
r.execute(u.current, A), x(c ? h[c] : {});
|
|
102
|
+
}, isExpired() {
|
|
103
|
+
return !(r != null && r.isExpired) || !n.current || !w() ? (console.warn("Turnstile has not been loaded"), !1) : r.isExpired(n.current);
|
|
104
|
+
} };
|
|
105
|
+
}, [n, e.execution, c, A, u, w, m, s]), b(() => {
|
|
106
|
+
O && !m && window.turnstile && D(!0);
|
|
107
|
+
}, [m, O]), b(() => {
|
|
108
|
+
x(j());
|
|
109
|
+
}, [e.execution, c, X]), b(() => {
|
|
110
|
+
!O || typeof L != "function" || L();
|
|
111
|
+
}, [O]), B(ae, { ref: u, as: V, id: P, style: { ...Z, ...G }, ...Y });
|
|
112
|
+
});
|
|
113
|
+
q.displayName = "Turnstile";
|
|
114
|
+
const we = ({
|
|
115
|
+
// token,
|
|
116
|
+
dependencia: t = "otra",
|
|
117
|
+
onTokenChange: a,
|
|
118
|
+
onLoadingChange: o,
|
|
119
|
+
captchaRef: e
|
|
120
|
+
// isInvalid = false
|
|
121
|
+
}) => /* @__PURE__ */ B(
|
|
122
|
+
q,
|
|
123
|
+
{
|
|
124
|
+
siteKey: t === "ser" ? "0x4AAAAAABawb_8OU0EC91K4" : t === "sesp" ? "0x4AAAAAABDt1J9rK4noS8tp" : "0x4AAAAAABdkdphlWd3QoT9u",
|
|
125
|
+
options: {
|
|
126
|
+
theme: "light",
|
|
127
|
+
language: "es"
|
|
128
|
+
},
|
|
129
|
+
onSuccess: (f) => {
|
|
130
|
+
a(f);
|
|
131
|
+
},
|
|
132
|
+
onLoad: () => {
|
|
133
|
+
o == null || o(!0);
|
|
134
|
+
},
|
|
135
|
+
ref: e
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
export {
|
|
139
|
+
we as CaptchaEcosistema,
|
|
140
|
+
we as default
|
|
141
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { useState as C } from "react";
|
|
2
|
+
const z = () => {
|
|
3
|
+
const [m, s] = C({}), [f, d] = C({}), u = {
|
|
4
|
+
personName: (e) => {
|
|
5
|
+
let r = e.replace(/[^a-zA-ZáéíóúÁÉÍÓÚñÑ\s]/g, "");
|
|
6
|
+
return r = r.replace(/\s+/g, " ").trim(), r === "" ? "" : r.split(" ").map((t) => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase()).join(" ");
|
|
7
|
+
},
|
|
8
|
+
phone: (e) => {
|
|
9
|
+
const r = e.replace(/\D/g, "");
|
|
10
|
+
return r.length < 10 ? r : r.slice(0, 10).replace(/(\d{3})(\d{3})(\d{4})/, "$1 $2 $3");
|
|
11
|
+
},
|
|
12
|
+
email: (e) => e.trim().toLowerCase(),
|
|
13
|
+
integer: (e) => {
|
|
14
|
+
const r = e.replace(/\D/g, "");
|
|
15
|
+
return r === "" || parseInt(r) < 1 ? "1" : r;
|
|
16
|
+
},
|
|
17
|
+
// Nuevos
|
|
18
|
+
day: (e) => (e = e.replace(/\D/g, ""), /^([1-9]|[12][0-9]|3[01])?$/.test(e) ? e : e.slice(0, -1)),
|
|
19
|
+
year: (e) => e.replace(/\D/g, "").slice(0, 4),
|
|
20
|
+
formatNIT: (e) => {
|
|
21
|
+
if (e === "") return e;
|
|
22
|
+
e = e.replace(/[^0-9\-]/g, "");
|
|
23
|
+
const [r, t] = e.split("-");
|
|
24
|
+
if (t !== void 0 && r.length < 9)
|
|
25
|
+
return r;
|
|
26
|
+
const a = r.slice(0, 9);
|
|
27
|
+
if (r.length > 9 && e.indexOf("-") === -1) {
|
|
28
|
+
const o = r.slice(9, 10);
|
|
29
|
+
return `${a}-${o}`;
|
|
30
|
+
}
|
|
31
|
+
if (t !== void 0) {
|
|
32
|
+
const o = t.slice(0, 1);
|
|
33
|
+
return `${a}-${o}`;
|
|
34
|
+
}
|
|
35
|
+
return a;
|
|
36
|
+
},
|
|
37
|
+
otherNames: (e) => {
|
|
38
|
+
if (e === "") return e;
|
|
39
|
+
if (e = e.replace(/\s{2,}/g, " "), !/^[A-Za-zÁÉÍÓÚáéíóúÑñ \-]{0,50}$/.test(e)) return e.slice(0, -1);
|
|
40
|
+
const t = ["de", "la", "los", "las", "y", "del", "el"], a = ["i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x", "xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix", "xx"];
|
|
41
|
+
return e.split(" ").map((o, l, n) => {
|
|
42
|
+
const g = l > 0 && n[l - 1].endsWith("-");
|
|
43
|
+
return a.includes(o.toLowerCase()) ? o.toUpperCase() : t.includes(o.toLowerCase()) && l !== 0 && !g ? o.toLowerCase() : o.charAt(0).toUpperCase() + o.slice(1).toLowerCase();
|
|
44
|
+
}).join(" ");
|
|
45
|
+
},
|
|
46
|
+
collectiveIds: (e) => e === "" ? e : (e = e.replace(/[^A-Za-zÁÉÍÓÚáéíóúÑñ0-9\-\/\.]/g, ""), e.slice(0, 20)),
|
|
47
|
+
url: (e) => e.replace(/[^\w\-.:/?&=#]/g, "").trim(),
|
|
48
|
+
numeroIdentificacion: (e, r) => {
|
|
49
|
+
const t = Number(r) || 1;
|
|
50
|
+
return t === 1 || t === 2 ? e.replace(/\D/g, "").slice(0, 10) : t === 4 || t === 5 ? e.replace(/[^A-Z0-9]/gi, "").slice(0, 10) : e.replace(/\D/g, "").slice(0, 10);
|
|
51
|
+
},
|
|
52
|
+
/*
|
|
53
|
+
Validador genericText (para campos como Nombre de la Entidad, Cargo, Plataforma, etc.)
|
|
54
|
+
- Permite letras, números y espacios.
|
|
55
|
+
- Elimina caracteres no permitidos.
|
|
56
|
+
- Divide el texto en palabras según los espacios.
|
|
57
|
+
- Para cada palabra COMPLETA (aquellas que no sean la última si ésta no termina en espacio)
|
|
58
|
+
se formatea: se capitaliza la primera letra y el resto se pasa a minúsculas.
|
|
59
|
+
- La última palabra se deja sin alterar si el input no termina en un espacio, permitiendo
|
|
60
|
+
que el usuario la edite o borre sin interferencias.
|
|
61
|
+
*/
|
|
62
|
+
genericText: (e) => {
|
|
63
|
+
if (!e) return "";
|
|
64
|
+
const r = e.endsWith(" "), t = e.split(" ");
|
|
65
|
+
return t.map((o, l) => {
|
|
66
|
+
if (l < t.length - 1 || r) {
|
|
67
|
+
const n = o.replace(/[^a-zA-Z0-9]/g, "");
|
|
68
|
+
return n.length === 0 ? "" : n.charAt(0).toUpperCase() + n.slice(1).toLowerCase();
|
|
69
|
+
} else
|
|
70
|
+
return o.replace(/[^a-zA-Z0-9]/g, "");
|
|
71
|
+
}).join(" ");
|
|
72
|
+
},
|
|
73
|
+
textParagraph: (e) => {
|
|
74
|
+
const r = e.split(/\r?\n/);
|
|
75
|
+
return r.map((a, o) => {
|
|
76
|
+
if (a === "") return a;
|
|
77
|
+
let l = a.replace(/^(\s*)([a-z])/, (n, g) => n + g.toUpperCase());
|
|
78
|
+
return l = l.replace(/(\.\s+)([a-z])/g, (n, g) => n + g.toUpperCase()), (o < r.length - 1 || e.endsWith(`
|
|
79
|
+
`) || e.endsWith(`\r
|
|
80
|
+
`)) && (/[.!?]\s*$/.test(l) || (l = l.replace(/\s*$/, "") + ".")), l;
|
|
81
|
+
}).join(`
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return { handleChange: (e) => {
|
|
86
|
+
var A;
|
|
87
|
+
const { value: r, name: t } = e.target, a = e.target.getAttribute("data-validation") || "", o = e.target.getAttribute("data-custom-error"), l = e.target.getAttribute("maxLength");
|
|
88
|
+
let n = r;
|
|
89
|
+
if (a && u[a] && (n = u[a](r)), l) {
|
|
90
|
+
const i = parseInt(l);
|
|
91
|
+
d((c) => ({
|
|
92
|
+
...c,
|
|
93
|
+
[t]: `${n.length}/${i} caracteres`
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
const g = e.target.getAttribute("data-tipo-identificacion") || "1";
|
|
97
|
+
if (a === "numeroIdentificacion" && (n = u.numeroIdentificacion(r, g)), a === "phone" && n.replace(/\s/g, "").length < 10)
|
|
98
|
+
s((i) => ({
|
|
99
|
+
...i,
|
|
100
|
+
[t]: o || "Número de teléfono inválido"
|
|
101
|
+
}));
|
|
102
|
+
else if (a === "email") {
|
|
103
|
+
const i = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
104
|
+
n.includes("@") ? ((A = n.split("@")[1]) == null ? void 0 : A.indexOf(".")) === -1 ? s((c) => ({
|
|
105
|
+
...c,
|
|
106
|
+
[t]: "El correo debe contener un punto (.) después del '@'."
|
|
107
|
+
})) : i.test(n) ? s(n ? (c) => ({ ...c, [t]: "" }) : (c) => ({
|
|
108
|
+
...c,
|
|
109
|
+
[t]: "Este campo es obligatorio."
|
|
110
|
+
})) : s((c) => ({
|
|
111
|
+
...c,
|
|
112
|
+
[t]: "Correo inválido."
|
|
113
|
+
})) : s((c) => ({
|
|
114
|
+
...c,
|
|
115
|
+
[t]: "El correo debe contener un '@'."
|
|
116
|
+
}));
|
|
117
|
+
} else if (a === "url") {
|
|
118
|
+
const i = n.trim(), $ = /^https?:\/\//i.test(i) ? i : `http://${i}`;
|
|
119
|
+
try {
|
|
120
|
+
const h = new URL($);
|
|
121
|
+
/\.[a-zA-Z]{2,}$/.test(h.hostname) ? s((x) => ({ ...x, [t]: "" })) : s((x) => ({
|
|
122
|
+
...x,
|
|
123
|
+
[t]: o || "URL inválida. Ej: www.ejemplo.com"
|
|
124
|
+
}));
|
|
125
|
+
} catch {
|
|
126
|
+
s((h) => ({
|
|
127
|
+
...h,
|
|
128
|
+
[t]: o || "URL inválida. Ej: www.ejemplo.com"
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
} else if (a === "genericText")
|
|
132
|
+
n.trim().length < 1 ? s((i) => ({
|
|
133
|
+
...i,
|
|
134
|
+
[t]: o || "Este campo es obligatorio"
|
|
135
|
+
})) : s((i) => ({ ...i, [t]: "" }));
|
|
136
|
+
else if (a === "personName")
|
|
137
|
+
n.trim().length < 1 ? s((i) => ({
|
|
138
|
+
...i,
|
|
139
|
+
[t]: o || "Este campo es obligatorio"
|
|
140
|
+
})) : s((i) => ({ ...i, [t]: "" }));
|
|
141
|
+
else if (a === "textParagraph")
|
|
142
|
+
n.trim().length < 1 ? s((i) => ({
|
|
143
|
+
...i,
|
|
144
|
+
[t]: o || "Este campo es obligatorio"
|
|
145
|
+
})) : s((i) => ({ ...i, [t]: "" }));
|
|
146
|
+
else if (a === "numeroIdentificacion")
|
|
147
|
+
(g === "1" || g === "2") && !/^\d{7,10}$/.test(n) ? s((i) => ({
|
|
148
|
+
...i,
|
|
149
|
+
[t]: o || "Debe tener entre 7 y 10 dígitos numéricos."
|
|
150
|
+
})) : (g === "4" || g === "5") && !/^[A-Z0-9]{7,10}$/.test(n) ? s((i) => ({
|
|
151
|
+
...i,
|
|
152
|
+
[t]: o || "Debe tener entre 7 y 10 caracteres alfanuméricos."
|
|
153
|
+
})) : s((i) => ({ ...i, [t]: "" }));
|
|
154
|
+
else if (a === "formatNIT") {
|
|
155
|
+
const i = /^\d{9}-\d{1}$/;
|
|
156
|
+
n ? /^\d{9}(-\d?)?$/.test(n) ? i.test(n) ? s((c) => ({ ...c, [t]: "" })) : s((c) => ({
|
|
157
|
+
...c,
|
|
158
|
+
[t]: "El formato debe ser 123456789-0."
|
|
159
|
+
})) : s((c) => ({
|
|
160
|
+
...c,
|
|
161
|
+
[t]: "El NIT debe tener 9 dígitos seguidos de un guion y un dígito verificador."
|
|
162
|
+
})) : s((c) => ({
|
|
163
|
+
...c,
|
|
164
|
+
[t]: o || "Este campo es obligatorio."
|
|
165
|
+
}));
|
|
166
|
+
} else
|
|
167
|
+
s((i) => ({ ...i, [t]: "" }));
|
|
168
|
+
const b = e.target.getAttribute("minLength"), p = b ? parseInt(b, 10) : null;
|
|
169
|
+
return p && n.trim().length < p && s((i) => i[t] ? i : {
|
|
170
|
+
...i,
|
|
171
|
+
[t]: o || `Debe ingresar al menos ${p} caracteres.`
|
|
172
|
+
}), n;
|
|
173
|
+
}, handleBlur: (e) => {
|
|
174
|
+
const { value: r, name: t } = e.target, a = r.trim(), o = e.target.getAttribute("data-custom-error");
|
|
175
|
+
return e.target.required && !a && s((l) => ({ ...l, [t]: o || "Este campo es obligatorio." })), a;
|
|
176
|
+
}, handleKeyPress: (e, r) => {
|
|
177
|
+
const t = e.key;
|
|
178
|
+
r === "text" && /\d/.test(t) && e.preventDefault(), r === "number" && /\D/.test(t) && e.preventDefault();
|
|
179
|
+
}, errors: m, counter: f };
|
|
180
|
+
}, Z = (m, s, f) => ({
|
|
181
|
+
control: (d) => ({
|
|
182
|
+
...d,
|
|
183
|
+
borderColor: m && !s[f] ? "#dc3545" : d.borderColor,
|
|
184
|
+
"&:hover": {
|
|
185
|
+
borderColor: m && !s[f] ? "#dc3545" : d["&:hover"].borderColor
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
export {
|
|
190
|
+
Z as IsInvalidStyles,
|
|
191
|
+
z as useFormValidation
|
|
192
|
+
};
|
package/dist/utils.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { AuthProvider as
|
|
2
|
-
import { ProtectedRoute as
|
|
3
|
-
import { UserRoute as
|
|
4
|
-
import { UnpHistorico as
|
|
1
|
+
import { AuthProvider as t } from "./auth/contexts/AuthContex.js";
|
|
2
|
+
import { ProtectedRoute as m } from "./utils/components/ProtectedRoute.js";
|
|
3
|
+
import { UserRoute as f } from "./utils/components/UserRoute.js";
|
|
4
|
+
import { UnpHistorico as x } from "./utils/unp-historico/UnpHistorico.js";
|
|
5
|
+
import { useFormValidation as s } from "./utils/validations/useFormValidation.js";
|
|
6
|
+
import { CaptchaEcosistema as u } from "./utils/captcha/CaptchaEcosistema.js";
|
|
5
7
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
t as AuthProvider,
|
|
9
|
+
u as CaptchaEcosistema,
|
|
10
|
+
m as ProtectedRoute,
|
|
11
|
+
x as UnpHistorico,
|
|
12
|
+
f as UserRoute,
|
|
13
|
+
s as useFormValidation
|
|
10
14
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-ecosistema-unp",
|
|
3
3
|
"author": "Ecosistema de Información - Unidad Nacional de Protección",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.5.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"react-router-dom": ">=6.0.0 <=8.0.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
+
"@marsidev/react-turnstile": "^1.1.0",
|
|
64
65
|
"bootstrap": "^5.3.3",
|
|
65
66
|
"jwt-decode": "^4.0.0",
|
|
66
67
|
"lottie-react": "^2.4.1",
|