@byyuurin/ui 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/nuxt.d.mts +13 -0
- package/dist/nuxt.d.ts +6 -3
- package/dist/nuxt.mjs +6 -3
- package/dist/resolver.d.mts +13 -0
- package/dist/resolver.d.ts +6 -3
- package/dist/resolver.mjs +5 -2
- package/dist/{components → runtime/components}/Accordion.vue +19 -3
- package/dist/{components → runtime/components}/App.vue +5 -1
- package/dist/{components → runtime/components}/Button.vue +92 -94
- package/dist/{components → runtime/components}/Checkbox.vue +101 -104
- package/dist/{components → runtime/components}/Input.vue +5 -1
- package/dist/{components → runtime/components}/ModalProvider.vue +1 -1
- package/dist/{components → runtime/components}/RadioGroup.vue +174 -180
- package/dist/runtime/components/ScrollArea.vue +72 -0
- package/dist/{components → runtime/components}/Select.vue +262 -258
- package/dist/{components → runtime/components}/Switch.vue +98 -99
- package/dist/{components → runtime/components}/Tabs.vue +117 -117
- package/dist/runtime/components/Textarea.vue +173 -0
- package/dist/{components → runtime/components}/Toast.vue +1 -1
- package/dist/{components → runtime/components}/Toaster.vue +35 -1
- package/dist/{components → runtime/components}/index.d.ts +2 -0
- package/dist/{components → runtime/components}/index.mjs +2 -0
- package/dist/runtime/composables/defineInjection.d.ts +11 -0
- package/dist/runtime/composables/defineInjection.mjs +9 -0
- package/dist/{composables → runtime/composables}/index.d.ts +1 -0
- package/dist/{composables → runtime/composables}/index.mjs +1 -0
- package/dist/{composables → runtime/composables}/useModal.d.ts +1 -1
- package/dist/{composables → runtime/composables}/useModal.mjs +3 -2
- package/dist/{composables → runtime/composables}/useTheme.d.ts +3 -2
- package/dist/runtime/composables/useTheme.mjs +26 -0
- package/dist/{composables → runtime/composables}/useToast.d.ts +1 -1
- package/dist/{theme → runtime/theme}/button.d.ts +0 -8
- package/dist/{theme → runtime/theme}/button.mjs +1 -9
- package/dist/{theme → runtime/theme}/checkbox.d.ts +0 -12
- package/dist/{theme → runtime/theme}/checkbox.mjs +4 -9
- package/dist/{theme → runtime/theme}/index.d.ts +2 -0
- package/dist/{theme → runtime/theme}/index.mjs +2 -0
- package/dist/{theme → runtime/theme}/radioGroup.d.ts +0 -24
- package/dist/{theme → runtime/theme}/radioGroup.mjs +8 -20
- package/dist/runtime/theme/scrollArea.d.ts +51 -0
- package/dist/runtime/theme/scrollArea.mjs +30 -0
- package/dist/{theme → runtime/theme}/switch.d.ts +0 -12
- package/dist/{theme → runtime/theme}/switch.mjs +2 -8
- package/dist/{theme → runtime/theme}/tabs.d.ts +32 -11
- package/dist/{theme → runtime/theme}/tabs.mjs +19 -12
- package/dist/runtime/theme/textarea.d.ts +90 -0
- package/dist/runtime/theme/textarea.mjs +100 -0
- package/dist/{theme → runtime/theme}/toast.mjs +1 -1
- package/dist/{types → runtime/types}/components.d.ts +2 -0
- package/dist/{types → runtime/types}/index.d.ts +1 -1
- package/dist/{utils → runtime/utils}/index.d.ts +3 -12
- package/dist/{utils → runtime/utils}/index.mjs +3 -12
- package/dist/{internal → runtime/utils}/styler.d.ts +0 -1
- package/dist/runtime/utils/styler.mjs +10 -0
- package/dist/{internal/constants.mjs → shared/ui.Cmq14xN9.mjs} +6 -2
- package/dist/unocss-preset.d.mts +57 -0
- package/dist/unocss-preset.d.ts +29 -9
- package/dist/unocss-preset.mjs +164 -110
- package/package.json +18 -12
- package/dist/composables/useTheme.mjs +0 -18
- package/dist/internal/constants.d.ts +0 -3
- package/dist/internal/index.d.ts +0 -4
- package/dist/internal/index.mjs +0 -4
- package/dist/internal/styler.mjs +0 -236
- package/dist/utils/unocss.d.ts +0 -3
- package/dist/utils/unocss.mjs +0 -50
- /package/dist/{components → runtime/components}/Card.vue +0 -0
- /package/dist/{components → runtime/components}/Drawer.vue +0 -0
- /package/dist/{components → runtime/components}/Link.vue +0 -0
- /package/dist/{components → runtime/components}/Modal.vue +0 -0
- /package/dist/{components → runtime/components}/Popover.vue +0 -0
- /package/dist/{components → runtime/components}/Tooltip.vue +0 -0
- /package/dist/{composables → runtime/composables}/useComponentIcons.d.ts +0 -0
- /package/dist/{composables → runtime/composables}/useComponentIcons.mjs +0 -0
- /package/dist/{composables → runtime/composables}/useToast.mjs +0 -0
- /package/dist/{theme → runtime/theme}/accordion.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/accordion.mjs +0 -0
- /package/dist/{theme → runtime/theme}/app.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/app.mjs +0 -0
- /package/dist/{theme → runtime/theme}/card.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/card.mjs +0 -0
- /package/dist/{theme → runtime/theme}/drawer.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/drawer.mjs +0 -0
- /package/dist/{theme → runtime/theme}/input.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/input.mjs +0 -0
- /package/dist/{theme → runtime/theme}/link.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/link.mjs +0 -0
- /package/dist/{theme → runtime/theme}/modal.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/modal.mjs +0 -0
- /package/dist/{theme → runtime/theme}/popover.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/popover.mjs +0 -0
- /package/dist/{theme → runtime/theme}/select.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/select.mjs +0 -0
- /package/dist/{theme → runtime/theme}/toast.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/toaster.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/toaster.mjs +0 -0
- /package/dist/{theme → runtime/theme}/tooltip.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/tooltip.mjs +0 -0
- /package/dist/{types → runtime/types}/components.mjs +0 -0
- /package/dist/{types → runtime/types}/index.mjs +0 -0
- /package/dist/{types → runtime/types}/utils.d.ts +0 -0
- /package/dist/{types → runtime/types}/utils.mjs +0 -0
- /package/dist/{internal → runtime/utils}/extend-theme.d.ts +0 -0
- /package/dist/{internal → runtime/utils}/extend-theme.mjs +0 -0
- /package/dist/{internal → runtime/utils}/link.d.ts +0 -0
- /package/dist/{internal → runtime/utils}/link.mjs +0 -0
package/README.md
CHANGED
|
@@ -15,10 +15,18 @@ https://byyuurin-ui.netlify.app/
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```ssh
|
|
18
|
-
pnpm i @byyuurin/ui
|
|
18
|
+
pnpm i -D unocss @unocss/reset @byyuurin/ui
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
icons
|
|
22
|
+
|
|
23
|
+
```ssh
|
|
24
|
+
pnpm i -D @iconify-json/[the-collection-you-want]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Setup
|
|
28
|
+
|
|
29
|
+
### UnoCSS
|
|
22
30
|
|
|
23
31
|
```ts
|
|
24
32
|
// uno.config.ts
|
|
@@ -28,8 +36,19 @@ import { defineConfig, presetIcons, presetUno } from 'unocss'
|
|
|
28
36
|
export default defineConfig({
|
|
29
37
|
presets: [
|
|
30
38
|
presetUno(),
|
|
31
|
-
presetIcons(
|
|
32
|
-
|
|
39
|
+
presetIcons({
|
|
40
|
+
cdn: 'https://esm.sh/', // OR install @iconify-json/[the-collection-you-want]
|
|
41
|
+
}),
|
|
42
|
+
ui({
|
|
43
|
+
radius: '0rem', // optional
|
|
44
|
+
radiusBox: '0rem', // optional
|
|
45
|
+
radiusButton: '0rem', // optional
|
|
46
|
+
radiusTabs: '0rem', // optional
|
|
47
|
+
cb: '#1f2937', // optional
|
|
48
|
+
c1: '#ffffff', // optional
|
|
49
|
+
c2: '#f2f2f2', // optional
|
|
50
|
+
c3: '#e5e6e6', // optional
|
|
51
|
+
}),
|
|
33
52
|
],
|
|
34
53
|
content: {
|
|
35
54
|
pipeline: {
|
|
@@ -42,11 +61,64 @@ export default defineConfig({
|
|
|
42
61
|
})
|
|
43
62
|
```
|
|
44
63
|
|
|
64
|
+
### Vite
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
// vite.config.ts
|
|
68
|
+
|
|
69
|
+
import UIResolver from '@byyuurin/ui/resolver'
|
|
70
|
+
import Vue from '@vitejs/plugin-vue'
|
|
71
|
+
import UnoCSS from 'unocss/vite'
|
|
72
|
+
import AutoImport from 'unplugin-auto-import/vite'
|
|
73
|
+
import VueComponents from 'unplugin-vue-components/vite'
|
|
74
|
+
import { defineConfig } from 'vite'
|
|
75
|
+
|
|
76
|
+
export default defineConfig({
|
|
77
|
+
plugins: [
|
|
78
|
+
UnoCSS(),
|
|
79
|
+
Vue(),
|
|
80
|
+
VueComponents({
|
|
81
|
+
dts: 'src/typed-components.d.ts',
|
|
82
|
+
resolvers: [
|
|
83
|
+
UIResolver({
|
|
84
|
+
prefix: 'U', // optional
|
|
85
|
+
}),
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
AutoImport({
|
|
89
|
+
dts: 'src/typed-imports.d.ts',
|
|
90
|
+
imports: ['vue'],
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Nuxt
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// nuxt.config.ts
|
|
100
|
+
|
|
101
|
+
export default defineNuxtConfig({
|
|
102
|
+
modules: [
|
|
103
|
+
'@unocss/nuxt',
|
|
104
|
+
'@byyuurin/ui/nuxt',
|
|
105
|
+
],
|
|
106
|
+
css: [
|
|
107
|
+
'@unocss/reset/tailwind.css',
|
|
108
|
+
],
|
|
109
|
+
ui: {
|
|
110
|
+
prefix: 'U', // optional
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
45
115
|
## Credits
|
|
46
116
|
|
|
47
117
|
- [UnoCSS](https://github.com/unocss/unocss)
|
|
48
118
|
- [daisyui](https://github.com/saadeghi/daisyui)
|
|
49
119
|
- [@nuxt/ui](https://github.com/nuxt/ui)
|
|
120
|
+
- [Reka UI](https://github.com/unovue/radix-vue)
|
|
121
|
+
- [VueUse](https://github.com/vueuse/vueuse)
|
|
50
122
|
|
|
51
123
|
## License
|
|
52
124
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './components';
|
|
2
|
-
export * from './composables';
|
|
3
|
-
export * from './types';
|
|
1
|
+
export * from './runtime/components';
|
|
2
|
+
export * from './runtime/composables';
|
|
3
|
+
export * from './runtime/types';
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./components/index.mjs";
|
|
2
|
-
export * from "./composables/index.mjs";
|
|
3
|
-
export * from "./types/index.mjs";
|
|
1
|
+
export * from "./runtime/components/index.mjs";
|
|
2
|
+
export * from "./runtime/composables/index.mjs";
|
|
3
|
+
export * from "./runtime/types/index.mjs";
|
package/dist/nuxt.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* prefix for components used in templates
|
|
6
|
+
*
|
|
7
|
+
* @default ""
|
|
8
|
+
*/
|
|
9
|
+
prefix?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
12
|
+
|
|
13
|
+
export { type ModuleOptions, _default as default };
|
package/dist/nuxt.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
2
4
|
/**
|
|
3
5
|
* prefix for components used in templates
|
|
4
6
|
*
|
|
@@ -6,5 +8,6 @@ export interface ModuleOptions {
|
|
|
6
8
|
*/
|
|
7
9
|
prefix?: string;
|
|
8
10
|
}
|
|
9
|
-
declare const _default:
|
|
10
|
-
|
|
11
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
12
|
+
|
|
13
|
+
export { type ModuleOptions, _default as default };
|
package/dist/nuxt.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { defineNuxtModule, useLogger, addComponent } from '@nuxt/kit';
|
|
2
|
+
import { p as packageName, c as componentNames } from './shared/ui.Cmq14xN9.mjs';
|
|
3
|
+
|
|
4
|
+
const nuxt = defineNuxtModule({
|
|
4
5
|
meta: {
|
|
5
6
|
name: packageName,
|
|
6
7
|
configKey: "ui",
|
|
@@ -26,3 +27,5 @@ export default defineNuxtModule({
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
});
|
|
30
|
+
|
|
31
|
+
export { nuxt as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentResolver } from 'unplugin-vue-components';
|
|
2
|
+
|
|
3
|
+
interface ResolverOptions {
|
|
4
|
+
/**
|
|
5
|
+
* prefix for components used in templates
|
|
6
|
+
*
|
|
7
|
+
* @default ""
|
|
8
|
+
*/
|
|
9
|
+
prefix?: string;
|
|
10
|
+
}
|
|
11
|
+
declare function export_default(options?: ResolverOptions): ComponentResolver;
|
|
12
|
+
|
|
13
|
+
export { type ResolverOptions, export_default as default };
|
package/dist/resolver.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ComponentResolver } from 'unplugin-vue-components';
|
|
2
|
+
|
|
3
|
+
interface ResolverOptions {
|
|
3
4
|
/**
|
|
4
5
|
* prefix for components used in templates
|
|
5
6
|
*
|
|
@@ -7,4 +8,6 @@ export interface ResolverOptions {
|
|
|
7
8
|
*/
|
|
8
9
|
prefix?: string;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
declare function export_default(options?: ResolverOptions): ComponentResolver;
|
|
12
|
+
|
|
13
|
+
export { type ResolverOptions, export_default as default };
|
package/dist/resolver.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { componentNames, packageName } from
|
|
2
|
-
|
|
1
|
+
import { c as componentNames, p as packageName } from './shared/ui.Cmq14xN9.mjs';
|
|
2
|
+
|
|
3
|
+
function resolver(options = {}) {
|
|
3
4
|
const { prefix = "" } = options;
|
|
4
5
|
return {
|
|
5
6
|
type: "component",
|
|
@@ -16,3 +17,5 @@ export default function(options = {}) {
|
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
}
|
|
20
|
+
|
|
21
|
+
export { resolver as default };
|
|
@@ -73,8 +73,8 @@ const style = computed(() => {
|
|
|
73
73
|
<i v-if="item.icon" :class="style.icon({ class: [item.icon, props.ui?.icon] })"></i>
|
|
74
74
|
</slot>
|
|
75
75
|
|
|
76
|
-
<span v-if="get(item, props.labelKey
|
|
77
|
-
<slot v-bind="{ item, index, open }">{{ get(item, props.labelKey
|
|
76
|
+
<span v-if="get(item, props.labelKey) || slots.default" :class="style.label({ class: props.ui?.label })">
|
|
77
|
+
<slot v-bind="{ item, index, open }">{{ get(item, props.labelKey) }}</slot>
|
|
78
78
|
</span>
|
|
79
79
|
|
|
80
80
|
<slot name="trailing-icon" v-bind="{ item, index, open }">
|
|
@@ -100,5 +100,21 @@ const style = computed(() => {
|
|
|
100
100
|
</template>
|
|
101
101
|
|
|
102
102
|
<style>
|
|
103
|
-
@keyframes accordion-up
|
|
103
|
+
@keyframes accordion-up {
|
|
104
|
+
from {
|
|
105
|
+
height: var(--reka-accordion-content-height);
|
|
106
|
+
}
|
|
107
|
+
to {
|
|
108
|
+
height: 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@keyframes accordion-down {
|
|
113
|
+
from {
|
|
114
|
+
height: 0;
|
|
115
|
+
}
|
|
116
|
+
to {
|
|
117
|
+
height: var(--reka-accordion-content-height);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
104
120
|
</style>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { ConfigProviderProps, TooltipProviderProps } from 'reka-ui'
|
|
3
|
+
import type { UserConfig } from 'unocss'
|
|
3
4
|
import type { ThemeExtension, ToasterProps } from '../types'
|
|
4
5
|
|
|
5
6
|
export interface AppProps extends Omit<ConfigProviderProps, 'useId' | 'dir' | 'locale'> {
|
|
7
|
+
unoConfig?: UserConfig
|
|
6
8
|
ui?: ThemeExtension
|
|
7
9
|
tooltip?: TooltipProviderProps
|
|
8
10
|
toaster?: ToasterProps
|
|
@@ -19,11 +21,12 @@ import { ConfigProvider, TooltipProvider, useForwardProps } from 'reka-ui'
|
|
|
19
21
|
import { computed, shallowRef, toRef, useId } from 'vue'
|
|
20
22
|
import type { ModalState } from '../composables/useModal'
|
|
21
23
|
import { provideModalState } from '../composables/useModal'
|
|
22
|
-
import { provideThemeExtension } from '../composables/useTheme'
|
|
24
|
+
import { provideThemeExtension, provideUnoConfig } from '../composables/useTheme'
|
|
23
25
|
import ModalProvider from './ModalProvider.vue'
|
|
24
26
|
import Toaster from './Toaster.vue'
|
|
25
27
|
|
|
26
28
|
const props = withDefaults(defineProps<AppProps>(), {
|
|
29
|
+
unoConfig: () => ({}),
|
|
27
30
|
ui: () => ({}),
|
|
28
31
|
})
|
|
29
32
|
|
|
@@ -41,6 +44,7 @@ const modalState = shallowRef<ModalState>({
|
|
|
41
44
|
const themeExtension = computed(() => props.ui)
|
|
42
45
|
|
|
43
46
|
provideModalState(modalState)
|
|
47
|
+
provideUnoConfig(props.unoConfig)
|
|
44
48
|
provideThemeExtension(themeExtension)
|
|
45
49
|
</script>
|
|
46
50
|
|
|
@@ -1,94 +1,92 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
-
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
4
|
-
import type { button } from '../theme'
|
|
5
|
-
import type { ComponentAttrs } from '../types'
|
|
6
|
-
import type { LinkProps } from './Link.vue'
|
|
7
|
-
|
|
8
|
-
export interface ButtonSlots {
|
|
9
|
-
default?: (props?: any) => any
|
|
10
|
-
prefix?: (props?: any) => any
|
|
11
|
-
suffix?: (props?: any) => any
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type ButtonVariants = VariantProps<typeof button>
|
|
15
|
-
type UIOptions = ComponentAttrs<typeof button>['ui'] & LinkProps['ui']
|
|
16
|
-
|
|
17
|
-
export interface ButtonProps extends Omit<ComponentAttrs<typeof button>, 'ui'>, UseComponentIconsProps, Omit<LinkProps, 'ui' | 'raw'> {
|
|
18
|
-
icon?: string
|
|
19
|
-
label?: string
|
|
20
|
-
variant?: ButtonVariants['variant']
|
|
21
|
-
size?: ButtonVariants['size']
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
props.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</Link>
|
|
94
|
-
</template>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from '@byyuurin/ui-kit'
|
|
3
|
+
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
4
|
+
import type { button } from '../theme'
|
|
5
|
+
import type { ComponentAttrs } from '../types'
|
|
6
|
+
import type { LinkProps } from './Link.vue'
|
|
7
|
+
|
|
8
|
+
export interface ButtonSlots {
|
|
9
|
+
default?: (props?: any) => any
|
|
10
|
+
prefix?: (props?: any) => any
|
|
11
|
+
suffix?: (props?: any) => any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type ButtonVariants = VariantProps<typeof button>
|
|
15
|
+
type UIOptions = ComponentAttrs<typeof button>['ui'] & LinkProps['ui']
|
|
16
|
+
|
|
17
|
+
export interface ButtonProps extends Omit<ComponentAttrs<typeof button>, 'ui'>, UseComponentIconsProps, Omit<LinkProps, 'ui' | 'raw'> {
|
|
18
|
+
icon?: string
|
|
19
|
+
label?: string
|
|
20
|
+
variant?: ButtonVariants['variant']
|
|
21
|
+
size?: ButtonVariants['size']
|
|
22
|
+
loading?: boolean
|
|
23
|
+
active?: boolean
|
|
24
|
+
disabled?: boolean
|
|
25
|
+
ui?: UIOptions
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts" setup>
|
|
30
|
+
import { computed } from 'vue'
|
|
31
|
+
import { useComponentIcons, useTheme } from '../composables'
|
|
32
|
+
import { omit, pickLinkProps } from '../utils'
|
|
33
|
+
import Link from './Link.vue'
|
|
34
|
+
|
|
35
|
+
const props = withDefaults(defineProps<ButtonProps>(), {
|
|
36
|
+
variant: 'solid',
|
|
37
|
+
size: 'md',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const slots = defineSlots<ButtonSlots>()
|
|
41
|
+
|
|
42
|
+
const { isPrefix, isSuffix, prefixIconName, suffixIconName } = useComponentIcons(
|
|
43
|
+
computed(() => ({ ...props, loading: props.loading })),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
const linkProps = pickLinkProps(props)
|
|
47
|
+
|
|
48
|
+
const { theme, createStyler } = useTheme()
|
|
49
|
+
|
|
50
|
+
const style = computed(() => {
|
|
51
|
+
const styler = createStyler(theme.value.button)
|
|
52
|
+
return styler({
|
|
53
|
+
...props,
|
|
54
|
+
prefix: isPrefix.value,
|
|
55
|
+
suffix: isSuffix.value,
|
|
56
|
+
class: [
|
|
57
|
+
props.class,
|
|
58
|
+
props.active ? props.ui?.active : props.ui?.inactive,
|
|
59
|
+
props.disabled ? props.ui?.disabled : undefined,
|
|
60
|
+
],
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<template>
|
|
66
|
+
<Link
|
|
67
|
+
:class="style.base({ class: [props.class, props.ui?.base] })"
|
|
68
|
+
:type="props.type"
|
|
69
|
+
:disabled="props.disabled || props.loading"
|
|
70
|
+
v-bind="omit(linkProps, ['type', 'disabled'])"
|
|
71
|
+
raw
|
|
72
|
+
>
|
|
73
|
+
<slot name="prefix">
|
|
74
|
+
<i
|
|
75
|
+
v-if="isPrefix && prefixIconName"
|
|
76
|
+
:class="style.prefixIcon({ class: [prefixIconName, props.ui?.prefixIcon] })"
|
|
77
|
+
></i>
|
|
78
|
+
</slot>
|
|
79
|
+
<span
|
|
80
|
+
v-if="slots.default || props.label"
|
|
81
|
+
:class="style.label({ class: props.ui?.label })"
|
|
82
|
+
>
|
|
83
|
+
<slot>{{ label }}</slot>
|
|
84
|
+
</span>
|
|
85
|
+
<slot name="suffix">
|
|
86
|
+
<i
|
|
87
|
+
v-if="isSuffix && suffixIconName"
|
|
88
|
+
:class="style.suffixIcon({ class: [suffixIconName, props.ui?.suffixIcon] })"
|
|
89
|
+
></i>
|
|
90
|
+
</slot>
|
|
91
|
+
</Link>
|
|
92
|
+
</template>
|