@mc-markets/ui 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.
Files changed (36) hide show
  1. package/README.md +502 -0
  2. package/dist/index.js +23 -0
  3. package/dist/packages/components/Dialog/index.vue.d.ts +51 -0
  4. package/dist/packages/components/Grid/components/GridItem.vue.d.ts +37 -0
  5. package/dist/packages/components/Grid/index.vue.d.ts +31 -0
  6. package/dist/packages/components/Grid/interface/index.d.ts +5 -0
  7. package/dist/packages/components/Icon/index.vue.d.ts +2 -0
  8. package/dist/packages/components/SearchBar/index.vue.d.ts +42 -0
  9. package/dist/packages/components/SearchForm/components/SearchFormItem.vue.d.ts +24 -0
  10. package/dist/packages/components/SearchForm/index.vue.d.ts +3019 -0
  11. package/dist/packages/components/proForm/components/FormItem.vue.d.ts +46 -0
  12. package/dist/packages/components/proForm/components/interface/index.d.ts +66 -0
  13. package/dist/packages/components/proForm/index.vue.d.ts +230 -0
  14. package/dist/packages/components/proTable/components/ColSetting.vue.d.ts +8 -0
  15. package/dist/packages/components/proTable/components/Pagination.vue.d.ts +17 -0
  16. package/dist/packages/components/proTable/components/TableColumn.vue.d.ts +6 -0
  17. package/dist/packages/components/proTable/interface/index.d.ts +66 -0
  18. package/dist/packages/hooks/interface/index.d.ts +28 -0
  19. package/dist/packages/hooks/useSelection.d.ts +16 -0
  20. package/dist/packages/hooks/useTable.d.ts +54 -0
  21. package/dist/packages/index.d.ts +24 -0
  22. package/dist/packages/utils/common.d.ts +13 -0
  23. package/dist/packages/utils/composables/useGlobalProperties.d.ts +1 -0
  24. package/dist/packages/utils/dayjs.d.ts +2 -0
  25. package/dist/packages/utils/directive.d.ts +2 -0
  26. package/dist/packages/utils/eventBus.d.ts +2 -0
  27. package/dist/packages/utils/index.d.ts +152 -0
  28. package/dist/packages/utils/is/index.d.ts +72 -0
  29. package/dist/packages/utils/validate.d.ts +112 -0
  30. package/dist/src/api/index.d.ts +24 -0
  31. package/dist/src/api/interface/index.d.ts +34 -0
  32. package/dist/src/api/test.d.ts +1 -0
  33. package/dist/src/main.d.ts +0 -0
  34. package/dist/style.css +1 -0
  35. package/dist/vite.config.d.ts +2 -0
  36. package/package.json +151 -0
