@apia/validations 2.0.7 → 2.0.9
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/da-DqVKtoV2.js.map +1 -1
- package/dist/de-CcX9-Rq3.js.map +1 -1
- package/dist/en-DCSKN2q5.js.map +1 -1
- package/dist/es-C-AXrgsF.js.map +1 -1
- package/dist/fa-CpOxXp-C.js.map +1 -1
- package/dist/fr-cmPfrK5Y.js.map +1 -1
- package/dist/gr-CmqXMJsZ.js.map +1 -1
- package/dist/hr-DIdEoOl4.js.map +1 -1
- package/dist/hu-VYwXwEzb.js.map +1 -1
- package/dist/index.d.ts +771 -25
- package/dist/index.js +114 -34
- package/dist/index.js.map +1 -1
- package/dist/it-CZNo0Ds3.js.map +1 -1
- package/dist/ja-CK5iBGzP.js.map +1 -1
- package/dist/jp-CK5iBGzP.js.map +1 -1
- package/dist/nl-BSU5Z9PJ.js.map +1 -1
- package/dist/pl-BSq2_6nm.js.map +1 -1
- package/dist/pt-DJTrqO4_.js.map +1 -1
- package/dist/ro-CAAZmoW6.js.map +1 -1
- package/package.json +6 -6
- package/rollup.validations.mjs +68 -68
- package/dist/collector/Collector.d.ts +0 -32
- package/dist/collector/Collector.d.ts.map +0 -1
- package/dist/collector/CollectorField.d.ts +0 -41
- package/dist/collector/CollectorField.d.ts.map +0 -1
- package/dist/collector/ValidatedCollectorField.d.ts +0 -44
- package/dist/collector/ValidatedCollectorField.d.ts.map +0 -1
- package/dist/collector/fields/Button.d.ts +0 -13
- package/dist/collector/fields/Button.d.ts.map +0 -1
- package/dist/collector/fields/Checkbox.d.ts +0 -13
- package/dist/collector/fields/Checkbox.d.ts.map +0 -1
- package/dist/collector/fields/Input.d.ts +0 -11
- package/dist/collector/fields/Input.d.ts.map +0 -1
- package/dist/collector/fields/Label.d.ts +0 -13
- package/dist/collector/fields/Label.d.ts.map +0 -1
- package/dist/collector/fields/Select.d.ts +0 -26
- package/dist/collector/fields/Select.d.ts.map +0 -1
- package/dist/collector/fields/Textarea.d.ts +0 -11
- package/dist/collector/fields/Textarea.d.ts.map +0 -1
- package/dist/components/Captcha.d.ts +0 -13
- package/dist/components/Captcha.d.ts.map +0 -1
- package/dist/components/Checkbox.d.ts +0 -12
- package/dist/components/Checkbox.d.ts.map +0 -1
- package/dist/components/DeletableInput.d.ts +0 -9
- package/dist/components/DeletableInput.d.ts.map +0 -1
- package/dist/components/FieldWrapper.d.ts +0 -20
- package/dist/components/FieldWrapper.d.ts.map +0 -1
- package/dist/components/FileInput.d.ts +0 -11
- package/dist/components/FileInput.d.ts.map +0 -1
- package/dist/components/Input.d.ts +0 -9
- package/dist/components/Input.d.ts.map +0 -1
- package/dist/components/NumberInput.d.ts +0 -14
- package/dist/components/NumberInput.d.ts.map +0 -1
- package/dist/components/Radio.d.ts +0 -14
- package/dist/components/Radio.d.ts.map +0 -1
- package/dist/components/Select.d.ts +0 -17
- package/dist/components/Select.d.ts.map +0 -1
- package/dist/components/Switchbox.d.ts +0 -11
- package/dist/components/Switchbox.d.ts.map +0 -1
- package/dist/components/Textarea.d.ts +0 -9
- package/dist/components/Textarea.d.ts.map +0 -1
- package/dist/components/ValidationError.d.ts +0 -17
- package/dist/components/ValidationError.d.ts.map +0 -1
- package/dist/components/types.d.ts +0 -11
- package/dist/components/types.d.ts.map +0 -1
- package/dist/form/Form.d.ts +0 -89
- package/dist/form/Form.d.ts.map +0 -1
- package/dist/form/FormContext.d.ts +0 -27
- package/dist/form/FormContext.d.ts.map +0 -1
- package/dist/hooks/useField.d.ts +0 -76
- package/dist/hooks/useField.d.ts.map +0 -1
- package/dist/hooks/useFieldStatesClassNames.d.ts +0 -4
- package/dist/hooks/useFieldStatesClassNames.d.ts.map +0 -1
- package/dist/hooks/useFieldValue.d.ts +0 -8
- package/dist/hooks/useFieldValue.d.ts.map +0 -1
- package/dist/hooks/useValidationClass.d.ts +0 -49
- package/dist/hooks/useValidationClass.d.ts.map +0 -1
- package/dist/lang/es.d.ts +0 -32
- package/dist/lang/es.d.ts.map +0 -1
- package/dist/types.d.ts +0 -130
- package/dist/types.d.ts.map +0 -1
- package/dist/util.d.ts +0 -36
- package/dist/util.d.ts.map +0 -1
- package/dist/validationStore.d.ts +0 -113
- package/dist/validationStore.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TNumberInput } from '@apia/components';
|
|
2
|
-
import React__default from 'react';
|
|
3
|
-
import { TDefaultFieldType } from './types.js';
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
GNR_NUMERIC: string;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
type TInput = TNumberInput & TDefaultFieldType;
|
|
11
|
-
declare const NumberInputf: React__default.MemoExoticComponent<React__default.ForwardRefExoticComponent<Omit<TInput, "ref"> & React__default.RefAttributes<HTMLInputElement>>>;
|
|
12
|
-
|
|
13
|
-
export { NumberInputf };
|
|
14
|
-
//# sourceMappingURL=NumberInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { RadioProps } from '@apia/theme';
|
|
3
|
-
import { TDefaultFieldType } from './types.js';
|
|
4
|
-
|
|
5
|
-
type TRadio = RadioProps & TDefaultFieldType & {
|
|
6
|
-
options: {
|
|
7
|
-
value: string;
|
|
8
|
-
label: string;
|
|
9
|
-
}[];
|
|
10
|
-
};
|
|
11
|
-
declare const Radio: React__default.ForwardRefExoticComponent<Omit<TRadio, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
12
|
-
|
|
13
|
-
export { Radio, type TRadio };
|
|
14
|
-
//# sourceMappingURL=Radio.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { SelectProps } from '@apia/theme';
|
|
3
|
-
import { TDefaultFieldType } from './types.js';
|
|
4
|
-
import { TId } from '@apia/util';
|
|
5
|
-
|
|
6
|
-
type TOption = {
|
|
7
|
-
value: TId;
|
|
8
|
-
label: string;
|
|
9
|
-
};
|
|
10
|
-
type TSelectProps = Omit<SelectProps, 'defaultValue'>;
|
|
11
|
-
type TSelect = TSelectProps & TDefaultFieldType & {
|
|
12
|
-
options: TOption[];
|
|
13
|
-
};
|
|
14
|
-
declare const Select: React__default.ForwardRefExoticComponent<Omit<TSelect, "ref"> & React__default.RefAttributes<HTMLSelectElement>>;
|
|
15
|
-
|
|
16
|
-
export { Select, type TOption, type TSelect, type TSelectProps };
|
|
17
|
-
//# sourceMappingURL=Select.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { SwitchProps, InputProps } from '@apia/theme';
|
|
3
|
-
import { TDefaultFieldType } from './types.js';
|
|
4
|
-
|
|
5
|
-
type TSwitchbox = Omit<SwitchProps, 'onChange'> & Pick<InputProps, 'onChange'> & TDefaultFieldType & {
|
|
6
|
-
reverse?: boolean;
|
|
7
|
-
};
|
|
8
|
-
declare const Switchbox: React__default.ForwardRefExoticComponent<Omit<TSwitchbox, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
9
|
-
|
|
10
|
-
export { Switchbox, type TSwitchbox };
|
|
11
|
-
//# sourceMappingURL=Switchbox.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Switchbox.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { TextareaProps } from '@apia/theme';
|
|
3
|
-
import { TDefaultFieldType } from './types.js';
|
|
4
|
-
|
|
5
|
-
type TTextarea = TextareaProps & TDefaultFieldType;
|
|
6
|
-
declare const Textarea: React__default.ForwardRefExoticComponent<Omit<TTextarea, "ref"> & React__default.RefAttributes<HTMLTextAreaElement>>;
|
|
7
|
-
|
|
8
|
-
export { Textarea };
|
|
9
|
-
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Renderiza los errores del campo con el nombre pasado
|
|
5
|
-
* como prop. En caso de que no exista error, no renderiza
|
|
6
|
-
* nada.
|
|
7
|
-
*
|
|
8
|
-
* @props
|
|
9
|
-
* *name:* El nombre del campo cuyos errores se quieren
|
|
10
|
-
* renderizar.
|
|
11
|
-
*/
|
|
12
|
-
declare const ValidationError: ({ name }: {
|
|
13
|
-
name: string;
|
|
14
|
-
}) => React.JSX.Element | null;
|
|
15
|
-
|
|
16
|
-
export { ValidationError };
|
|
17
|
-
//# sourceMappingURL=ValidationError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationError.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TUseField } from '../hooks/useField.js';
|
|
2
|
-
import { IWrapper } from './FieldWrapper.js';
|
|
3
|
-
|
|
4
|
-
type TDefaultFieldType<ValueType = string> = Omit<TUseField<ValueType>, 'error' | 'value' | 'isTouched'> & {
|
|
5
|
-
label?: string;
|
|
6
|
-
initialValue?: ValueType;
|
|
7
|
-
validationClass?: string;
|
|
8
|
-
} & Pick<IWrapper, 'avoidSemicolon'>;
|
|
9
|
-
|
|
10
|
-
export type { TDefaultFieldType };
|
|
11
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/form/Form.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { TValidationResult } from '../types.js';
|
|
3
|
-
|
|
4
|
-
type TOnValidate<ValueType extends Record<string, unknown> = Record<string, unknown>, SubmitValueType extends Record<keyof ValueType, unknown> = ValueType> = (validationResult: TValidationResult<ValueType, SubmitValueType>) => unknown;
|
|
5
|
-
interface IForm<ValueType extends Record<string, unknown>, SubmitValueType extends Record<keyof ValueType, unknown> = ValueType> {
|
|
6
|
-
/**
|
|
7
|
-
* Si se pasa en true, los campos que se registren en este form no
|
|
8
|
-
* sobreescribirán valores previos si es que existen, sin importar el valor de
|
|
9
|
-
* avoidRegisterIfExists pasado al useField.
|
|
10
|
-
*/
|
|
11
|
-
avoidFieldsOverride?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Impide que se apliquen los estilos que indican que un campo fue alterado.
|
|
14
|
-
*/
|
|
15
|
-
avoidFieldsTouch?: boolean;
|
|
16
|
-
children: React__default.ReactNode;
|
|
17
|
-
className?: string;
|
|
18
|
-
initialValues?: Partial<ValueType>;
|
|
19
|
-
name?: string;
|
|
20
|
-
onUnmount?: () => unknown;
|
|
21
|
-
/**
|
|
22
|
-
* Cuando se ejecuta una acción de validación desde
|
|
23
|
-
* algún lugar de la aplicación se llama a este método
|
|
24
|
-
* con el resultado de dicha ejecución.
|
|
25
|
-
*/
|
|
26
|
-
onValidate?: TOnValidate<ValueType, SubmitValueType>;
|
|
27
|
-
/**
|
|
28
|
-
* Permite definir si el formulario va a ser borrado de la validación al ser
|
|
29
|
-
* desmontado
|
|
30
|
-
*/
|
|
31
|
-
unregisterOnUnmount?: boolean;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Cuando se desea usar el sistema de validación,
|
|
35
|
-
* se debe utilizar este componente como form contenedor
|
|
36
|
-
* de todos los campos que quieran validarse.
|
|
37
|
-
*
|
|
38
|
-
* Es importante que no se coloquen formularios dentro
|
|
39
|
-
* de formularios ya que esto podría afectar negativamente
|
|
40
|
-
* el proceso de validación.
|
|
41
|
-
*
|
|
42
|
-
* @props
|
|
43
|
-
* *name:* Se puede pasar un nombre para identificar
|
|
44
|
-
* el form. Este nombre será utilizado para almacenar
|
|
45
|
-
* la información en Redux, por lo que si se desea
|
|
46
|
-
* acceder a la información recolectada por la librería,
|
|
47
|
-
* es conveniente pasar un nombre conocido y único. En
|
|
48
|
-
* caso de no se pase ningún nombre, la aplicación
|
|
49
|
-
* generará un nombre único automaticamente.
|
|
50
|
-
*
|
|
51
|
-
* *onValidate:* Un callback que será llamado cuando
|
|
52
|
-
* se invoque el método validateForm del store o cuando
|
|
53
|
-
* se lance el evento de submit del elemento form (por
|
|
54
|
-
* ejemplo mediante un click en un botón que no tenga
|
|
55
|
-
* type="button"), con el resultado de la validación.
|
|
56
|
-
*
|
|
57
|
-
* avoidFieldsOverride
|
|
58
|
-
* avoidFieldsTouch
|
|
59
|
-
*
|
|
60
|
-
* @see useField
|
|
61
|
-
* @see useForm
|
|
62
|
-
*
|
|
63
|
-
* @important Debido a que este hook renderiza un elemento
|
|
64
|
-
* form en el DOM, es importante agregar el atributo
|
|
65
|
-
* type="button" a todos los botones dentro del formulario
|
|
66
|
-
* que no se desea que disparen la validación.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* Para ver un ejemplo funcional, mira el componente
|
|
70
|
-
* Invitations.tsx
|
|
71
|
-
*
|
|
72
|
-
* // IMPORTANTE: El tipado del componente Form es genérico
|
|
73
|
-
* // por lo que es posible instanciarlo como se muestra a
|
|
74
|
-
* // continuación, lo que nos da el tipado correcto en el
|
|
75
|
-
* // callback onValidate.
|
|
76
|
-
* <Form<FormDataType> onValidate={(res) => {
|
|
77
|
-
* if(hasSucceedValidation(res)) {
|
|
78
|
-
* // Do something with submitValues
|
|
79
|
-
* } else {
|
|
80
|
-
* // Do something with errors
|
|
81
|
-
* }
|
|
82
|
-
* }}>
|
|
83
|
-
* ...{children}
|
|
84
|
-
* </Form>
|
|
85
|
-
*/
|
|
86
|
-
declare const Form: <ValueType extends Record<string, unknown>, SubmitValueType extends Record<keyof ValueType, unknown> = ValueType>({ avoidFieldsOverride, avoidFieldsTouch, children, className, name, initialValues, onUnmount, onValidate, unregisterOnUnmount, }: IForm<ValueType, SubmitValueType>) => React__default.JSX.Element | null;
|
|
87
|
-
|
|
88
|
-
export { Form, type IForm, type TOnValidate };
|
|
89
|
-
//# sourceMappingURL=Form.d.ts.map
|
package/dist/form/Form.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { TValidationResult } from '../types.js';
|
|
3
|
-
|
|
4
|
-
interface IFormContext<ValueType extends Record<string, unknown> = Record<string, unknown>, SubmitValueType extends Record<keyof ValueType, unknown> = ValueType> {
|
|
5
|
-
avoidFieldsTouch?: boolean;
|
|
6
|
-
name: string;
|
|
7
|
-
validate: () => Promise<TValidationResult<ValueType, SubmitValueType>>;
|
|
8
|
-
}
|
|
9
|
-
declare const FormContext: React__default.Context<IFormContext<Record<string, unknown>, Record<string, unknown>>>;
|
|
10
|
-
/**
|
|
11
|
-
* Provee acceso de forma sencilla al contexto de
|
|
12
|
-
* validación, que básicamente posee el nombre del
|
|
13
|
-
* form en caso de que se quiera usar para acceder
|
|
14
|
-
* a través de Redux a la información del mismo y un
|
|
15
|
-
* método validate, que dispara la validación del
|
|
16
|
-
* form.
|
|
17
|
-
*
|
|
18
|
-
* En la práctica, el método validate es casi
|
|
19
|
-
* innecesario, ya que la validación se puede disparar
|
|
20
|
-
* con cualquier botón que no tenga seteado el
|
|
21
|
-
* atributo type="button" (esto es así ya que en el
|
|
22
|
-
* DOM se renderiza un elemento de tipo form).
|
|
23
|
-
*/
|
|
24
|
-
declare function useFormContext(): IFormContext<Record<string, unknown>, Record<string, unknown>>;
|
|
25
|
-
|
|
26
|
-
export { FormContext, type IFormContext, useFormContext };
|
|
27
|
-
//# sourceMappingURL=FormContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormContext.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/hooks/useField.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import { TValidationField } from '../types.js';
|
|
3
|
-
|
|
4
|
-
type TUseField<ValueType = unknown, SubmitValueType = ValueType> = Omit<TValidationField<ValueType, SubmitValueType>, 'error' | 'value' | 'isTouched'> & {
|
|
5
|
-
/**
|
|
6
|
-
* Con esta propiedad es posible evitar que el campo
|
|
7
|
-
* se registre cuando ya fue registrado previamente en
|
|
8
|
-
* el store. De esta forma, se evitaría escribir sobre
|
|
9
|
-
* un valor que ya estaba seteado anteriormente.
|
|
10
|
-
*/
|
|
11
|
-
avoidRegisterIfExists?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Si se está fuera de contexto de validación, se puede pasar un formName
|
|
14
|
-
* para evitar que el hook lo intente tomar de contexto.
|
|
15
|
-
*/
|
|
16
|
-
formName?: string;
|
|
17
|
-
initialValue?: ValueType;
|
|
18
|
-
removeOnUnmount?: boolean;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Este hook permite registrar un field para ser validado,
|
|
22
|
-
* o simplemente para recolectar su valor, e incluso aplicar
|
|
23
|
-
* una función de transformación de dicho valor antes de
|
|
24
|
-
* hacer submit.
|
|
25
|
-
*
|
|
26
|
-
* @returns
|
|
27
|
-
* *error:* Es null mientras que no haya errores de
|
|
28
|
-
* validación, y un string en caso de que si lo haya.
|
|
29
|
-
*
|
|
30
|
-
* *value:* Es el valor actual del campo.
|
|
31
|
-
*
|
|
32
|
-
* *name:* Debería utilizarse para dar * valor al atributo
|
|
33
|
-
* name o id del contenedor que debe recibir el foco en caso
|
|
34
|
-
* de que la validación fallara. (Esto es, cuando se deba
|
|
35
|
-
* realizar foco porque la validación falló, la librería
|
|
36
|
-
* intentará encontrar un campo con el selector
|
|
37
|
-
* [name=${name}, #${name}] dentro del formulario).
|
|
38
|
-
*
|
|
39
|
-
* *onChange:* Se utiliza para setear el valor del campo,
|
|
40
|
-
* puede utilizarse directamente como callback para la
|
|
41
|
-
* propiedad onChange que aceptan la mayoría de los campos,
|
|
42
|
-
* ya que intentará setear el valor con ev.target.value
|
|
43
|
-
* y si esa propiedad no está definida, lo hará directamente
|
|
44
|
-
* con ev.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* // Si se desea un ejemplo más complejo, vea el componente
|
|
48
|
-
* // Invitations.tsx que se encuentra dentro del directorio
|
|
49
|
-
* // de la librería.
|
|
50
|
-
*
|
|
51
|
-
* const inputProps = useField<string>({
|
|
52
|
-
name: 'name',
|
|
53
|
-
validationRules: {
|
|
54
|
-
required: true,
|
|
55
|
-
minLength: 5,
|
|
56
|
-
maxLength: 10
|
|
57
|
-
},
|
|
58
|
-
initialValue: metadata.value,
|
|
59
|
-
* });
|
|
60
|
-
|
|
61
|
-
return <Box>
|
|
62
|
-
<Input {...inputProps} />
|
|
63
|
-
<ValidationError name="name" />
|
|
64
|
-
</Box>
|
|
65
|
-
*/
|
|
66
|
-
declare function useField<ValueType = unknown, SubmitValueType = ValueType>(fieldDefinition: TUseField<ValueType, SubmitValueType>): {
|
|
67
|
-
error: string | null | undefined;
|
|
68
|
-
isTouched: boolean;
|
|
69
|
-
name: string;
|
|
70
|
-
onChange: (ev: React__default.ChangeEvent | ValueType) => void;
|
|
71
|
-
updateValidations: ({ validationFunction, validationRules, }: Pick<TValidationField, 'validationRules' | 'validationFunction'>) => void;
|
|
72
|
-
value: ValueType;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export { type TUseField, useField };
|
|
76
|
-
//# sourceMappingURL=useField.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useField.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldStatesClassNames.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldValue.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { TDefaultFieldType } from '../components/types.js';
|
|
2
|
-
import { TValidationFunction } from '../types.js';
|
|
3
|
-
|
|
4
|
-
declare function useValidationClass<T>({ customValidation, formName, name, validationClass, validationFunction, validationRules, }: Pick<TDefaultFieldType<T>, 'validationClass' | 'validationFunction' | 'validationRules' | 'name'> & {
|
|
5
|
-
customValidation?: TValidationFunction<T>;
|
|
6
|
-
formName?: string;
|
|
7
|
-
}): {
|
|
8
|
-
actualValidationFunction: TValidationFunction<T>;
|
|
9
|
-
actualValidationRules: {
|
|
10
|
-
number?: boolean | undefined;
|
|
11
|
-
required?: boolean | undefined;
|
|
12
|
-
alpha?: boolean | undefined;
|
|
13
|
-
alphanum?: boolean | undefined;
|
|
14
|
-
nodigit?: boolean | undefined;
|
|
15
|
-
digit?: boolean | undefined;
|
|
16
|
-
email?: boolean | undefined;
|
|
17
|
-
image?: boolean | undefined;
|
|
18
|
-
phone?: boolean | undefined;
|
|
19
|
-
url?: boolean | undefined;
|
|
20
|
-
lengthmax?: boolean | undefined;
|
|
21
|
-
lengthmin?: boolean | undefined;
|
|
22
|
-
checkbox?: boolean | undefined;
|
|
23
|
-
radios?: boolean | undefined;
|
|
24
|
-
select?: boolean | undefined;
|
|
25
|
-
select_multiple?: boolean | undefined;
|
|
26
|
-
errorsTitle?: boolean | undefined;
|
|
27
|
-
digitmin?: number | undefined;
|
|
28
|
-
digitltd?: [number, number] | undefined;
|
|
29
|
-
confirm?: string | undefined;
|
|
30
|
-
differs?: string | undefined;
|
|
31
|
-
length_str?: [number, number] | undefined;
|
|
32
|
-
length_fix?: number | undefined;
|
|
33
|
-
words_min?: number | undefined;
|
|
34
|
-
words_max?: number | undefined;
|
|
35
|
-
words_range?: [number, number] | undefined;
|
|
36
|
-
checkboxes_group?: number | undefined;
|
|
37
|
-
patternMessage?: string | undefined;
|
|
38
|
-
pattern?: string | RegExp | undefined;
|
|
39
|
-
digitmax?: number | undefined;
|
|
40
|
-
validName?: string | undefined;
|
|
41
|
-
maxLength?: number | undefined;
|
|
42
|
-
minLength?: number | undefined;
|
|
43
|
-
min?: number | undefined;
|
|
44
|
-
max?: number | undefined;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export { useValidationClass };
|
|
49
|
-
//# sourceMappingURL=useValidationClass.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useValidationClass.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/lang/es.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
declare const formcheckLanguage: {
|
|
2
|
-
required: string;
|
|
3
|
-
alpha: string;
|
|
4
|
-
alphanum: string;
|
|
5
|
-
nodigit: string;
|
|
6
|
-
digit: string;
|
|
7
|
-
digitmin: string;
|
|
8
|
-
digitltd: string;
|
|
9
|
-
number: string;
|
|
10
|
-
email: string;
|
|
11
|
-
image: string;
|
|
12
|
-
phone: string;
|
|
13
|
-
url: string;
|
|
14
|
-
confirm: string;
|
|
15
|
-
differs: string;
|
|
16
|
-
length_str: string;
|
|
17
|
-
length_fix: string;
|
|
18
|
-
lengthmax: string;
|
|
19
|
-
lengthmin: string;
|
|
20
|
-
words_min: string;
|
|
21
|
-
words_max: string;
|
|
22
|
-
words_range: string;
|
|
23
|
-
checkbox: string;
|
|
24
|
-
checkboxes_group: string;
|
|
25
|
-
radios: string;
|
|
26
|
-
select: string;
|
|
27
|
-
select_multiple: string;
|
|
28
|
-
errorsTitle: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { formcheckLanguage as default };
|
|
32
|
-
//# sourceMappingURL=es.d.ts.map
|
package/dist/lang/es.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"es.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/types.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { TModify } from '@apia/util';
|
|
2
|
-
import formcheckLanguage from './lang/es.js';
|
|
3
|
-
|
|
4
|
-
type TValidate = Partial<TModify<Record<keyof typeof formcheckLanguage, boolean>, {
|
|
5
|
-
digitmin: number;
|
|
6
|
-
digitltd: [number, number];
|
|
7
|
-
confirm: string;
|
|
8
|
-
differs: string;
|
|
9
|
-
length_str: [number, number];
|
|
10
|
-
length_fix: number;
|
|
11
|
-
words_min: number;
|
|
12
|
-
words_max: number;
|
|
13
|
-
words_range: [number, number];
|
|
14
|
-
checkboxes_group: number;
|
|
15
|
-
}> & {
|
|
16
|
-
patternMessage: string;
|
|
17
|
-
pattern: RegExp | string;
|
|
18
|
-
digitmax: number;
|
|
19
|
-
validName?: string;
|
|
20
|
-
maxLength: number;
|
|
21
|
-
minLength: number;
|
|
22
|
-
min: number;
|
|
23
|
-
max: number;
|
|
24
|
-
}>;
|
|
25
|
-
interface IFieldDefinition<ValueType = string> {
|
|
26
|
-
toolTip: string;
|
|
27
|
-
label: string;
|
|
28
|
-
name: string;
|
|
29
|
-
validate?: TValidate;
|
|
30
|
-
value: ValueType;
|
|
31
|
-
options?: {
|
|
32
|
-
label: string;
|
|
33
|
-
value: number | number;
|
|
34
|
-
selected?: boolean;
|
|
35
|
-
}[];
|
|
36
|
-
}
|
|
37
|
-
type TPromiseOrNot<Type> = Promise<Type> | Type;
|
|
38
|
-
type TSuccessfulValidation<ValueType extends Record<string, unknown>, SubmitValueType extends Record<keyof ValueType, unknown> = ValueType> = {
|
|
39
|
-
values: ValueType;
|
|
40
|
-
submitValues: SubmitValueType;
|
|
41
|
-
};
|
|
42
|
-
type TWrongValidation = {
|
|
43
|
-
errors: Record<string, string>;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Esta interfaz representa el resultado de la validación
|
|
47
|
-
* de un formulario.
|
|
48
|
-
*/
|
|
49
|
-
type TValidationResult<ValueType extends Record<string, unknown>, SubmitValueType extends Record<keyof ValueType, unknown> = ValueType> = TSuccessfulValidation<ValueType, SubmitValueType> | TWrongValidation;
|
|
50
|
-
type TFieldValidationResult = true | string;
|
|
51
|
-
type TValidationFunction<ValueType> = (value: ValueType, formName: string) => TPromiseOrNot<TFieldValidationResult>;
|
|
52
|
-
type TValidationSubmitValueParser<ValueType = unknown, SubmitValueType = ValueType> = (value: ValueType) => SubmitValueType;
|
|
53
|
-
type TValidationValueParser<ValueType = unknown, ValidationValueType = unknown> = (value: ValueType) => ValidationValueType;
|
|
54
|
-
type TValidationRules = IFieldDefinition['validate'];
|
|
55
|
-
/**
|
|
56
|
-
* Esta interfaz representa el estado de un campo dentro
|
|
57
|
-
* del hook de validación.
|
|
58
|
-
*
|
|
59
|
-
* Las funcionalidades contempladas hasta el momento son:
|
|
60
|
-
*
|
|
61
|
-
* - Contener los valores del formulario.
|
|
62
|
-
* - Foco: Se hará querySelector sobre el form que lo contiene
|
|
63
|
-
* con el nombre provisto.
|
|
64
|
-
* - Función de validación o lista de reglas.
|
|
65
|
-
* - Manejo de errores.
|
|
66
|
-
* - Parsearlos para hacer submit.
|
|
67
|
-
*/
|
|
68
|
-
type TValidationField<ValueType = any, SubmitValueType = ValueType> = {
|
|
69
|
-
error?: string | null;
|
|
70
|
-
isTouched: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* El nombre se utilizará para hacer foco en el campo en caso
|
|
73
|
-
* de que la validación del mismo fallara. Para ello se
|
|
74
|
-
* intenta recuperar un campo con el selector
|
|
75
|
-
* [name=${name}, #${name}], en caso de que el selector no
|
|
76
|
-
* encontrar ningún campo, se intentará hacer foco en el
|
|
77
|
-
* siguiente campo con error.
|
|
78
|
-
*/
|
|
79
|
-
name: string;
|
|
80
|
-
/**
|
|
81
|
-
* Como dice el nombre, es posible cambiar el nombre de un
|
|
82
|
-
* campo al hacer submit.
|
|
83
|
-
*/
|
|
84
|
-
submitName?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Es posible recibir un valor ya parseado en el callback
|
|
87
|
-
* onValidate del Form, para ello se puede proveer este
|
|
88
|
-
* callback, que será llamado previo a llamar a onValidate.
|
|
89
|
-
*/
|
|
90
|
-
submitValueParser?: TValidationSubmitValueParser<ValueType, SubmitValueType | Promise<SubmitValueType> | undefined>;
|
|
91
|
-
/**
|
|
92
|
-
* Es posible pasar una función de validación personalizada
|
|
93
|
-
* para casos en los que la validación es significativamente
|
|
94
|
-
* compleja. En la mayoría de los casos debería bastar con
|
|
95
|
-
* la propiedad validationRules.
|
|
96
|
-
*/
|
|
97
|
-
validationFunction?: TValidationFunction<ValueType>;
|
|
98
|
-
/**
|
|
99
|
-
* Permite pasar una serie de reglas que el campo debe cumplir
|
|
100
|
-
* al validar.
|
|
101
|
-
*/
|
|
102
|
-
validationRules?: TValidationRules;
|
|
103
|
-
validationValueParser?: TValidationValueParser<ValueType>;
|
|
104
|
-
value: ValueType;
|
|
105
|
-
};
|
|
106
|
-
type TRegisterFormOptions = Partial<{
|
|
107
|
-
/**
|
|
108
|
-
* Si esta propiedad está seteada en true, el formulario se registrará y
|
|
109
|
-
* aquellos campos que ya tuvieran valor en el store no se volverán a
|
|
110
|
-
* registrar. En caso de que se incluyera initialValue, se hará updateValue de
|
|
111
|
-
* estos campos.
|
|
112
|
-
*/
|
|
113
|
-
avoidFieldsOverride: boolean;
|
|
114
|
-
initialValues: Record<string, unknown>;
|
|
115
|
-
}>;
|
|
116
|
-
type TRegisterFieldOptions = {
|
|
117
|
-
avoidPropagation?: boolean;
|
|
118
|
-
registerIfExists?: boolean;
|
|
119
|
-
};
|
|
120
|
-
type TRegisterField = Partial<TValidationField> & Pick<TValidationField, 'name'>;
|
|
121
|
-
type TFormState = {
|
|
122
|
-
fields: string[];
|
|
123
|
-
name: string;
|
|
124
|
-
isTouched: boolean;
|
|
125
|
-
isValid: boolean;
|
|
126
|
-
validationResult: TValidationResult<Record<string, unknown>> | null;
|
|
127
|
-
} & Pick<TRegisterFormOptions, 'avoidFieldsOverride'>;
|
|
128
|
-
|
|
129
|
-
export type { IFieldDefinition, TFieldValidationResult, TFormState, TPromiseOrNot, TRegisterField, TRegisterFieldOptions, TRegisterFormOptions, TSuccessfulValidation, TValidate, TValidationField, TValidationFunction, TValidationResult, TValidationRules, TValidationSubmitValueParser, TValidationValueParser, TWrongValidation };
|
|
130
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/util.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { TFieldValidationResult, TValidationResult, TSuccessfulValidation, TValidationField, IFieldDefinition } from './types.js';
|
|
2
|
-
import formcheckLanguage from './lang/es.js';
|
|
3
|
-
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
NO_LANGUAGE_EXCEPTION: string;
|
|
7
|
-
MSG_INVALID_REG_EXP: string;
|
|
8
|
-
GNR_INVALID_NAME: string;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Determina si la validación de un campo resultó exitosa.
|
|
13
|
-
*/
|
|
14
|
-
declare function hasSucceedFieldValidation(result: TFieldValidationResult): result is true;
|
|
15
|
-
/**
|
|
16
|
-
* Determina si la validación de un formulario resultó
|
|
17
|
-
* exitosa. Está pensada para utilizar en el callback
|
|
18
|
-
* onValidate de Form o en la acción validationsActions.validateForm
|
|
19
|
-
*/
|
|
20
|
-
declare function hasSucceedFormValidation<ValueType extends Record<string, unknown>, SubmitValueType extends Record<keyof ValueType, unknown> = ValueType>(result: TValidationResult<ValueType, SubmitValueType>): result is TSuccessfulValidation<ValueType, SubmitValueType>;
|
|
21
|
-
/**
|
|
22
|
-
* Devuelve la cadena correspondiente a un código
|
|
23
|
-
* de error, realizando los reemplazos correspondientes.
|
|
24
|
-
*/
|
|
25
|
-
declare function lang(errorCode: keyof typeof formcheckLanguage, ...replacements: (string | number)[]): string;
|
|
26
|
-
declare function classToValidationFunction<T = string>(className: string): TValidationField<T>['validationFunction'];
|
|
27
|
-
declare function classToValidate(className: string): IFieldDefinition['validate'];
|
|
28
|
-
/**
|
|
29
|
-
* Realiza la carga de los mensajes de errores para el lenguaje
|
|
30
|
-
* especificado. Este método debe llamarse antes de utilizar
|
|
31
|
-
* las validaciones.
|
|
32
|
-
*/
|
|
33
|
-
declare function initValidations(): Promise<void>;
|
|
34
|
-
|
|
35
|
-
export { classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang };
|
|
36
|
-
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|