echo-library-vue 1.0.0
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/LICENSE +21 -0
- package/README.md +226 -0
- package/dist/components/Button/index.d.ts +6 -0
- package/dist/components/Button/index.vue.d.ts +56 -0
- package/dist/components/Button/types.d.ts +11 -0
- package/dist/components/ColorPicker/constant.d.ts +1 -0
- package/dist/components/ColorPicker/index.d.ts +6 -0
- package/dist/components/ColorPicker/index.vue.d.ts +54 -0
- package/dist/components/ColorPicker/types.d.ts +11 -0
- package/dist/components/ColorPicker/utils.d.ts +156 -0
- package/dist/components/Dropdown/index.d.ts +6 -0
- package/dist/components/Dropdown/index.vue.d.ts +53 -0
- package/dist/components/Dropdown/types.d.ts +44 -0
- package/dist/components/Icon/index.d.ts +6 -0
- package/dist/components/Icon/index.vue.d.ts +44 -0
- package/dist/components/Icon/types.d.ts +6 -0
- package/dist/components/Input/index.d.ts +6 -0
- package/dist/components/Input/index.vue.d.ts +67 -0
- package/dist/components/Input/types.d.ts +14 -0
- package/dist/index.d.ts +598 -0
- package/dist/index.esm.js +676 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +120 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Echo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Echo Library Vue
|
|
2
|
+
|
|
3
|
+
一个基于 Vue 3 + TypeScript 的现代化组件库,提供高质量、可复用的 UI 组件。
|
|
4
|
+
|
|
5
|
+
## 🎯 项目目标
|
|
6
|
+
|
|
7
|
+
- 提供一套完整的 Vue 3 + TypeScript UI 组件库
|
|
8
|
+
- 支持按需引入,减少打包体积
|
|
9
|
+
- 提供完整的 TypeScript 类型支持
|
|
10
|
+
- 支持主题定制和样式覆盖
|
|
11
|
+
- 提供详细的文档和示例
|
|
12
|
+
|
|
13
|
+
## 🏗️ 项目架构
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
echo-library-vue/
|
|
17
|
+
├── packages/ # 组件包目录
|
|
18
|
+
│ ├── components/ # 组件源码
|
|
19
|
+
│ ├── utils/ # 工具函数
|
|
20
|
+
│ └── styles/ # 样式文件
|
|
21
|
+
├── docs/ # 文档目录
|
|
22
|
+
├── src/ # 示例项目
|
|
23
|
+
├── scripts/ # 构建脚本
|
|
24
|
+
├── tests/ # 测试文件
|
|
25
|
+
└── dist/ # 构建输出
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 🚀 快速开始
|
|
29
|
+
|
|
30
|
+
### 安装
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install echo-library-vue
|
|
34
|
+
# 或
|
|
35
|
+
yarn add echo-library-vue
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 使用
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// 完整引入
|
|
42
|
+
import { createApp } from 'vue'
|
|
43
|
+
import { EchoLibrary } from 'echo-library-vue'
|
|
44
|
+
import 'echo-library-vue/dist/style.css'
|
|
45
|
+
|
|
46
|
+
const app = createApp(App)
|
|
47
|
+
app.use(EchoLibrary)
|
|
48
|
+
app.mount('#app')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// 按需引入
|
|
53
|
+
import { Button, Input } from 'echo-library-vue'
|
|
54
|
+
import 'echo-library-vue/dist/button/style.css'
|
|
55
|
+
import 'echo-library-vue/dist/input/style.css'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 📦 组件列表
|
|
59
|
+
|
|
60
|
+
### 基础组件
|
|
61
|
+
|
|
62
|
+
- [x] Button - 按钮组件
|
|
63
|
+
- [x] Input - 输入框组件
|
|
64
|
+
- [x] Icon - 图标组件
|
|
65
|
+
|
|
66
|
+
### 布局组件
|
|
67
|
+
|
|
68
|
+
- [ ] Layout - 布局组件
|
|
69
|
+
- [ ] Grid - 栅格组件
|
|
70
|
+
- [ ] Space - 间距组件
|
|
71
|
+
|
|
72
|
+
### 数据展示
|
|
73
|
+
|
|
74
|
+
- [ ] Table - 表格组件
|
|
75
|
+
- [ ] Card - 卡片组件
|
|
76
|
+
- [ ] Tag - 标签组件
|
|
77
|
+
|
|
78
|
+
### 反馈组件
|
|
79
|
+
|
|
80
|
+
- [ ] Modal - 对话框组件
|
|
81
|
+
- [ ] Message - 消息提示
|
|
82
|
+
- [ ] Loading - 加载组件
|
|
83
|
+
|
|
84
|
+
### 导航组件
|
|
85
|
+
|
|
86
|
+
- [ ] Menu - 菜单组件
|
|
87
|
+
- [ ] Tabs - 标签页组件
|
|
88
|
+
- [ ] Breadcrumb - 面包屑组件
|
|
89
|
+
|
|
90
|
+
## 🛠️ 开发指南
|
|
91
|
+
|
|
92
|
+
### 环境要求
|
|
93
|
+
|
|
94
|
+
- Node.js >= 16
|
|
95
|
+
- npm >= 8 或 yarn >= 1.22
|
|
96
|
+
|
|
97
|
+
### 开发命令
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# 安装依赖
|
|
101
|
+
npm install
|
|
102
|
+
|
|
103
|
+
# 启动开发服务器
|
|
104
|
+
npm run dev
|
|
105
|
+
|
|
106
|
+
# 构建组件库
|
|
107
|
+
npm run build
|
|
108
|
+
|
|
109
|
+
# 运行测试
|
|
110
|
+
npm run test
|
|
111
|
+
|
|
112
|
+
# 生成文档
|
|
113
|
+
npm run docs:dev
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 添加新组件
|
|
117
|
+
|
|
118
|
+
1. 在 `packages/components` 目录下创建组件文件夹
|
|
119
|
+
2. 创建组件文件:`index.vue`、`index.ts`、`style.scss`
|
|
120
|
+
3. 在 `packages/index.ts` 中导出组件
|
|
121
|
+
4. 在 `docs` 目录下添加组件文档
|
|
122
|
+
5. 编写测试用例
|
|
123
|
+
|
|
124
|
+
## 🎨 主题定制
|
|
125
|
+
|
|
126
|
+
组件库支持主题定制,可以通过 CSS 变量覆盖默认样式:
|
|
127
|
+
|
|
128
|
+
```css
|
|
129
|
+
:root {
|
|
130
|
+
--echo-primary-color: #1890ff;
|
|
131
|
+
--echo-border-radius: 6px;
|
|
132
|
+
--echo-font-size: 14px;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## 📝 贡献指南
|
|
137
|
+
|
|
138
|
+
1. Fork 项目
|
|
139
|
+
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
|
|
140
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
141
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
142
|
+
5. 打开 Pull Request
|
|
143
|
+
|
|
144
|
+
## 📄 许可证
|
|
145
|
+
|
|
146
|
+
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
|
|
147
|
+
|
|
148
|
+
## 🤝 联系我们
|
|
149
|
+
|
|
150
|
+
如有问题或建议,请提交 Issue 或联系开发团队。
|
|
151
|
+
|
|
152
|
+
## 📋 项目完成总结
|
|
153
|
+
|
|
154
|
+
### ✅ 已完成的功能
|
|
155
|
+
|
|
156
|
+
1. **项目架构搭建**
|
|
157
|
+
- 使用 Vite 作为构建工具
|
|
158
|
+
- 配置 TypeScript 支持
|
|
159
|
+
- 设置 ESLint 和 Prettier 代码规范
|
|
160
|
+
- 配置 Vitest 测试框架
|
|
161
|
+
|
|
162
|
+
2. **核心组件开发**
|
|
163
|
+
- **Button 按钮组件**: 支持多种类型、尺寸、状态
|
|
164
|
+
- **Input 输入框组件**: 支持前缀/后缀图标、清除功能、字数限制
|
|
165
|
+
- **Icon 图标组件**: 内置常用图标,支持自定义大小和颜色
|
|
166
|
+
|
|
167
|
+
3. **样式系统**
|
|
168
|
+
- 基于 CSS 变量的主题系统
|
|
169
|
+
- 响应式设计支持
|
|
170
|
+
- 完整的工具类库
|
|
171
|
+
- 动画效果
|
|
172
|
+
|
|
173
|
+
4. **开发工具**
|
|
174
|
+
- 热重载开发服务器
|
|
175
|
+
- 组件库构建配置
|
|
176
|
+
- 类型声明文件生成
|
|
177
|
+
- 测试用例示例
|
|
178
|
+
|
|
179
|
+
5. **文档和示例**
|
|
180
|
+
- 详细的 README 文档
|
|
181
|
+
- 组件使用示例
|
|
182
|
+
- 在线演示页面
|
|
183
|
+
|
|
184
|
+
### 🚀 使用方法
|
|
185
|
+
|
|
186
|
+
1. **启动开发服务器**
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
npm run dev
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
2. **构建组件库**
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npm run build:lib
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
3. **运行测试**
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
npm run test
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
4. **启动文档服务器**
|
|
205
|
+
```bash
|
|
206
|
+
npm run docs:dev
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 🎯 技术特点
|
|
210
|
+
|
|
211
|
+
- **现代化**: 基于 Vue 3 Composition API 和 TypeScript
|
|
212
|
+
- **可扩展**: 模块化设计,易于添加新组件
|
|
213
|
+
- **类型安全**: 完整的 TypeScript 类型支持
|
|
214
|
+
- **主题定制**: 通过 CSS 变量轻松定制主题
|
|
215
|
+
- **按需引入**: 支持按需引入,减少打包体积
|
|
216
|
+
- **测试覆盖**: 完整的单元测试支持
|
|
217
|
+
|
|
218
|
+
### 📈 后续规划
|
|
219
|
+
|
|
220
|
+
1. **更多组件**: 添加 Layout、Grid、Table、Modal 等组件
|
|
221
|
+
2. **文档完善**: 使用 VitePress 构建完整的文档网站
|
|
222
|
+
3. **国际化**: 支持多语言
|
|
223
|
+
4. **性能优化**: 进一步优化打包体积和运行时性能
|
|
224
|
+
5. **社区建设**: 建立贡献指南和社区规范
|
|
225
|
+
|
|
226
|
+
这个组件库项目已经具备了完整的基础架构和核心功能,可以作为进一步开发的基础。
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ButtonProps } from './types.ts';
|
|
2
|
+
|
|
3
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ButtonProps>, {
|
|
4
|
+
type: string;
|
|
5
|
+
size: string;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
round: boolean;
|
|
9
|
+
plain: boolean;
|
|
10
|
+
icon: string;
|
|
11
|
+
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
12
|
+
click: (event: MouseEvent) => void;
|
|
13
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ButtonProps>, {
|
|
14
|
+
type: string;
|
|
15
|
+
size: string;
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
round: boolean;
|
|
19
|
+
plain: boolean;
|
|
20
|
+
icon: string;
|
|
21
|
+
}>>> & Readonly<{
|
|
22
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
23
|
+
}>, {
|
|
24
|
+
size: import('./types.ts').ButtonSize;
|
|
25
|
+
type: import('./types.ts').ButtonType;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
round: boolean;
|
|
29
|
+
plain: boolean;
|
|
30
|
+
icon: string;
|
|
31
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>, {
|
|
32
|
+
default?(_: {}): any;
|
|
33
|
+
}>;
|
|
34
|
+
export default _default;
|
|
35
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
36
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
37
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
38
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
39
|
+
} : {
|
|
40
|
+
type: import('vue').PropType<T[K]>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
type __VLS_WithDefaults<P, D> = {
|
|
45
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
46
|
+
default: D[K];
|
|
47
|
+
}> : P[K];
|
|
48
|
+
};
|
|
49
|
+
type __VLS_Prettify<T> = {
|
|
50
|
+
[K in keyof T]: T[K];
|
|
51
|
+
} & {};
|
|
52
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
53
|
+
new (): {
|
|
54
|
+
$slots: S;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ButtonType = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info';
|
|
2
|
+
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
type?: ButtonType;
|
|
5
|
+
size?: ButtonSize;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
round?: boolean;
|
|
9
|
+
plain?: boolean;
|
|
10
|
+
icon?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_COLORS: string[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ColorPickerProps } from './types.ts';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ColorPickerProps>, {
|
|
4
|
+
theme: string;
|
|
5
|
+
type: string;
|
|
6
|
+
mode: string;
|
|
7
|
+
showAlpha: boolean;
|
|
8
|
+
showEyeDropper: boolean;
|
|
9
|
+
showPickerMode: boolean;
|
|
10
|
+
showColorList: boolean;
|
|
11
|
+
defaultColors: () => string[];
|
|
12
|
+
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
13
|
+
"update:color": (color: string) => void;
|
|
14
|
+
colorChange: (color: string) => void;
|
|
15
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ColorPickerProps>, {
|
|
16
|
+
theme: string;
|
|
17
|
+
type: string;
|
|
18
|
+
mode: string;
|
|
19
|
+
showAlpha: boolean;
|
|
20
|
+
showEyeDropper: boolean;
|
|
21
|
+
showPickerMode: boolean;
|
|
22
|
+
showColorList: boolean;
|
|
23
|
+
defaultColors: () => string[];
|
|
24
|
+
}>>> & Readonly<{
|
|
25
|
+
"onUpdate:color"?: ((color: string) => any) | undefined;
|
|
26
|
+
onColorChange?: ((color: string) => any) | undefined;
|
|
27
|
+
}>, {
|
|
28
|
+
type: "hex" | "rgb" | "hsl";
|
|
29
|
+
mode: "solid" | "gradient";
|
|
30
|
+
theme: "light" | "dark";
|
|
31
|
+
showAlpha: boolean;
|
|
32
|
+
showEyeDropper: boolean;
|
|
33
|
+
showPickerMode: boolean;
|
|
34
|
+
showColorList: boolean;
|
|
35
|
+
defaultColors: string[];
|
|
36
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
37
|
+
export default _default;
|
|
38
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
39
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
40
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
41
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
42
|
+
} : {
|
|
43
|
+
type: import('vue').PropType<T[K]>;
|
|
44
|
+
required: true;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
type __VLS_WithDefaults<P, D> = {
|
|
48
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
49
|
+
default: D[K];
|
|
50
|
+
}> : P[K];
|
|
51
|
+
};
|
|
52
|
+
type __VLS_Prettify<T> = {
|
|
53
|
+
[K in keyof T]: T[K];
|
|
54
|
+
} & {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ColorPickerProps {
|
|
2
|
+
color?: string | null;
|
|
3
|
+
theme?: 'light' | 'dark';
|
|
4
|
+
type?: 'hex' | 'rgb' | 'hsl';
|
|
5
|
+
mode?: 'solid' | 'gradient';
|
|
6
|
+
showAlpha?: boolean;
|
|
7
|
+
showEyeDropper?: boolean;
|
|
8
|
+
showPickerMode?: boolean;
|
|
9
|
+
showColorList?: boolean;
|
|
10
|
+
defaultColors?: string[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 颜色工具函数
|
|
3
|
+
* 用于颜色格式之间的转换
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* HEX 转 RGB
|
|
7
|
+
* @param hex
|
|
8
|
+
* @returns RGB对象 {r, g, b}
|
|
9
|
+
*/
|
|
10
|
+
export declare const hexToRgb: (hex: string) => {
|
|
11
|
+
r: number;
|
|
12
|
+
g: number;
|
|
13
|
+
b: number;
|
|
14
|
+
} | null;
|
|
15
|
+
/**
|
|
16
|
+
* rgb转hex
|
|
17
|
+
* @param r 红色值 0-255
|
|
18
|
+
* @param g 绿色值 0-255
|
|
19
|
+
* @param b 蓝色值 0-255
|
|
20
|
+
* @returnd HEX颜色值
|
|
21
|
+
*/
|
|
22
|
+
export declare const rgbToHex: (r: number, g: number, b: number) => string;
|
|
23
|
+
/**
|
|
24
|
+
* RGB 转 HSL
|
|
25
|
+
* @param r 红色值 0-255
|
|
26
|
+
* @param g 绿色值 0-255
|
|
27
|
+
* @param b 蓝色值 0-255
|
|
28
|
+
* @returns HSL对象 {h, s, l}, h: 0-360, s: 0-100, l: 0-100
|
|
29
|
+
*/
|
|
30
|
+
export declare const rgbToHsl: (r: number, g: number, b: number) => {
|
|
31
|
+
h: number;
|
|
32
|
+
s: number;
|
|
33
|
+
l: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* HSL 转 RGB
|
|
37
|
+
* @param h 色相 0-360
|
|
38
|
+
* @param s 饱和度 0-100
|
|
39
|
+
* @param l 明度 0-100
|
|
40
|
+
* @returns RGB对象 {r, g, b}
|
|
41
|
+
*/
|
|
42
|
+
export declare function hslToRgb(h: number, s: number, l: number): {
|
|
43
|
+
r: number;
|
|
44
|
+
g: number;
|
|
45
|
+
b: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* HEX 转 HSL
|
|
49
|
+
* @param hex HEX颜色值
|
|
50
|
+
* @returns HSL对象
|
|
51
|
+
*/
|
|
52
|
+
export declare function hexToHsl(hex: string): {
|
|
53
|
+
h: number;
|
|
54
|
+
s: number;
|
|
55
|
+
l: number;
|
|
56
|
+
} | null;
|
|
57
|
+
/**
|
|
58
|
+
* HSL 转 HEX
|
|
59
|
+
* @param h 色相
|
|
60
|
+
* @param s 饱和度
|
|
61
|
+
* @param l 明度
|
|
62
|
+
* @returns HEX颜色值
|
|
63
|
+
*/
|
|
64
|
+
export declare function hslToHex(h: number, s: number, l: number): string;
|
|
65
|
+
/**
|
|
66
|
+
* 验证 HEX 颜色格式
|
|
67
|
+
* @param hex HEX颜色值
|
|
68
|
+
* @returns 是否为有效格式
|
|
69
|
+
*/
|
|
70
|
+
export declare function isValidHex(hex: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* HEX 转 RGBA
|
|
73
|
+
* @param hex HEX颜色值(支持 #RRGGBB 或 #RRGGBBAA)
|
|
74
|
+
* @param alpha 透明度 0-1,如果不提供则从hex中解析
|
|
75
|
+
* @returns RGBA对象 {r, g, b, a}
|
|
76
|
+
*/
|
|
77
|
+
export declare function hexToRgba(hex: string, alpha?: number): {
|
|
78
|
+
r: number;
|
|
79
|
+
g: number;
|
|
80
|
+
b: number;
|
|
81
|
+
a: number;
|
|
82
|
+
} | null;
|
|
83
|
+
/**
|
|
84
|
+
* RGBA 转 HEX(8位带透明度)
|
|
85
|
+
* @param r 红色值 0-255
|
|
86
|
+
* @param g 绿色值 0-255
|
|
87
|
+
* @param b 蓝色值 0-255
|
|
88
|
+
* @param a 透明度 0-1
|
|
89
|
+
* @returns HEX颜色值 #RRGGBBAA
|
|
90
|
+
*/
|
|
91
|
+
export declare function rgbaToHex(r: number, g: number, b: number, a?: number): string;
|
|
92
|
+
/**
|
|
93
|
+
* RGBA 转 HEX(6位不带透明度)
|
|
94
|
+
* @param r 红色值 0-255
|
|
95
|
+
* @param g 绿色值 0-255
|
|
96
|
+
* @param b 蓝色值 0-255
|
|
97
|
+
* @returns HEX颜色值 #RRGGBB
|
|
98
|
+
*/
|
|
99
|
+
export declare function rgbToHexWithoutAlpha(r: number, g: number, b: number): string;
|
|
100
|
+
/**
|
|
101
|
+
* HSL 转 RGBA
|
|
102
|
+
* @param h 色相 0-360
|
|
103
|
+
* @param s 饱和度 0-100
|
|
104
|
+
* @param l 明度 0-100
|
|
105
|
+
* @param a 透明度 0-1
|
|
106
|
+
* @returns RGBA对象
|
|
107
|
+
*/
|
|
108
|
+
export declare function hslaToRgba(h: number, s: number, l: number, a?: number): {
|
|
109
|
+
r: number;
|
|
110
|
+
g: number;
|
|
111
|
+
b: number;
|
|
112
|
+
a: number;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* RGBA 转 HSL
|
|
116
|
+
* @param r 红色值 0-255
|
|
117
|
+
* @param g 绿色值 0-255
|
|
118
|
+
* @param b 蓝色值 0-255
|
|
119
|
+
* @param a 透明度 0-1
|
|
120
|
+
* @returns HSLA对象 {h, s, l, a}
|
|
121
|
+
*/
|
|
122
|
+
export declare function rgbaToHsla(r: number, g: number, b: number, a?: number): {
|
|
123
|
+
h: number;
|
|
124
|
+
s: number;
|
|
125
|
+
l: number;
|
|
126
|
+
a: number;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* HSL 转 RGBA HEX(8位)
|
|
130
|
+
* @param h 色相
|
|
131
|
+
* @param s 饱和度
|
|
132
|
+
* @param l 明度
|
|
133
|
+
* @param a 透明度
|
|
134
|
+
* @returns HEX颜色值 #RRGGBBAA
|
|
135
|
+
*/
|
|
136
|
+
export declare function hslaToHex(h: number, s: number, l: number, a?: number): string;
|
|
137
|
+
/**
|
|
138
|
+
* HEX 转 HSLA
|
|
139
|
+
* @param hex HEX颜色值(支持 #RRGGBB 或 #RRGGBBAA)
|
|
140
|
+
* @returns HSLA对象
|
|
141
|
+
*/
|
|
142
|
+
export declare function hexToHsla(hex: string): {
|
|
143
|
+
h: number;
|
|
144
|
+
s: number;
|
|
145
|
+
l: number;
|
|
146
|
+
a: number;
|
|
147
|
+
} | null;
|
|
148
|
+
/**
|
|
149
|
+
* RGBA 转 CSS rgba 字符串
|
|
150
|
+
* @param r 红色值 0-255
|
|
151
|
+
* @param g 绿色值 0-255
|
|
152
|
+
* @param b 蓝色值 0-255
|
|
153
|
+
* @param a 透明度 0-1
|
|
154
|
+
* @returns CSS rgba 字符串
|
|
155
|
+
*/
|
|
156
|
+
export declare function rgbaToCss(r: number, g: number, b: number, a?: number): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DropdownItem, DropdownProps } from './types.ts';
|
|
2
|
+
|
|
3
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<DropdownProps>, {
|
|
4
|
+
trigger: string;
|
|
5
|
+
placement: string;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
items: () => never[];
|
|
8
|
+
hideOnClick: boolean;
|
|
9
|
+
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
10
|
+
select: (item: DropdownItem, index: number) => void;
|
|
11
|
+
openChange: (opened: boolean) => void;
|
|
12
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<DropdownProps>, {
|
|
13
|
+
trigger: string;
|
|
14
|
+
placement: string;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
items: () => never[];
|
|
17
|
+
hideOnClick: boolean;
|
|
18
|
+
}>>> & Readonly<{
|
|
19
|
+
onSelect?: ((item: DropdownItem, index: number) => any) | undefined;
|
|
20
|
+
onOpenChange?: ((opened: boolean) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
trigger: "click" | "hover";
|
|
24
|
+
placement: "bottom" | "left" | "right" | "top" | "top-start" | "top-end" | "top-center" | "bottom-start" | "bottom-end" | "bottom-center" | "left-start" | "left-end" | "left-center" | "right-start" | "right-end" | "right-center";
|
|
25
|
+
items: DropdownItem[];
|
|
26
|
+
hideOnClick: boolean;
|
|
27
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>, {
|
|
28
|
+
default?(_: {}): any;
|
|
29
|
+
menu?(_: {}): any;
|
|
30
|
+
}>;
|
|
31
|
+
export default _default;
|
|
32
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
33
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
34
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
35
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
36
|
+
} : {
|
|
37
|
+
type: import('vue').PropType<T[K]>;
|
|
38
|
+
required: true;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type __VLS_WithDefaults<P, D> = {
|
|
42
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
43
|
+
default: D[K];
|
|
44
|
+
}> : P[K];
|
|
45
|
+
};
|
|
46
|
+
type __VLS_Prettify<T> = {
|
|
47
|
+
[K in keyof T]: T[K];
|
|
48
|
+
} & {};
|
|
49
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
50
|
+
new (): {
|
|
51
|
+
$slots: S;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Component, CSSProperties } from 'vue';
|
|
2
|
+
|
|
3
|
+
export interface DropdownProps {
|
|
4
|
+
/** 触发方式 */
|
|
5
|
+
trigger?: 'click' | 'hover';
|
|
6
|
+
/** 弹出方向 */
|
|
7
|
+
placement?: 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'top-center' | 'bottom-start' | 'bottom-end' | 'bottom-center' | 'left-start' | 'left-end' | 'left-center' | 'right-start' | 'right-end' | 'right-center';
|
|
8
|
+
/** 菜单项 */
|
|
9
|
+
items: DropdownItem[];
|
|
10
|
+
/** 是否禁用 */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** 菜单渲染父节点 */
|
|
13
|
+
getPopupContainer?: () => HTMLElement | string;
|
|
14
|
+
/** 菜单类名 */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** 菜单样式 */
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
/** 是否隐藏菜单 */
|
|
19
|
+
hideOnClick?: boolean;
|
|
20
|
+
/** 触发器图标 */
|
|
21
|
+
icon?: Component;
|
|
22
|
+
}
|
|
23
|
+
export interface DropdownItem {
|
|
24
|
+
/** 唯一标识 */
|
|
25
|
+
key: string | number;
|
|
26
|
+
/** 显示文本 */
|
|
27
|
+
label: string;
|
|
28
|
+
/** 图标 */
|
|
29
|
+
icon?: string;
|
|
30
|
+
/** 子菜单 */
|
|
31
|
+
children?: DropdownItem[];
|
|
32
|
+
/** 是否禁用 */
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/** 是否显示分割线 */
|
|
35
|
+
divider?: boolean;
|
|
36
|
+
/** 是否选中 */
|
|
37
|
+
checked?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface DropdownEmits {
|
|
40
|
+
/** 菜单项点击 */
|
|
41
|
+
(e: 'select', item: DropdownItem, index: number): void;
|
|
42
|
+
/** 菜单显示状态改变 */
|
|
43
|
+
(e: 'openChange', opened: boolean): void;
|
|
44
|
+
}
|