|
1 |
| -import { PropType, ExtractPublicPropTypes } from 'vue' |
2 |
| - |
3 |
| -// Button Props |
4 |
| -export const buttonProps = { |
| 1 | +export type ButtonProps = { |
5 | 2 | /**
|
6 | 3 | * Specifies the visual style variant of the button
|
7 | 4 | * @default 'primary'
|
8 | 5 | */
|
9 |
| - variant: { |
10 |
| - type: String as PropType<'solid' | 'outlined' | 'text' | 'link' | 'dashed' | 'filled'>, |
11 |
| - default: 'solid', |
12 |
| - }, |
13 |
| - |
| 6 | + variant?: 'solid' | 'outlined' | 'text' | 'link' | 'dashed' | 'filled' |
14 | 7 | /**
|
15 | 8 | * Specifies the size of the button
|
16 | 9 | * @default 'md'
|
17 | 10 | */
|
18 |
| - size: { |
19 |
| - type: String as PropType<'sm' | 'md' | 'lg'>, |
20 |
| - default: 'md', |
21 |
| - }, |
22 |
| - |
| 11 | + size?: 'sm' | 'md' | 'lg' |
23 | 12 | /**
|
24 | 13 | * Specifies the shape of the button
|
25 | 14 | * @default 'default'
|
26 | 15 | */
|
27 |
| - shape: { |
28 |
| - type: String as PropType<'default' | 'circle' | 'round'>, |
29 |
| - default: 'default', |
30 |
| - }, |
31 |
| - |
| 16 | + shape?: 'default' | 'circle' | 'round' |
32 | 17 | /**
|
33 | 18 | * Specifies the loading state of the button
|
34 | 19 | * @default false
|
35 | 20 | */
|
36 |
| - loading: { |
37 |
| - type: Boolean, |
38 |
| - default: false, |
39 |
| - }, |
40 |
| - |
| 21 | + loading?: boolean |
41 | 22 | /**
|
42 | 23 | * Specifies the disabled state of the button
|
43 | 24 | * @default false
|
44 | 25 | */
|
45 |
| - disabled: { |
46 |
| - type: Boolean, |
47 |
| - default: false, |
48 |
| - }, |
49 |
| - |
| 26 | + disabled?: boolean |
50 | 27 | /**
|
51 | 28 | * Specifies the danger state of the button
|
52 | 29 | * @default false
|
53 | 30 | */
|
54 |
| - danger: { |
55 |
| - type: Boolean, |
56 |
| - default: false, |
57 |
| - }, |
58 |
| - |
| 31 | + danger?: boolean |
59 | 32 | /**
|
60 | 33 | * Specifies the color of the button
|
61 | 34 | */
|
62 |
| - color: { |
63 |
| - type: String, |
64 |
| - }, |
65 |
| - |
| 35 | + color?: string |
66 | 36 | /**
|
67 | 37 | * Specifies the href of the button
|
68 | 38 | */
|
69 |
| - href: { |
70 |
| - type: String, |
71 |
| - }, |
72 |
| - |
| 39 | + href?: string |
73 | 40 | /**
|
74 | 41 | * Specifies the target of the button
|
75 | 42 | */
|
76 |
| - target: { |
77 |
| - type: String, |
78 |
| - }, |
79 |
| -} as const |
| 43 | + target?: string |
| 44 | +} |
80 | 45 |
|
81 |
| -export type ButtonProps = ExtractPublicPropTypes<typeof buttonProps> |
| 46 | +export const buttonDefaultProps = { |
| 47 | + variant: 'solid', |
| 48 | + size: 'md', |
| 49 | + shape: 'default', |
| 50 | + loading: false, |
| 51 | + disabled: false, |
| 52 | +} as const |
82 | 53 |
|
83 |
| -// Button Emits |
84 |
| -export const buttonEmits = { |
| 54 | +export type ButtonEmits = { |
85 | 55 | /**
|
86 | 56 | * Triggered when the button is clicked by the user
|
87 | 57 | * @param e - The native MouseEvent object
|
88 | 58 | */
|
89 |
| - click: (e: MouseEvent) => e instanceof MouseEvent, |
90 |
| -} as const |
| 59 | + (e: 'click', event: MouseEvent): void |
| 60 | +} |
91 | 61 |
|
92 |
| -export type ButtonEmits = typeof buttonEmits |
93 |
| - |
94 |
| -// Button Slots |
95 |
| -export const buttonSlots = { |
| 62 | +export type ButtonSlots = { |
96 | 63 | /**
|
97 | 64 | * Main content slot for the button text or custom content
|
98 | 65 | */
|
99 |
| - default: (_: any) => null as any, |
| 66 | + default?: (_: any) => any |
100 | 67 | /**
|
101 | 68 | * Slot for the button icon
|
102 | 69 | */
|
103 |
| - icon: (_: any) => null as any, |
| 70 | + icon?: (_: any) => any |
104 | 71 | /**
|
105 | 72 | * Slot for the button loading indicator
|
106 | 73 | */
|
107 |
| - loading: (_: any) => null as any, |
108 |
| -} as const |
109 |
| - |
110 |
| -export type ButtonSlots = Partial<typeof buttonSlots> |
| 74 | + loading?: (_: any) => any |
| 75 | +} |
0 commit comments