mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-21 07:21:46 +01:00
chore(Button): use utils to get link props
This commit is contained in:
@@ -23,8 +23,8 @@ import { twMerge, twJoin } from 'tailwind-merge'
|
||||
import UIcon from '../elements/Icon.vue'
|
||||
import ULink from '../elements/Link.vue'
|
||||
import { useUI } from '../../composables/useUI'
|
||||
import { mergeConfig, omit } from '../../utils'
|
||||
import { nuxtLinkProps } from '../../utils/nuxt-link'
|
||||
import { mergeConfig } from '../../utils'
|
||||
import { nuxtLinkProps, getNuxtLinkProps } from '../../utils/nuxt-link'
|
||||
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
|
||||
import type { ButtonColor, ButtonSize, ButtonVariant, Strategy } from '../../types'
|
||||
// @ts-expect-error
|
||||
@@ -192,12 +192,7 @@ export default defineComponent({
|
||||
)
|
||||
})
|
||||
|
||||
const linkProps = computed(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { type, block, label, loading, disabled, padded, size, color, variant, icon, loadingIcon, leadingIcon, trailingIcon, trailing, leading, square, truncate, class: className, ui, ...rest } = props
|
||||
|
||||
return rest
|
||||
})
|
||||
const linkProps = computed(() => getNuxtLinkProps(props))
|
||||
|
||||
return {
|
||||
// eslint-disable-next-line vue/no-dupe-keys
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PropType } from 'vue'
|
||||
import type { RouteLocationRaw } from '#vue-router'
|
||||
import type { RouteLocationRaw } from 'vue-router'
|
||||
|
||||
export const nuxtLinkProps = {
|
||||
to: {
|
||||
@@ -60,3 +60,13 @@ export const nuxtLinkProps = {
|
||||
default: undefined
|
||||
}
|
||||
} as const
|
||||
|
||||
export const getNuxtLinkProps = (props: Record<string, unknown>) => {
|
||||
const nuxtLinkPropsKeys = Object.keys(nuxtLinkProps)
|
||||
return nuxtLinkPropsKeys.reduce((acc, key) => {
|
||||
if (props[key] !== undefined) {
|
||||
acc[key] = props[key]
|
||||
}
|
||||
return acc
|
||||
}, {} as Record<string, unknown>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user