@apia/validations 2.0.9 → 2.0.10

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.
Files changed (68) hide show
  1. package/dist/collector/Collector.d.ts +32 -0
  2. package/dist/collector/Collector.d.ts.map +1 -0
  3. package/dist/collector/CollectorField.d.ts +41 -0
  4. package/dist/collector/CollectorField.d.ts.map +1 -0
  5. package/dist/collector/ValidatedCollectorField.d.ts +44 -0
  6. package/dist/collector/ValidatedCollectorField.d.ts.map +1 -0
  7. package/dist/collector/fields/Button.d.ts +13 -0
  8. package/dist/collector/fields/Button.d.ts.map +1 -0
  9. package/dist/collector/fields/Checkbox.d.ts +13 -0
  10. package/dist/collector/fields/Checkbox.d.ts.map +1 -0
  11. package/dist/collector/fields/Input.d.ts +11 -0
  12. package/dist/collector/fields/Input.d.ts.map +1 -0
  13. package/dist/collector/fields/Label.d.ts +13 -0
  14. package/dist/collector/fields/Label.d.ts.map +1 -0
  15. package/dist/collector/fields/Select.d.ts +26 -0
  16. package/dist/collector/fields/Select.d.ts.map +1 -0
  17. package/dist/collector/fields/Textarea.d.ts +11 -0
  18. package/dist/collector/fields/Textarea.d.ts.map +1 -0
  19. package/dist/components/Captcha.d.ts +13 -0
  20. package/dist/components/Captcha.d.ts.map +1 -0
  21. package/dist/components/Checkbox.d.ts +12 -0
  22. package/dist/components/Checkbox.d.ts.map +1 -0
  23. package/dist/components/DeletableInput.d.ts +9 -0
  24. package/dist/components/DeletableInput.d.ts.map +1 -0
  25. package/dist/components/FieldWrapper.d.ts +20 -0
  26. package/dist/components/FieldWrapper.d.ts.map +1 -0
  27. package/dist/components/FileInput.d.ts +11 -0
  28. package/dist/components/FileInput.d.ts.map +1 -0
  29. package/dist/components/Input.d.ts +9 -0
  30. package/dist/components/Input.d.ts.map +1 -0
  31. package/dist/components/NumberInput.d.ts +14 -0
  32. package/dist/components/NumberInput.d.ts.map +1 -0
  33. package/dist/components/Radio.d.ts +14 -0
  34. package/dist/components/Radio.d.ts.map +1 -0
  35. package/dist/components/Select.d.ts +17 -0
  36. package/dist/components/Select.d.ts.map +1 -0
  37. package/dist/components/Switchbox.d.ts +11 -0
  38. package/dist/components/Switchbox.d.ts.map +1 -0
  39. package/dist/components/Textarea.d.ts +9 -0
  40. package/dist/components/Textarea.d.ts.map +1 -0
  41. package/dist/components/ValidationError.d.ts +17 -0
  42. package/dist/components/ValidationError.d.ts.map +1 -0
  43. package/dist/components/types.d.ts +11 -0
  44. package/dist/components/types.d.ts.map +1 -0
  45. package/dist/form/Form.d.ts +89 -0
  46. package/dist/form/Form.d.ts.map +1 -0
  47. package/dist/form/FormContext.d.ts +27 -0
  48. package/dist/form/FormContext.d.ts.map +1 -0
  49. package/dist/hooks/useField.d.ts +76 -0
  50. package/dist/hooks/useField.d.ts.map +1 -0
  51. package/dist/hooks/useFieldStatesClassNames.d.ts +4 -0
  52. package/dist/hooks/useFieldStatesClassNames.d.ts.map +1 -0
  53. package/dist/hooks/useFieldValue.d.ts +8 -0
  54. package/dist/hooks/useFieldValue.d.ts.map +1 -0
  55. package/dist/hooks/useValidationClass.d.ts +49 -0
  56. package/dist/hooks/useValidationClass.d.ts.map +1 -0
  57. package/dist/index.d.ts +25 -771
  58. package/dist/index.js +31 -111
  59. package/dist/index.js.map +1 -1
  60. package/dist/lang/es.d.ts +32 -0
  61. package/dist/lang/es.d.ts.map +1 -0
  62. package/dist/types.d.ts +130 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/util.d.ts +36 -0
  65. package/dist/util.d.ts.map +1 -0
  66. package/dist/validationStore.d.ts +113 -0
  67. package/dist/validationStore.d.ts.map +1 -0
  68. package/package.json +3 -3
