@apia/validations 4.0.58 → 4.0.60
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 +59 -19
- package/dist/index.js +432 -169
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, {
|
|
3
|
-
import { TModify, TPropsSelector, TPropsComparator, TPropsConfiguration, TId, EventEmitter } from '@apia/util';
|
|
2
|
+
import React__default, { FC, ChangeEvent, ReactNode } from 'react';
|
|
3
|
+
import { TModify, TPropsSelector, TPropsComparator, TPropsConfiguration, TId, EventEmitter, TLabel } from '@apia/util';
|
|
4
4
|
import { TNumberInput, 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';
|
|
@@ -553,9 +553,7 @@ type TSelect = TSelectProps & TDefaultFieldType & {
|
|
|
553
553
|
};
|
|
554
554
|
declare const Select: React__default.ForwardRefExoticComponent<Omit<TSelect, "ref"> & React__default.RefAttributes<HTMLSelectElement>>;
|
|
555
555
|
|
|
556
|
-
type TSwitchbox = Omit<SwitchProps, 'onChange'> & Pick<InputProps, 'onChange'> & TDefaultFieldType
|
|
557
|
-
reverse?: boolean;
|
|
558
|
-
};
|
|
556
|
+
type TSwitchbox = Omit<SwitchProps, 'onChange' | 'defaultChecked' | 'defaultValue'> & Pick<InputProps, 'onChange'> & TDefaultFieldType<boolean>;
|
|
559
557
|
declare const Switchbox: React__default.ForwardRefExoticComponent<Omit<TSwitchbox, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
560
558
|
|
|
561
559
|
type TTextarea = TextareaProps & TDefaultFieldType;
|
|
@@ -583,14 +581,16 @@ declare abstract class CollectorField<ValueType = any, FieldProps = any> extends
|
|
|
583
581
|
}> {
|
|
584
582
|
#private;
|
|
585
583
|
readonly name: string;
|
|
586
|
-
protected label:
|
|
584
|
+
protected label: string | TLabel;
|
|
587
585
|
/**
|
|
588
586
|
* Este es el componente de implementación de cada campo particular
|
|
589
587
|
*/
|
|
590
588
|
abstract Component: FC;
|
|
591
589
|
abstract type: string;
|
|
592
|
-
constructor(name: string, label:
|
|
593
|
-
|
|
590
|
+
constructor(name: string, label: string | TLabel, properties?: Partial<FieldProps>);
|
|
591
|
+
protected _collector: Collector;
|
|
592
|
+
get collector(): Collector;
|
|
593
|
+
set collector(c: Collector);
|
|
594
594
|
isHidden: () => boolean;
|
|
595
595
|
setIsHidden: (isHidden: boolean) => void;
|
|
596
596
|
protected properties: Partial<FieldProps>;
|
|
@@ -605,25 +605,27 @@ declare abstract class CollectorField<ValueType = any, FieldProps = any> extends
|
|
|
605
605
|
|
|
606
606
|
declare abstract class ValidatedCollectorField<ValueType = any, FieldProps = any> extends CollectorField<ValueType, FieldProps> {
|
|
607
607
|
readonly name: string;
|
|
608
|
-
protected label: string;
|
|
608
|
+
protected label: string | TLabel;
|
|
609
609
|
protected config: Partial<{
|
|
610
610
|
initialValue: ValueType;
|
|
611
611
|
properties: Partial<FieldProps>;
|
|
612
612
|
validationFunction: TValidationFunction<ValueType>;
|
|
613
613
|
validationRules: TValidationRules;
|
|
614
614
|
}>;
|
|
615
|
-
constructor(name: string, label: string, config?: Partial<{
|
|
615
|
+
constructor(name: string, label: string | TLabel, config?: Partial<{
|
|
616
616
|
initialValue: ValueType;
|
|
617
617
|
properties: Partial<FieldProps>;
|
|
618
618
|
validationFunction: TValidationFunction<ValueType>;
|
|
619
619
|
validationRules: TValidationRules;
|
|
620
620
|
}>);
|
|
621
|
+
set collector(c: Collector);
|
|
621
622
|
get initialValue(): ValueType | undefined;
|
|
622
623
|
get value(): any;
|
|
623
624
|
setInitialValue: (newValue: ValueType) => void;
|
|
624
625
|
setValidationFunction: (newFunction: TValidationFunction<ValueType>) => void;
|
|
625
626
|
setValidationRules: (newRules: TValidationRules) => void;
|
|
626
|
-
setValue
|
|
627
|
+
setValue(newValue: ValueType): void;
|
|
628
|
+
toggleRequired: (isReq?: boolean) => void;
|
|
627
629
|
protected useValidationFunction: () => TValidationFunction<ValueType> | undefined;
|
|
628
630
|
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"> & {
|
|
629
631
|
digitmin: number;
|
|
@@ -684,20 +686,42 @@ declare class CollectorLabel extends CollectorField {
|
|
|
684
686
|
private kind;
|
|
685
687
|
private static maxId;
|
|
686
688
|
type: string;
|
|
687
|
-
constructor(label:
|
|
689
|
+
constructor(label: string | TLabel, kind?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'label');
|
|
688
690
|
Component: () => React.JSX.Element;
|
|
689
691
|
}
|
|
690
692
|
|
|
691
693
|
declare class CollectorButton extends CollectorField<null, Omit<ButtonProps, 'children'>> {
|
|
692
|
-
protected label: string;
|
|
694
|
+
protected label: string | TLabel;
|
|
695
|
+
type: string;
|
|
696
|
+
constructor(label: string | TLabel, properties?: Omit<ButtonProps, 'children'>);
|
|
697
|
+
Component: () => React.JSX.Element;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
declare class CollectorSwitch extends ValidatedCollectorField<boolean, Omit<TSwitchbox, 'name'>> {
|
|
701
|
+
type: string;
|
|
702
|
+
Component: () => React.JSX.Element;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
declare class CollectorTitle extends CollectorLabel {
|
|
706
|
+
constructor(label: string | TLabel, level: number);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
declare class CollectorSeparator extends CollectorField {
|
|
710
|
+
private static maxId;
|
|
711
|
+
type: string;
|
|
712
|
+
constructor();
|
|
713
|
+
Component: () => React.JSX.Element;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
declare class CollectorAutogrowTextarea extends ValidatedCollectorField<string, Omit<TextareaProps, 'name'>> {
|
|
693
717
|
type: string;
|
|
694
|
-
constructor(label: string, properties?: Omit<ButtonProps, 'children'>);
|
|
695
718
|
Component: () => React.JSX.Element;
|
|
696
719
|
}
|
|
697
720
|
|
|
698
721
|
declare class Collector {
|
|
699
722
|
#private;
|
|
700
723
|
fields: {
|
|
724
|
+
autogrowTextarea: typeof CollectorAutogrowTextarea;
|
|
701
725
|
button: typeof CollectorButton;
|
|
702
726
|
checkbox: typeof CollectorCheckbox;
|
|
703
727
|
input: typeof CollectorInput;
|
|
@@ -707,26 +731,42 @@ declare class Collector {
|
|
|
707
731
|
*/
|
|
708
732
|
label: typeof CollectorLabel;
|
|
709
733
|
select: typeof CollectorSelect;
|
|
734
|
+
separator: typeof CollectorSeparator;
|
|
735
|
+
switch: typeof CollectorSwitch;
|
|
710
736
|
textarea: typeof CollectorTextarea;
|
|
737
|
+
title: typeof CollectorTitle;
|
|
711
738
|
};
|
|
712
739
|
private private__id;
|
|
713
740
|
get id(): string;
|
|
714
741
|
modal: ApiaUtilModalHandler | null;
|
|
715
|
-
|
|
716
|
-
|
|
742
|
+
protected fieldsStore: Record<string, CollectorField>;
|
|
743
|
+
add(...fields: CollectorField[]): this;
|
|
744
|
+
forEach(cb: (field: CollectorField, i: number) => void): void;
|
|
717
745
|
readonly Render: ({ hideConfirm, modal, resolve, className, }: {
|
|
718
746
|
className?: string;
|
|
719
747
|
hideConfirm?: boolean;
|
|
720
748
|
modal?: TModalContext;
|
|
721
749
|
resolve: (v: Record<string, unknown>) => boolean;
|
|
722
750
|
}) => React.JSX.Element;
|
|
723
|
-
show
|
|
751
|
+
show<FormValues extends Record<string, unknown>>(modalProps?: Partial<Omit<TOpenModal, 'children' | 'onConfirm' | 'onCancel' | 'confirmProps'>> & Partial<{
|
|
724
752
|
hideConfirm: boolean;
|
|
725
753
|
/**
|
|
726
754
|
* Si este método devuelve false, el modal no se cerrará
|
|
727
755
|
*/
|
|
728
756
|
onConfirm?: (res: FormValues | null) => boolean;
|
|
729
|
-
}>)
|
|
757
|
+
}>): Promise<FormValues | null>;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
declare class WithMemoryCollector extends Collector {
|
|
761
|
+
protected prefix: string;
|
|
762
|
+
constructor(prefix: string);
|
|
763
|
+
private memoized;
|
|
764
|
+
private getKey;
|
|
765
|
+
addMemoized(...fields: CollectorField[]): this;
|
|
766
|
+
show<FormValues extends Record<string, unknown>>(modalProps?: Partial<Omit<TOpenModal, 'children' | 'onConfirm' | 'onCancel' | 'confirmProps'>> & Partial<{
|
|
767
|
+
hideConfirm: boolean;
|
|
768
|
+
onConfirm?: (res: FormValues | null) => boolean;
|
|
769
|
+
}>): Promise<FormValues | null>;
|
|
730
770
|
}
|
|
731
771
|
|
|
732
772
|
declare function useFieldStatesClassNames<T = unknown>(name: string, formName?: string): string;
|
|
@@ -914,5 +954,5 @@ declare abstract class Validable<T extends object> {
|
|
|
914
954
|
validate(): Promise<true | Record<string, string>>;
|
|
915
955
|
}
|
|
916
956
|
|
|
917
|
-
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 };
|
|
957
|
+
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 };
|
|
918
958
|
//# sourceMappingURL=index.d.ts.map
|