@coffic/cosy-ui 0.8.25 → 0.8.27
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/dist/app.css +1 -1
- package/dist/index-astro.ts +1 -0
- package/dist/index-vue.ts +18 -0
- package/dist/src-astro/alert/Alert.astro +45 -5
- package/dist/src-astro/badge/Badge.astro +67 -0
- package/dist/src-astro/badge/index.ts +1 -0
- package/dist/src-vue/alert/Alert.vue +65 -39
- package/dist/src-vue/badge/Badge.vue +66 -0
- package/dist/src-vue/badge/index.ts +1 -0
- package/dist/src-vue/card/Card.vue +52 -0
- package/dist/src-vue/card/CardCourse.vue +34 -0
- package/dist/src-vue/card/index.ts +2 -0
- package/dist/src-vue/key-catcher/KeyCatcher.vue +121 -0
- package/dist/src-vue/key-catcher/index.ts +1 -0
- package/dist/src-vue/progress/Progress.vue +68 -0
- package/dist/src-vue/progress/index.ts +1 -0
- package/dist/src-vue/status-bar/StatusBar.vue +101 -0
- package/dist/src-vue/status-bar/StatusBarItem.vue +97 -0
- package/dist/src-vue/status-bar/index.ts +2 -0
- package/dist/src-vue/tool-bar/ToolBar.vue +95 -0
- package/dist/src-vue/tool-bar/index.ts +1 -0
- package/package.json +1 -1
@@ -0,0 +1,68 @@
|
|
1
|
+
<!--
|
2
|
+
Progress 组件
|
3
|
+
|
4
|
+
基于DaisyUI的进度条组件,支持多种颜色主题和进度值动态更新。
|
5
|
+
当不传入value时,将显示不确定进度的动画效果。
|
6
|
+
|
7
|
+
使用示例:
|
8
|
+
```vue
|
9
|
+
<Progress />
|
10
|
+
<Progress :value="40" />
|
11
|
+
<Progress :value="70" color="primary" />
|
12
|
+
<Progress :value="30" color="secondary" />
|
13
|
+
<Progress :value="50" color="accent" />
|
14
|
+
<Progress :value="60" color="info" />
|
15
|
+
<Progress :value="80" color="success" />
|
16
|
+
<Progress :value="90" color="warning" />
|
17
|
+
<Progress :value="20" color="error" />
|
18
|
+
```
|
19
|
+
|
20
|
+
属性说明:
|
21
|
+
- value: 当前进度值
|
22
|
+
- 类型: number
|
23
|
+
- 默认值: undefined (不传入时显示不确定进度动画)
|
24
|
+
- max: 最大值
|
25
|
+
- 类型: number
|
26
|
+
- 默认值: 100
|
27
|
+
- color: 颜色主题
|
28
|
+
- 可选值: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error'
|
29
|
+
- 默认值: 'neutral'
|
30
|
+
-->
|
31
|
+
|
32
|
+
<script setup lang="ts">
|
33
|
+
import { computed } from 'vue'
|
34
|
+
import '../../style';
|
35
|
+
|
36
|
+
interface Props {
|
37
|
+
// 当前进度值
|
38
|
+
value?: number
|
39
|
+
// 最大值
|
40
|
+
max?: number
|
41
|
+
// 颜色主题
|
42
|
+
color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error'
|
43
|
+
}
|
44
|
+
|
45
|
+
const props = withDefaults(defineProps<Props>(), {
|
46
|
+
value: undefined,
|
47
|
+
max: 100,
|
48
|
+
color: 'neutral'
|
49
|
+
})
|
50
|
+
|
51
|
+
// 计算进度条的类名(不能用字符串拼接,需枚举所有可能)
|
52
|
+
const progressClass = computed(() => {
|
53
|
+
const classes = ['cosy:progress', 'cosy:w-56']
|
54
|
+
if (props.color === 'primary') classes.push('cosy:progress-primary')
|
55
|
+
else if (props.color === 'secondary') classes.push('cosy:progress-secondary')
|
56
|
+
else if (props.color === 'accent') classes.push('cosy:progress-accent')
|
57
|
+
else if (props.color === 'info') classes.push('cosy:progress-info')
|
58
|
+
else if (props.color === 'success') classes.push('cosy:progress-success')
|
59
|
+
else if (props.color === 'warning') classes.push('cosy:progress-warning')
|
60
|
+
else if (props.color === 'error') classes.push('cosy:progress-error')
|
61
|
+
// neutral 不加变体类
|
62
|
+
return classes.join(' ')
|
63
|
+
})
|
64
|
+
</script>
|
65
|
+
|
66
|
+
<template>
|
67
|
+
<progress :class="progressClass" :value="value" :max="max"></progress>
|
68
|
+
</template>
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as Progress } from './Progress.vue';
|
@@ -0,0 +1,101 @@
|
|
1
|
+
<!--
|
2
|
+
StatusBar 组件
|
3
|
+
|
4
|
+
一个基于DaisyUI的底部状态栏组件,类似VSCode底部状态栏,采用Raycast风格设计。
|
5
|
+
支持左右两侧内容布局,可以放置按钮、图标和文字等元素。
|
6
|
+
|
7
|
+
使用示例:
|
8
|
+
```vue
|
9
|
+
<StatusBar>
|
10
|
+
<template #left>
|
11
|
+
<span>左侧状态信息</span>
|
12
|
+
</template>
|
13
|
+
<template #right>
|
14
|
+
<span>右侧状态信息</span>
|
15
|
+
</template>
|
16
|
+
</StatusBar>
|
17
|
+
|
18
|
+
<StatusBar>
|
19
|
+
<template #left>
|
20
|
+
<StatusBar.Item>
|
21
|
+
<i class="i-carbon-information"></i>
|
22
|
+
<span>分支: main</span>
|
23
|
+
</StatusBar.Item>
|
24
|
+
<StatusBar.Item>
|
25
|
+
<i class="i-carbon-git-commit"></i>
|
26
|
+
<span>3 changes</span>
|
27
|
+
</StatusBar.Item>
|
28
|
+
</template>
|
29
|
+
<template #right>
|
30
|
+
<StatusBar.Item clickable @click="handleClick">
|
31
|
+
<i class="i-carbon-checkmark"></i>
|
32
|
+
<span>Ready</span>
|
33
|
+
</StatusBar.Item>
|
34
|
+
</template>
|
35
|
+
</StatusBar>
|
36
|
+
```
|
37
|
+
|
38
|
+
属性说明:
|
39
|
+
- variant: 状态栏变体
|
40
|
+
- 可选值: 'default' | 'compact'
|
41
|
+
- 默认值: 'default'
|
42
|
+
- bordered: 是否显示上边框
|
43
|
+
- 类型: boolean
|
44
|
+
- 默认值: true
|
45
|
+
|
46
|
+
插槽:
|
47
|
+
- left: 左侧内容区域
|
48
|
+
- right: 右侧内容区域
|
49
|
+
-->
|
50
|
+
|
51
|
+
<script setup lang="ts">
|
52
|
+
import { computed } from 'vue';
|
53
|
+
import '../../style';
|
54
|
+
|
55
|
+
interface Props {
|
56
|
+
// 状态栏变体
|
57
|
+
variant?: 'default' | 'compact'
|
58
|
+
// 是否显示上边框
|
59
|
+
bordered?: boolean
|
60
|
+
}
|
61
|
+
|
62
|
+
const props = withDefaults(defineProps<Props>(), {
|
63
|
+
variant: 'default',
|
64
|
+
bordered: true
|
65
|
+
})
|
66
|
+
|
67
|
+
// 计算状态栏类名
|
68
|
+
const statusBarClass = computed(() => {
|
69
|
+
return [
|
70
|
+
'cosy:w-full cosy:h-full',
|
71
|
+
'cosy:flex',
|
72
|
+
'cosy:justify-between',
|
73
|
+
'cosy:items-center',
|
74
|
+
'cosy:bg-base-200',
|
75
|
+
'cosy:text-base-content/70',
|
76
|
+
'cosy:text-xs',
|
77
|
+
'no-drag-region',
|
78
|
+
'cosy:transition-all',
|
79
|
+
'cosy:duration-200',
|
80
|
+
{
|
81
|
+
'cosy:h-8': props.variant === 'default',
|
82
|
+
'cosy:h-6': props.variant === 'compact',
|
83
|
+
'cosy:border-t cosy:border-base-300': props.bordered
|
84
|
+
}
|
85
|
+
]
|
86
|
+
})
|
87
|
+
</script>
|
88
|
+
|
89
|
+
<template>
|
90
|
+
<div :class="statusBarClass">
|
91
|
+
<!-- 左侧内容区域 -->
|
92
|
+
<div class="cosy:flex cosy:items-center cosy:h-full cosy:overflow-hidden">
|
93
|
+
<slot name="left"></slot>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<!-- 右侧内容区域 -->
|
97
|
+
<div class="cosy:flex cosy:items-center cosy:h-full cosy:overflow-hidden">
|
98
|
+
<slot name="right"></slot>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
</template>
|
@@ -0,0 +1,97 @@
|
|
1
|
+
<!--
|
2
|
+
StatusBarItem 组件
|
3
|
+
|
4
|
+
一个用于在StatusBar中显示单个状态项的组件,支持可点击和不可点击两种状态。
|
5
|
+
|
6
|
+
使用示例:
|
7
|
+
```vue
|
8
|
+
<StatusBarItem>
|
9
|
+
<i class="i-carbon-information"></i>
|
10
|
+
<span>状态信息</span>
|
11
|
+
</StatusBarItem>
|
12
|
+
|
13
|
+
<StatusBarItem clickable @click="handleClick">
|
14
|
+
<i class="i-carbon-git-branch"></i>
|
15
|
+
<span>main</span>
|
16
|
+
</StatusBarItem>
|
17
|
+
|
18
|
+
<StatusBarItem variant="primary">主要状态</StatusBarItem>
|
19
|
+
<StatusBarItem variant="success">成功状态</StatusBarItem>
|
20
|
+
<StatusBarItem variant="warning">警告状态</StatusBarItem>
|
21
|
+
<StatusBarItem variant="error">错误状态</StatusBarItem>
|
22
|
+
```
|
23
|
+
|
24
|
+
属性说明:
|
25
|
+
- clickable: 是否可点击
|
26
|
+
- 类型: boolean
|
27
|
+
- 默认值: false
|
28
|
+
- variant: 状态项变体
|
29
|
+
- 可选值: 'default' | 'primary' | 'success' | 'warning' | 'error'
|
30
|
+
- 默认值: 'default'
|
31
|
+
- active: 是否激活状态
|
32
|
+
- 类型: boolean
|
33
|
+
- 默认值: false
|
34
|
+
|
35
|
+
事件:
|
36
|
+
- click: 点击状态项时触发(仅在clickable为true时有效)
|
37
|
+
-->
|
38
|
+
|
39
|
+
<script setup lang="ts">
|
40
|
+
import { computed } from 'vue';
|
41
|
+
import '../../style';
|
42
|
+
|
43
|
+
interface Props {
|
44
|
+
// 是否可点击
|
45
|
+
clickable?: boolean
|
46
|
+
// 状态项变体
|
47
|
+
variant?: 'default' | 'primary' | 'success' | 'warning' | 'error'
|
48
|
+
// 是否激活状态
|
49
|
+
active?: boolean
|
50
|
+
}
|
51
|
+
|
52
|
+
const props = withDefaults(defineProps<Props>(), {
|
53
|
+
clickable: false,
|
54
|
+
variant: 'default',
|
55
|
+
active: false
|
56
|
+
})
|
57
|
+
|
58
|
+
const emit = defineEmits<{
|
59
|
+
(e: 'click', event: MouseEvent): void
|
60
|
+
}>()
|
61
|
+
|
62
|
+
const handleClick = (event: MouseEvent) => {
|
63
|
+
if (props.clickable) {
|
64
|
+
emit('click', event)
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
// 计算状态项类名
|
69
|
+
const itemClass = computed(() => {
|
70
|
+
return [
|
71
|
+
'cosy:status-bar-item',
|
72
|
+
'cosy:h-full',
|
73
|
+
'cosy:flex',
|
74
|
+
'cosy:items-center',
|
75
|
+
'cosy:gap-1',
|
76
|
+
'cosy:px-2',
|
77
|
+
'cosy:text-xs',
|
78
|
+
'cosy:transition-all',
|
79
|
+
'cosy:duration-200',
|
80
|
+
{
|
81
|
+
'cosy:cursor-pointer cosy:hover:bg-base-300': props.clickable,
|
82
|
+
'cosy:cursor-default': !props.clickable,
|
83
|
+
'cosy:bg-base-300': props.active,
|
84
|
+
'cosy:text-primary': props.variant === 'primary',
|
85
|
+
'cosy:text-success': props.variant === 'success',
|
86
|
+
'cosy:text-warning': props.variant === 'warning',
|
87
|
+
'cosy:text-error': props.variant === 'error'
|
88
|
+
}
|
89
|
+
]
|
90
|
+
})
|
91
|
+
</script>
|
92
|
+
|
93
|
+
<template>
|
94
|
+
<div :class="itemClass" @click="handleClick">
|
95
|
+
<slot></slot>
|
96
|
+
</div>
|
97
|
+
</template>
|
@@ -0,0 +1,95 @@
|
|
1
|
+
<!--
|
2
|
+
ToolBar 组件
|
3
|
+
|
4
|
+
一个基于 DaisyUI navbar 的顶部工具栏组件,采用现代化设计。
|
5
|
+
支持左中右三段式布局,可以放置按钮、输入框、图标和文字等元素。
|
6
|
+
|
7
|
+
使用示例:
|
8
|
+
```vue
|
9
|
+
<ToolBar>
|
10
|
+
<template #left>
|
11
|
+
<button class="btn btn-ghost btn-sm">
|
12
|
+
<i class="i-carbon-menu"></i>
|
13
|
+
</button>
|
14
|
+
</template>
|
15
|
+
<template #center>
|
16
|
+
<div class="w-full max-w-2xl">
|
17
|
+
<input type="text" class="input input-sm w-full bg-base-300" placeholder="输入URL地址" />
|
18
|
+
</div>
|
19
|
+
</template>
|
20
|
+
<template #right>
|
21
|
+
<button class="btn btn-ghost btn-sm" @click="handleRefresh">
|
22
|
+
<i class="i-carbon-refresh"></i>
|
23
|
+
</button>
|
24
|
+
</template>
|
25
|
+
</ToolBar>
|
26
|
+
```
|
27
|
+
|
28
|
+
属性说明:
|
29
|
+
- variant: 工具栏变体
|
30
|
+
- 可选值: 'default' | 'compact'
|
31
|
+
- 默认值: 'default'
|
32
|
+
- bordered: 是否显示下边框
|
33
|
+
- 类型: boolean
|
34
|
+
- 默认值: true
|
35
|
+
|
36
|
+
插槽:
|
37
|
+
- left: 左侧内容区域
|
38
|
+
- center: 中间内容区域
|
39
|
+
- right: 右侧内容区域
|
40
|
+
-->
|
41
|
+
|
42
|
+
<script setup lang="ts">
|
43
|
+
import { computed } from 'vue';
|
44
|
+
import '../../style';
|
45
|
+
|
46
|
+
interface Props {
|
47
|
+
// 工具栏变体
|
48
|
+
variant?: 'default' | 'compact'
|
49
|
+
// 是否显示下边框
|
50
|
+
bordered?: boolean
|
51
|
+
}
|
52
|
+
|
53
|
+
const props = withDefaults(defineProps<Props>(), {
|
54
|
+
variant: 'default',
|
55
|
+
bordered: true
|
56
|
+
})
|
57
|
+
|
58
|
+
// 计算工具栏类名
|
59
|
+
const toolBarClass = computed(() => {
|
60
|
+
return [
|
61
|
+
'cosy:navbar',
|
62
|
+
'cosy:bg-base-200',
|
63
|
+
'cosy:text-base-content/70',
|
64
|
+
'cosy:text-sm',
|
65
|
+
'no-drag-region',
|
66
|
+
'cosy:transition-all',
|
67
|
+
'cosy:duration-200',
|
68
|
+
'cosy:rounded-box',
|
69
|
+
{
|
70
|
+
'cosy:min-h-12': props.variant === 'default',
|
71
|
+
'cosy:min-h-10': props.variant === 'compact',
|
72
|
+
'cosy:border-b cosy:border-base-300': props.bordered
|
73
|
+
}
|
74
|
+
]
|
75
|
+
})
|
76
|
+
</script>
|
77
|
+
|
78
|
+
<template>
|
79
|
+
<div :class="toolBarClass">
|
80
|
+
<!-- 左侧内容区域 -->
|
81
|
+
<div class="cosy:navbar-start">
|
82
|
+
<slot name="left"></slot>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<!-- 中间内容区域 -->
|
86
|
+
<div class="cosy:navbar-center">
|
87
|
+
<slot name="center"></slot>
|
88
|
+
</div>
|
89
|
+
|
90
|
+
<!-- 右侧内容区域 -->
|
91
|
+
<div class="cosy:navbar-end">
|
92
|
+
<slot name="right"></slot>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
</template>
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as ToolBar } from './ToolBar.vue';
|