This commit is contained in:
Benjamin Canac
2024-03-27 12:34:25 +01:00
155 changed files with 11236 additions and 3062 deletions

5
src/runtime/types/app.config.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
declare module '#build/app.config' {
import type { AppConfig } from '@nuxt/schema'
const _default: AppConfig
export default _default
}

View File

@@ -1,7 +1,25 @@
import type { Ref } from 'vue'
import type { ComputedRef, Ref } from 'vue'
export interface FormError<T extends string = string> {
path: T
export interface Form<T> {
validate (opts?: { name: string | string[], silent?: false, nested?: boolean }): Promise<T | false>
clear (path?: string): void
errors: Ref<FormError[]>
setErrors (errs: FormError[], path?: string): void
getErrors (path?: string): FormError[]
submit (): Promise<void>
disabled: ComputedRef<boolean>
}
export type FormSchema<T extends object> =
| ZodSchema
| YupObjectSchema<T>
| ValibotObjectSchema<T>
| JoiSchema<T>
export type FormInputEvents = 'input' | 'blur' | 'change'
export interface FormError<P extends string = string> {
name: P
message: string
}
@@ -9,30 +27,48 @@ export interface FormErrorWithId extends FormError {
id: string
}
export interface Form<T> {
validate(path?: string | string[], opts?: { silent?: true }): Promise<T | false>;
validate(path?: string | string[], opts?: { silent?: false }): Promise<T>;
clear(path?: string): void
errors: Ref<FormError[]>
setErrors(errs: FormError[], path?: string): void
getErrors(path?: string): FormError[]
submit(): Promise<void>
}
export type FormSubmitEvent<T> = SubmitEvent & { data: T }
export type FormErrorEvent = SubmitEvent & { errors: FormErrorWithId[] }
export type FormEventType = 'blur' | 'input' | 'change' | 'submit'
export type FormValidationError = {
errors: FormErrorWithId[]
childrens: FormValidationError[]
}
export interface FormEvent {
export type FormErrorEvent = SubmitEvent & FormValidationError
export type FormEventType = FormInputEvents
export type FormChildAttachEvent = {
type: 'attach'
formId: string | number
validate: Form<any>['validate']
}
export type FormChildDetachEvent = {
type: 'detach'
formId: string | number
}
export type FormInputEvent = {
type: FormEventType
path?: string
name?: string
}
export interface InjectedFormGroupValue {
inputId: Ref<string | undefined>
name: Ref<string>
size: Ref<string | number | symbol>
error: Ref<string | boolean | undefined>
eagerValidation: Ref<boolean>
export type FormEvent =
| FormInputEvent
| FormChildAttachEvent
| FormChildDetachEvent
export interface FormInjectedOptions {
disabled?: ComputedRef<boolean>
validateOnInputDelay?: ComputedRef<number>
}
export interface FormFieldInjectedOptions<T> {
inputId: Ref<string | undefined>
name: ComputedRef<string | undefined>
size: ComputedRef<T['size']>
error: ComputedRef<string | boolean | undefined>
eagerValidation: ComputedRef<boolean | undefined>
validateOnInputDelay: ComputedRef<number | undefined>
}

View File

@@ -1,31 +0,0 @@
export * from './accordion'
export * from './alert'
export * from './avatar'
export * from './badge'
export * from './breadcrumb'
export * from './button'
export * from './chip'
export * from './clipboard'
export * from './command-palette'
export * from './divider'
export * from './dropdown'
export * from './form-group'
export * from './form'
export * from './horizontal-navigation'
export * from './input'
export * from './kbd'
export * from './link'
export * from './meter'
export * from './modal'
export * from './slideover'
export * from './notification'
export * from './popper'
export * from './progress'
export * from './range'
export * from './select'
export * from './tabs'
export * from './textarea'
export * from './toggle'
export * from './tooltip'
export * from './vertical-navigation'
export * from './utils'