package/README.md ADDED
@@ -0,0 +1,502 @@
1
+ # mc-pro-ui
2
+
3
+ 一个功能强大的 Vue 3 UI 组件库,提供完整的 TypeScript 支持,基于 Element Plus 构建,包含专业的表格、表单、搜索等组件。
4
+
5
+ ## ✨ 特性
6
+
7
+ - 🚀 **Vue 3 + TypeScript** - 完全支持 Vue 3 Composition API 和 TypeScript
8
+ - 🎨 **Element Plus 集成** - 基于 Element Plus 构建,保持一致的视觉风格
9
+ - 📊 **专业表格组件** - ProTable 支持搜索、分页、列设置、拖拽排序等
10
+ - 🔍 **智能搜索表单** - SearchForm 支持响应式布局和多种表单控件
11
+ - 📝 **高级表单组件** - ProForm 支持动态表单和复杂布局
12
+ - 🎯 **响应式网格系统** - Grid 组件支持断点响应式布局
13
+ - 🎭 **灵活对话框** - Dialog 组件支持多种配置选项
14
+ - 🔧 **开箱即用** - 提供完整的类型定义和示例代码
15
+
16
+ ## 📦 安装
17
+
18
+ ```bash
19
+ npm install mc-pro-ui
20
+ # 或
21
+ yarn add mc-pro-ui
22
+ # 或
23
+ pnpm add mc-pro-ui
24
+ ```
25
+
26
+ ## 🔧 使用
27
+
28
+ ### 完整引入
29
+
30
+ ```typescript
31
+ import { createApp } from 'vue'
32
+ import mcProUi from 'mc-pro-ui'
33
+ import 'mc-pro-ui/dist/style.css'
34
+
35
+ const app = createApp(App)
36
+ app.use(mcProUi)
37
+ app.mount('#app')
38
+ ```
39
+
40
+ ### 按需引入
41
+
42
+ ```typescript
43
+ import { createApp } from 'vue'
44
+ import { ProTable, SearchForm, ProForm, Grid, Dialog } from 'mc-pro-ui'
45
+ import 'mc-pro-ui/dist/style.css'
46
+
47
+ const app = createApp(App)
48
+ app.component('ProTable', ProTable)
49
+ app.component('SearchForm', SearchForm)
50
+ app.component('ProForm', ProForm)
51
+ app.component('Grid', Grid)
52
+ app.component('Dialog', Dialog)
53
+ app.mount('#app')
54
+ ```
55
+
56
+ ## 🎯 组件使用
57
+
58
+ ### ProTable - 专业表格组件
59
+
60
+ 功能强大的表格组件,支持搜索、分页、列设置、拖拽排序等。
61
+
62
+ ```vue
63
+ <template>
64
+ <ProTable
65
+ :columns="columns"
66
+ :request-api="getTableList"
67
+ :pagination="true"
68
+ :tool-button="['refresh', 'setting', 'search']"
69
+ @search="handleSearch"
70
+ @reset="handleReset"
71
+ >
72
+ <!-- 自定义表格头部 -->
73
+ <template #tableHeader="{ selectedList, isSelected }">
74
+ <el-button
75
+ type="primary"
76
+ :disabled="!isSelected"
77
+ @click="handleBatchDelete(selectedList)"
78
+ >
79
+ 批量删除
80
+ </el-button>
81
+ </template>
82
+
83
+ <!-- 自定义操作列 -->
84
+ <template #operation="{ row }">
85
+ <el-button type="primary" @click="handleEdit(row)">编辑</el-button>
86
+ <el-button type="danger" @click="handleDelete(row)">删除</el-button>
87
+ </template>
88
+ </ProTable>
89
+ </template>
90
+
91
+ <script setup lang="ts">
92
+ import { ref } from 'vue'
93
+ import { ProTable } from 'mc-pro-ui'
94
+ import type { ColumnProps } from 'mc-pro-ui'
95
+
96
+ // 表格列配置
97
+ const columns: ColumnProps[] = [
98
+ {
99
+ type: 'selection',
100
+ width: 55,
101
+ align: 'center'
102
+ },
103
+ {
104
+ type: 'index',
105
+ label: '序号',
106
+ width: 60,
107
+ align: 'center'
108
+ },
109
+ {
110
+ prop: 'name',
111
+ label: '姓名',
112
+ search: {
113
+ el: 'input',
114
+ props: {
115
+ placeholder: '请输入姓名'
116
+ }
117
+ }
118
+ },
119
+ {
120
+ prop: 'age',
121
+ label: '年龄',
122
+ search: {
123
+ el: 'input-number',
124
+ props: {
125
+ placeholder: '请输入年龄'
126
+ }
127
+ }
128
+ },
129
+ {
130
+ prop: 'status',
131
+ label: '状态',
132
+ search: {
133
+ el: 'select',
134
+ props: {
135
+ placeholder: '请选择状态'
136
+ },
137
+ enum: [
138
+ { label: '启用', value: 1 },
139
+ { label: '禁用', value: 0 }
140
+ ]
141
+ },
142
+ tag: true
143
+ },
144
+ {
145
+ prop: 'operation',
146
+ label: '操作',
147
+ width: 180,
148
+ align: 'center',
149
+ fixed: 'right'
150
+ }
151
+ ]
152
+
153
+ // 获取表格数据
154
+ const getTableList = async (params: any) => {
155
+ // 模拟 API 请求
156
+ const response = await fetch('/api/users', { params })
157
+ return response.json()
158
+ }
159
+
160
+ const handleSearch = () => {
161
+ console.log('搜索')
162
+ }
163
+
164
+ const handleReset = () => {
165
+ console.log('重置')
166
+ }
167
+
168
+ const handleEdit = (row: any) => {
169
+ console.log('编辑', row)
170
+ }
171
+
172
+ const handleDelete = (row: any) => {
173
+ console.log('删除', row)
174
+ }
175
+
176
+ const handleBatchDelete = (selectedList: any[]) => {
177
+ console.log('批量删除', selectedList)
178
+ }
179
+ </script>
180
+ ```
181
+
182
+ ### SearchForm - 智能搜索表单
183
+
184
+ 响应式搜索表单组件,支持多种表单控件和布局配置。
185
+
186
+ ```vue
187
+ <template>
188
+ <SearchForm
189
+ :columns="searchColumns"
190
+ :search-param="searchParam"
191
+ :search-col="{ xs: 1, sm: 2, md: 3, lg: 4, xl: 5 }"
192
+ @search="handleSearch"
193
+ @reset="handleReset"
194
+ >
195
+ <template #searchButton>
196
+ <el-button type="primary" @click="handleSearch">搜索</el-button>
197
+ <el-button @click="handleReset">重置</el-button>
198
+ </template>
199
+ </SearchForm>
200
+ </template>
201
+
202
+ <script setup lang="ts">
203
+ import { ref } from 'vue'
204
+ import { SearchForm } from 'mc-pro-ui'
205
+ import type { ColumnProps } from 'mc-pro-ui'
206
+
207
+ const searchParam = ref({
208
+ name: '',
209
+ age: '',
210
+ status: ''
211
+ })
212
+
213
+ const searchColumns: ColumnProps[] = [
214
+ {
215
+ prop: 'name',
216
+ label: '姓名',
217
+ search: {
218
+ el: 'input',
219
+ props: {
220
+ placeholder: '请输入姓名'
221
+ }
222
+ }
223
+ },
224
+ {
225
+ prop: 'age',
226
+ label: '年龄',
227
+ search: {
228
+ el: 'input-number',
229
+ props: {
230
+ placeholder: '请输入年龄'
231
+ }
232
+ }
233
+ },
234
+ {
235
+ prop: 'status',
236
+ label: '状态',
237
+ search: {
238
+ el: 'select',
239
+ props: {
240
+ placeholder: '请选择状态'
241
+ },
242
+ enum: [
243
+ { label: '启用', value: 1 },
244
+ { label: '禁用', value: 0 }
245
+ ]
246
+ }
247
+ }
248
+ ]
249
+
250
+ const handleSearch = () => {
251
+ console.log('搜索参数:', searchParam.value)
252
+ }
253
+
254
+ const handleReset = () => {
255
+ searchParam.value = {
256
+ name: '',
257
+ age: '',
258
+ status: ''
259
+ }
260
+ }
261
+ </script>
262
+ ```
263
+
264
+ ### ProForm - 高级表单组件
265
+
266
+ 支持动态表单和复杂布局的表单组件。
267
+
268
+ ```vue
269
+ <template>
270
+ <ProForm
271
+ :form-json="formConfig"
272
+ :form-col="{ xs: 24, sm: 12, md: 8, lg: 6, xl: 4 }"
273
+ />
274
+ </template>
275
+
276
+ <script setup lang="ts">
277
+ import { ref } from 'vue'
278
+ import { ProForm } from 'mc-pro-ui'
279
+
280
+ const formConfig = ref({
281
+ config: {
282
+ labelWidth: '120px',
283
+ labelPosition: 'right'
284
+ },
285
+ fields: {
286
+ name: {
287
+ label: '姓名',
288
+ el: 'input',
289
+ props: {
290
+ placeholder: '请输入姓名'
291
+ }
292
+ },
293
+ age: {
294
+ label: '年龄',
295
+ el: 'input-number',
296
+ props: {
297
+ placeholder: '请输入年龄',
298
+ min: 0,
299
+ max: 150
300
+ }
301
+ },
302
+ gender: {
303
+ label: '性别',
304
+ el: 'radio-group',
305
+ options: [
306
+ { label: '男', value: 'male' },
307
+ { label: '女', value: 'female' }
308
+ ]
309
+ },
310
+ city: {
311
+ label: '城市',
312
+ el: 'select',
313
+ options: [
314
+ { label: '北京', value: 'beijing' },
315
+ { label: '上海', value: 'shanghai' },
316
+ { label: '广州', value: 'guangzhou' }
317
+ ]
318
+ }
319
+ }
320
+ })
321
+ </script>
322
+ ```
323
+
324
+ ### Grid - 响应式网格系统
325
+
326
+ 基于 CSS Grid 的响应式布局系统。
327
+
328
+ ```vue
329
+ <template>
330
+ <Grid :cols="{ xs: 1, sm: 2, md: 3, lg: 4, xl: 6 }" :gap="[20, 20]">
331
+ <GridItem v-for="i in 12" :key="i" :span="1">
332
+ <div class="grid-item">
333
+ Grid Item {{ i }}
334
+ </div>
335
+ </GridItem>
336
+ </Grid>
337
+ </template>
338
+
339
+ <script setup lang="ts">
340
+ import { Grid, GridItem } from 'mc-pro-ui'
341
+ </script>
342
+
343
+ <style scoped>
344
+ .grid-item {
345
+ background: #f5f5f5;
346
+ padding: 20px;
347
+ text-align: center;
348
+ border-radius: 4px;
349
+ }
350
+ </style>
351
+ ```
352
+
353
+ ### Dialog - 灵活对话框
354
+
355
+ 可配置的对话框组件。
356
+
357
+ ```vue
358
+ <template>
359
+ <Dialog
360
+ v-model="dialogVisible"
361
+ title="用户信息"
362
+ width="600px"
363
+ :draggable="true"
364
+ @confirm="handleConfirm"
365
+ >
366
+ <div>对话框内容</div>
367
+ </Dialog>
368
+ </template>
369
+
370
+ <script setup lang="ts">
371
+ import { ref } from 'vue'
372
+ import { Dialog } from 'mc-pro-ui'
373
+
374
+ const dialogVisible = ref(false)
375
+
376
+ const handleConfirm = () => {
377
+ console.log('确认')
378
+ dialogVisible.value = false
379
+ }
380
+ </script>
381
+ ```
382
+
383
+ ## 🔧 API 配置
384
+
385
+ ### ProTable Props
386
+
387
+ | 参数 | 说明 | 类型 | 默认值 |
388
+ |------|------|------|--------|
389
+ | columns | 列配置项 | ColumnProps[] | [] |
390
+ | data | 静态表格数据 | any[] | - |
391
+ | requestApi | 请求表格数据的 API | Function | - |
392
+ | requestAuto | 是否自动执行请求 | boolean | true |
393
+ | pagination | 是否需要分页组件 | boolean | true |
394
+ | toolButton | 功能按钮配置 | string[] \| boolean | false |
395
+ | rowKey | 行数据的 Key | string | 'id' |
396
+ | searchCol | 搜索项每列占比配置 | number \| Record<BreakPoint, number> | { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 } |
397
+
398
+ ### SearchForm Props
399
+
400
+ | 参数 | 说明 | 类型 | 默认值 |
401
+ |------|------|------|--------|
402
+ | columns | 搜索列配置 | ColumnProps[] | [] |
403
+ | searchParam | 搜索参数 | object | {} |
404
+ | searchCol | 搜索项每列占比配置 | number \| Record<BreakPoint, number> | { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 } |
405
+
406
+ ### Grid Props
407
+
408
+ | 参数 | 说明 | 类型 | 默认值 |
409
+ |------|------|------|--------|
410
+ | cols | 列数配置 | number \| Record<BreakPoint, number> | 12 |
411
+ | gap | 间距配置 | number \| [number, number] | 0 |
412
+
413
+ ## 🎨 样式定制
414
+
415
+ 组件库使用 CSS 变量,可以通过覆盖变量来自定义样式:
416
+
417
+ ```css
418
+ :root {
419
+ --mc-primary-color: #409eff;
420
+ --mc-success-color: #67c23a;
421
+ --mc-warning-color: #e6a23c;
422
+ --mc-danger-color: #f56c6c;
423
+ --mc-info-color: #909399;
424
+ }
425
+ ```
426
+
427
+ ## 📚 类型定义
428
+
429
+ 完整的 TypeScript 类型定义:
430
+
431
+ ```typescript
432
+ import type {
433
+ ColumnProps,
434
+ SearchProps,
435
+ ProTableProps,
436
+ RenderScope,
437
+ HeaderRenderScope
438
+ } from 'mc-pro-ui'
439
+ ```
440
+
441
+ ## 🤝 贡献
442
+
443
+ 欢迎提交 Issue 和 Pull Request!
444
+
445
+ ## 📄 许可证
446
+
447
+ [MIT License](LICENSE)
448
+
449
+ ## 🔗 相关链接
450
+
451
+ - [Vue 3](https://vuejs.org/)
452
+ - [Element Plus](https://element-plus.org/)
453
+ - [TypeScript](https://www.typescriptlang.org/)
454
+
455
+ ## 🛠️ 开发指南
456
+
457
+ ### 本地开发
458
+
459
+ ```bash
460
+ # 安装依赖
461
+ npm install
462
+
463
+ # 启动开发服务器
464
+ npm run dev
465
+
466
+ # 类型检查
467
+ npm run type-check
468
+
469
+ # 代码格式化
470
+ npm run format
471
+
472
+ # 代码检查
473
+ npm run lint
474
+ ```
475
+
476
+ ### 构建和发布
477
+
478
+ ```bash
479
+ # 构建项目
480
+ npm run build
481
+
482
+ # 发布到 npm(自动构建 + 发布)
483
+ npm run publish:lib
484
+ ```
485
+
486
+ **注意:** 发布时会自动执行构建,无需手动构建。
487
+
488
+ ### 项目结构
489
+
490
+ ```
491
+ npm-pro-ui/
492
+ ├── packages/ # 组件库源码
493
+ │ ├── components/ # 组件
494
+ │ ├── hooks/ # 组合式函数
495
+ │ ├── types/ # 类型定义
496
+ │ ├── utils/ # 工具函数
497
+ │ └── index.ts # 入口文件
498
+ ├── dist/ # 构建输出
499
+ ├── vite.config.ts # Vite 配置
500
+ ├── package.json # 项目配置
501
+ └── README.md # 项目文档
502
+ ```