@@ -0,0 +1,32 @@
1
+ import { TOpenModal } from '@apia/components';
2
+ import { CollectorField } from './CollectorField.js';
3
+ import { CollectorCheckbox } from './fields/Checkbox.js';
4
+ import { CollectorInput } from './fields/Input.js';
5
+ import { CollectorSelect } from './fields/Select.js';
6
+ import { CollectorTextarea } from './fields/Textarea.js';
7
+ import { CollectorLabel } from './fields/Label.js';
8
+ import { CollectorButton } from './fields/Button.js';
9
+
10
+ declare class Collector {
11
+ #private;
12
+ fields: {
13
+ button: typeof CollectorButton;
14
+ checkbox: typeof CollectorCheckbox;
15
+ input: typeof CollectorInput;
16
+ /**
17
+ * Muestra una etiqueta con tag personalizable: h1...h6, p, label. (Por
18
+ * defecto: label)
19
+ */
20
+ label: typeof CollectorLabel;
21
+ select: typeof CollectorSelect;
22
+ textarea: typeof CollectorTextarea;
23
+ };
24
+ private private__id;
25
+ get id(): string;
26
+ add: (field: CollectorField) => void;
27
+ forEach: (cb: (field: CollectorField, i: number) => void) => void;
28
+ show: <FormValues extends Record<string, unknown>>(modalProps?: Partial<Omit<TOpenModal, 'children'>>) => Promise<FormValues | null>;
29
+ }
30
+
31
+ export { Collector };
32
+ //# sourceMappingURL=Collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collector.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import { FC } from 'react';
3
+ import { EventEmitter } from '@apia/util';
4
+ import { TValidationFunction, TValidationRules } from '../types.js';
5
+ import '../components/FieldWrapper.js';
6
+ import '../components/NumberInput.js';
7
+ import { TOption } from '../components/Select.js';
8
+ import { Collector } from './Collector.js';
9
+
10
+ declare abstract class CollectorField<ValueType = any, FieldProps = any> extends EventEmitter<{
11
+ functionUpdate: TValidationFunction<ValueType>;
12
+ optionsUpdate: TOption[];
13
+ propsUpdate: Partial<FieldProps>;
14
+ rulesUpdate: TValidationRules;
15
+ }> {
16
+ #private;
17
+ protected _name: string;
18
+ protected label: string;
19
+ /**
20
+ * Este es el componente de implementación de cada campo particular
21
+ */
22
+ abstract Component: FC;
23
+ abstract type: string;
24
+ constructor(_name: string, label: string, properties?: Partial<FieldProps>);
25
+ get name(): string;
26
+ set name(name: string);
27
+ collector: Collector;
28
+ isHidden: () => boolean;
29
+ setIsHidden: (isHidden: boolean) => void;
30
+ protected properties: Partial<FieldProps>;
31
+ setProperties: (newProps: Partial<FieldProps>) => void;
32
+ protected useProperties: () => Partial<FieldProps>;
33
+ /**
34
+ * Este componente se utiliza para controlar propiedades comunes a todos los
35
+ * campos.
36
+ */
37
+ SuperComponent: () => React.JSX.Element | null;
38
+ }
39
+
40
+ export { CollectorField };
41
+ //# sourceMappingURL=CollectorField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollectorField.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ import { CollectorField } from './CollectorField.js';
2
+ import { TValidationFunction, TValidationRules } from '../types.js';
3
+
4
+ declare abstract class ValidatedCollectorField<ValueType = any, FieldProps = any> extends CollectorField<ValueType, FieldProps> {
5
+ #private;
6
+ protected _name: string;
7
+ protected label: string;
8
+ protected initialValue: ValueType;
9
+ constructor(_name: string, label: string, config?: Partial<{
10
+ initialValue: ValueType;
11
+ properties: Partial<FieldProps>;
12
+ validationFunction: TValidationFunction<ValueType>;
13
+ validationRules: TValidationRules;
14
+ }>);
15
+ setInitialValue: (newValue: ValueType) => void;
16
+ setValidationFunction: (newFunction: TValidationFunction<ValueType>) => void;
17
+ setValidationRules: (newRules: TValidationRules) => void;
18
+ setValue: (newValue: ValueType) => void;
19
+ protected useValidationFunction: () => TValidationFunction<ValueType>;
20
+ protected useValidationRules: () => Partial<Omit<Record<"number" | "required" | "alpha" | "alphanum" | "nodigit" | "digit" | "digitmin" | "digitltd" | "email" | "image" | "phone" | "url" | "confirm" | "differs" | "length_str" | "length_fix" | "lengthmax" | "lengthmin" | "words_min" | "words_max" | "words_range" | "checkbox" | "checkboxes_group" | "radios" | "select" | "select_multiple" | "errorsTitle", boolean>, "digitmin" | "digitltd" | "confirm" | "differs" | "length_str" | "length_fix" | "words_min" | "words_max" | "words_range" | "checkboxes_group"> & {
21
+ digitmin: number;
22
+ digitltd: [number, number];
23
+ confirm: string;
24
+ differs: string;
25
+ length_str: [number, number];
26
+ length_fix: number;
27
+ words_min: number;
28
+ words_max: number;
29
+ words_range: [number, number];
30
+ checkboxes_group: number;
31
+ } & {
32
+ patternMessage: string;
33
+ pattern: string | RegExp;
34
+ digitmax: number;
35
+ validName?: string | undefined;
36
+ maxLength: number;
37
+ minLength: number;
38
+ min: number;
39
+ max: number;
40
+ }> | undefined;
41
+ }
42
+
43
+ export { ValidatedCollectorField };
44
+ //# sourceMappingURL=ValidatedCollectorField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidatedCollectorField.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { CollectorField } from '../CollectorField.js';
3
+ import { ButtonProps } from '@apia/theme';
4
+
5
+ declare class CollectorButton extends CollectorField<null, Omit<ButtonProps, 'children'>> {
6
+ protected label: string;
7
+ type: string;
8
+ constructor(label: string, properties?: Omit<ButtonProps, 'children'>);
9
+ Component: () => React.JSX.Element;
10
+ }
11
+
12
+ export { CollectorButton };
13
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import '../../components/FieldWrapper.js';
3
+ import { TCheckboxProps } from '../../components/Checkbox.js';
4
+ import '../../components/NumberInput.js';
5
+ import { ValidatedCollectorField } from '../ValidatedCollectorField.js';
6
+
7
+ declare class CollectorCheckbox extends ValidatedCollectorField<string | boolean, Omit<TCheckboxProps, 'name'>> {
8
+ type: string;
9
+ Component: () => React.JSX.Element;
10
+ }
11
+
12
+ export { CollectorCheckbox };
13
+ //# sourceMappingURL=Checkbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Checkbox.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { InputProps } from '@apia/theme';
3
+ import { ValidatedCollectorField } from '../ValidatedCollectorField.js';
4
+
5
+ declare class CollectorInput extends ValidatedCollectorField<string, Omit<InputProps, 'name'>> {
6
+ type: string;
7
+ Component: () => React.JSX.Element;
8
+ }
9
+
10
+ export { CollectorInput };
11
+ //# sourceMappingURL=Input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { CollectorField } from '../CollectorField.js';
3
+
4
+ declare class CollectorLabel extends CollectorField {
5
+ private kind;
6
+ private static maxId;
7
+ type: string;
8
+ constructor(label: string, kind?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'label');
9
+ Component: () => React.JSX.Element;
10
+ }
11
+
12
+ export { CollectorLabel };
13
+ //# sourceMappingURL=Label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Label.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { TValidationFunction, TValidationRules } from '../../types.js';
3
+ import '../../components/FieldWrapper.js';
4
+ import '../../components/NumberInput.js';
5
+ import { TSelectProps, TOption } from '../../components/Select.js';
6
+ import { ValidatedCollectorField } from '../ValidatedCollectorField.js';
7
+
8
+ declare class CollectorSelect extends ValidatedCollectorField<string, Omit<TSelectProps, 'name'>> {
9
+ #private;
10
+ protected _name: string;
11
+ protected label: string;
12
+ type: string;
13
+ constructor(_name: string, label: string, config?: Partial<{
14
+ initialValue: string;
15
+ options: TOption[];
16
+ properties: Partial<Omit<TSelectProps, 'name'>>;
17
+ validationFunction: TValidationFunction<string>;
18
+ validationRules: TValidationRules;
19
+ }>);
20
+ addOption: (newOption: TOption) => void;
21
+ setOptions: (newOptions: TOption[]) => void;
22
+ Component: () => React.JSX.Element;
23
+ }
24
+
25
+ export { CollectorSelect };
26
+ //# sourceMappingURL=Select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { TextareaProps } from '@apia/theme';
3
+ import { ValidatedCollectorField } from '../ValidatedCollectorField.js';
4
+
5
+ declare class CollectorTextarea extends ValidatedCollectorField<string, Omit<TextareaProps, 'name'>> {
6
+ type: string;
7
+ Component: () => React.JSX.Element;
8
+ }
9
+
10
+ export { CollectorTextarea };
11
+ //# sourceMappingURL=Textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Textarea.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { TDefaultFieldType } from './types.js';
2
+ import React__default from 'react';
3
+
4
+ type TCaptchaProps = {
5
+ name: string;
6
+ imageUrl: string;
7
+ className?: string;
8
+ };
9
+ type TCaptcha = TCaptchaProps & Omit<TDefaultFieldType, 'validationFunction' | 'validationRules' | 'validationClass'>;
10
+ declare const InnerCaptcha: ({ className, name, imageUrl, avoidRegisterIfExists, avoidSemicolon, formName, label, removeOnUnmount, submitName, submitValueParser, validationValueParser, }: TCaptcha) => React__default.JSX.Element;
11
+
12
+ export { InnerCaptcha as Captcha };
13
+ //# sourceMappingURL=Captcha.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Captcha.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import React__default from 'react';
2
+ import { ButtonProps, InputProps } from '@apia/theme';
3
+ import { TDefaultFieldType } from './types.js';
4
+
5
+ type TCheckboxProps = Omit<ButtonProps, 'onChange' | 'defaultChecked' | 'defaultValue'> & Pick<InputProps, 'onChange'>;
6
+ type TCheckbox = TCheckboxProps & TDefaultFieldType<boolean | string> & {
7
+ native?: boolean;
8
+ };
9
+ declare const Checkbox: React__default.ForwardRefExoticComponent<Omit<TCheckbox, "ref"> & React__default.RefAttributes<HTMLButtonElement>>;
10
+
11
+ export { Checkbox, type TCheckbox, type TCheckboxProps };
12
+ //# sourceMappingURL=Checkbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Checkbox.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import React__default from 'react';
2
+ import { InputProps } from '@apia/theme';
3
+ import { TDefaultFieldType } from './types.js';
4
+
5
+ type TDeletableInput = InputProps & TDefaultFieldType;
6
+ declare const DeletableInput: React__default.ForwardRefExoticComponent<Omit<TDeletableInput, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
7
+
8
+ export { DeletableInput };
9
+ //# sourceMappingURL=DeletableInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeletableInput.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import React__default from 'react';
2
+ import { BoxProps } from '@apia/theme';
3
+
4
+ declare global {
5
+ interface Window {
6
+ SHOW_REQUIRED_POSITION: string;
7
+ }
8
+ }
9
+ interface IWrapper extends BoxProps {
10
+ avoidSemicolon?: boolean;
11
+ children: React__default.ReactNode;
12
+ label?: string;
13
+ name: string;
14
+ required?: boolean;
15
+ type?: 'checkbox';
16
+ }
17
+ declare const FieldWrapper: ({ name, label, avoidSemicolon, children, className, as, type, ...props }: IWrapper) => React__default.JSX.Element;
18
+
19
+ export { FieldWrapper, type IWrapper };
20
+ //# sourceMappingURL=FieldWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldWrapper.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import React__default from 'react';
2
+ import { InputProps } from '@apia/theme';
3
+ import { TUseField } from '../hooks/useField.js';
4
+ import { IWrapper } from './FieldWrapper.js';
5
+ import { TDefaultFieldType } from './types.js';
6
+
7
+ type TFileInput = Omit<InputProps, 'onChange' | 'type' | 'value' | 'multiple'> & TDefaultFieldType<File | null> & Pick<TUseField, 'removeOnUnmount'> & Pick<IWrapper, 'avoidSemicolon'>;
8
+ declare const FileInput: React__default.MemoExoticComponent<React__default.ForwardRefExoticComponent<Omit<TFileInput, "ref"> & React__default.RefAttributes<HTMLInputElement>>>;
9
+
10
+ export { FileInput };
11
+ //# sourceMappingURL=FileInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileInput.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import React__default from 'react';
2
+ import { InputProps } from '@apia/theme';
3
+ import { TDefaultFieldType } from './types.js';
4
+
5
+ type TInput = InputProps & TDefaultFieldType;
6
+ declare const Input: React__default.MemoExoticComponent<React__default.ForwardRefExoticComponent<Omit<TInput, "ref"> & React__default.RefAttributes<HTMLInputElement>>>;
7
+
8
+ export { Input, type TInput };
9
+ //# sourceMappingURL=Input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumberInput.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Radio.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switchbox.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Textarea.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationError.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,89 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Form.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormContext.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}