@juantroconisf/lib 2.4.0 → 2.5.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.mts +37 -18
- package/dist/index.d.ts +37 -18
- package/dist/index.js +21 -20
- package/dist/index.mjs +18 -17
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
3
1
|
import { InputProps } from '@heroui/react';
|
|
4
2
|
|
|
3
|
+
type StateType = Record<string, any>;
|
|
5
4
|
type ValidatorFunction<T, U> = (val: T, ...args: U[]) => boolean;
|
|
6
5
|
interface Validator<T, U = any> {
|
|
7
6
|
validate: ValidatorFunction<T, U>;
|
|
@@ -20,33 +19,53 @@ interface ValidatorTypes {
|
|
|
20
19
|
password: Validator<string, boolean>;
|
|
21
20
|
custom: Validator<any, boolean>;
|
|
22
21
|
}
|
|
22
|
+
|
|
23
23
|
type ValidatorParams = {
|
|
24
24
|
[K in keyof ValidatorTypes]?: ValidatorTypes[K] extends Validator<any, infer U> ? U : never;
|
|
25
25
|
};
|
|
26
26
|
type ValidatorErrorMessage = {
|
|
27
27
|
[K in keyof ValidatorTypes]?: string;
|
|
28
28
|
};
|
|
29
|
-
|
|
30
29
|
interface ValidationProps {
|
|
31
30
|
isInvalid: InputProps["isInvalid"];
|
|
32
31
|
errorMessage: InputProps["errorMessage"];
|
|
33
32
|
}
|
|
34
|
-
interface
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
interface FormChangeState<O extends StateType> {
|
|
34
|
+
state: O;
|
|
35
|
+
validations?: {
|
|
36
|
+
[key in keyof O]?: ValidatorParams;
|
|
37
|
+
};
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
onChange: ({ target: { id, value }, }: ChangeEvent<HTMLInputElement>) => void;
|
|
43
|
-
onBlur: ({ target: { id } }: FocusEvent<HTMLInputElement>) => void;
|
|
44
|
-
state: InitialObj;
|
|
45
|
-
setState: react.Dispatch<react.SetStateAction<InitialObj>>;
|
|
46
|
-
register: <K extends keyof InitialObj>(id: K, validations?: ValidatorParams, errorMessages?: ValidatorErrorMessage) => RegisterInputProps;
|
|
47
|
-
hasInvalidValues: () => boolean;
|
|
48
|
-
touched: InitialObj;
|
|
49
|
-
resetForm: () => void;
|
|
39
|
+
type TouchedType = {
|
|
40
|
+
[key: string]: boolean;
|
|
50
41
|
};
|
|
42
|
+
interface TargetChangeProps<O extends StateType> {
|
|
43
|
+
target: {
|
|
44
|
+
id: keyof O;
|
|
45
|
+
value?: O[keyof O];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
type InputChangeFunc<O extends StateType> = (props: TargetChangeProps<O>) => void;
|
|
49
|
+
interface RegisterInputProps<O extends StateType> extends ValidationProps {
|
|
50
|
+
id: keyof O;
|
|
51
|
+
onChange: InputChangeFunc<O>;
|
|
52
|
+
onBlur: InputChangeFunc<O>;
|
|
53
|
+
value: O[keyof O];
|
|
54
|
+
}
|
|
55
|
+
type RegisterFunc<O extends StateType> = (id: keyof O, errorMessages?: ValidatorErrorMessage) => RegisterInputProps<O>;
|
|
56
|
+
type HasInvalidValuesFunc = () => boolean;
|
|
57
|
+
type ResetFormFunc = () => void;
|
|
58
|
+
interface UseFormChangeResponse<O extends StateType> {
|
|
59
|
+
onChange: InputChangeFunc<O>;
|
|
60
|
+
onBlur: InputChangeFunc<O>;
|
|
61
|
+
state: O;
|
|
62
|
+
setState: React.Dispatch<React.SetStateAction<O>>;
|
|
63
|
+
register: RegisterFunc<O>;
|
|
64
|
+
hasInvalidValues: HasInvalidValuesFunc;
|
|
65
|
+
touched: TouchedType;
|
|
66
|
+
resetForm: ResetFormFunc;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare function useFormChange<O extends StateType>({ state: newState, validations, }: FormChangeState<O>): UseFormChangeResponse<O>;
|
|
51
70
|
|
|
52
71
|
export { useFormChange };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
3
1
|
import { InputProps } from '@heroui/react';
|
|
4
2
|
|
|
3
|
+
type StateType = Record<string, any>;
|
|
5
4
|
type ValidatorFunction<T, U> = (val: T, ...args: U[]) => boolean;
|
|
6
5
|
interface Validator<T, U = any> {
|
|
7
6
|
validate: ValidatorFunction<T, U>;
|
|
@@ -20,33 +19,53 @@ interface ValidatorTypes {
|
|
|
20
19
|
password: Validator<string, boolean>;
|
|
21
20
|
custom: Validator<any, boolean>;
|
|
22
21
|
}
|
|
22
|
+
|
|
23
23
|
type ValidatorParams = {
|
|
24
24
|
[K in keyof ValidatorTypes]?: ValidatorTypes[K] extends Validator<any, infer U> ? U : never;
|
|
25
25
|
};
|
|
26
26
|
type ValidatorErrorMessage = {
|
|
27
27
|
[K in keyof ValidatorTypes]?: string;
|
|
28
28
|
};
|
|
29
|
-
|
|
30
29
|
interface ValidationProps {
|
|
31
30
|
isInvalid: InputProps["isInvalid"];
|
|
32
31
|
errorMessage: InputProps["errorMessage"];
|
|
33
32
|
}
|
|
34
|
-
interface
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
interface FormChangeState<O extends StateType> {
|
|
34
|
+
state: O;
|
|
35
|
+
validations?: {
|
|
36
|
+
[key in keyof O]?: ValidatorParams;
|
|
37
|
+
};
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
onChange: ({ target: { id, value }, }: ChangeEvent<HTMLInputElement>) => void;
|
|
43
|
-
onBlur: ({ target: { id } }: FocusEvent<HTMLInputElement>) => void;
|
|
44
|
-
state: InitialObj;
|
|
45
|
-
setState: react.Dispatch<react.SetStateAction<InitialObj>>;
|
|
46
|
-
register: <K extends keyof InitialObj>(id: K, validations?: ValidatorParams, errorMessages?: ValidatorErrorMessage) => RegisterInputProps;
|
|
47
|
-
hasInvalidValues: () => boolean;
|
|
48
|
-
touched: InitialObj;
|
|
49
|
-
resetForm: () => void;
|
|
39
|
+
type TouchedType = {
|
|
40
|
+
[key: string]: boolean;
|
|
50
41
|
};
|
|
42
|
+
interface TargetChangeProps<O extends StateType> {
|
|
43
|
+
target: {
|
|
44
|
+
id: keyof O;
|
|
45
|
+
value?: O[keyof O];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
type InputChangeFunc<O extends StateType> = (props: TargetChangeProps<O>) => void;
|
|
49
|
+
interface RegisterInputProps<O extends StateType> extends ValidationProps {
|
|
50
|
+
id: keyof O;
|
|
51
|
+
onChange: InputChangeFunc<O>;
|
|
52
|
+
onBlur: InputChangeFunc<O>;
|
|
53
|
+
value: O[keyof O];
|
|
54
|
+
}
|
|
55
|
+
type RegisterFunc<O extends StateType> = (id: keyof O, errorMessages?: ValidatorErrorMessage) => RegisterInputProps<O>;
|
|
56
|
+
type HasInvalidValuesFunc = () => boolean;
|
|
57
|
+
type ResetFormFunc = () => void;
|
|
58
|
+
interface UseFormChangeResponse<O extends StateType> {
|
|
59
|
+
onChange: InputChangeFunc<O>;
|
|
60
|
+
onBlur: InputChangeFunc<O>;
|
|
61
|
+
state: O;
|
|
62
|
+
setState: React.Dispatch<React.SetStateAction<O>>;
|
|
63
|
+
register: RegisterFunc<O>;
|
|
64
|
+
hasInvalidValues: HasInvalidValuesFunc;
|
|
65
|
+
touched: TouchedType;
|
|
66
|
+
resetForm: ResetFormFunc;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare function useFormChange<O extends StateType>({ state: newState, validations, }: FormChangeState<O>): UseFormChangeResponse<O>;
|
|
51
70
|
|
|
52
71
|
export { useFormChange };
|
package/dist/index.js
CHANGED
|
@@ -17,16 +17,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
19
|
// src/index.ts
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
22
|
useFormChange: () => useFormChange
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(index_exports);
|
|
25
25
|
|
|
26
26
|
// src/hooks/useFormChange.tsx
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
|
|
29
|
-
// types
|
|
29
|
+
// src/types.ts
|
|
30
30
|
var NextUIError = class {
|
|
31
31
|
isInvalid;
|
|
32
32
|
errorMessage;
|
|
@@ -54,10 +54,10 @@ function handleNestedChange({
|
|
|
54
54
|
current[propertyDepth[propertyDepth.length - 1]] = value;
|
|
55
55
|
return { ...newValues };
|
|
56
56
|
}
|
|
57
|
-
var allToValue = (obj,
|
|
57
|
+
var allToValue = (obj, bool) => Object.keys(obj).reduce(
|
|
58
58
|
(acc, key) => ({
|
|
59
59
|
...acc,
|
|
60
|
-
[key]:
|
|
60
|
+
[key]: bool
|
|
61
61
|
}),
|
|
62
62
|
{}
|
|
63
63
|
);
|
|
@@ -125,14 +125,12 @@ var en_default = { BIRTH_DATE: "Birth date", DAY: "Day", DAY_PLACEHOLDER: "Choos
|
|
|
125
125
|
// lang/es.json
|
|
126
126
|
var es_default = { BIRTH_DATE: "Fecha de nacimiento", DAY: "D\xEDa", DAY_PLACEHOLDER: "Elige un d\xEDa", MONTH: "Mes", MONTH_PLACEHOLDER: "Elige un mes", YEAR: "A\xF1o", YEAR_PLACEHOLDER: "Elige un a\xF1o", PRICING: "Precio", PRICING_TABLE: "Tabla de precios", OUR_PRICING_PLAN: "Nuestros precios", PRICING_DESCRIPTION: "Mejora tu experiencia. Descubre el plan que desbloquea las funciones que necesitas.", VALUE_STORAGE: "{{value}} almacenamiento", GOOGLE_CALENDAR_SYNC: "Google Calenar Sync", INTERNAL_REMINDERS: "Recordatorios internos", WHATSAPP_AUTOMATED_REMINDERS: "Recordatorios automatizados de WhatsApp", PROFESSIONAL: "Profesional", PROFESSIONAL_PLAN_DESCRIPTION: "Para doctores individuales que buscan elevar sus pr\xE1cticas", DIGITAL_PRESCRIPTIONS: "Recipes digitales", DICOM_VIEWER: "Visualizador DICOM", VERIFIED_MEDICAL_CREDENTIALS: "Credenciales m\xE9dicas verificadas", PATIENT_SELF_MANAGEMENT: "Auto gesti\xF3n para pacientes", BUY_NOW: "Comprar ahora", ORGANIZATION: "Organizaci\xF3n", ORGANIZATION_PLAN_DESCRIPTION: "Para organizaciones con m\xFAltiples usuarios que buscan compartir informaci\xF3n", UP_TO_VALUE_STORAGE: "Hasta {{value}} de almacenamiento", CONFIGURABLE_USER_PERMISSIONS: "Permisolog\xEDa configurable para usuarios", CALCULATE_PRICING: "Calcular precio", DOCTORS: "Doctores", ASSISTANTS: "Asistentes", BASIC: "B\xE1sico", BASIC_PLAN_DESCRIPTION: "Para iniciar en la industria m\xE9dica", USER: "Usuario", TYPE_A_VALUE: "Ingresa un valor", STORAGE: "Almacenamiento", PASSWORD: "Contrase\xF1a", PASSWORD_PLACEHOLDER: "Ingresa tu contrase\xF1a", REQUIRED: "Requerido", TOO_SHORT: "Demasiado corto", TOO_LONG: "Demasiado largo", VALUE_LOW: "El valor es muy bajo", VALUE_HIGH: "El valor es muy alto", PATTERN_INVALID: "El patr\xF3n no es v\xE1lido", INVALID_EMAIL: "Correo inv\xE1lido", SHOW_PASSWORD: "Mostrar contrase\xF1a", HIDE_PASSWORD: "Esconder contrase\xF1a", GROUP_PRICING_CALCULATOR: "Calculadora de precios grupal", VERIFIED_ACCOUNT: "Cuenta verificada", VERIFIED_ACCOUNT_TEXT: "Esta cuenta ha sido verificada por Clinikos, as\xED como sus afiliaciones con las siguientes instituciones", PHONE_NUMBER: "N\xFAmero de tel\xE9fono", PHONE_NUMBER_PLACEHOLDER: "Ingrese su n\xFAmero de tel\xE9fono", SEND_MESSAGE: "Enviar mensaje", BOOK_MEETING: "Agendar cita", SIGN_UP: "Reg\xEDstrate", INVALID_PASSWORD: "Tu contrase\xF1a no cumple con los requisitos de seguridad.", NOT_EQUAL: "Los valores no son iguales", GENDER: "G\xE9nero", FEMALE: "Femenino", MALE: "Masculino", CLOSE: "Cerrar", MANDATORY_FIELDS_WARNING: "", INVALID_FIELDS_WARNING: "", COUNTRY: "Pa\xEDs", COUNTRY_PLACEHOLDER: "Selecciona un pa\xEDs", STATE: "Estado", STATE_PLACEHOLDER: "Selecciona un estado", CITY: "Ciudad", CITY_PLACEHOLDER: "Selecciona una ciudad", TIMEZONE: "Zona horaria", TIMEZONE_PLACEHOLDER: "Selecciona una zora horaria", NAME: "Nombre", OK: "Ok", PAGE_NOT_FOUND: "P\xE1gina no encontrada", PAGE_NOT_FOUND_DESCRIPTION: "El enlace en el que hiciste click puede que est\xE9 roto o la p\xE1gina puede haber sido eliminada o renombrada", TODAY: "Hoy", WEEK: "Semana", CALENDAR: "Calendario", EVENT: "Evento", NO_INFORMATION: "Sin informaci\xF3n", SYNC_GOOGLE_CALENDAR: "Vincular Calendario de Google", NO_RESULTS: "No se encontraron resultados", GOOGLE_MEET: "Google Meet", LONG_TIME_AGO: "Hace mucho tiempo", TOMORROW: "Ma\xF1ana", CHOOSE_PLAN: "Elige un plan", CHOOSE_PLAN_DESCRIPTION: "\xA1Elige el plan que se ajuste a tus necesidades!", PRIVACY_POLICY: "", OPTIONAL: "Opcional", RESULTS: "Resultados", LOCATION: "Ubicaci\xF3n", ADDRESS: "Direcci\xF3n", ADDRESS_PLACEHOLDER: "Ingresa tu direcci\xF3n", COPY_TO_CLIPBOARD: "Copiar al portapapeles", ACTIONS: "Acciones", MIN: "M\xEDnimo", MAX: "M\xE1ximo", DUE_DATE: "Fecha l\xEDmite", QUICK_SEARCH: "B\xFAsqueda r\xE1pida", MONTHLY: "Mensual", WEEKLY: "Semanal", GOOGLE_MAPS_LINK: "Link de Google Maps", MINUTE: "Minuto", MINUTES: "Minutos", HOUR: "Hora", HOURS: "Horas", VE_ID: "C\xE9dula de Identidad", ACCOUNT_VERIFIED_BY_CLINIKOS: "Esta cuenta ha sido verificada por Clinikos, as\xED como sus afiliaciones con las siguientes instituciones", INBOX: "Bandeja de entrada", ACCEPTED: "Aceptado", DECLINED: "Declinado", NEEDS_ACTION: "Necesita acci\xF3n", OVERDUE: "Atrasado", FILTER_BY: "Filtrar por", REFRESH: "Refrescar", LOADING: "Cargando", MINUTE_LEFT: "Un minuto restante", VALUE_MINUTES_LEFT: "{{value}} minutos restantes", PLAY: "Reproducir", PAUSE: "Pausar", STOP: "Detener", LOAD_MORE: "Cargar m\xE1s", BILLING: "Facturaci\xF3n", DOCTOR: "Doctor", ASSISTANT: "Asistente", NUMBER_OF_DOCTORS: "N\xFAmero de Doctores", NUMBER_OF_ASSISTANTS: "N\xFAmero de Asistentes", EACH_DOCTOR: "Cada doctor", EACH_ASSISTANT: "Cada asistente", ROLE: "Rol", PAYMENT_METHODS: "M\xE9todos de pago", UPGRADE: "Mejorar", TOTAL: "Total", BUY: "Comprar", TYPE: "Tipo", RECURRENT: "Recurrente", ACCEPT: "Aceptar", DECLINE: "Declinar", PREFERENCES: "Preferencias", BOOKING: "Agendar cita", PATTERN_NOT_VALID: "El patr\xF3n no es v\xE1lido" };
|
|
127
127
|
|
|
128
|
-
//
|
|
128
|
+
// src/hooks/useComponentLang.tsx
|
|
129
|
+
var cookieName = "LOCALE";
|
|
129
130
|
var langMap = {
|
|
130
131
|
en: en_default,
|
|
131
132
|
es: es_default
|
|
132
133
|
};
|
|
133
|
-
|
|
134
|
-
// src/hooks/useComponentLang.tsx
|
|
135
|
-
var cookieName = "LOCALE";
|
|
136
134
|
var getClientCookie = () => {
|
|
137
135
|
const value = "; " + document.cookie, decodedValue = decodeURIComponent(value), parts = decodedValue.split("; " + cookieName + "=");
|
|
138
136
|
if (parts.length === 2) return parts.pop()?.split(";").shift();
|
|
@@ -179,17 +177,20 @@ function useValidation() {
|
|
|
179
177
|
}
|
|
180
178
|
|
|
181
179
|
// src/hooks/useFormChange.tsx
|
|
182
|
-
function useFormChange(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
180
|
+
function useFormChange({
|
|
181
|
+
state: newState,
|
|
182
|
+
validations
|
|
183
|
+
}) {
|
|
184
|
+
const [state, setState] = (0, import_react.useState)(newState), [touched, setTouched] = (0, import_react.useState)(allToValue(newState, false)), { getValidation } = useValidation(), errors2 = (0, import_react.useRef)(allToValue(newState, false));
|
|
185
|
+
const onChange = ({ target: { id, value } }) => setState(handleNestedChange({ state, id, value })), onBlur = ({ target: { id } }) => setTouched(
|
|
186
|
+
handleNestedChange({ state: touched, id, value: true })
|
|
187
|
+
), resetForm = () => {
|
|
188
|
+
setTouched(allToValue(newState, false));
|
|
189
|
+
setState(newState);
|
|
189
190
|
};
|
|
190
191
|
const register = (0, import_react.useCallback)(
|
|
191
|
-
(id,
|
|
192
|
-
const [value, isTouched] = [state[id], touched[id]],
|
|
192
|
+
(id, errorMessages) => {
|
|
193
|
+
const [value, isTouched] = [state[id], touched[id]], selectedValidations = validations[id], hasValidations = selectedValidations !== void 0, inputValidations = hasValidations ? getValidation(value, isTouched, selectedValidations, errorMessages) : {};
|
|
193
194
|
errors2.current = handleNestedChange({
|
|
194
195
|
state: errors2.current,
|
|
195
196
|
id,
|
|
@@ -204,7 +205,7 @@ function useFormChange(initialObj) {
|
|
|
204
205
|
errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
|
|
205
206
|
};
|
|
206
207
|
},
|
|
207
|
-
[getValidation, onChange, onBlur]
|
|
208
|
+
[getValidation, onChange, onBlur, touched]
|
|
208
209
|
);
|
|
209
210
|
const hasInvalidValues = () => {
|
|
210
211
|
setTouched(allToValue(touched, true));
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
// src/hooks/useFormChange.tsx
|
|
9
9
|
import { useState, useRef, useCallback } from "react";
|
|
10
10
|
|
|
11
|
-
// types
|
|
11
|
+
// src/types.ts
|
|
12
12
|
var NextUIError = class {
|
|
13
13
|
isInvalid;
|
|
14
14
|
errorMessage;
|
|
@@ -36,10 +36,10 @@ function handleNestedChange({
|
|
|
36
36
|
current[propertyDepth[propertyDepth.length - 1]] = value;
|
|
37
37
|
return { ...newValues };
|
|
38
38
|
}
|
|
39
|
-
var allToValue = (obj,
|
|
39
|
+
var allToValue = (obj, bool) => Object.keys(obj).reduce(
|
|
40
40
|
(acc, key) => ({
|
|
41
41
|
...acc,
|
|
42
|
-
[key]:
|
|
42
|
+
[key]: bool
|
|
43
43
|
}),
|
|
44
44
|
{}
|
|
45
45
|
);
|
|
@@ -107,14 +107,12 @@ var en_default = { BIRTH_DATE: "Birth date", DAY: "Day", DAY_PLACEHOLDER: "Choos
|
|
|
107
107
|
// lang/es.json
|
|
108
108
|
var es_default = { BIRTH_DATE: "Fecha de nacimiento", DAY: "D\xEDa", DAY_PLACEHOLDER: "Elige un d\xEDa", MONTH: "Mes", MONTH_PLACEHOLDER: "Elige un mes", YEAR: "A\xF1o", YEAR_PLACEHOLDER: "Elige un a\xF1o", PRICING: "Precio", PRICING_TABLE: "Tabla de precios", OUR_PRICING_PLAN: "Nuestros precios", PRICING_DESCRIPTION: "Mejora tu experiencia. Descubre el plan que desbloquea las funciones que necesitas.", VALUE_STORAGE: "{{value}} almacenamiento", GOOGLE_CALENDAR_SYNC: "Google Calenar Sync", INTERNAL_REMINDERS: "Recordatorios internos", WHATSAPP_AUTOMATED_REMINDERS: "Recordatorios automatizados de WhatsApp", PROFESSIONAL: "Profesional", PROFESSIONAL_PLAN_DESCRIPTION: "Para doctores individuales que buscan elevar sus pr\xE1cticas", DIGITAL_PRESCRIPTIONS: "Recipes digitales", DICOM_VIEWER: "Visualizador DICOM", VERIFIED_MEDICAL_CREDENTIALS: "Credenciales m\xE9dicas verificadas", PATIENT_SELF_MANAGEMENT: "Auto gesti\xF3n para pacientes", BUY_NOW: "Comprar ahora", ORGANIZATION: "Organizaci\xF3n", ORGANIZATION_PLAN_DESCRIPTION: "Para organizaciones con m\xFAltiples usuarios que buscan compartir informaci\xF3n", UP_TO_VALUE_STORAGE: "Hasta {{value}} de almacenamiento", CONFIGURABLE_USER_PERMISSIONS: "Permisolog\xEDa configurable para usuarios", CALCULATE_PRICING: "Calcular precio", DOCTORS: "Doctores", ASSISTANTS: "Asistentes", BASIC: "B\xE1sico", BASIC_PLAN_DESCRIPTION: "Para iniciar en la industria m\xE9dica", USER: "Usuario", TYPE_A_VALUE: "Ingresa un valor", STORAGE: "Almacenamiento", PASSWORD: "Contrase\xF1a", PASSWORD_PLACEHOLDER: "Ingresa tu contrase\xF1a", REQUIRED: "Requerido", TOO_SHORT: "Demasiado corto", TOO_LONG: "Demasiado largo", VALUE_LOW: "El valor es muy bajo", VALUE_HIGH: "El valor es muy alto", PATTERN_INVALID: "El patr\xF3n no es v\xE1lido", INVALID_EMAIL: "Correo inv\xE1lido", SHOW_PASSWORD: "Mostrar contrase\xF1a", HIDE_PASSWORD: "Esconder contrase\xF1a", GROUP_PRICING_CALCULATOR: "Calculadora de precios grupal", VERIFIED_ACCOUNT: "Cuenta verificada", VERIFIED_ACCOUNT_TEXT: "Esta cuenta ha sido verificada por Clinikos, as\xED como sus afiliaciones con las siguientes instituciones", PHONE_NUMBER: "N\xFAmero de tel\xE9fono", PHONE_NUMBER_PLACEHOLDER: "Ingrese su n\xFAmero de tel\xE9fono", SEND_MESSAGE: "Enviar mensaje", BOOK_MEETING: "Agendar cita", SIGN_UP: "Reg\xEDstrate", INVALID_PASSWORD: "Tu contrase\xF1a no cumple con los requisitos de seguridad.", NOT_EQUAL: "Los valores no son iguales", GENDER: "G\xE9nero", FEMALE: "Femenino", MALE: "Masculino", CLOSE: "Cerrar", MANDATORY_FIELDS_WARNING: "", INVALID_FIELDS_WARNING: "", COUNTRY: "Pa\xEDs", COUNTRY_PLACEHOLDER: "Selecciona un pa\xEDs", STATE: "Estado", STATE_PLACEHOLDER: "Selecciona un estado", CITY: "Ciudad", CITY_PLACEHOLDER: "Selecciona una ciudad", TIMEZONE: "Zona horaria", TIMEZONE_PLACEHOLDER: "Selecciona una zora horaria", NAME: "Nombre", OK: "Ok", PAGE_NOT_FOUND: "P\xE1gina no encontrada", PAGE_NOT_FOUND_DESCRIPTION: "El enlace en el que hiciste click puede que est\xE9 roto o la p\xE1gina puede haber sido eliminada o renombrada", TODAY: "Hoy", WEEK: "Semana", CALENDAR: "Calendario", EVENT: "Evento", NO_INFORMATION: "Sin informaci\xF3n", SYNC_GOOGLE_CALENDAR: "Vincular Calendario de Google", NO_RESULTS: "No se encontraron resultados", GOOGLE_MEET: "Google Meet", LONG_TIME_AGO: "Hace mucho tiempo", TOMORROW: "Ma\xF1ana", CHOOSE_PLAN: "Elige un plan", CHOOSE_PLAN_DESCRIPTION: "\xA1Elige el plan que se ajuste a tus necesidades!", PRIVACY_POLICY: "", OPTIONAL: "Opcional", RESULTS: "Resultados", LOCATION: "Ubicaci\xF3n", ADDRESS: "Direcci\xF3n", ADDRESS_PLACEHOLDER: "Ingresa tu direcci\xF3n", COPY_TO_CLIPBOARD: "Copiar al portapapeles", ACTIONS: "Acciones", MIN: "M\xEDnimo", MAX: "M\xE1ximo", DUE_DATE: "Fecha l\xEDmite", QUICK_SEARCH: "B\xFAsqueda r\xE1pida", MONTHLY: "Mensual", WEEKLY: "Semanal", GOOGLE_MAPS_LINK: "Link de Google Maps", MINUTE: "Minuto", MINUTES: "Minutos", HOUR: "Hora", HOURS: "Horas", VE_ID: "C\xE9dula de Identidad", ACCOUNT_VERIFIED_BY_CLINIKOS: "Esta cuenta ha sido verificada por Clinikos, as\xED como sus afiliaciones con las siguientes instituciones", INBOX: "Bandeja de entrada", ACCEPTED: "Aceptado", DECLINED: "Declinado", NEEDS_ACTION: "Necesita acci\xF3n", OVERDUE: "Atrasado", FILTER_BY: "Filtrar por", REFRESH: "Refrescar", LOADING: "Cargando", MINUTE_LEFT: "Un minuto restante", VALUE_MINUTES_LEFT: "{{value}} minutos restantes", PLAY: "Reproducir", PAUSE: "Pausar", STOP: "Detener", LOAD_MORE: "Cargar m\xE1s", BILLING: "Facturaci\xF3n", DOCTOR: "Doctor", ASSISTANT: "Asistente", NUMBER_OF_DOCTORS: "N\xFAmero de Doctores", NUMBER_OF_ASSISTANTS: "N\xFAmero de Asistentes", EACH_DOCTOR: "Cada doctor", EACH_ASSISTANT: "Cada asistente", ROLE: "Rol", PAYMENT_METHODS: "M\xE9todos de pago", UPGRADE: "Mejorar", TOTAL: "Total", BUY: "Comprar", TYPE: "Tipo", RECURRENT: "Recurrente", ACCEPT: "Aceptar", DECLINE: "Declinar", PREFERENCES: "Preferencias", BOOKING: "Agendar cita", PATTERN_NOT_VALID: "El patr\xF3n no es v\xE1lido" };
|
|
109
109
|
|
|
110
|
-
//
|
|
110
|
+
// src/hooks/useComponentLang.tsx
|
|
111
|
+
var cookieName = "LOCALE";
|
|
111
112
|
var langMap = {
|
|
112
113
|
en: en_default,
|
|
113
114
|
es: es_default
|
|
114
115
|
};
|
|
115
|
-
|
|
116
|
-
// src/hooks/useComponentLang.tsx
|
|
117
|
-
var cookieName = "LOCALE";
|
|
118
116
|
var getClientCookie = () => {
|
|
119
117
|
const value = "; " + document.cookie, decodedValue = decodeURIComponent(value), parts = decodedValue.split("; " + cookieName + "=");
|
|
120
118
|
if (parts.length === 2) return parts.pop()?.split(";").shift();
|
|
@@ -161,17 +159,20 @@ function useValidation() {
|
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
// src/hooks/useFormChange.tsx
|
|
164
|
-
function useFormChange(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
function useFormChange({
|
|
163
|
+
state: newState,
|
|
164
|
+
validations
|
|
165
|
+
}) {
|
|
166
|
+
const [state, setState] = useState(newState), [touched, setTouched] = useState(allToValue(newState, false)), { getValidation } = useValidation(), errors2 = useRef(allToValue(newState, false));
|
|
167
|
+
const onChange = ({ target: { id, value } }) => setState(handleNestedChange({ state, id, value })), onBlur = ({ target: { id } }) => setTouched(
|
|
168
|
+
handleNestedChange({ state: touched, id, value: true })
|
|
169
|
+
), resetForm = () => {
|
|
170
|
+
setTouched(allToValue(newState, false));
|
|
171
|
+
setState(newState);
|
|
171
172
|
};
|
|
172
173
|
const register = useCallback(
|
|
173
|
-
(id,
|
|
174
|
-
const [value, isTouched] = [state[id], touched[id]],
|
|
174
|
+
(id, errorMessages) => {
|
|
175
|
+
const [value, isTouched] = [state[id], touched[id]], selectedValidations = validations[id], hasValidations = selectedValidations !== void 0, inputValidations = hasValidations ? getValidation(value, isTouched, selectedValidations, errorMessages) : {};
|
|
175
176
|
errors2.current = handleNestedChange({
|
|
176
177
|
state: errors2.current,
|
|
177
178
|
id,
|
|
@@ -186,7 +187,7 @@ function useFormChange(initialObj) {
|
|
|
186
187
|
errorMessage: hasValidations ? inputValidations.validationProps.errorMessage : ""
|
|
187
188
|
};
|
|
188
189
|
},
|
|
189
|
-
[getValidation, onChange, onBlur]
|
|
190
|
+
[getValidation, onChange, onBlur, touched]
|
|
190
191
|
);
|
|
191
192
|
const hasInvalidValues = () => {
|
|
192
193
|
setTouched(allToValue(touched, true));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juantroconisf/lib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"typings": "dist/index.d.ts",
|
|
18
18
|
"homepage": "https://github.com/juandiegotroconis/lib#readme",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@heroui/react": "^2.
|
|
21
|
-
"@types/node": "^22.
|
|
22
|
-
"@types/react": "^
|
|
23
|
-
"tsup": "^8.
|
|
24
|
-
"typescript": "^5.
|
|
20
|
+
"@heroui/react": "^2.7.5",
|
|
21
|
+
"@types/node": "^22.13.10",
|
|
22
|
+
"@types/react": "^19.0.12",
|
|
23
|
+
"tsup": "^8.4.0",
|
|
24
|
+
"typescript": "^5.8.2"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"react": "^19.0.0"
|