@klu_dev/ui-klu-green 1.2.10 → 1.2.11
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 +66 -0
- package/dist/index.css +15 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ npm install @klu_dev/ui-klu-green
|
|
|
27
27
|
- InputCode
|
|
28
28
|
- GridCard
|
|
29
29
|
- CheckBox
|
|
30
|
+
- InputPhone
|
|
30
31
|
|
|
31
32
|
## Antes de comenzar a agregar componentes
|
|
32
33
|
|
|
@@ -897,3 +898,68 @@ export default function CheckboxExample() {
|
|
|
897
898
|
| `checked` | `boolean` | - | Estado binario síncrono en modo controlado. |
|
|
898
899
|
| `onChange` | `(checked: boolean) => void` | - | Callback gatillado automáticamente al alterar la interacción del recuadro. |
|
|
899
900
|
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
## Uso de InputPhone
|
|
904
|
+
El componente InputPhone es un campo de entrada de texto optimizado para la captura de números telefónicos. Permite la selección dinámica de prefijos internacionales (LADAS/códigos de país) mediante un menú desplegable integrado y ofrece soporte nativo para la validación y visualización de estados de error, variantes de tamaño y un comportamiento adaptables (full width).
|
|
905
|
+
|
|
906
|
+
```tsx
|
|
907
|
+
import React, { useState } from 'react';
|
|
908
|
+
import { InputPhone } from './components/InputPhone';
|
|
909
|
+
|
|
910
|
+
const RegistrationForm = () => {
|
|
911
|
+
const [phoneNumber, setPhoneNumber] = useState('');
|
|
912
|
+
const [error, setError] = useState('');
|
|
913
|
+
|
|
914
|
+
const paisesLadas = [
|
|
915
|
+
{ label: 'MX', code: '+52' },
|
|
916
|
+
{ label: 'US', code: '+1' },
|
|
917
|
+
{ label: 'ES', code: '+34' },
|
|
918
|
+
{ label: 'AR', code: '+54' },
|
|
919
|
+
{ label: 'CO', code: '+57' },
|
|
920
|
+
{ label: 'CL', code: '+56' },
|
|
921
|
+
{ label: 'PE', code: '+51' },
|
|
922
|
+
];
|
|
923
|
+
|
|
924
|
+
const handlePhoneChange = (value: string) => {
|
|
925
|
+
setPhoneNumber(value);
|
|
926
|
+
// Validación simple de longitud sin espacios
|
|
927
|
+
const pureNumbers = value.replace(/\s/g, '');
|
|
928
|
+
if (pureNumbers.length > 0 && pureNumbers.length < 10) {
|
|
929
|
+
setError('El número telefónico debe tener al menos 10 dígitos.');
|
|
930
|
+
} else {
|
|
931
|
+
setError('');
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
return (
|
|
936
|
+
<div style={{ maxWidth: '400px', padding: '20px' }}>
|
|
937
|
+
<label htmlFor="phone">Número de Teléfono</label>
|
|
938
|
+
<InputPhone
|
|
939
|
+
id="phone"
|
|
940
|
+
size="full"
|
|
941
|
+
placeholder="55 0000 0000"
|
|
942
|
+
value={phoneNumber}
|
|
943
|
+
onChange={handlePhoneChange}
|
|
944
|
+
error={error}
|
|
945
|
+
ladas={paisesLadas}
|
|
946
|
+
defaultLadaIndex={0} // Selecciona MX por defecto
|
|
947
|
+
/>
|
|
948
|
+
</div>
|
|
949
|
+
);
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
export default RegistrationForm;
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
### Props de InputPhone
|
|
956
|
+
|
|
957
|
+
| Prop | Tipo | Por Defecto | Descripción |
|
|
958
|
+
| :--- | :--- | :--- | :--- |
|
|
959
|
+
| `size` | `'sm' \| 'md' \| 'lg' \| 'full'` | `'lg'` | Define las dimensiones del componente. `full` expande el input al 100% del ancho del contenedor. |
|
|
960
|
+
| `placeholder` | `string` | *Opcional* | Texto de ayuda que se muestra cuando el input está vacío. |
|
|
961
|
+
| `value` | `string` | *Opcional* | El valor actual del campo de texto (para componentes controlados). |
|
|
962
|
+
| `onChange` | `(value: string) => void` | *Opcional* | Función callback que se ejecuta cada vez que el usuario escribe o modifica el valor. |
|
|
963
|
+
| `error` | `string` | *Opcional* | Mensaje de error. Si se proporciona, el componente cambia visualmente a un estado de error y despliega el texto. |
|
|
964
|
+
| `ladas` | `Array<{ label: string; code: string }>` | *Opcional* | Listado de códigos telefónicos de país para el menú desplegable. |
|
|
965
|
+
| `defaultLadaIndex` | `number` | *Opcional* | Índice del arreglo de `ladas` que se seleccionará de manera inicial por defecto. |
|
package/dist/index.css
CHANGED
|
@@ -287,6 +287,11 @@ button,
|
|
|
287
287
|
.uiklu-m-0{
|
|
288
288
|
margin: 0px;
|
|
289
289
|
|
|
290
|
+
}
|
|
291
|
+
.uiklu-mx-2{
|
|
292
|
+
margin-left: 0.5rem;
|
|
293
|
+
margin-right: 0.5rem;
|
|
294
|
+
|
|
290
295
|
}
|
|
291
296
|
.uiklu-mx-auto{
|
|
292
297
|
margin-left: auto;
|
|
@@ -522,8 +527,8 @@ button,
|
|
|
522
527
|
max-height: 24rem;
|
|
523
528
|
|
|
524
529
|
}
|
|
525
|
-
.uiklu-max-h-\[
|
|
526
|
-
max-height:
|
|
530
|
+
.uiklu-max-h-\[150px\]{
|
|
531
|
+
max-height: 150px;
|
|
527
532
|
|
|
528
533
|
}
|
|
529
534
|
.uiklu-max-h-\[40px\]{
|
|
@@ -581,10 +586,6 @@ button,
|
|
|
581
586
|
.uiklu-w-8{
|
|
582
587
|
width: 2rem;
|
|
583
588
|
|
|
584
|
-
}
|
|
585
|
-
.uiklu-w-\[120px\]{
|
|
586
|
-
width: 120px;
|
|
587
|
-
|
|
588
589
|
}
|
|
589
590
|
.uiklu-w-\[141px\]{
|
|
590
591
|
width: 141px;
|
|
@@ -938,6 +939,10 @@ button,
|
|
|
938
939
|
.uiklu-gap-\[20px\]{
|
|
939
940
|
gap: 20px;
|
|
940
941
|
|
|
942
|
+
}
|
|
943
|
+
.uiklu-gap-\[2px\]{
|
|
944
|
+
gap: 2px;
|
|
945
|
+
|
|
941
946
|
}
|
|
942
947
|
.uiklu-gap-x-1\.5{
|
|
943
948
|
-moz-column-gap: 0.375rem;
|
|
@@ -1646,6 +1651,10 @@ button,
|
|
|
1646
1651
|
.uiklu-pt-4{
|
|
1647
1652
|
padding-top: 1rem;
|
|
1648
1653
|
|
|
1654
|
+
}
|
|
1655
|
+
.uiklu-pt-\[10px\]{
|
|
1656
|
+
padding-top: 10px;
|
|
1657
|
+
|
|
1649
1658
|
}
|
|
1650
1659
|
.uiklu-pt-\[20px\]{
|
|
1651
1660
|
padding-top: 20px;
|
|
@@ -2268,11 +2277,6 @@ input.uiklu-flex:not(:placeholder-shown) {
|
|
|
2268
2277
|
|
|
2269
2278
|
}
|
|
2270
2279
|
|
|
2271
|
-
.hover\:uiklu-bg-primary900\/10:hover{
|
|
2272
|
-
background-color: hsl(var(--uiklu-primary-900) / 0.1);
|
|
2273
|
-
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
2280
|
.hover\:uiklu-bg-primary900\/5:hover{
|
|
2277
2281
|
background-color: hsl(var(--uiklu-primary-900) / 0.05);
|
|
2278
2282
|
|
|
@@ -2441,18 +2445,6 @@ input.uiklu-flex:not(:placeholder-shown) {
|
|
|
2441
2445
|
|
|
2442
2446
|
}
|
|
2443
2447
|
|
|
2444
|
-
.data-\[highlighted\]\:uiklu-bg-primary900[data-highlighted]{
|
|
2445
|
-
--tw-bg-opacity: 1;
|
|
2446
|
-
background-color: hsl(var(--uiklu-primary-900) / var(--tw-bg-opacity, 1));
|
|
2447
|
-
|
|
2448
|
-
}
|
|
2449
|
-
|
|
2450
|
-
.data-\[highlighted\]\:uiklu-text-white[data-highlighted]{
|
|
2451
|
-
--tw-text-opacity: 1;
|
|
2452
|
-
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
|
|
2453
|
-
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
2448
|
.data-\[placeholder\]\:uiklu-text-gray500[data-placeholder]{
|
|
2457
2449
|
--tw-text-opacity: 1;
|
|
2458
2450
|
color: hsl(var(--uiklu-gray-500) / var(--tw-text-opacity, 1));
|