@klu_dev/ui-klu-green 1.2.6 → 1.2.7
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 +86 -1
- package/dist/index.css +30 -0
- package/dist/index.d.ts +28 -2
- package/dist/index.js +255 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,11 @@ npm install @klu_dev/ui-klu-green
|
|
|
20
20
|
- BalanceInfo
|
|
21
21
|
- Toast
|
|
22
22
|
- LoaderScreen
|
|
23
|
+
- PromoBanner
|
|
24
|
+
- SidebarTabs
|
|
25
|
+
- MobileMenuDrawer
|
|
26
|
+
- SearchSelect
|
|
27
|
+
- InputCode
|
|
23
28
|
|
|
24
29
|
## Antes de comenzar a agregar componentes
|
|
25
30
|
|
|
@@ -724,7 +729,6 @@ export function AppMobileLayout() {
|
|
|
724
729
|
```
|
|
725
730
|
|
|
726
731
|
|
|
727
|
-
### Props de MobileMenuDrawer
|
|
728
732
|
### Props de MobileMenuDrawer
|
|
729
733
|
|
|
730
734
|
| Prop | Tipo | Descripción |
|
|
@@ -736,3 +740,84 @@ export function AppMobileLayout() {
|
|
|
736
740
|
| `onTabChange` | `(id: string) => void` | Callback gatillado al pulsar una nueva opción del menú. Devuelve el `id`. |
|
|
737
741
|
|
|
738
742
|
|
|
743
|
+
## Uso de InputCode
|
|
744
|
+
|
|
745
|
+
Componente modular de 6 celdas independientes para captura de tokens numéricos (MFA/OTP). Soporta autoenfoque secuencial inteligente, pegado (paste) masivo inteligente de cadenas numéricas enteras y control condicional de estados destructivos.
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
```tsx
|
|
749
|
+
import { InputCode } from "@klu_dev/ui-klu-green"
|
|
750
|
+
import { useState } from "react"
|
|
751
|
+
|
|
752
|
+
export default function VerificationForm() {
|
|
753
|
+
const [hasError, setHasError] = useState(false)
|
|
754
|
+
|
|
755
|
+
const handleComplete = (code: string) => {
|
|
756
|
+
console.log("Código unificado enviado:", code)
|
|
757
|
+
if (code !== "123456") {
|
|
758
|
+
setHasError(true) // Pinta bordes y texto numérico en color destructivo
|
|
759
|
+
} else {
|
|
760
|
+
setHasError(false)
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
return (
|
|
765
|
+
<div className="uiklu-max-w-[400px] uiklu-mx-auto uiklu-p-6">
|
|
766
|
+
<InputCode hasError="{hasError}" onComplete="{handleComplete}" title="Código de seguridad SMS"/>
|
|
767
|
+
{hasError && (
|
|
768
|
+
<p className="uiklu-text-destructive uiklu-text-xs uiklu-text-center uiklu-mt-2">
|
|
769
|
+
Código inválido. Revisa tus dígitos e intenta de nuevo.
|
|
770
|
+
</p>
|
|
771
|
+
)}
|
|
772
|
+
</div>
|
|
773
|
+
)
|
|
774
|
+
}
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
### Props de InputCode
|
|
778
|
+
|
|
779
|
+
| Prop | Tipo | Por defecto | Descripción |
|
|
780
|
+
| :--- | :--- | :--- | :--- |
|
|
781
|
+
| `title` | `string` | `"Código de autenticación"` | Texto dinámico renderizado en la etiqueta del componente. |
|
|
782
|
+
| `hasError` | `boolean` | `false` | Modifica de forma síncrona el color de los bordes y el contenido numérico a la variable destructiva. |
|
|
783
|
+
| `onComplete` | `(code: string) => void` | - | Callback gatillado automáticamente cuando se ha rellenado la celda número 6. |
|
|
784
|
+
|
|
785
|
+
## Uso de SearchSelect
|
|
786
|
+
|
|
787
|
+
Componente de menú desplegable de búsqueda avanzada impulsado con Radix UI Popover. Permite filtrado de texto reactivo en tiempo real con limpieza rápida integrada, slots dinámicos laterales adicionales y escala adaptativa de dimensiones.
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
```tsx
|
|
791
|
+
import { SearchSelect } from "@klu_dev/ui-klu-green"
|
|
792
|
+
import { useState } from "react"
|
|
793
|
+
|
|
794
|
+
export default function BankSelector() {
|
|
795
|
+
const [selectedBank, setSelectedBank] = useState("")
|
|
796
|
+
|
|
797
|
+
const bancos = [
|
|
798
|
+
{ value: "002", label: "Banamex", extra: <span className="uiklu-text-xs uiklu-opacity-50">Nacional</span> },
|
|
799
|
+
{ value: "012", label: "BBVA Bancomer" },
|
|
800
|
+
{ value: "014", label: "Santander", extra: <span className="uiklu-text-xs uiklu-text-primary">Popular</span> },
|
|
801
|
+
{ value: "072", label: "Banorte" },
|
|
802
|
+
{ value: "646", label: "KLU Banca Digital" }
|
|
803
|
+
]
|
|
804
|
+
|
|
805
|
+
return (
|
|
806
|
+
<div className="uiklu-flex uiklu-flex-col uiklu-gap-4 uiklu-p-6">
|
|
807
|
+
<SearchSelect error="{false}" onChange="{setSelectedBank}" options="{bancos}" placeholder="Selecciona tu banco emisor..." size="lg" value="{selectedBank}"/>
|
|
808
|
+
<p className="uiklu-text-sm">ID Banco Seleccionado: <strong>{selectedBank || "Ninguno"}</strong></p>
|
|
809
|
+
</div>
|
|
810
|
+
)
|
|
811
|
+
}
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
### Props de SearchSelect
|
|
815
|
+
| Prop | Tipo | Por defecto | Descripción |
|
|
816
|
+
| :--- | :--- | :--- | :--- |
|
|
817
|
+
| `options` | `Option[]` | - | Listado de opciones de formato `{ value: string; label: string; extra?: ReactNode }`. |
|
|
818
|
+
| `value` | `string` | - | ID de la opción seleccionada. |
|
|
819
|
+
| `onChange` | `(value: string) => void` | - | Callback despachado al seleccionar o limpiar una opción. |
|
|
820
|
+
| `placeholder` | `string` | `"Buscar..."` | Texto de soporte visible cuando el campo se encuentra vacío. |
|
|
821
|
+
| `size` | `'sm' \| 'md' \| 'lg' \| 'full'` | `'lg'` | Determina la escala del ancho mínimo, alto de caja e interlineado tipográfico interno. |
|
|
822
|
+
| `error` | `boolean` | `false` | Alterna el color de la caja a la paleta destructiva y formatea el color del placeholder. |
|
|
823
|
+
| `disabled` | `boolean` | `false` | Inactiva por completo la interacción del gatillo y cancela el despliegue del Popover. |
|
package/dist/index.css
CHANGED
|
@@ -321,6 +321,10 @@ button,
|
|
|
321
321
|
.uiklu-mb-\[10px\]{
|
|
322
322
|
margin-bottom: 10px;
|
|
323
323
|
|
|
324
|
+
}
|
|
325
|
+
.uiklu-mb-\[12px\]{
|
|
326
|
+
margin-bottom: 12px;
|
|
327
|
+
|
|
324
328
|
}
|
|
325
329
|
.uiklu-mb-\[18px\]{
|
|
326
330
|
margin-bottom: 18px;
|
|
@@ -461,6 +465,10 @@ button,
|
|
|
461
465
|
.uiklu-h-\[40px\]{
|
|
462
466
|
height: 40px;
|
|
463
467
|
|
|
468
|
+
}
|
|
469
|
+
.uiklu-h-\[43px\]{
|
|
470
|
+
height: 43px;
|
|
471
|
+
|
|
464
472
|
}
|
|
465
473
|
.uiklu-h-\[44px\]{
|
|
466
474
|
height: 44px;
|
|
@@ -593,6 +601,10 @@ button,
|
|
|
593
601
|
.uiklu-w-\[383px\]{
|
|
594
602
|
width: 383px;
|
|
595
603
|
|
|
604
|
+
}
|
|
605
|
+
.uiklu-w-\[39px\]{
|
|
606
|
+
width: 39px;
|
|
607
|
+
|
|
596
608
|
}
|
|
597
609
|
.uiklu-w-\[40px\]{
|
|
598
610
|
width: 40px;
|
|
@@ -1018,6 +1030,10 @@ button,
|
|
|
1018
1030
|
.uiklu-rounded-\[50px\]{
|
|
1019
1031
|
border-radius: 50px;
|
|
1020
1032
|
|
|
1033
|
+
}
|
|
1034
|
+
.uiklu-rounded-\[8px\]{
|
|
1035
|
+
border-radius: 8px;
|
|
1036
|
+
|
|
1021
1037
|
}
|
|
1022
1038
|
.uiklu-rounded-full{
|
|
1023
1039
|
border-radius: 9999px;
|
|
@@ -1629,6 +1645,10 @@ button,
|
|
|
1629
1645
|
.uiklu-text-\[24px\]{
|
|
1630
1646
|
font-size: 24px;
|
|
1631
1647
|
|
|
1648
|
+
}
|
|
1649
|
+
.uiklu-text-\[28px\]{
|
|
1650
|
+
font-size: 28px;
|
|
1651
|
+
|
|
1632
1652
|
}
|
|
1633
1653
|
.uiklu-text-\[32px\]{
|
|
1634
1654
|
font-size: 32px;
|
|
@@ -1666,6 +1686,10 @@ button,
|
|
|
1666
1686
|
line-height: 14px;
|
|
1667
1687
|
font-weight: 500;
|
|
1668
1688
|
|
|
1689
|
+
}
|
|
1690
|
+
.uiklu-font-\[600\]{
|
|
1691
|
+
font-weight: 600;
|
|
1692
|
+
|
|
1669
1693
|
}
|
|
1670
1694
|
.uiklu-font-bold{
|
|
1671
1695
|
font-weight: 700;
|
|
@@ -2176,6 +2200,12 @@ input.uiklu-flex:not(:placeholder-shown) {
|
|
|
2176
2200
|
|
|
2177
2201
|
}
|
|
2178
2202
|
|
|
2203
|
+
.focus\:uiklu-border-gray800:focus{
|
|
2204
|
+
--tw-border-opacity: 1;
|
|
2205
|
+
border-color: hsl(var(--uiklu-gray-800) / var(--tw-border-opacity, 1));
|
|
2206
|
+
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2179
2209
|
.focus\:uiklu-border-primary900:focus{
|
|
2180
2210
|
--tw-border-opacity: 1;
|
|
2181
2211
|
border-color: hsl(var(--uiklu-primary-900) / var(--tw-border-opacity, 1));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
3
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
@@ -159,4 +159,30 @@ declare const Icons: {
|
|
|
159
159
|
CIRCLE_MOVEMENTS: react_jsx_runtime.JSX.Element;
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
declare const searchSelectTriggerVariants: (props?: ({
|
|
163
|
+
size?: "sm" | "md" | "lg" | "full" | null | undefined;
|
|
164
|
+
error?: boolean | null | undefined;
|
|
165
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
166
|
+
interface Option {
|
|
167
|
+
value: string;
|
|
168
|
+
label: string;
|
|
169
|
+
extra?: React.ReactNode;
|
|
170
|
+
}
|
|
171
|
+
interface SearchSelectProps extends VariantProps<typeof searchSelectTriggerVariants> {
|
|
172
|
+
options: Option[];
|
|
173
|
+
value: string;
|
|
174
|
+
onChange: (value: string) => void;
|
|
175
|
+
placeholder?: string;
|
|
176
|
+
disabled?: boolean;
|
|
177
|
+
className?: string;
|
|
178
|
+
}
|
|
179
|
+
declare const SearchSelect: ({ options, value, onChange, placeholder, size, error, disabled, className, }: SearchSelectProps) => react_jsx_runtime.JSX.Element;
|
|
180
|
+
|
|
181
|
+
interface AuthCodeProps {
|
|
182
|
+
onComplete?: (code: string) => void;
|
|
183
|
+
title?: string;
|
|
184
|
+
hasError?: boolean;
|
|
185
|
+
}
|
|
186
|
+
declare const InputCode: React__default.FC<AuthCodeProps>;
|
|
187
|
+
|
|
188
|
+
export { BackButton, BalanceInfo, Button, Icons, Input, InputCode, LoadingScreen, Modal, PromoBanner, SearchSelect, Select, SidebarTabs, ToastAction, Toaster, Typography, useToast };
|
package/dist/index.js
CHANGED
|
@@ -1402,15 +1402,270 @@ function SidebarTabs({ items }) {
|
|
|
1402
1402
|
/* @__PURE__ */ jsx17("div", { className: "uiklu-flex-1", children: currentActiveItem?.content ? currentActiveItem.content : /* @__PURE__ */ jsx17("div", { className: "uiklu-p-8", children: /* @__PURE__ */ jsx17("h2", { children: "Pr\xF3ximamente..." }) }) })
|
|
1403
1403
|
] });
|
|
1404
1404
|
}
|
|
1405
|
+
|
|
1406
|
+
// src/components/ui/searchSelect/searchSelect.tsx
|
|
1407
|
+
import * as React10 from "react";
|
|
1408
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
1409
|
+
import { Check as Check2, ChevronDown as ChevronDown2, X } from "lucide-react";
|
|
1410
|
+
import { cva as cva5 } from "class-variance-authority";
|
|
1411
|
+
import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1412
|
+
var searchSelectTriggerVariants = cva5(
|
|
1413
|
+
[
|
|
1414
|
+
"uiklu-flex uiklu-items-center uiklu-justify-between uiklu-transition-all",
|
|
1415
|
+
"uiklu-rounded-[50px] uiklu-border-[1px] uiklu-border-solid uiklu-bg-background uiklu-font-sans",
|
|
1416
|
+
"uiklu-outline-none focus-within:uiklu-border-baseblack focus-within:uiklu-border-[1px]",
|
|
1417
|
+
"disabled:uiklu-cursor-not-allowed disabled:uiklu-opacity-50",
|
|
1418
|
+
"uiklu-leading-none"
|
|
1419
|
+
],
|
|
1420
|
+
{
|
|
1421
|
+
variants: {
|
|
1422
|
+
size: {
|
|
1423
|
+
sm: "uiklu-h-[40px] uiklu-w-[150px] uiklu-min-w-[150px] uiklu-px-4 uiklu-text-sm",
|
|
1424
|
+
md: "uiklu-h-[40px] uiklu-w-[250px] uiklu-min-w-[250px] uiklu-px-5 uiklu-text-md",
|
|
1425
|
+
lg: "uiklu-h-[50px] uiklu-w-[350px] uiklu-min-w-[350px] uiklu-px-5 uiklu-text-lg",
|
|
1426
|
+
full: "uiklu-h-[50px] uiklu-w-full uiklu-px-5 uiklu-text-lg"
|
|
1427
|
+
},
|
|
1428
|
+
error: {
|
|
1429
|
+
true: "uiklu-border-destructive uiklu-text-destructive focus-within:uiklu-border-destructive",
|
|
1430
|
+
false: "uiklu-border-border uiklu-text-inputtext"
|
|
1431
|
+
}
|
|
1432
|
+
},
|
|
1433
|
+
defaultVariants: {
|
|
1434
|
+
size: "lg",
|
|
1435
|
+
error: false
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
);
|
|
1439
|
+
var inputFontSizes = {
|
|
1440
|
+
sm: "uiklu-text-sm",
|
|
1441
|
+
md: "uiklu-text-md",
|
|
1442
|
+
lg: "uiklu-text-lg",
|
|
1443
|
+
full: "uiklu-text-lg"
|
|
1444
|
+
};
|
|
1445
|
+
var SearchSelect = ({
|
|
1446
|
+
options,
|
|
1447
|
+
value,
|
|
1448
|
+
onChange,
|
|
1449
|
+
placeholder = "Buscar...",
|
|
1450
|
+
size = "lg",
|
|
1451
|
+
error = false,
|
|
1452
|
+
disabled = false,
|
|
1453
|
+
className
|
|
1454
|
+
}) => {
|
|
1455
|
+
const [open, setOpen] = React10.useState(false);
|
|
1456
|
+
const [search, setSearch] = React10.useState("");
|
|
1457
|
+
const containerRef = React10.useRef(null);
|
|
1458
|
+
const inputRef = React10.useRef(null);
|
|
1459
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
1460
|
+
React10.useEffect(() => {
|
|
1461
|
+
if (selectedOption) {
|
|
1462
|
+
setSearch(selectedOption.label);
|
|
1463
|
+
} else {
|
|
1464
|
+
setSearch("");
|
|
1465
|
+
}
|
|
1466
|
+
}, [selectedOption]);
|
|
1467
|
+
const filteredOptions = options.filter(
|
|
1468
|
+
(option) => option.label.toLowerCase().includes(search.toLowerCase())
|
|
1469
|
+
);
|
|
1470
|
+
const handleClear = (e) => {
|
|
1471
|
+
e.stopPropagation();
|
|
1472
|
+
onChange("");
|
|
1473
|
+
setSearch("");
|
|
1474
|
+
setOpen(true);
|
|
1475
|
+
inputRef.current?.focus();
|
|
1476
|
+
};
|
|
1477
|
+
return /* @__PURE__ */ jsxs15(PopoverPrimitive.Root, { open, onOpenChange: setOpen, children: [
|
|
1478
|
+
/* @__PURE__ */ jsx18(PopoverPrimitive.Anchor, { asChild: true, children: /* @__PURE__ */ jsxs15(
|
|
1479
|
+
"div",
|
|
1480
|
+
{
|
|
1481
|
+
ref: containerRef,
|
|
1482
|
+
className: cn(
|
|
1483
|
+
searchSelectTriggerVariants({ size, error, className }),
|
|
1484
|
+
"uiklu-cursor-text uiklu-relative",
|
|
1485
|
+
disabled && "uiklu-opacity-50 uiklu-pointer-events-none"
|
|
1486
|
+
),
|
|
1487
|
+
onClick: () => {
|
|
1488
|
+
inputRef.current?.focus();
|
|
1489
|
+
setOpen(true);
|
|
1490
|
+
},
|
|
1491
|
+
children: [
|
|
1492
|
+
/* @__PURE__ */ jsx18(
|
|
1493
|
+
"input",
|
|
1494
|
+
{
|
|
1495
|
+
ref: inputRef,
|
|
1496
|
+
type: "text",
|
|
1497
|
+
className: cn(
|
|
1498
|
+
"uiklu-w-full uiklu-bg-transparent uiklu-outline-none uiklu-border-none uiklu-p-0",
|
|
1499
|
+
"uiklu-font-sans uiklu-text-gray800 placeholder:uiklu-opacity-100",
|
|
1500
|
+
inputFontSizes[size || "lg"],
|
|
1501
|
+
!error ? "placeholder:uiklu-text-gray500" : "placeholder:uiklu-text-destructive"
|
|
1502
|
+
),
|
|
1503
|
+
placeholder,
|
|
1504
|
+
value: search,
|
|
1505
|
+
disabled,
|
|
1506
|
+
onFocus: () => setOpen(true),
|
|
1507
|
+
onClick: (e) => {
|
|
1508
|
+
e.stopPropagation();
|
|
1509
|
+
setOpen(true);
|
|
1510
|
+
},
|
|
1511
|
+
onChange: (e) => {
|
|
1512
|
+
setSearch(e.target.value);
|
|
1513
|
+
if (!open) setOpen(true);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
),
|
|
1517
|
+
/* @__PURE__ */ jsxs15("div", { className: "uiklu-flex uiklu-items-center uiklu-ml-2 uiklu-shrink-0", children: [
|
|
1518
|
+
search && /* @__PURE__ */ jsx18(
|
|
1519
|
+
"button",
|
|
1520
|
+
{
|
|
1521
|
+
type: "button",
|
|
1522
|
+
onClick: handleClear,
|
|
1523
|
+
className: "uiklu-mr-1 uiklu-opacity-50 hover:uiklu-opacity-100 uiklu-transition-opacity\n uiklu-bg-transparent uiklu-border-none uiklu-outline-none uiklu-p-0 \n uiklu-cursor-pointer uiklu-flex uiklu-items-center uiklu-justify-center",
|
|
1524
|
+
children: /* @__PURE__ */ jsx18(X, { className: "uiklu-h-4 uiklu-w-4" })
|
|
1525
|
+
}
|
|
1526
|
+
),
|
|
1527
|
+
/* @__PURE__ */ jsx18(
|
|
1528
|
+
ChevronDown2,
|
|
1529
|
+
{
|
|
1530
|
+
className: cn(
|
|
1531
|
+
"uiklu-h-5 uiklu-w-5 uiklu-transition-opacity uiklu-opacity-70 uiklu-cursor-pointer",
|
|
1532
|
+
error ? "uiklu-text-destructive" : "uiklu-text-inputtext"
|
|
1533
|
+
),
|
|
1534
|
+
onClick: (e) => {
|
|
1535
|
+
e.stopPropagation();
|
|
1536
|
+
setOpen((prev) => !prev);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
)
|
|
1540
|
+
] })
|
|
1541
|
+
]
|
|
1542
|
+
}
|
|
1543
|
+
) }),
|
|
1544
|
+
/* @__PURE__ */ jsx18(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx18(
|
|
1545
|
+
PopoverPrimitive.Content,
|
|
1546
|
+
{
|
|
1547
|
+
className: cn(
|
|
1548
|
+
"uiklu-relative uiklu-z-50 uiklu-overflow-hidden uiklu-rounded-[20px] uiklu-border-[1px] uiklu-border-border uiklu-bg-background uiklu-text-inputtext uiklu-font-sans uiklu-shadow-md uiklu-translate-y-1"
|
|
1549
|
+
),
|
|
1550
|
+
style: {
|
|
1551
|
+
width: containerRef.current ? containerRef.current.offsetWidth : "var(--radix-popover-trigger-width)"
|
|
1552
|
+
},
|
|
1553
|
+
align: "start",
|
|
1554
|
+
sideOffset: 4,
|
|
1555
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
1556
|
+
children: /* @__PURE__ */ jsx18("div", { className: "uiklu-py-1 uiklu-px-0 uiklu-max-h-96 uiklu-overflow-y-auto uiklu-overflow-x-hidden uiklu-w-full uiklu-box-border", children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx18("div", { className: "uiklu-py-3 uiklu-px-4 uiklu-text-sm uiklu-text-center uiklu-opacity-50 uiklu-font-sans", children: "No se encontraron resultados" }) : filteredOptions.map((option) => {
|
|
1557
|
+
const isSelected = value === option.value;
|
|
1558
|
+
return /* @__PURE__ */ jsxs15(
|
|
1559
|
+
"div",
|
|
1560
|
+
{
|
|
1561
|
+
onClick: () => {
|
|
1562
|
+
onChange(option.value);
|
|
1563
|
+
setSearch(option.label);
|
|
1564
|
+
setOpen(false);
|
|
1565
|
+
},
|
|
1566
|
+
className: cn(
|
|
1567
|
+
"uiklu-relative uiklu-flex uiklu-w-full uiklu-box-border uiklu-cursor-pointer uiklu-select-none uiklu-items-center uiklu-py-2.5 uiklu-pl-10 uiklu-pr-4 uiklu-text-md uiklu-font-sans uiklu-outline-none hover:uiklu-bg-primary/10 hover:uiklu-text-primary uiklu-transition-colors",
|
|
1568
|
+
isSelected && "uiklu-bg-primary/5 uiklu-text-primary uiklu-font-medium"
|
|
1569
|
+
),
|
|
1570
|
+
children: [
|
|
1571
|
+
/* @__PURE__ */ jsx18("span", { className: "uiklu-absolute uiklu-left-3 uiklu-flex uiklu-h-3.5 uiklu-w-3.5 uiklu-items-center uiklu-justify-center", children: isSelected && /* @__PURE__ */ jsx18(Check2, { className: "uiklu-h-4 uiklu-w-4 uiklu-text-primary" }) }),
|
|
1572
|
+
/* @__PURE__ */ jsx18("span", { className: "uiklu-flex-1 uiklu-truncate uiklu-min-w-0", children: option.label }),
|
|
1573
|
+
option.extra && /* @__PURE__ */ jsx18("span", { className: "uiklu-ml-2 uiklu-shrink-0 uiklu-flex uiklu-items-center", children: option.extra })
|
|
1574
|
+
]
|
|
1575
|
+
},
|
|
1576
|
+
option.value
|
|
1577
|
+
);
|
|
1578
|
+
}) })
|
|
1579
|
+
}
|
|
1580
|
+
) })
|
|
1581
|
+
] });
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
// src/components/ui/inputCode/inputCode.tsx
|
|
1585
|
+
import { useRef as useRef2, useState as useState6 } from "react";
|
|
1586
|
+
import { jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1587
|
+
var InputCode = ({
|
|
1588
|
+
onComplete,
|
|
1589
|
+
title = "C\xF3digo de autenticaci\xF3n",
|
|
1590
|
+
hasError = false
|
|
1591
|
+
}) => {
|
|
1592
|
+
const [code, setCode] = useState6(Array(6).fill(""));
|
|
1593
|
+
const inputsRef = useRef2([]);
|
|
1594
|
+
const handleChange = (e, index) => {
|
|
1595
|
+
const value = e.target.value;
|
|
1596
|
+
if (isNaN(Number(value))) return;
|
|
1597
|
+
const newCode = [...code];
|
|
1598
|
+
newCode[index] = value.substring(value.length - 1);
|
|
1599
|
+
setCode(newCode);
|
|
1600
|
+
const fullCode = newCode.join("");
|
|
1601
|
+
if (fullCode.length === 6 && onComplete) {
|
|
1602
|
+
onComplete(fullCode);
|
|
1603
|
+
}
|
|
1604
|
+
if (value && index < 5) {
|
|
1605
|
+
inputsRef.current[index + 1]?.focus();
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
const handleKeyDown = (e, index) => {
|
|
1609
|
+
if (e.key === "Backspace" && !code[index] && index > 0) {
|
|
1610
|
+
inputsRef.current[index - 1]?.focus();
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
const handlePaste = (e) => {
|
|
1614
|
+
e.preventDefault();
|
|
1615
|
+
const pastedData = e.clipboardData.getData("text").trim();
|
|
1616
|
+
if (!/^\d+$/.test(pastedData)) return;
|
|
1617
|
+
const pastedCode = pastedData.slice(0, 6).split("");
|
|
1618
|
+
const newCode = [...code];
|
|
1619
|
+
pastedCode.forEach((char, index) => {
|
|
1620
|
+
if (index < 6) newCode[index] = char;
|
|
1621
|
+
});
|
|
1622
|
+
setCode(newCode);
|
|
1623
|
+
const focusIndex = Math.min(pastedCode.length, 5);
|
|
1624
|
+
inputsRef.current[focusIndex]?.focus();
|
|
1625
|
+
const fullCode = newCode.join("");
|
|
1626
|
+
if (fullCode.length === 6 && onComplete) {
|
|
1627
|
+
onComplete(fullCode);
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1630
|
+
return /* @__PURE__ */ jsxs16("div", { className: "uiklu-flex uiklu-flex-col uiklu-items-center \n uiklu-justify-center uiklu-font-sans uiklu-w-full", children: [
|
|
1631
|
+
/* @__PURE__ */ jsx19("label", { className: "uiklu-text-[14px] uiklu-text-gray600 uiklu-font-normal\n uiklu-block uiklu-mb-[12px]", children: title }),
|
|
1632
|
+
/* @__PURE__ */ jsx19("div", { className: "uiklu-flex uiklu-justify-center uiklu-gap-[14px] uiklu-w-full", children: code.map((digit, index) => /* @__PURE__ */ jsx19(
|
|
1633
|
+
"input",
|
|
1634
|
+
{
|
|
1635
|
+
ref: (el) => {
|
|
1636
|
+
if (el) inputsRef.current[index] = el;
|
|
1637
|
+
},
|
|
1638
|
+
type: "text",
|
|
1639
|
+
inputMode: "numeric",
|
|
1640
|
+
pattern: "[0-9]*",
|
|
1641
|
+
maxLength: 1,
|
|
1642
|
+
value: digit,
|
|
1643
|
+
onChange: (e) => handleChange(e, index),
|
|
1644
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
1645
|
+
onPaste: index === 0 ? handlePaste : void 0,
|
|
1646
|
+
className: `uiklu-w-[39px] uiklu-h-[43px]
|
|
1647
|
+
uiklu-flex-shrink-0 uiklu-box-border uiklu-text-center
|
|
1648
|
+
uiklu-text-[28px] uiklu-font-sans uiklu-font-[600]
|
|
1649
|
+
uiklu-border-[1px] uiklu-border-solid
|
|
1650
|
+
uiklu-rounded-[8px] uiklu-transition-colors uiklu-text-ellipsis
|
|
1651
|
+
focus:uiklu-outline-none
|
|
1652
|
+
${hasError ? "uiklu-border-destructive uiklu-text-destructive focus:uiklu-border-destructive" : "uiklu-border-inputlight uiklu-text-gray800 focus:uiklu-border-gray800"}`
|
|
1653
|
+
},
|
|
1654
|
+
index
|
|
1655
|
+
)) })
|
|
1656
|
+
] });
|
|
1657
|
+
};
|
|
1405
1658
|
export {
|
|
1406
1659
|
BackButton,
|
|
1407
1660
|
BalanceInfo,
|
|
1408
1661
|
Button,
|
|
1409
1662
|
Icons,
|
|
1410
1663
|
Input,
|
|
1664
|
+
InputCode,
|
|
1411
1665
|
LoadingScreen,
|
|
1412
1666
|
Modal,
|
|
1413
1667
|
PromoBanner,
|
|
1668
|
+
SearchSelect,
|
|
1414
1669
|
Select,
|
|
1415
1670
|
SidebarTabs,
|
|
1416
1671
|
ToastAction,
|