123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- import * as vue from 'vue';
- import { ComponentPropsOptions, ExtractPropTypes, VNodeChild, VNode, PropType, Ref } from 'vue';
- type SlotsToProps<U extends RawSlots, T = MakeInternalSlots<U>> = {
- $children?: (VNodeChild | (T extends {
- default: infer V;
- } ? V : {}) | {
- [K in keyof T]?: T[K];
- });
- 'v-slots'?: {
- [K in keyof T]?: T[K] | false;
- };
- } & {
- [K in keyof T as `v-slot:${K & string}`]?: T[K] | false;
- };
- type RawSlots = Record<string, unknown>;
- type Slot<T> = [T] extends [never] ? () => VNodeChild : (arg: T) => VNodeChild;
- type VueSlot<T> = [T] extends [never] ? () => VNode[] : (arg: T) => VNode[];
- type MakeInternalSlots<T extends RawSlots> = {
- [K in keyof T]: Slot<T[K]>;
- };
- type MakeSlots<T extends RawSlots> = {
- [K in keyof T]: VueSlot<T[K]>;
- };
- type GenericProps<Props, Slots extends Record<string, unknown>> = {
- $props: Props & SlotsToProps<Slots>;
- $slots: MakeSlots<Slots>;
- };
- interface FilterPropsOptions<PropsOptions extends Readonly<ComponentPropsOptions>, Props = ExtractPropTypes<PropsOptions>> {
- filterProps<T extends Partial<Props>, U extends Exclude<keyof Props, Exclude<keyof Props, keyof T>>>(props: T): Partial<Pick<T, U>>;
- }
- type MaybeRef<T> = T | Ref<T>;
- type EventProp<T extends any[] = any[], F = (...args: T) => void> = F;
- declare const EventProp: <T extends any[] = any[]>() => PropType<EventProp<T>>;
- type ValidationResult = string | boolean;
- type ValidationRule = ValidationResult | PromiseLike<ValidationResult> | ((value: any) => ValidationResult) | ((value: any) => PromiseLike<ValidationResult>);
- type ValidateOnValue = 'blur' | 'input' | 'submit' | 'invalid-input';
- type ValidateOn = ValidateOnValue | `${ValidateOnValue} lazy` | `${ValidateOnValue} eager` | `lazy ${ValidateOnValue}` | `eager ${ValidateOnValue}` | 'lazy' | 'eager';
- interface ValidationProps {
- disabled: boolean | null;
- error: boolean;
- errorMessages: string | readonly string[] | null;
- focused: boolean;
- maxErrors: string | number;
- name: string | undefined;
- label: string | undefined;
- readonly: boolean | null;
- rules: readonly ValidationRule[];
- modelValue: any;
- 'onUpdate:modelValue': EventProp | undefined;
- validateOn?: ValidateOn;
- validationValue: any;
- }
- declare function useValidation(props: ValidationProps, name?: string, id?: MaybeRef<string | number>): {
- errorMessages: vue.ComputedRef<string[]>;
- isDirty: vue.ComputedRef<boolean>;
- isDisabled: vue.ComputedRef<boolean>;
- isReadonly: vue.ComputedRef<boolean>;
- isPristine: vue.ShallowRef<boolean>;
- isValid: vue.ComputedRef<boolean | null>;
- isValidating: vue.ShallowRef<boolean>;
- reset: () => Promise<void>;
- resetValidation: () => Promise<void>;
- validate: (silent?: boolean) => Promise<string[]>;
- validationClasses: vue.ComputedRef<{
- [x: string]: boolean;
- }>;
- };
- type VValidationSlots = {
- default: ReturnType<typeof useValidation>;
- };
- declare const VValidation: {
- new (...args: any[]): vue.CreateComponentPublicInstance<{
- error: boolean;
- disabled: boolean | null;
- readonly: boolean | null;
- focused: boolean;
- errorMessages: string | readonly string[] | null;
- maxErrors: string | number;
- rules: readonly ValidationRule[];
- } & {
- name?: string | undefined;
- label?: string | undefined;
- 'onUpdate:focused'?: ((args_0: boolean) => void) | undefined;
- validateOn?: ("eager" | "lazy" | ("input" | "blur" | "submit" | "invalid-input") | "input lazy" | "blur lazy" | "submit lazy" | "invalid-input lazy" | "input eager" | "blur eager" | "submit eager" | "invalid-input eager" | "lazy input" | "lazy blur" | "lazy submit" | "lazy invalid-input" | "eager input" | "eager blur" | "eager submit" | "eager invalid-input") | undefined;
- validationValue?: any;
- } & {}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
- [key: string]: any;
- }>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Omit<{
- 'update:modelValue': (value: any) => true;
- }, "$children" | "v-slots" | "v-slot:default" | "modelValue" | "update:modelValue">, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & {
- error: boolean;
- disabled: boolean | null;
- readonly: boolean | null;
- focused: boolean;
- errorMessages: string | readonly string[] | null;
- maxErrors: string | number;
- rules: readonly ValidationRule[];
- } & {
- name?: string | undefined;
- label?: string | undefined;
- 'onUpdate:focused'?: ((args_0: boolean) => void) | undefined;
- validateOn?: ("eager" | "lazy" | ("input" | "blur" | "submit" | "invalid-input") | "input lazy" | "blur lazy" | "submit lazy" | "invalid-input lazy" | "input eager" | "blur eager" | "submit eager" | "invalid-input eager" | "lazy input" | "lazy blur" | "lazy submit" | "lazy invalid-input" | "eager input" | "eager blur" | "eager submit" | "eager invalid-input") | undefined;
- validationValue?: any;
- } & {}, {
- error: boolean;
- disabled: boolean | null;
- readonly: boolean | null;
- focused: boolean;
- errorMessages: string | readonly string[] | null;
- maxErrors: string | number;
- rules: readonly ValidationRule[];
- }, true, {}, vue.SlotsType<Partial<{
- default: (arg: {
- errorMessages: vue.ComputedRef<string[]>;
- isDirty: vue.ComputedRef<boolean>;
- isDisabled: vue.ComputedRef<boolean>;
- isReadonly: vue.ComputedRef<boolean>;
- isPristine: vue.ShallowRef<boolean>;
- isValid: vue.ComputedRef<boolean | null>;
- isValidating: vue.ShallowRef<boolean>;
- reset: () => Promise<void>;
- resetValidation: () => Promise<void>;
- validate: (silent?: boolean) => Promise<string[]>;
- validationClasses: vue.ComputedRef<{
- [x: string]: boolean;
- }>;
- }) => vue.VNode[];
- }>>, {
- P: {};
- B: {};
- D: {};
- C: {};
- M: {};
- Defaults: {};
- }, {
- error: boolean;
- disabled: boolean | null;
- readonly: boolean | null;
- focused: boolean;
- errorMessages: string | readonly string[] | null;
- maxErrors: string | number;
- rules: readonly ValidationRule[];
- } & {
- name?: string | undefined;
- label?: string | undefined;
- 'onUpdate:focused'?: ((args_0: boolean) => void) | undefined;
- validateOn?: ("eager" | "lazy" | ("input" | "blur" | "submit" | "invalid-input") | "input lazy" | "blur lazy" | "submit lazy" | "invalid-input lazy" | "input eager" | "blur eager" | "submit eager" | "invalid-input eager" | "lazy input" | "lazy blur" | "lazy submit" | "lazy invalid-input" | "eager input" | "eager blur" | "eager submit" | "eager invalid-input") | undefined;
- validationValue?: any;
- } & {}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
- [key: string]: any;
- }>[] | undefined, {}, {}, {}, {
- error: boolean;
- disabled: boolean | null;
- readonly: boolean | null;
- focused: boolean;
- errorMessages: string | readonly string[] | null;
- maxErrors: string | number;
- rules: readonly ValidationRule[];
- }>;
- __isFragment?: never;
- __isTeleport?: never;
- __isSuspense?: never;
- } & vue.ComponentOptionsBase<{
- error: boolean;
- disabled: boolean | null;
- readonly: boolean | null;
- focused: boolean;
- errorMessages: string | readonly string[] | null;
- maxErrors: string | number;
- rules: readonly ValidationRule[];
- } & {
- name?: string | undefined;
- label?: string | undefined;
- 'onUpdate:focused'?: ((args_0: boolean) => void) | undefined;
- validateOn?: ("eager" | "lazy" | ("input" | "blur" | "submit" | "invalid-input") | "input lazy" | "blur lazy" | "submit lazy" | "invalid-input lazy" | "input eager" | "blur eager" | "submit eager" | "invalid-input eager" | "lazy input" | "lazy blur" | "lazy submit" | "lazy invalid-input" | "eager input" | "eager blur" | "eager submit" | "eager invalid-input") | undefined;
- validationValue?: any;
- } & {}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
- [key: string]: any;
- }>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Omit<{
- 'update:modelValue': (value: any) => true;
- }, "$children" | "v-slots" | "v-slot:default" | "modelValue" | "update:modelValue">, string, {
- error: boolean;
- disabled: boolean | null;
- readonly: boolean | null;
- focused: boolean;
- errorMessages: string | readonly string[] | null;
- maxErrors: string | number;
- rules: readonly ValidationRule[];
- }, {}, string, vue.SlotsType<Partial<{
- default: (arg: {
- errorMessages: vue.ComputedRef<string[]>;
- isDirty: vue.ComputedRef<boolean>;
- isDisabled: vue.ComputedRef<boolean>;
- isReadonly: vue.ComputedRef<boolean>;
- isPristine: vue.ShallowRef<boolean>;
- isValid: vue.ComputedRef<boolean | null>;
- isValidating: vue.ShallowRef<boolean>;
- reset: () => Promise<void>;
- resetValidation: () => Promise<void>;
- validate: (silent?: boolean) => Promise<string[]>;
- validationClasses: vue.ComputedRef<{
- [x: string]: boolean;
- }>;
- }) => vue.VNode[];
- }>>> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new <T>(props: {
- modelValue?: T | null;
- "onUpdate:modelValue"?: (value: T | null) => void;
- }, slots: VValidationSlots) => GenericProps<typeof props, typeof slots>) & FilterPropsOptions<{
- focused: BooleanConstructor;
- 'onUpdate:focused': vue.PropType<(args_0: boolean) => void>;
- disabled: {
- type: vue.PropType<boolean | null>;
- default: null;
- };
- error: BooleanConstructor;
- errorMessages: {
- type: vue.PropType<string | readonly string[] | null>;
- default: () => never[];
- };
- maxErrors: {
- type: (StringConstructor | NumberConstructor)[];
- default: number;
- };
- name: StringConstructor;
- label: StringConstructor;
- readonly: {
- type: vue.PropType<boolean | null>;
- default: null;
- };
- rules: {
- type: vue.PropType<readonly ValidationRule[]>;
- default: () => never[];
- };
- modelValue: null;
- validateOn: vue.PropType<ValidationProps["validateOn"]>;
- validationValue: null;
- }, vue.ExtractPropTypes<{
- focused: BooleanConstructor;
- 'onUpdate:focused': vue.PropType<(args_0: boolean) => void>;
- disabled: {
- type: vue.PropType<boolean | null>;
- default: null;
- };
- error: BooleanConstructor;
- errorMessages: {
- type: vue.PropType<string | readonly string[] | null>;
- default: () => never[];
- };
- maxErrors: {
- type: (StringConstructor | NumberConstructor)[];
- default: number;
- };
- name: StringConstructor;
- label: StringConstructor;
- readonly: {
- type: vue.PropType<boolean | null>;
- default: null;
- };
- rules: {
- type: vue.PropType<readonly ValidationRule[]>;
- default: () => never[];
- };
- modelValue: null;
- validateOn: vue.PropType<ValidationProps["validateOn"]>;
- validationValue: null;
- }>>;
- type VValidation = InstanceType<typeof VValidation>;
- export { VValidation };
|