Skip to content

Commit

Permalink
Types
Browse files Browse the repository at this point in the history
  • Loading branch information
ManukMinasyan committed Oct 9, 2023
1 parent 724f593 commit 4621c7f
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ dist
dist-ssr
*.local
docs/.vitepress/cache
types
9 changes: 9 additions & 0 deletions src/types/accordion.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Button } from './button'

export interface AccordionItem extends Button {
slot?: string
disabled?: boolean
content?: string
defaultOpen?: boolean
closeOthers?: boolean
}
15 changes: 15 additions & 0 deletions src/types/avatar.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { avatar } from '../ui.config'
import colors from '../../constants/colors.config'

export type AvatarSize = keyof typeof avatar.size
export type AvatarChipColor = 'gray' | typeof colors[number]
export type AvatarChipPosition = keyof typeof avatar.chip.position

export interface Avatar {
src?: string | boolean
alt?: string
text?: string
size?: AvatarSize
chipColor?: AvatarChipColor
chipPosition?: AvatarChipPosition
}
30 changes: 30 additions & 0 deletions src/types/button.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Link } from './link'
import { button } from '../ui.config'
import type { NestedKeyOf } from '.'
import colors from '#ui-colors'

export type ButtonSize = keyof typeof button.size
export type ButtonColor = keyof typeof button.color | typeof colors[number]
export type ButtonVariant = keyof typeof button.variant | NestedKeyOf<typeof button.color>

export interface Button extends Link {
type?: string
block?: boolean
label?: string
loading?: boolean
disabled?: boolean
padded?: boolean
size?: ButtonSize
color?: ButtonColor
variant?: ButtonVariant
icon?: string
loadingIcon?: string
leadingIcon?: string
trailingIcon?: string
trailing?: boolean
leading?: boolean
to?: string | object
target?: string
square?: boolean
truncate?: boolean
}
3 changes: 3 additions & 0 deletions src/types/clipboard.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface ClipboardPlugin {
copy: (text: string, success?: { title?: string, description?: string }, failure?: { title?: string, description?: string }) => void
}
26 changes: 26 additions & 0 deletions src/types/command-palette.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { FuseSortFunctionMatch, FuseSortFunctionMatchList } from 'fuse.js'
import type { Avatar } from './avatar'

export interface Command {
id: string | number
prefix?: string
suffix?: string
icon?: string
iconClass?: string
avatar?: Partial<Avatar>
chip?: string
disabled?: boolean
shortcuts?: string[]
group?: string
score?: number
matches?: (FuseSortFunctionMatch | FuseSortFunctionMatchList)[]
[key: string]: any
}

export interface Group {
key: string
active?: string
inactive?: string
commands: Command[]
[key: string]: any
}
13 changes: 13 additions & 0 deletions src/types/dropdown.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Link } from './link'
import type { Avatar } from './avatar'

export interface DropdownItem extends Link {
label: string
slot?: string
icon?: string
iconClass?: string
avatar?: Avatar
shortcuts?: string[]
disabled?: boolean
click?: Function
}
28 changes: 28 additions & 0 deletions src/types/form.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export interface FormError {
path: string
message: string
}

export interface Form<T> {
validate(path?: string, opts: { silent?: boolean }): Promise<T>
clear(path?: string): void
errors: Ref<FormError[]>
setErrors(errs: FormError[], path?: string): void
getErrors(path?: string): FormError[]
}

export type FormSubmitEvent<T> = SubmitEvent & { data: T }

export type FormEventType = 'blur' | 'input' | 'change' | 'submit'

export interface FormEvent {
type: FormEventType
path: string
}

export interface InjectedFormGroupValue {
inputId: Ref<string>
name: Ref<string>
size: Ref<string>
error: Ref<string | boolean>
}
13 changes: 13 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export * from './accordion'
export * from './avatar'
export * from './button'
export * from './clipboard'
export * from './command-palette'
export * from './dropdown'
export * from './form'
export * from './link'
export * from './notification'
export * from './popper'
export * from './tabs'
export * from './vertical-navigation'
export * from './utils'
9 changes: 9 additions & 0 deletions src/types/link.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { NuxtLinkProps } from '#app'

export interface Link extends NuxtLinkProps {
active?: boolean
exact?: boolean
exactQuery?: boolean
exactMatch?: boolean
inactiveClass?: string
}
22 changes: 22 additions & 0 deletions src/types/notification.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Avatar } from './avatar'
import type { Button } from './button'
import appConfig from '#build/app.config'

export interface NotificationAction extends Partial<Button> {
click: Function
}

export interface Notification {
id: string
title: string
description: string
icon?: string
avatar?: Partial<Avatar>
closeButton?: Partial<Button>
timeout: number
actions?: NotificationAction[]
click?: Function
callback?: Function
color?: string
ui?: Partial<typeof appConfig.ui.notification>
}
14 changes: 14 additions & 0 deletions src/types/popper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Placement, PositioningStrategy } from '@popperjs/core'

export interface PopperOptions {
locked?: boolean
overflowPadding?: number
offsetDistance?: number
offsetSkid?: number
placement?: Placement
strategy?: PositioningStrategy
gpuAcceleration?: boolean
adaptive?: boolean
scroll?: boolean
resize?: boolean
}
7 changes: 7 additions & 0 deletions src/types/tabs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface TabItem {
label: string
slot?: string
disabled?: boolean
content?: string
[key: string]: any
}
11 changes: 11 additions & 0 deletions src/types/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export type Strategy = 'merge' | 'override';

export type NestedKeyOf<ObjectType extends object> = {
[Key in keyof ObjectType]: ObjectType[Key] extends object
? NestedKeyOf<ObjectType[Key]>
: Key;
}[keyof ObjectType];

export type DeepPartial<T> = Partial<{
[P in keyof T]: DeepPartial<T[P]> | { [key: string]: string };
}>;
11 changes: 11 additions & 0 deletions src/types/vertical-navigation.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Link } from './link'
import type { Avatar } from './avatar'

export interface VerticalNavigationLink extends Link {
label: string
icon?: string
iconClass?: string
avatar?: Avatar
click?: Function
badge?: string | number
}

0 comments on commit 4621c7f

Please sign in to comment.