UNPKG

vuetify

Version:

Vue Material Component Framework

280 lines (274 loc) 11 kB
import * as vue from 'vue'; import { ComponentPropsOptions, ExtractPropTypes, VNodeChild, VNode, Ref, PropType } 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<(...args: T) => void>; type ValidationResult = string | boolean; type ValidationRule = ValidationResult | PromiseLike<ValidationResult> | ((value: any) => ValidationResult) | ((value: any) => PromiseLike<ValidationResult>); type ValidateOnValue = 'blur' | 'input' | 'submit'; 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?: ValidateOnValue | `${ValidateOnValue} lazy` | `lazy ${ValidateOnValue}` | 'lazy'; 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: () => void; resetValidation: () => 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?: "lazy" | ("input" | "blur" | "submit") | "input lazy" | "blur lazy" | "submit lazy" | "lazy input" | "lazy blur" | "lazy submit" | undefined; validationValue?: any; } & {}, () => vue.VNode<vue.RendererNode, vue.RendererElement, { [key: string]: any; }>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Omit<{ 'update:modelValue': (value: any) => boolean; }, "$children" | "v-slot:default" | "v-slots" | "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?: "lazy" | ("input" | "blur" | "submit") | "input lazy" | "blur lazy" | "submit lazy" | "lazy input" | "lazy blur" | "lazy submit" | 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: () => void; resetValidation: () => void; validate: (silent?: boolean) => Promise<string[]>; validationClasses: vue.ComputedRef<{ [x: string]: boolean; }>; }) => vue.VNode<vue.RendererNode, vue.RendererElement, { [key: string]: any; }>[]; }>>, { 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?: "lazy" | ("input" | "blur" | "submit") | "input lazy" | "blur lazy" | "submit lazy" | "lazy input" | "lazy blur" | "lazy submit" | 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?: undefined; __isTeleport?: undefined; __isSuspense?: undefined; } & 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?: "lazy" | ("input" | "blur" | "submit") | "input lazy" | "blur lazy" | "submit lazy" | "lazy input" | "lazy blur" | "lazy submit" | undefined; validationValue?: any; } & {}, () => vue.VNode<vue.RendererNode, vue.RendererElement, { [key: string]: any; }>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Omit<{ 'update:modelValue': (value: any) => boolean; }, "$children" | "v-slot:default" | "v-slots" | "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: () => void; resetValidation: () => void; validate: (silent?: boolean) => Promise<string[]>; validationClasses: vue.ComputedRef<{ [x: string]: boolean; }>; }) => vue.VNode<vue.RendererNode, vue.RendererElement, { [key: string]: any; }>[]; }>>> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new <T>(props: { modelValue?: T | null | undefined; 'onUpdate:modelValue'?: ((value: T | null) => void) | undefined; }, slots: VValidationSlots) => GenericProps<{ modelValue?: T | null | undefined; 'onUpdate:modelValue'?: ((value: T | null) => void) | undefined; }, VValidationSlots>) & 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<"lazy" | ("input" | "blur" | "submit") | "input lazy" | "blur lazy" | "submit lazy" | "lazy input" | "lazy blur" | "lazy submit" | undefined>; 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<"lazy" | ("input" | "blur" | "submit") | "input lazy" | "blur lazy" | "submit lazy" | "lazy input" | "lazy blur" | "lazy submit" | undefined>; validationValue: null; }>>; type VValidation = InstanceType<typeof VValidation>; export { VValidation };