react-ecosistema-unp 2.0.0 → 2.1.0

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.
@@ -1,71 +1,78 @@
1
- import { jsxs as b, jsx as r } from "react/jsx-runtime";
2
- import { s as n } from "../../SileoNotifications-BESOBARG.js";
3
- const s = (o) => {
4
- const t = o ? o.toString() : "2147483647";
5
- document.documentElement.style.setProperty("--sileo-z-index", t);
6
- }, g = (o, t = "Éxito", i) => {
7
- s(i), n.success({ title: t, description: o, position: "top-right" });
8
- }, E = (o, t = "Error", i) => {
9
- s(i), n.error({ title: t, description: o, position: "bottom-center" });
10
- }, N = (o, t = "Procesando...", i) => (s(i), n.show({
11
- title: t,
1
+ import { jsxs as _, jsx as u } from "react/jsx-runtime";
2
+ import '../../assets/SileoNotifications.css';/* empty css */
3
+ import { s as i } from "../../index-C1R4rkuA.js";
4
+ const g = 2147483647, m = 3500, A = 6e3, x = 150, l = {
5
+ exito: "#F0FDF4",
6
+ // Fondo Éxito (Verde Pastel)
7
+ error: "#FEF2F2",
8
+ // Fondo Error (Rojo Pastel)
9
+ aviso: "#FFFBEB",
10
+ // Fondo Advertencia (Ámbar Pastel)
11
+ info: "#EFF6FF",
12
+ // Fondo Información (Azul Pastel)
13
+ cargando: "#F9FAFB",
14
+ // Fondo Neutral / Cargando (Gris Pastel)
15
+ accion: "#F5F3FF"
16
+ // Fondo Acción (Morado Pastel)
17
+ }, a = (o) => {
18
+ const e = (o ?? g).toString();
19
+ document.documentElement.style.setProperty("--sileo-z-index", e);
20
+ }, h = (o, e = "Éxito", t) => (a(t), i.success({ title: e, description: o, position: "top-right", duration: m, fill: l.exito })), T = (o, e = "Error", t) => (a(t), i.error({ title: e, description: o, position: "bottom-center", fill: l.error })), y = (o, e = "Procesando...", t) => (a(t), i.show({
21
+ type: "loading",
22
+ title: e,
12
23
  description: o,
13
- icon: /* @__PURE__ */ r("div", { className: "eco-sileo-loading-spinner" }),
24
+ icon: /* @__PURE__ */ u("div", { className: "sileo-loading-spinner eco-sileo-loading-spinner" }),
14
25
  position: "bottom-center",
15
- duration: 0
16
- })), j = (o, t = "Atención", i, e) => {
17
- s(e), n.warning({ title: t, description: o, position: "top-center", duration: i });
18
- }, w = (o, t = "Información", i, e) => {
19
- s(e), n.info({ title: t, description: o, position: "top-center", duration: i });
20
- }, y = () => {
21
- n.clear();
22
- }, A = (o, t, i = {}, e) => {
23
- let c = {};
24
- typeof i == "function" ? c = { onConfirm: i, onCancel: e, showCancel: !!e } : c = i;
25
- const {
26
- labelConfirm: d = "Enviar",
27
- labelCancel: p = "Ajustar",
28
- onConfirm: f = () => {
29
- },
30
- onCancel: m = () => {
31
- },
32
- showCancel: u = !0,
33
- zIndex: C,
34
- position: x = "top-center"
35
- } = c;
36
- s(C);
37
- const a = n.action({
26
+ duration: 0,
27
+ fill: l.cargando
28
+ })), w = (o, e = "Atención", t = A, n) => (a(n), i.warning({ title: e, description: o, position: "top-center", duration: t, fill: l.aviso })), U = (o, e = "Información", t = A, n) => (a(n), i.info({ title: e, description: o, position: "top-center", duration: t, fill: l.info })), j = () => {
29
+ i.clear();
30
+ }, b = (o) => {
31
+ typeof i.dismiss == "function" ? i.dismiss(o) : i.clear();
32
+ }, z = (o, e, t, n, I, v, D) => {
33
+ let r = () => {
34
+ }, d = () => {
35
+ }, f = I || "Si, tomar caso", C = v || "Cancelar", F = !0, p = D, E = "top-center";
36
+ typeof t == "function" ? (r = t, n && (d = n)) : t && typeof t == "object" && (t.onConfirm && (r = t.onConfirm), t.onCancel && (d = t.onCancel), t.labelConfirm && (f = t.labelConfirm), t.labelCancel && (C = t.labelCancel), t.showCancel !== void 0 && (F = t.showCancel), t.zIndex !== void 0 && (p = t.zIndex), t.position && (E = t.position)), a(p);
37
+ let s;
38
+ return s = i.action({
38
39
  title: o,
39
- description: /* @__PURE__ */ b("div", { className: "eco-sileo-action-stack", children: [
40
- /* @__PURE__ */ r("p", { className: "eco-sileo-action-text", children: t }),
41
- u && /* @__PURE__ */ r(
42
- "div",
40
+ fill: l.accion,
41
+ description: /* @__PURE__ */ _("div", { className: "sileo-action-stack eco-sileo-action-stack", children: [
42
+ e ? /* @__PURE__ */ u("div", { className: "sileo-action-text eco-sileo-action-text", children: e }) : null,
43
+ F && /* @__PURE__ */ u(
44
+ "button",
43
45
  {
44
- className: "eco-sileo-btn-ajustar",
45
- role: "button",
46
- onClick: (l) => {
47
- l.preventDefault(), l.stopPropagation(), typeof n.dismiss == "function" ? n.dismiss(a) : n.clear(), setTimeout(() => m(), 150);
46
+ type: "button",
47
+ className: "sileo-btn-ajustar eco-sileo-btn-ajustar",
48
+ style: { pointerEvents: "auto", position: "relative", zIndex: 50 },
49
+ onPointerDown: (c) => c.stopPropagation(),
50
+ onClick: (c) => {
51
+ c.preventDefault(), c.stopPropagation(), b(s), setTimeout(() => d(), x);
48
52
  },
49
- children: p
53
+ children: C
50
54
  }
51
55
  )
52
56
  ] }),
53
- position: x,
57
+ position: E,
54
58
  duration: null,
55
59
  button: {
56
- title: d,
60
+ title: f,
57
61
  onClick: () => {
58
- typeof n.dismiss == "function" ? n.dismiss(a) : n.clear(), setTimeout(() => f(), 150);
62
+ b(s), setTimeout(() => r(), x);
59
63
  }
60
64
  }
61
- });
65
+ }), s;
62
66
  };
63
67
  export {
64
- y as limpiarNotificaciones,
65
- A as notificarAccion,
66
- j as notificarAviso,
67
- N as notificarCargando,
68
- E as notificarError,
69
- g as notificarExito,
70
- w as notificarInfo
68
+ l as COLOR_FILLS,
69
+ b as cerrarNotificacion,
70
+ j as limpiarNotificaciones,
71
+ z as notificarAccion,
72
+ w as notificarAviso,
73
+ y as notificarCargando,
74
+ T as notificarError,
75
+ h as notificarExito,
76
+ U as notificarInfo,
77
+ a as setSileoZIndex
71
78
  };
@@ -1,8 +1,8 @@
1
1
  var u = Object.defineProperty;
2
- var k = (n, t, e) => t in n ? u(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var r = (n, t, e) => k(n, typeof t != "symbol" ? t + "" : t, e);
4
- const i = [3e3, 3e4, 18e4];
5
- class S {
2
+ var S = (c, t, e) => t in c ? u(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
+ var r = (c, t, e) => S(c, typeof t != "symbol" ? t + "" : t, e);
4
+ const a = [3e3, 3e4, 18e4];
5
+ class d {
6
6
  constructor() {
7
7
  r(this, "sockets", /* @__PURE__ */ new Map());
8
8
  r(this, "statusCallbacks", []);
@@ -43,10 +43,10 @@ class S {
43
43
  const s = new WebSocket(t);
44
44
  e.socket = s, s.onopen = () => {
45
45
  console.log(`✅ WebSocket conectado a ${t}`), this.setSocketStatus(t, "connected"), e.reconnectTimer && clearTimeout(e.reconnectTimer), e.reconnectTimer = null, e.retryCount = 0;
46
- }, s.onmessage = (c) => {
46
+ }, s.onmessage = (n) => {
47
47
  try {
48
- const o = JSON.parse(c.data);
49
- e == null || e.messageHandlers.forEach((a) => a(o));
48
+ const o = JSON.parse(n.data);
49
+ e == null || e.messageHandlers.forEach((i) => i(o));
50
50
  } catch (o) {
51
51
  console.error("❌ Error parseando mensaje WebSocket", o);
52
52
  }
@@ -55,16 +55,20 @@ class S {
55
55
  this.setSocketStatus(t, "disconnected");
56
56
  return;
57
57
  }
58
- if (e.retryCount >= i.length) {
58
+ if (typeof document < "u" && document.hidden) {
59
+ console.warn(`🔌 WebSocket: la pestaña está inactiva. Se pausan reintentos para ${t}`), this.setSocketStatus(t, "disconnected");
60
+ return;
61
+ }
62
+ if (e.retryCount >= a.length) {
59
63
  console.warn(`🔌 WebSocket: se agotaron los reintentos para ${t}`), e.shouldReconnect = !1, this.setSocketStatus(t, "disconnected");
60
64
  return;
61
65
  }
62
- const c = i[e.retryCount];
63
- e.retryCount++, console.warn(`🔌 WebSocket cerrado para ${t}. Reintentando en ${c / 1e3}s (intento ${e.retryCount}/${i.length})...`), this.setSocketStatus(t, "connecting"), e.reconnectTimer || (e.reconnectTimer = setTimeout(() => {
66
+ const n = a[e.retryCount];
67
+ e.retryCount++, console.warn(`🔌 WebSocket cerrado para ${t}. Reintentando en ${n / 1e3}s (intento ${e.retryCount}/${a.length})...`), this.setSocketStatus(t, "connecting"), e.reconnectTimer || (e.reconnectTimer = setTimeout(() => {
64
68
  e.reconnectTimer = null, e.shouldReconnect && this.connect(t);
65
- }, c));
66
- }, s.onerror = (c) => {
67
- console.error("⚠️ WebSocket error:", c), this.setSocketStatus(t, "disconnected"), s.close();
69
+ }, n));
70
+ }, s.onerror = (n) => {
71
+ console.error("⚠️ WebSocket error:", n), this.setSocketStatus(t, "disconnected"), s.close();
68
72
  };
69
73
  }
70
74
  disconnect(t) {
@@ -79,13 +83,13 @@ class S {
79
83
  send(t, e) {
80
84
  var s;
81
85
  if (e) {
82
- const c = this.sockets.get(e);
83
- ((s = c == null ? void 0 : c.socket) == null ? void 0 : s.readyState) === WebSocket.OPEN && c.socket.send(JSON.stringify(t));
86
+ const n = this.sockets.get(e);
87
+ ((s = n == null ? void 0 : n.socket) == null ? void 0 : s.readyState) === WebSocket.OPEN && n.socket.send(JSON.stringify(t));
84
88
  return;
85
89
  }
86
- this.sockets.forEach((c) => {
90
+ this.sockets.forEach((n) => {
87
91
  var o;
88
- ((o = c.socket) == null ? void 0 : o.readyState) === WebSocket.OPEN && c.socket.send(JSON.stringify(t));
92
+ ((o = n.socket) == null ? void 0 : o.readyState) === WebSocket.OPEN && n.socket.send(JSON.stringify(t));
89
93
  });
90
94
  }
91
95
  subscribe(t, e) {
@@ -96,7 +100,7 @@ class S {
96
100
  s == null || s.messageHandlers.delete(e);
97
101
  }
98
102
  }
99
- const h = new S();
103
+ const h = new d();
100
104
  export {
101
105
  h as webSocketService
102
106
  };
package/dist/utils.js CHANGED
@@ -1,38 +1,41 @@
1
- import { formatDate as t } from "./utils/formatters/dateFormatter.js";
1
+ import { formatDate as e } from "./utils/formatters/dateFormatter.js";
2
2
  import { IsInvalidStyles as i, useFormValidation as a } from "./utils/validations/useFormValidation.js";
3
- import { CaptchaEcosistema as c } from "./utils/captcha/CaptchaEcosistema.js";
3
+ import { CaptchaEcosistema as f } from "./utils/captcha/CaptchaEcosistema.js";
4
4
  import { useFetchData as n } from "./utils/fetch-data/useFetchData.js";
5
5
  import { WebSocketProvider as x, useWebSocketConnection as s } from "./utils/websocket-manager/WebSocketContext.js";
6
6
  import { useWebSocket as u } from "./utils/websocket-manager/useWebSocket.js";
7
- import { ModalRadicado as v } from "./utils/modal-radicados/ModalRadicado.js";
8
- import { ModalDocumento as E } from "./utils/modal-radicados/ModalDocumento.js";
9
- import { limpiarNotificaciones as b, notificarAccion as k, notificarAviso as C, notificarCargando as I, notificarError as P, notificarExito as R, notificarInfo as W } from "./utils/notifications/SileoNotifications.js";
10
- import { T as A } from "./SileoNotifications-BESOBARG.js";
11
- import { EcoProvider as M } from "./utils/eco-provider/EcoContext.js";
12
- import { ProtectedRoute as U } from "./utils/components/ProtectedRoute.js";
13
- import { UserRoute as g } from "./utils/components/UserRoute.js";
14
- import { UnpHistorico as H } from "./utils/unp-historico/UnpHistorico.js";
15
- import { VisorDocumento as j } from "./utils/modal-radicados/VisorDocumento.js";
7
+ import { ModalRadicado as S } from "./utils/modal-radicados/ModalRadicado.js";
8
+ import { ModalDocumento as v } from "./utils/modal-radicados/ModalDocumento.js";
9
+ import { COLOR_FILLS as D, cerrarNotificacion as E, limpiarNotificaciones as R, notificarAccion as b, notificarAviso as k, notificarCargando as F, notificarError as L, notificarExito as P, notificarInfo as W, setSileoZIndex as h } from "./utils/notifications/SileoNotifications.js";
10
+ import { Toaster as M } from "./utils/notifications/EcoToaster.js";
11
+ import { EcoProvider as O } from "./utils/eco-provider/EcoContext.js";
12
+ import { ProtectedRoute as V } from "./utils/components/ProtectedRoute.js";
13
+ import { UserRoute as y } from "./utils/components/UserRoute.js";
14
+ import { UnpHistorico as T } from "./utils/unp-historico/UnpHistorico.js";
15
+ import { VisorDocumento as _ } from "./utils/modal-radicados/VisorDocumento.js";
16
16
  export {
17
- c as CaptchaEcosistema,
18
- M as EcoProvider,
17
+ D as COLOR_FILLS,
18
+ f as CaptchaEcosistema,
19
+ O as EcoProvider,
19
20
  i as IsInvalidStyles,
20
- E as ModalDocumento,
21
- v as ModalRadicado,
22
- U as ProtectedRoute,
23
- A as Toaster,
24
- H as UnpHistorico,
25
- g as UserRoute,
26
- j as VisorDocumento,
21
+ v as ModalDocumento,
22
+ S as ModalRadicado,
23
+ V as ProtectedRoute,
24
+ M as Toaster,
25
+ T as UnpHistorico,
26
+ y as UserRoute,
27
+ _ as VisorDocumento,
27
28
  x as WebSocketProvider,
28
- t as formatDate,
29
- b as limpiarNotificaciones,
30
- k as notificarAccion,
31
- C as notificarAviso,
32
- I as notificarCargando,
33
- P as notificarError,
34
- R as notificarExito,
29
+ E as cerrarNotificacion,
30
+ e as formatDate,
31
+ R as limpiarNotificaciones,
32
+ b as notificarAccion,
33
+ k as notificarAviso,
34
+ F as notificarCargando,
35
+ L as notificarError,
36
+ P as notificarExito,
35
37
  W as notificarInfo,
38
+ h as setSileoZIndex,
36
39
  n as useFetchData,
37
40
  a as useFormValidation,
38
41
  u as useWebSocket,
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": "2.0.0",
5
+ "version": "2.1.0",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {