mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 00:15:05 +01:00
chore(utils): improve link utils
This commit is contained in:
@@ -74,3 +74,4 @@ export function looseToNumber (val: any): any {
|
||||
}
|
||||
|
||||
export * from './lodash'
|
||||
export * from './link'
|
||||
|
||||
@@ -61,12 +61,47 @@ export const nuxtLinkProps = {
|
||||
}
|
||||
} as const
|
||||
|
||||
export const getNuxtLinkProps = (props: Record<string, unknown>) => {
|
||||
const nuxtLinkPropsKeys = Object.keys(nuxtLinkProps)
|
||||
return nuxtLinkPropsKeys.reduce((acc, key) => {
|
||||
const uLinkProps = {
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: undefined
|
||||
},
|
||||
exact: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
exactQuery: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
exactHash: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
inactiveClass: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
} as const
|
||||
|
||||
export const getNuxtLinkProps = (props) => {
|
||||
const keys = Object.keys(nuxtLinkProps)
|
||||
|
||||
return keys.reduce((acc, key) => {
|
||||
if (props[key] !== undefined) {
|
||||
acc[key] = props[key]
|
||||
}
|
||||
return acc
|
||||
}, {} as Record<string, unknown>)
|
||||
}, {})
|
||||
}
|
||||
|
||||
export const getULinkProps = (props) => {
|
||||
const keys = [...Object.keys(nuxtLinkProps), ...Object.keys(uLinkProps)]
|
||||
|
||||
return keys.reduce((acc, key) => {
|
||||
if (props[key] !== undefined) {
|
||||
acc[key] = props[key]
|
||||
}
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
Reference in New Issue
Block a user