@apia/validations 5.0.0 → 5.0.1
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 +84 -28
- package/dist/index.js +537 -189
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, {
|
|
3
|
-
import { TModify, TPropsSelector, TPropsComparator, TPropsConfiguration, TId, EventEmitter } from '@apia/util';
|
|
4
|
-
import { TNumberInput, ApiaUtilModalHandler, TOpenModal, TFieldLabel } from '@apia/components';
|
|
2
|
+
import React__default, { FC, ReactNode } from 'react';
|
|
3
|
+
import { TModify, TPropsSelector, TPropsComparator, TPropsConfiguration, TChangeEventHandler, TId, EventEmitter, TLabel } from '@apia/util';
|
|
4
|
+
import { TNumberInput, SwitchMultipleOption, ApiaUtilModalHandler, TOpenModal, TFieldLabel } from '@apia/components';
|
|
5
5
|
import { BoxProps, ButtonProps, InputProps, RadioProps, SelectProps, SwitchProps, TextareaProps } from '@apia/theme';
|
|
6
6
|
import { TModalContext } from '@apia/components/src/components/modals/ModalContext';
|
|
7
7
|
|
|
@@ -289,11 +289,6 @@ declare const FormContext: React__default.Context<IFormContext<Record<string, un
|
|
|
289
289
|
*/
|
|
290
290
|
declare function useFormContext(): IFormContext<Record<string, unknown>, Record<string, unknown>>;
|
|
291
291
|
|
|
292
|
-
declare global {
|
|
293
|
-
interface Window {
|
|
294
|
-
MSG_WRONG_VALIDATION_NO_FOCUSED_FILE: string;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
292
|
declare const validationsStore: {
|
|
298
293
|
activeForms: string[];
|
|
299
294
|
timeouts: Record<string, ReturnType<typeof setTimeout> | true>;
|
|
@@ -517,7 +512,9 @@ type TCaptchaProps = {
|
|
|
517
512
|
type TCaptcha = TCaptchaProps & Omit<TDefaultFieldType, 'validationFunction' | 'validationRules' | 'validationClass'>;
|
|
518
513
|
declare const InnerCaptcha: ({ className, name, imageUrl, avoidRegisterIfExists, avoidSemicolon, formName, label, removeOnUnmount, submitName, submitValueParser, validationValueParser, }: TCaptcha) => React__default.JSX.Element;
|
|
519
514
|
|
|
520
|
-
type TCheckboxProps = Omit<ButtonProps, 'onChange' | 'defaultChecked' | 'defaultValue'> &
|
|
515
|
+
type TCheckboxProps = Omit<ButtonProps, 'onChange' | 'defaultChecked' | 'defaultValue'> & {
|
|
516
|
+
onChange?: TChangeEventHandler<boolean>;
|
|
517
|
+
};
|
|
521
518
|
type TCheckbox = TCheckboxProps & TDefaultFieldType<boolean | string> & {
|
|
522
519
|
native?: boolean;
|
|
523
520
|
};
|
|
@@ -558,9 +555,7 @@ type TSelect = TSelectProps & TDefaultFieldType & {
|
|
|
558
555
|
};
|
|
559
556
|
declare const Select: React__default.ForwardRefExoticComponent<Omit<TSelect, "ref"> & React__default.RefAttributes<HTMLSelectElement>>;
|
|
560
557
|
|
|
561
|
-
type TSwitchbox = Omit<SwitchProps, 'onChange'> & Pick<InputProps, 'onChange'> & TDefaultFieldType
|
|
562
|
-
reverse?: boolean;
|
|
563
|
-
};
|
|
558
|
+
type TSwitchbox = Omit<SwitchProps, 'onChange' | 'defaultChecked' | 'defaultValue'> & Pick<InputProps, 'onChange'> & TDefaultFieldType<boolean>;
|
|
564
559
|
declare const Switchbox: React__default.ForwardRefExoticComponent<Omit<TSwitchbox, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
565
560
|
|
|
566
561
|
type TTextarea = TextareaProps & TDefaultFieldType;
|
|
@@ -588,14 +583,16 @@ declare abstract class CollectorField<ValueType = any, FieldProps = any> extends
|
|
|
588
583
|
}> {
|
|
589
584
|
#private;
|
|
590
585
|
readonly name: string;
|
|
591
|
-
protected label:
|
|
586
|
+
protected label: string | TLabel;
|
|
592
587
|
/**
|
|
593
588
|
* Este es el componente de implementación de cada campo particular
|
|
594
589
|
*/
|
|
595
590
|
abstract Component: FC;
|
|
596
591
|
abstract type: string;
|
|
597
|
-
constructor(name: string, label:
|
|
598
|
-
|
|
592
|
+
constructor(name: string, label: string | TLabel, properties?: Partial<FieldProps>);
|
|
593
|
+
protected _collector: Collector;
|
|
594
|
+
get collector(): Collector;
|
|
595
|
+
set collector(c: Collector);
|
|
599
596
|
isHidden: () => boolean;
|
|
600
597
|
setIsHidden: (isHidden: boolean) => void;
|
|
601
598
|
protected properties: Partial<FieldProps>;
|
|
@@ -610,25 +607,27 @@ declare abstract class CollectorField<ValueType = any, FieldProps = any> extends
|
|
|
610
607
|
|
|
611
608
|
declare abstract class ValidatedCollectorField<ValueType = any, FieldProps = any> extends CollectorField<ValueType, FieldProps> {
|
|
612
609
|
readonly name: string;
|
|
613
|
-
protected label: string;
|
|
610
|
+
protected label: string | TLabel;
|
|
614
611
|
protected config: Partial<{
|
|
615
612
|
initialValue: ValueType;
|
|
616
613
|
properties: Partial<FieldProps>;
|
|
617
614
|
validationFunction: TValidationFunction<ValueType>;
|
|
618
615
|
validationRules: TValidationRules;
|
|
619
616
|
}>;
|
|
620
|
-
constructor(name: string, label: string, config?: Partial<{
|
|
617
|
+
constructor(name: string, label: string | TLabel, config?: Partial<{
|
|
621
618
|
initialValue: ValueType;
|
|
622
619
|
properties: Partial<FieldProps>;
|
|
623
620
|
validationFunction: TValidationFunction<ValueType>;
|
|
624
621
|
validationRules: TValidationRules;
|
|
625
622
|
}>);
|
|
623
|
+
set collector(c: Collector);
|
|
626
624
|
get initialValue(): ValueType | undefined;
|
|
627
|
-
get value():
|
|
625
|
+
get value(): ValueType;
|
|
628
626
|
setInitialValue: (newValue: ValueType) => void;
|
|
629
627
|
setValidationFunction: (newFunction: TValidationFunction<ValueType>) => void;
|
|
630
628
|
setValidationRules: (newRules: TValidationRules) => void;
|
|
631
|
-
setValue
|
|
629
|
+
setValue(newValue: ValueType): void;
|
|
630
|
+
toggleRequired: (isReq?: boolean) => void;
|
|
632
631
|
protected useValidationFunction: () => TValidationFunction<ValueType> | undefined;
|
|
633
632
|
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"> & {
|
|
634
633
|
digitmin: number;
|
|
@@ -689,20 +688,59 @@ declare class CollectorLabel extends CollectorField {
|
|
|
689
688
|
private kind;
|
|
690
689
|
private static maxId;
|
|
691
690
|
type: string;
|
|
692
|
-
constructor(label:
|
|
691
|
+
constructor(label: string | TLabel, kind?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'label');
|
|
693
692
|
Component: () => React.JSX.Element;
|
|
694
693
|
}
|
|
695
694
|
|
|
696
695
|
declare class CollectorButton extends CollectorField<null, Omit<ButtonProps, 'children'>> {
|
|
697
|
-
protected label: string;
|
|
696
|
+
protected label: string | TLabel;
|
|
697
|
+
type: string;
|
|
698
|
+
constructor(label: string | TLabel, properties?: Omit<ButtonProps, 'children'>);
|
|
699
|
+
Component: () => React.JSX.Element;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
declare class CollectorSwitch extends ValidatedCollectorField<boolean, Omit<TSwitchbox, 'name'>> {
|
|
703
|
+
type: string;
|
|
704
|
+
Component: () => React.JSX.Element;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
declare class CollectorTitle extends CollectorLabel {
|
|
708
|
+
constructor(label: string | TLabel, level: number);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
declare class CollectorSeparator extends CollectorField {
|
|
712
|
+
private static maxId;
|
|
713
|
+
type: string;
|
|
714
|
+
constructor();
|
|
715
|
+
Component: () => React.JSX.Element;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
declare class CollectorAutogrowTextarea extends ValidatedCollectorField<string, Omit<TextareaProps, 'name'>> {
|
|
719
|
+
type: string;
|
|
720
|
+
Component: () => React.JSX.Element;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
type SwitchInputProps<T extends string> = {
|
|
724
|
+
name: string;
|
|
725
|
+
label?: string;
|
|
726
|
+
title?: string;
|
|
727
|
+
options: SwitchMultipleOption<T>[];
|
|
728
|
+
formName?: string;
|
|
729
|
+
initialValue?: T;
|
|
730
|
+
removeOnUnmount?: boolean;
|
|
731
|
+
validationFunction?: any;
|
|
732
|
+
validationRules?: any;
|
|
733
|
+
onChange?: (ev: T) => void;
|
|
734
|
+
};
|
|
735
|
+
declare class CollectorSwitchMultiple<T extends string = string> extends ValidatedCollectorField<T, Omit<InputProps, 'name' | 'onChange'> & SwitchInputProps<T>> {
|
|
698
736
|
type: string;
|
|
699
|
-
constructor(label: string, properties?: Omit<ButtonProps, 'children'>);
|
|
700
737
|
Component: () => React.JSX.Element;
|
|
701
738
|
}
|
|
702
739
|
|
|
703
740
|
declare class Collector {
|
|
704
741
|
#private;
|
|
705
742
|
fields: {
|
|
743
|
+
autogrowTextarea: typeof CollectorAutogrowTextarea;
|
|
706
744
|
button: typeof CollectorButton;
|
|
707
745
|
checkbox: typeof CollectorCheckbox;
|
|
708
746
|
input: typeof CollectorInput;
|
|
@@ -712,26 +750,44 @@ declare class Collector {
|
|
|
712
750
|
*/
|
|
713
751
|
label: typeof CollectorLabel;
|
|
714
752
|
select: typeof CollectorSelect;
|
|
753
|
+
separator: typeof CollectorSeparator;
|
|
754
|
+
switch: typeof CollectorSwitch;
|
|
715
755
|
textarea: typeof CollectorTextarea;
|
|
756
|
+
title: typeof CollectorTitle;
|
|
757
|
+
switchMultiple: typeof CollectorSwitchMultiple;
|
|
716
758
|
};
|
|
717
759
|
private private__id;
|
|
718
760
|
get id(): string;
|
|
719
761
|
modal: ApiaUtilModalHandler | null;
|
|
720
|
-
|
|
721
|
-
|
|
762
|
+
protected fieldsStore: Record<string, CollectorField>;
|
|
763
|
+
add(...fields: CollectorField[]): this;
|
|
764
|
+
forEach(cb: (field: CollectorField, i: number) => void): void;
|
|
765
|
+
getByName<T extends CollectorField = CollectorField>(name: string): T;
|
|
722
766
|
readonly Render: ({ hideConfirm, modal, resolve, className, }: {
|
|
723
767
|
className?: string;
|
|
724
768
|
hideConfirm?: boolean;
|
|
725
769
|
modal?: TModalContext;
|
|
726
770
|
resolve: (v: Record<string, unknown>) => boolean;
|
|
727
771
|
}) => React.JSX.Element;
|
|
728
|
-
show
|
|
772
|
+
show<FormValues extends Record<string, unknown>>(modalProps?: Partial<Omit<TOpenModal, 'children' | 'onConfirm' | 'onCancel' | 'confirmProps'>> & Partial<{
|
|
729
773
|
hideConfirm: boolean;
|
|
730
774
|
/**
|
|
731
775
|
* Si este método devuelve false, el modal no se cerrará
|
|
732
776
|
*/
|
|
733
777
|
onConfirm?: (res: FormValues | null) => boolean;
|
|
734
|
-
}>)
|
|
778
|
+
}>): Promise<FormValues | null>;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
declare class WithMemoryCollector extends Collector {
|
|
782
|
+
protected prefix: string;
|
|
783
|
+
constructor(prefix: string);
|
|
784
|
+
private memoized;
|
|
785
|
+
private getKey;
|
|
786
|
+
addMemoized(...fields: CollectorField[]): this;
|
|
787
|
+
show<FormValues extends Record<string, unknown>>(modalProps?: Partial<Omit<TOpenModal, 'children' | 'onConfirm' | 'onCancel' | 'confirmProps'>> & Partial<{
|
|
788
|
+
hideConfirm: boolean;
|
|
789
|
+
onConfirm?: (res: FormValues | null) => boolean;
|
|
790
|
+
}>): Promise<FormValues | null>;
|
|
735
791
|
}
|
|
736
792
|
|
|
737
793
|
declare function useFieldStatesClassNames<T = unknown>(name: string, formName?: string): string;
|
|
@@ -856,7 +912,7 @@ type ValidableFieldProps<T extends object> = {
|
|
|
856
912
|
className?: string;
|
|
857
913
|
context: Validable<T>;
|
|
858
914
|
label?: string;
|
|
859
|
-
onChange?:
|
|
915
|
+
onChange?: TChangeEventHandler<any>;
|
|
860
916
|
path: TObjectInspection<T>;
|
|
861
917
|
title?: string;
|
|
862
918
|
};
|
|
@@ -920,5 +976,5 @@ declare abstract class Validable<T extends object> {
|
|
|
920
976
|
validate(): Promise<true | Record<string, string>>;
|
|
921
977
|
}
|
|
922
978
|
|
|
923
|
-
export { InnerCaptcha as Captcha, Checkbox, Collector, CollectorField, DeletableInput, FieldWrapper, FileInput, Form, FormContext, type IWrapper, Input, NumberInputf, Radio, Select, Switchbox, type TCheckbox, type TCheckboxProps, type TDefaultFieldType, type TInput$1 as TInput, type TObjectInspection, type TOnValidate, type TOption, type TRadio, type TSelect, type TSelectProps, type TSwitchbox, type TUseField, type TValidationFunction, type TValidationResult, type TValidationRules, Textarea, Validable, ValidableCheck, ValidableContext, ValidableField, ValidableInput, ValidableSelect, ValidableTextarea, ValidatedCollectorField, ValidationError, type ValidationRules, type ValidationsMap, classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang, useField, useFieldSelector, useFieldStatesClassNames, useFieldValue, useFormContext, useFormSelector, useValidableContext, useValidationClass, validate, validationsStore };
|
|
979
|
+
export { InnerCaptcha as Captcha, Checkbox, Collector, CollectorField, DeletableInput, FieldWrapper, FileInput, Form, FormContext, type IWrapper, Input, NumberInputf, Radio, Select, Switchbox, type TCheckbox, type TCheckboxProps, type TDefaultFieldType, type TInput$1 as TInput, type TObjectInspection, type TOnValidate, type TOption, type TRadio, type TSelect, type TSelectProps, type TSwitchbox, type TUseField, type TValidationFunction, type TValidationResult, type TValidationRules, Textarea, Validable, ValidableCheck, ValidableContext, ValidableField, ValidableInput, ValidableSelect, ValidableTextarea, ValidatedCollectorField, ValidationError, type ValidationRules, type ValidationsMap, WithMemoryCollector, classToValidate, classToValidationFunction, hasSucceedFieldValidation, hasSucceedFormValidation, initValidations, lang, useField, useFieldSelector, useFieldStatesClassNames, useFieldValue, useFormContext, useFormSelector, useValidableContext, useValidationClass, validate, validationsStore };
|
|
924
980
|
//# sourceMappingURL=index.d.ts.map
|