@byyuurin/ui 0.0.2 → 0.0.3
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 +75 -5
- package/dist/index.cjs +38 -0
- 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}/Button.vue +93 -94
- package/dist/{components → runtime/components}/Checkbox.vue +104 -104
- package/dist/{components → runtime/components}/RadioGroup.vue +180 -180
- package/dist/{components → runtime/components}/Select.vue +262 -258
- package/dist/{components → runtime/components}/Switch.vue +99 -99
- package/dist/{components → runtime/components}/Tabs.vue +117 -117
- package/dist/{components → runtime/components}/Toaster.vue +35 -1
- package/dist/runtime/components/index.cjs +132 -0
- package/dist/runtime/composables/index.cjs +33 -0
- package/dist/runtime/composables/useComponentIcons.cjs +30 -0
- package/dist/runtime/composables/useModal.cjs +55 -0
- package/dist/runtime/composables/useTheme.cjs +30 -0
- package/dist/{composables → runtime/composables}/useTheme.d.ts +0 -1
- package/dist/{composables → runtime/composables}/useTheme.mjs +3 -3
- package/dist/runtime/composables/useToast.cjs +51 -0
- package/dist/{composables → runtime/composables}/useToast.d.ts +1 -1
- package/dist/runtime/theme/accordion.cjs +27 -0
- package/dist/runtime/theme/app.cjs +15 -0
- package/dist/runtime/theme/button.cjs +127 -0
- package/dist/runtime/theme/card.cjs +17 -0
- package/dist/runtime/theme/checkbox.cjs +56 -0
- package/dist/runtime/theme/drawer.cjs +73 -0
- package/dist/runtime/theme/index.cjs +125 -0
- package/dist/runtime/theme/input.cjs +115 -0
- package/dist/runtime/theme/link.cjs +23 -0
- package/dist/runtime/theme/modal.cjs +55 -0
- package/dist/runtime/theme/popover.cjs +13 -0
- package/dist/runtime/theme/radioGroup.cjs +73 -0
- package/dist/runtime/theme/select.cjs +128 -0
- package/dist/runtime/theme/switch.cjs +73 -0
- package/dist/runtime/theme/tabs.cjs +105 -0
- package/dist/runtime/theme/toast.cjs +33 -0
- package/dist/runtime/theme/toaster.cjs +72 -0
- package/dist/runtime/theme/tooltip.cjs +14 -0
- package/dist/runtime/types/components.cjs +1 -0
- package/dist/runtime/types/index.cjs +27 -0
- package/dist/{types → runtime/types}/index.d.ts +1 -1
- package/dist/runtime/types/utils.cjs +1 -0
- package/dist/runtime/utils/extend-theme.cjs +24 -0
- package/dist/runtime/utils/index.cjs +119 -0
- package/dist/{utils → runtime/utils}/index.d.ts +3 -1
- package/dist/{utils → runtime/utils}/index.mjs +3 -1
- package/dist/runtime/utils/link.cjs +10 -0
- package/dist/runtime/utils/styler.cjs +18 -0
- 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.CPXA9QoM.mjs} +4 -2
- package/dist/unocss-preset.d.mts +49 -0
- package/dist/unocss-preset.d.ts +20 -8
- package/dist/unocss-preset.mjs +428 -78
- package/package.json +15 -10
- 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}/App.vue +0 -0
- /package/dist/{components → runtime/components}/Card.vue +0 -0
- /package/dist/{components → runtime/components}/Drawer.vue +0 -0
- /package/dist/{components → runtime/components}/Input.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}/ModalProvider.vue +0 -0
- /package/dist/{components → runtime/components}/Popover.vue +0 -0
- /package/dist/{components → runtime/components}/Toast.vue +0 -0
- /package/dist/{components → runtime/components}/Tooltip.vue +0 -0
- /package/dist/{components → runtime/components}/index.d.ts +0 -0
- /package/dist/{components → runtime/components}/index.mjs +0 -0
- /package/dist/{composables → runtime/composables}/index.d.ts +0 -0
- /package/dist/{composables → runtime/composables}/index.mjs +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}/useModal.d.ts +0 -0
- /package/dist/{composables → runtime/composables}/useModal.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}/button.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/button.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}/checkbox.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/checkbox.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}/index.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/index.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}/radioGroup.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/radioGroup.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}/switch.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/switch.mjs +0 -0
- /package/dist/{theme → runtime/theme}/tabs.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/tabs.mjs +0 -0
- /package/dist/{theme → runtime/theme}/toast.d.ts +0 -0
- /package/dist/{theme → runtime/theme}/toast.mjs +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.d.ts +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,7 +61,58 @@ export default defineConfig({
|
|
|
42
61
|
})
|
|
43
62
|
```
|
|
44
63
|
|
|
45
|
-
|
|
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',
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Thanks
|
|
46
116
|
|
|
47
117
|
- [UnoCSS](https://github.com/unocss/unocss)
|
|
48
118
|
- [daisyui](https://github.com/saadeghi/daisyui)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _components = require("./runtime/components/index.cjs");
|
|
7
|
+
Object.keys(_components).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _components[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _components[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _composables = require("./runtime/composables/index.cjs");
|
|
18
|
+
Object.keys(_composables).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _composables[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _composables[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _types = require("./runtime/types/index.cjs");
|
|
29
|
+
Object.keys(_types).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _types[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
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.CPXA9QoM.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.CPXA9QoM.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,94 +1,93 @@
|
|
|
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
|
-
round?: boolean
|
|
23
|
-
loading?: boolean
|
|
24
|
-
active?: boolean
|
|
25
|
-
disabled?: boolean
|
|
26
|
-
ui?: UIOptions
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<script lang="ts" setup>
|
|
31
|
-
import { computed } from 'vue'
|
|
32
|
-
import { useComponentIcons, useTheme } from '../composables'
|
|
33
|
-
import { pickLinkProps } from '../
|
|
34
|
-
import
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
props.
|
|
60
|
-
props.
|
|
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
|
-
|
|
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
|
+
round?: boolean
|
|
23
|
+
loading?: boolean
|
|
24
|
+
active?: boolean
|
|
25
|
+
disabled?: boolean
|
|
26
|
+
ui?: UIOptions
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script lang="ts" setup>
|
|
31
|
+
import { computed } from 'vue'
|
|
32
|
+
import { useComponentIcons, useTheme } from '../composables'
|
|
33
|
+
import { omit, pickLinkProps } from '../utils'
|
|
34
|
+
import Link from './Link.vue'
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(defineProps<ButtonProps>(), {
|
|
37
|
+
variant: 'solid',
|
|
38
|
+
size: 'md',
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const slots = defineSlots<ButtonSlots>()
|
|
42
|
+
|
|
43
|
+
const { isPrefix, isSuffix, prefixIconName, suffixIconName } = useComponentIcons(
|
|
44
|
+
computed(() => ({ ...props, loading: props.loading })),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
const linkProps = pickLinkProps(props)
|
|
48
|
+
|
|
49
|
+
const { theme, createStyler } = useTheme()
|
|
50
|
+
|
|
51
|
+
const style = computed(() => {
|
|
52
|
+
const styler = createStyler(theme.value.button)
|
|
53
|
+
return styler({
|
|
54
|
+
...props,
|
|
55
|
+
prefix: isPrefix.value,
|
|
56
|
+
suffix: isSuffix.value,
|
|
57
|
+
class: [
|
|
58
|
+
props.class,
|
|
59
|
+
props.active ? props.ui?.active : props.ui?.inactive,
|
|
60
|
+
props.disabled ? props.ui?.disabled : undefined,
|
|
61
|
+
],
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<Link
|
|
68
|
+
:class="style.base({ class: [props.class, props.ui?.base] })"
|
|
69
|
+
:type="props.type"
|
|
70
|
+
:disabled="props.disabled || props.loading"
|
|
71
|
+
v-bind="omit(linkProps, ['type', 'disabled'])"
|
|
72
|
+
raw
|
|
73
|
+
>
|
|
74
|
+
<slot name="prefix">
|
|
75
|
+
<i
|
|
76
|
+
v-if="isPrefix && prefixIconName"
|
|
77
|
+
:class="style.prefixIcon({ class: [prefixIconName, props.ui?.prefixIcon] })"
|
|
78
|
+
></i>
|
|
79
|
+
</slot>
|
|
80
|
+
<span
|
|
81
|
+
v-if="slots.default || props.label"
|
|
82
|
+
:class="style.label({ class: props.ui?.label })"
|
|
83
|
+
>
|
|
84
|
+
<slot>{{ label }}</slot>
|
|
85
|
+
</span>
|
|
86
|
+
<slot name="suffix">
|
|
87
|
+
<i
|
|
88
|
+
v-if="isSuffix && suffixIconName"
|
|
89
|
+
:class="style.suffixIcon({ class: [suffixIconName, props.ui?.suffixIcon] })"
|
|
90
|
+
></i>
|
|
91
|
+
</slot>
|
|
92
|
+
</Link>
|
|
93
|
+
</template>
|