@onpe/ui 1.2.40 → 1.2.42
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/README.md +192 -13
- package/dist/components/Feedback/ModalDnieVersions/ModalDnieVersions.d.ts +9 -0
- package/dist/components/Feedback/ModalDnieVersions/index.d.ts +4 -0
- package/dist/components/Feedback/ModalNfc/ModalNfc.d.ts +9 -0
- package/dist/components/Feedback/ModalNfc/index.d.ts +4 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components.css +416 -285
- package/dist/components.esm.css +416 -285
- package/dist/components.esm.js +34 -29
- package/dist/components.js +34 -29
- package/dist/icons/Actions/IconCloseRadius/IconCloseRadius.d.ts +4 -0
- package/dist/icons/Actions/IconCloseRadius/index.d.ts +2 -0
- package/dist/icons/Actions/IconMobileNfc/IconMobileNfc.d.ts +4 -0
- package/dist/icons/Actions/IconMobileNfc/index.d.ts +4 -0
- package/dist/icons/Actions/index.d.ts +1 -0
- package/dist/index.css +416 -285
- package/dist/index.esm.css +416 -285
- package/dist/index.esm.js +36 -29
- package/dist/index.js +36 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,9 +35,10 @@ npx @onpe/ui add <componente>
|
|
|
35
35
|
|
|
36
36
|
- **Prefijos Únicos**: Todas las clases usan el prefijo `onpe-` para evitar conflictos
|
|
37
37
|
- **CSS Compilado**: Se genera un CSS optimizado y minificado sin `@import` de Tailwind
|
|
38
|
-
- **Variables CSS
|
|
38
|
+
- **Variables CSS en `:root`**: Colores con prefijos únicos (`--onpe-ui-blue`, etc.) disponibles globalmente
|
|
39
39
|
- **Sin Reset de Tailwind**: No interfiere con tu configuración existente
|
|
40
40
|
- **Compatible con**: Material UI, Shadcn, Chakra UI, Ant Design, Bootstrap, etc.
|
|
41
|
+
- **CSP Compatible**: Genera archivos CSS externos para cumplir con Content Security Policy
|
|
41
42
|
|
|
42
43
|
### 🚀 Instalación Rápida
|
|
43
44
|
|
|
@@ -47,6 +48,7 @@ npm install @onpe/ui
|
|
|
47
48
|
|
|
48
49
|
```tsx
|
|
49
50
|
// Importar estilos compilados (solo una vez en tu app)
|
|
51
|
+
// ⚠️ IMPORTANTE: Esto define las variables CSS en :root
|
|
50
52
|
import '@onpe/ui/dist/index.css';
|
|
51
53
|
|
|
52
54
|
// O usando el export específico
|
|
@@ -65,6 +67,85 @@ function App() {
|
|
|
65
67
|
}
|
|
66
68
|
```
|
|
67
69
|
|
|
70
|
+
### 🎨 Variables CSS en `:root`
|
|
71
|
+
|
|
72
|
+
**Los colores ONPE se definen automáticamente en `:root` cuando importas el CSS:**
|
|
73
|
+
|
|
74
|
+
```css
|
|
75
|
+
:root {
|
|
76
|
+
--onpe-ui-blue: #003770;
|
|
77
|
+
--onpe-ui-skyblue: #0073cf;
|
|
78
|
+
--onpe-ui-skyblue-light: #69b2e8;
|
|
79
|
+
--onpe-ui-yellow: #ffb81c;
|
|
80
|
+
--onpe-ui-light-skyblue: #aaeff6;
|
|
81
|
+
--onpe-ui-gray: #bcbcbc;
|
|
82
|
+
--onpe-ui-gray-light: #bdbdbd;
|
|
83
|
+
--onpe-ui-gray-extra-light: #f2f2f2;
|
|
84
|
+
--onpe-ui-red: #e3002b;
|
|
85
|
+
--onpe-ui-dark-gray: #4f4f4f;
|
|
86
|
+
--onpe-ui-green: #76bd43;
|
|
87
|
+
--onpe-ui-yellow-light: #FFF1D2;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Esto permite:**
|
|
92
|
+
- ✅ **Uso directo en CSS del proyecto host**
|
|
93
|
+
- ✅ **Sobrescribir colores si es necesario**
|
|
94
|
+
- ✅ **Compatibilidad con CSP (Content Security Policy)**
|
|
95
|
+
- ✅ **Acceso global a los colores ONPE**
|
|
96
|
+
|
|
97
|
+
### 💡 Uso de Variables CSS en tu Proyecto
|
|
98
|
+
|
|
99
|
+
**Puedes usar los colores ONPE directamente en tu CSS:**
|
|
100
|
+
|
|
101
|
+
```css
|
|
102
|
+
/* En tu archivo CSS del proyecto host */
|
|
103
|
+
.mi-componente {
|
|
104
|
+
color: var(--onpe-ui-blue);
|
|
105
|
+
background: var(--onpe-ui-skyblue-light);
|
|
106
|
+
border: 2px solid var(--onpe-ui-red);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.mi-boton-personalizado {
|
|
110
|
+
background: var(--onpe-ui-green);
|
|
111
|
+
color: white;
|
|
112
|
+
padding: 12px 24px;
|
|
113
|
+
border-radius: 8px;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Sobrescribir colores si es necesario:**
|
|
118
|
+
|
|
119
|
+
```css
|
|
120
|
+
/* En tu archivo CSS del proyecto host */
|
|
121
|
+
:root {
|
|
122
|
+
/* Cambiar el azul principal */
|
|
123
|
+
--onpe-ui-blue: #1a365d;
|
|
124
|
+
|
|
125
|
+
/* Cambiar el rojo */
|
|
126
|
+
--onpe-ui-red: #c53030;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Uso en componentes React con estilos inline:**
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
function MiComponente() {
|
|
134
|
+
return (
|
|
135
|
+
<div
|
|
136
|
+
style={{
|
|
137
|
+
color: 'var(--onpe-ui-blue)',
|
|
138
|
+
backgroundColor: 'var(--onpe-ui-skyblue-light)',
|
|
139
|
+
padding: '16px',
|
|
140
|
+
borderRadius: '8px'
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
Contenido con colores ONPE
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
68
149
|
### 🎯 ¿Cómo Evitamos Conflictos?
|
|
69
150
|
|
|
70
151
|
1. **Prefijos Únicos**: `bg-blue-500` → `onpe-bg-onpe-ui-blue`
|
|
@@ -714,7 +795,7 @@ function App() {
|
|
|
714
795
|
|
|
715
796
|
### ModalConfirm
|
|
716
797
|
|
|
717
|
-
Modal de confirmación para acciones importantes.
|
|
798
|
+
Modal de confirmación para acciones importantes con colores dinámicos.
|
|
718
799
|
|
|
719
800
|
```tsx
|
|
720
801
|
import { ModalConfirm } from '@onpe/ui/components';
|
|
@@ -723,20 +804,52 @@ function App() {
|
|
|
723
804
|
const [showConfirm, setShowConfirm] = useState(false);
|
|
724
805
|
|
|
725
806
|
return (
|
|
726
|
-
<
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
807
|
+
<div className="space-y-4">
|
|
808
|
+
{/* Modal Azul (Por Defecto) */}
|
|
809
|
+
<ModalConfirm
|
|
810
|
+
isOpen={showConfirm}
|
|
811
|
+
onClose={() => setShowConfirm(false)}
|
|
812
|
+
onConfirm={() => {
|
|
813
|
+
// Acción a confirmar
|
|
814
|
+
setShowConfirm(false);
|
|
815
|
+
}}
|
|
816
|
+
title="Confirmar acción"
|
|
817
|
+
message="¿Estás seguro de realizar esta acción?"
|
|
818
|
+
color="blue" // Por defecto
|
|
819
|
+
/>
|
|
820
|
+
|
|
821
|
+
{/* Modal Rojo para Advertencias */}
|
|
822
|
+
<ModalConfirm
|
|
823
|
+
isOpen={showConfirm}
|
|
824
|
+
onClose={() => setShowConfirm(false)}
|
|
825
|
+
onConfirm={() => {
|
|
826
|
+
// Acción peligrosa
|
|
827
|
+
setShowConfirm(false);
|
|
828
|
+
}}
|
|
829
|
+
title="Advertencia"
|
|
830
|
+
message="Esta acción es irreversible y no se puede deshacer."
|
|
831
|
+
color="red" // Color rojo para advertencias
|
|
832
|
+
icon="warning"
|
|
833
|
+
/>
|
|
834
|
+
</div>
|
|
736
835
|
);
|
|
737
836
|
}
|
|
738
837
|
```
|
|
739
838
|
|
|
839
|
+
#### Props del ModalConfirm
|
|
840
|
+
|
|
841
|
+
| Prop | Tipo | Default | Descripción |
|
|
842
|
+
|------|------|---------|-------------|
|
|
843
|
+
| `isOpen` | `boolean` | - | Estado de apertura del modal (requerido) |
|
|
844
|
+
| `onClose` | `function` | - | Función para cerrar el modal (requerido) |
|
|
845
|
+
| `onConfirm` | `function` | - | Función para confirmar la acción (requerido) |
|
|
846
|
+
| `title` | `string` | - | Título del modal (requerido) |
|
|
847
|
+
| `message` | `string` | - | Mensaje del modal (requerido) |
|
|
848
|
+
| `color` | `'blue' \| 'red'` | `'blue'` | Color del icono y título |
|
|
849
|
+
| `icon` | `'warning' \| 'success'` | `'warning'` | Tipo de icono a mostrar |
|
|
850
|
+
| `confirmText` | `string` | `'Confirmar'` | Texto del botón de confirmación |
|
|
851
|
+
| `cancelText` | `string` | `'Cancelar'` | Texto del botón de cancelación |
|
|
852
|
+
|
|
740
853
|
### ModalLoading
|
|
741
854
|
|
|
742
855
|
Modal de carga para mostrar estados de procesamiento.
|
|
@@ -966,12 +1079,78 @@ La librería incluye breakpoints personalizados para ONPE:
|
|
|
966
1079
|
.bg-onpe-ui-gray-extra-light /* Fondo gris muy claro */
|
|
967
1080
|
```
|
|
968
1081
|
|
|
1082
|
+
## 🛡️ Compatibilidad con CSP (Content Security Policy)
|
|
1083
|
+
|
|
1084
|
+
**La librería es completamente compatible con Content Security Policy estricto.**
|
|
1085
|
+
|
|
1086
|
+
### ✅ Características CSP
|
|
1087
|
+
|
|
1088
|
+
- **Archivos CSS externos**: No usa estilos inline que violen CSP
|
|
1089
|
+
- **Sin `'unsafe-inline'`**: Compatible con `style-src 'self'`
|
|
1090
|
+
- **Variables CSS en `:root`**: Disponibles globalmente sin violar políticas
|
|
1091
|
+
- **Archivos estáticos**: Todos los recursos se sirven como archivos externos
|
|
1092
|
+
|
|
1093
|
+
### 🔧 Configuración CSP Recomendada
|
|
1094
|
+
|
|
1095
|
+
```html
|
|
1096
|
+
<!-- En tu HTML head -->
|
|
1097
|
+
<meta http-equiv="Content-Security-Policy"
|
|
1098
|
+
content="style-src 'self' https://fonts.googleapis.com;
|
|
1099
|
+
script-src 'self';
|
|
1100
|
+
img-src 'self' data:;">
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
### 📋 Instrucciones para Proyectos con CSP
|
|
1104
|
+
|
|
1105
|
+
**1. Instalar la librería:**
|
|
1106
|
+
```bash
|
|
1107
|
+
npm install @onpe/ui@1.2.40
|
|
1108
|
+
```
|
|
1109
|
+
|
|
1110
|
+
**2. Importar CSS (CRÍTICO):**
|
|
1111
|
+
```tsx
|
|
1112
|
+
// ✅ CORRECTO - Esto carga el CSS externo
|
|
1113
|
+
import '@onpe/ui/dist/index.css';
|
|
1114
|
+
import { ModalConfirm, Button } from '@onpe/ui/components';
|
|
1115
|
+
```
|
|
1116
|
+
|
|
1117
|
+
**3. Verificar que las variables CSS estén disponibles:**
|
|
1118
|
+
```tsx
|
|
1119
|
+
// Las variables CSS se definen automáticamente en :root
|
|
1120
|
+
function MiComponente() {
|
|
1121
|
+
return (
|
|
1122
|
+
<div style={{ color: 'var(--onpe-ui-blue)' }}>
|
|
1123
|
+
Este texto usa el color azul ONPE
|
|
1124
|
+
</div>
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
### ⚠️ Problemas Comunes con CSP
|
|
1130
|
+
|
|
1131
|
+
**Error: "Refused to apply inline style"**
|
|
1132
|
+
```bash
|
|
1133
|
+
# ❌ PROBLEMA: Estilos inline bloqueados por CSP
|
|
1134
|
+
# ✅ SOLUCIÓN: Usar archivos CSS externos (ya implementado)
|
|
1135
|
+
```
|
|
1136
|
+
|
|
1137
|
+
**Error: "Variable CSS not defined"**
|
|
1138
|
+
```tsx
|
|
1139
|
+
// ❌ PROBLEMA: No importar el CSS
|
|
1140
|
+
import { Button } from '@onpe/ui/components';
|
|
1141
|
+
|
|
1142
|
+
// ✅ SOLUCIÓN: Importar CSS primero
|
|
1143
|
+
import '@onpe/ui/dist/index.css';
|
|
1144
|
+
import { Button } from '@onpe/ui/components';
|
|
1145
|
+
```
|
|
1146
|
+
|
|
969
1147
|
## 📋 Versiones
|
|
970
1148
|
|
|
971
|
-
- **v1.
|
|
1149
|
+
- **v1.2.40** - Versión actual con CSP compatible
|
|
972
1150
|
- Compatible con React 16.8+
|
|
973
1151
|
- TailwindCSS v4
|
|
974
1152
|
- TypeScript 5.3+
|
|
1153
|
+
- CSP (Content Security Policy) compatible
|
|
975
1154
|
|
|
976
1155
|
## 🔧 Desarrollo
|
|
977
1156
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./ModalDnieVersions.css";
|
|
2
|
+
export interface ModalDnieVersionsProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ModalDnieVersions: ({ isOpen, onClose, className }: ModalDnieVersionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default ModalDnieVersions;
|
|
9
|
+
//# sourceMappingURL=ModalDnieVersions.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./ModalNfc.css";
|
|
2
|
+
export interface ModalNfcProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ModalNfc: ({ isOpen, onClose, className }: ModalNfcProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default ModalNfc;
|
|
9
|
+
//# sourceMappingURL=ModalNfc.d.ts.map
|
|
@@ -3,4 +3,8 @@ export type { ButtonProps } from "./Button";
|
|
|
3
3
|
export { Footer } from "./Footer";
|
|
4
4
|
export type { FooterProps } from "./Footer";
|
|
5
5
|
export { BrowserRecommended } from "./BrowserRecommended";
|
|
6
|
+
export { ModalDnieVersions } from "./Feedback/ModalDnieVersions";
|
|
7
|
+
export type { ModalDnieVersionsProps } from "./Feedback/ModalDnieVersions";
|
|
8
|
+
export { ModalNfc } from "./Feedback/ModalNfc";
|
|
9
|
+
export type { ModalNfcProps } from "./Feedback/ModalNfc";
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|