@komensal/ui 0.2.2 → 0.3.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.
- package/dist/index.d.ts +539 -3
- package/dist/index.js +70 -17
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -110,7 +110,55 @@ import * as React2 from "react";
|
|
|
110
110
|
|
|
111
111
|
// src/components/spinner.tsx
|
|
112
112
|
import clsx2 from "clsx";
|
|
113
|
-
|
|
113
|
+
|
|
114
|
+
// src/lib/i18n.ts
|
|
115
|
+
import i18n from "i18next";
|
|
116
|
+
import { initReactI18next, useTranslation } from "react-i18next";
|
|
117
|
+
|
|
118
|
+
// src/locales/es/ui.json
|
|
119
|
+
var ui_default = {
|
|
120
|
+
otpField: {
|
|
121
|
+
description: "Se ha enviado un c\xF3digo OTP a tu correo . Revisa tu bandeja de entrada."
|
|
122
|
+
},
|
|
123
|
+
inputField: {
|
|
124
|
+
showPassword: "Mostrar contrase\xF1a",
|
|
125
|
+
hidePassword: "Ocultar contrase\xF1a",
|
|
126
|
+
clear: "Limpiar"
|
|
127
|
+
},
|
|
128
|
+
dialog: {
|
|
129
|
+
close: "Cerrar"
|
|
130
|
+
},
|
|
131
|
+
selectInput: {
|
|
132
|
+
placeholder: "Selecciona...",
|
|
133
|
+
loading: "Cargando...",
|
|
134
|
+
search: "Buscar...",
|
|
135
|
+
noResults: "Sin resultados."
|
|
136
|
+
},
|
|
137
|
+
passwordChecklist: {
|
|
138
|
+
minLength: "M\xEDnimo {{min}} caracteres",
|
|
139
|
+
hasUpperAndLower: "Una may\xFAscula y min\xFAscula",
|
|
140
|
+
hasNumber: "Un n\xFAmero",
|
|
141
|
+
hasSpecialChar: "Un car\xE1cter especial"
|
|
142
|
+
},
|
|
143
|
+
spinner: {
|
|
144
|
+
loading: "Cargando..."
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/lib/i18n.ts
|
|
149
|
+
var uiI18n = i18n.createInstance();
|
|
150
|
+
void uiI18n.use(initReactI18next).init({
|
|
151
|
+
defaultNS: "ui",
|
|
152
|
+
fallbackLng: "es",
|
|
153
|
+
interpolation: { escapeValue: false },
|
|
154
|
+
lng: "es",
|
|
155
|
+
ns: ["ui"],
|
|
156
|
+
resources: { es: { ui: ui_default } }
|
|
157
|
+
});
|
|
158
|
+
var setUiLanguage = (lng) => uiI18n.changeLanguage(lng);
|
|
159
|
+
var useUiT = () => useTranslation("ui", { i18n: uiI18n }).t;
|
|
160
|
+
|
|
161
|
+
// src/components/spinner.tsx
|
|
114
162
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
115
163
|
var sizes = {
|
|
116
164
|
lg: "70",
|
|
@@ -124,8 +172,8 @@ var variants = {
|
|
|
124
172
|
primary: "var(--color-spinner-primary)",
|
|
125
173
|
secondary: "var(--color-spinner-secondary)"
|
|
126
174
|
};
|
|
127
|
-
var Spinner = ({ className = "", size = "md", variant = "primary" }) => {
|
|
128
|
-
const
|
|
175
|
+
var Spinner = ({ className = "", loadingLabel, size = "md", variant = "primary" }) => {
|
|
176
|
+
const t = useUiT();
|
|
129
177
|
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
130
178
|
/* @__PURE__ */ jsx3(
|
|
131
179
|
"svg",
|
|
@@ -164,7 +212,7 @@ var Spinner = ({ className = "", size = "md", variant = "primary" }) => {
|
|
|
164
212
|
] })
|
|
165
213
|
}
|
|
166
214
|
),
|
|
167
|
-
/* @__PURE__ */ jsx3("span", { className: "sr-only", children: t("spinner.loading") })
|
|
215
|
+
/* @__PURE__ */ jsx3("span", { className: "sr-only", children: loadingLabel ?? t("spinner.loading") })
|
|
168
216
|
] });
|
|
169
217
|
};
|
|
170
218
|
|
|
@@ -292,7 +340,6 @@ import * as React4 from "react";
|
|
|
292
340
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
293
341
|
import { Cross2Icon } from "@radix-ui/react-icons";
|
|
294
342
|
import * as React3 from "react";
|
|
295
|
-
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
296
343
|
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
297
344
|
var Dialog = DialogPrimitive.Root;
|
|
298
345
|
var DialogTrigger = DialogPrimitive.Trigger;
|
|
@@ -312,8 +359,8 @@ var DialogOverlay = React3.forwardRef(({ className, isAbsolute = false, ...props
|
|
|
312
359
|
));
|
|
313
360
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
314
361
|
var DialogContent = React3.forwardRef(
|
|
315
|
-
({ children, className, container, isAbsolute = false, isCloseIcon = false, overlayClassName, ...props }, ref) => {
|
|
316
|
-
const
|
|
362
|
+
({ children, className, closeLabel, container, isAbsolute = false, isCloseIcon = false, overlayClassName, ...props }, ref) => {
|
|
363
|
+
const t = useUiT();
|
|
317
364
|
return /* @__PURE__ */ jsxs6(DialogPortal, { container, children: [
|
|
318
365
|
/* @__PURE__ */ jsx6(DialogOverlay, { className: overlayClassName, isAbsolute }),
|
|
319
366
|
/* @__PURE__ */ jsxs6(
|
|
@@ -330,7 +377,7 @@ var DialogContent = React3.forwardRef(
|
|
|
330
377
|
children,
|
|
331
378
|
isCloseIcon && /* @__PURE__ */ jsxs6(DialogPrimitive.Close, { className: "data-[state=open]:text-muted ring-offset-surface focus:ring-ring data-[state=open]:bg-hover border-border bg-border absolute top-11 right-8 flex h-8 w-8 min-w-8 cursor-pointer items-center justify-center rounded-full opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none", children: [
|
|
332
379
|
/* @__PURE__ */ jsx6(Cross2Icon, { className: "text-body hover:text-primary-dark h-4 w-4" }),
|
|
333
|
-
/* @__PURE__ */ jsx6("span", { className: "sr-only", children: t("dialog.close") })
|
|
380
|
+
/* @__PURE__ */ jsx6("span", { className: "sr-only", children: closeLabel ?? t("dialog.close") })
|
|
334
381
|
] })
|
|
335
382
|
]
|
|
336
383
|
}
|
|
@@ -529,7 +576,6 @@ FormMessage.displayName = "FormMessage";
|
|
|
529
576
|
|
|
530
577
|
// src/components/form-fields/input-field.tsx
|
|
531
578
|
import { useState } from "react";
|
|
532
|
-
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
533
579
|
import { FaRegEye, FaRegEyeSlash } from "react-icons/fa6";
|
|
534
580
|
import { RxCross2 } from "react-icons/rx";
|
|
535
581
|
|
|
@@ -590,8 +636,10 @@ var LabelField = ({ label, labelClassName, name, visualRequired }) => {
|
|
|
590
636
|
// src/components/form-fields/input-field.tsx
|
|
591
637
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
592
638
|
var InputField = ({
|
|
639
|
+
clearLabel,
|
|
593
640
|
control,
|
|
594
641
|
disabled,
|
|
642
|
+
hidePasswordLabel,
|
|
595
643
|
inputClassName,
|
|
596
644
|
isClearable,
|
|
597
645
|
label,
|
|
@@ -600,10 +648,11 @@ var InputField = ({
|
|
|
600
648
|
name,
|
|
601
649
|
onClear,
|
|
602
650
|
placeholder,
|
|
651
|
+
showPasswordLabel,
|
|
603
652
|
type = "text",
|
|
604
653
|
visualRequired
|
|
605
654
|
}) => {
|
|
606
|
-
const
|
|
655
|
+
const t = useUiT();
|
|
607
656
|
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
608
657
|
const togglePasswordVisibility = () => {
|
|
609
658
|
setIsPasswordVisible((prev) => !prev);
|
|
@@ -662,7 +711,7 @@ var InputField = ({
|
|
|
662
711
|
{
|
|
663
712
|
className: "focus:outline-none",
|
|
664
713
|
onClick: onClear,
|
|
665
|
-
title: t("inputField.clear"),
|
|
714
|
+
title: clearLabel ?? t("inputField.clear"),
|
|
666
715
|
type: "button",
|
|
667
716
|
children: /* @__PURE__ */ jsx12(RxCross2, { size: 18 })
|
|
668
717
|
}
|
|
@@ -672,7 +721,7 @@ var InputField = ({
|
|
|
672
721
|
{
|
|
673
722
|
className: "focus:outline-none",
|
|
674
723
|
onClick: togglePasswordVisibility,
|
|
675
|
-
title: isPasswordVisible ? t("inputField.hidePassword") : t("inputField.showPassword"),
|
|
724
|
+
title: isPasswordVisible ? hidePasswordLabel ?? t("inputField.hidePassword") : showPasswordLabel ?? t("inputField.showPassword"),
|
|
676
725
|
type: "button",
|
|
677
726
|
children: isPasswordVisible ? /* @__PURE__ */ jsx12(FaRegEye, { size: 18 }) : /* @__PURE__ */ jsx12(FaRegEyeSlash, { size: 20 })
|
|
678
727
|
}
|
|
@@ -1018,7 +1067,6 @@ function OTPField({
|
|
|
1018
1067
|
// src/components/select-input.tsx
|
|
1019
1068
|
import { ChevronDown, ChevronUp, Clock, XIcon } from "lucide-react";
|
|
1020
1069
|
import { cloneElement, useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
1021
|
-
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
1022
1070
|
|
|
1023
1071
|
// src/components/popover.tsx
|
|
1024
1072
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
@@ -1045,7 +1093,7 @@ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
|
1045
1093
|
// src/components/select-input.tsx
|
|
1046
1094
|
import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1047
1095
|
var SelectInput = (props) => {
|
|
1048
|
-
const
|
|
1096
|
+
const t = useUiT();
|
|
1049
1097
|
const {
|
|
1050
1098
|
ableDeleteOption,
|
|
1051
1099
|
className,
|
|
@@ -1055,12 +1103,15 @@ var SelectInput = (props) => {
|
|
|
1055
1103
|
labelKey = "label",
|
|
1056
1104
|
leftIcon,
|
|
1057
1105
|
loading = false,
|
|
1106
|
+
loadingLabel,
|
|
1107
|
+
noResultsLabel,
|
|
1058
1108
|
onBlur,
|
|
1059
1109
|
onChange,
|
|
1060
1110
|
onValueChangeCallBack = () => void 0,
|
|
1061
1111
|
placeholder,
|
|
1062
1112
|
placeholderClassName = "",
|
|
1063
1113
|
search = false,
|
|
1114
|
+
searchPlaceholder,
|
|
1064
1115
|
timeField = false,
|
|
1065
1116
|
value = "",
|
|
1066
1117
|
valueKey = "value"
|
|
@@ -1138,7 +1189,7 @@ var SelectInput = (props) => {
|
|
|
1138
1189
|
role: "combobox",
|
|
1139
1190
|
variant: "primary",
|
|
1140
1191
|
children: loading ? /* @__PURE__ */ jsxs14(Fragment3, { children: [
|
|
1141
|
-
t("selectInput.loading"),
|
|
1192
|
+
loadingLabel ?? t("selectInput.loading"),
|
|
1142
1193
|
" ",
|
|
1143
1194
|
/* @__PURE__ */ jsx18(Spinner, {})
|
|
1144
1195
|
] }) : /* @__PURE__ */ jsxs14("div", { className: "relative flex h-5 w-full items-center", children: [
|
|
@@ -1179,11 +1230,11 @@ var SelectInput = (props) => {
|
|
|
1179
1230
|
{
|
|
1180
1231
|
className: "mb-1 rounded-sm",
|
|
1181
1232
|
onChange: (e) => setQuery(e.target.value),
|
|
1182
|
-
placeholder: t("selectInput.search"),
|
|
1233
|
+
placeholder: searchPlaceholder ?? t("selectInput.search"),
|
|
1183
1234
|
value: query
|
|
1184
1235
|
}
|
|
1185
1236
|
),
|
|
1186
|
-
/* @__PURE__ */ jsx18(CommandEmpty, { className: "text-center", children: t("selectInput.noResults") }),
|
|
1237
|
+
/* @__PURE__ */ jsx18(CommandEmpty, { className: "text-center", children: noResultsLabel ?? t("selectInput.noResults") }),
|
|
1187
1238
|
/* @__PURE__ */ jsx18(CommandList, { children: /* @__PURE__ */ jsx18(CommandGroup, { className: "p-0", children: filteredOptions.map((item) => {
|
|
1188
1239
|
const labelValue = item[labelKey];
|
|
1189
1240
|
const valueValue = item[valueKey];
|
|
@@ -1704,7 +1755,9 @@ export {
|
|
|
1704
1755
|
inputFocus,
|
|
1705
1756
|
inputPlaceholder,
|
|
1706
1757
|
registerToastEmitter,
|
|
1758
|
+
setUiLanguage,
|
|
1707
1759
|
toast,
|
|
1760
|
+
uiI18n,
|
|
1708
1761
|
useFormField
|
|
1709
1762
|
};
|
|
1710
1763
|
//# sourceMappingURL=index.js.map
|