chore: trim button radix dependency
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
import type { AsTag } from 'radix-vue';
|
|
||||||
|
|
||||||
import type { Component } from 'vue';
|
import type { Component } from 'vue';
|
||||||
|
|
||||||
import type { ButtonVariants, ButtonVariantSize } from '../../ui';
|
import type {
|
||||||
|
ButtonVariants,
|
||||||
|
ButtonVariantSize,
|
||||||
|
} from '../../ui/button/types';
|
||||||
|
|
||||||
export interface VbenButtonProps {
|
export interface VbenButtonProps {
|
||||||
/**
|
/**
|
||||||
* The element or component this component should render as. Can be overwrite by `asChild`
|
* The element or component this component should render as. Can be overwrite by `asChild`
|
||||||
* @defaultValue "div"
|
* @defaultValue "div"
|
||||||
*/
|
*/
|
||||||
as?: AsTag | Component;
|
as?: Component | string;
|
||||||
/**
|
/**
|
||||||
* Change the default rendered element for the one passed as a child, merging their props and behavior.
|
* Change the default rendered element for the one passed as a child, merging their props and behavior.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { VbenButtonProps } from './button';
|
import type { VbenButtonProps } from './button';
|
||||||
|
|
||||||
import { computed } from 'vue';
|
import { computed, useAttrs } from 'vue';
|
||||||
|
|
||||||
import { LoaderCircle } from '@vben-core/icons';
|
import { LoaderCircle } from '@vben-core/icons';
|
||||||
import { cn } from '@vben-core/shared/utils';
|
import { cn } from '@vben-core/shared/utils';
|
||||||
|
|
||||||
import { Primitive } from 'radix-vue';
|
import { buttonVariants } from '../../ui/button/button';
|
||||||
|
|
||||||
import { buttonVariants } from '../../ui';
|
|
||||||
|
|
||||||
interface Props extends VbenButtonProps {}
|
interface Props extends VbenButtonProps {}
|
||||||
|
|
||||||
@@ -20,23 +18,26 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
size: 'default',
|
size: 'default',
|
||||||
variant: 'default',
|
variant: 'default',
|
||||||
});
|
});
|
||||||
|
defineOptions({ inheritAttrs: false });
|
||||||
|
|
||||||
const isDisabled = computed(() => {
|
const isDisabled = computed(() => {
|
||||||
return props.disabled || props.loading;
|
return props.disabled || props.loading;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Primitive
|
<component
|
||||||
:as="as"
|
:is="as"
|
||||||
:as-child="asChild"
|
|
||||||
:class="cn(buttonVariants({ variant, size }), props.class)"
|
:class="cn(buttonVariants({ variant, size }), props.class)"
|
||||||
:disabled="isDisabled"
|
:disabled="isDisabled"
|
||||||
|
v-bind="attrs"
|
||||||
>
|
>
|
||||||
<LoaderCircle
|
<LoaderCircle
|
||||||
v-if="loading"
|
v-if="loading"
|
||||||
class="text-md mr-2 size-4 flex-shrink-0 animate-spin"
|
class="text-md mr-2 size-4 flex-shrink-0 animate-spin"
|
||||||
/>
|
/>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</Primitive>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
import type { ButtonVariants } from '../../ui';
|
import type { ButtonVariants } from '../../ui';
|
||||||
import type { VbenButtonProps } from './button';
|
import type { VbenButtonProps } from './button';
|
||||||
|
|
||||||
import { computed, useSlots } from 'vue';
|
import { computed, defineAsyncComponent, useSlots } from 'vue';
|
||||||
|
|
||||||
import { cn } from '@vben-core/shared/utils';
|
import { cn } from '@vben-core/shared/utils';
|
||||||
|
|
||||||
import { VbenTooltip } from '../tooltip';
|
|
||||||
import VbenButton from './button.vue';
|
import VbenButton from './button.vue';
|
||||||
|
|
||||||
|
const VbenTooltip = defineAsyncComponent(() => import('../tooltip/tooltip.vue'));
|
||||||
|
|
||||||
interface Props extends VbenButtonProps {
|
interface Props extends VbenButtonProps {
|
||||||
class?: any;
|
class?: any;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user