@uf_lee/leeui 1.0.19 → 1.0.21

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 (2) hide show
  1. package/README.md +470 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,18 +1,477 @@
1
- <!--
2
- * @Author: 李天惊 uf_lee@163.com
3
- * @Date: 2025-03-20 12:35:35
4
- * @LastEditors: 李天惊 uf_lee@163.com
5
- * @LastEditTime: 2025-03-20 14:50:41
6
- * @FilePath: \leelcp2022\lee_ui\README.md
7
- * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved.
8
- -->
1
+
9
2
  # LeeUI
10
3
 
11
- 一个支持TypeScript的简单单实例Vue 3组件库。
4
+ 一个支持 TypeScript 的简单单实例 Vue 3 组件库,基于 `Element Plus` 进行封装,提供便捷的表单渲染功能。
5
+
6
+ ## 🚀 特性
7
+
8
+ - 📌 **基于 Vue 3 + TypeScript**,类型安全,支持 Vite。
9
+ - 🎨 **Element Plus 兼容**,二次封装,优化开发体验。
10
+ - ⚡ **动态表单渲染**,支持 `schema` 配置化表单。
11
+ - 💡 **可扩展性强**,方便集成和定制。
12
+
13
+ ## 📦 安装
12
14
 
13
- ## 安装
14
- 要安装项目的依赖项,运行以下命令:
15
+ 使用 `npm` 或 `yarn` 进行安装:
15
16
 
16
17
  ```bash
17
18
  npm install @uf_lee/leeui
19
+ ```
20
+
21
+
22
+
23
+ ```bash
24
+ yarn add @uf_lee/leeui
25
+ ```
26
+
27
+ ## 🚀 快速开始
28
+
29
+ ### 组件注册
30
+
31
+ 在 `main.ts` 中引入并注册组件库:
32
+
33
+ ```ts
34
+ import { createApp } from "vue";
35
+ import App from "./App.vue";
36
+ import LeeUI from "@uf_lee/leeui";
37
+ import "@uf_lee/leeui/dist/style.css"; // 可能需要引入样式
38
+
39
+ const app = createApp(App);
40
+ app.use(LeeUI);
41
+ app.mount("#app");
42
+ ```
43
+
44
+ ### 示例代码
45
+
46
+ ```vue
47
+ <script setup lang="ts">
48
+ import { reactive, ref, onMounted } from "vue";
49
+ import { ElDivider } from "element-plus";
50
+ import { LElForm, LElFormItemCom } from "@uf_lee/leeui";
51
+ import type { FormSchema } from "@uf_lee/leeui/dist/types/types";
52
+
53
+ // --------------------- Autocomplete 使用的一些设置 start -------------------------
54
+ interface RestaurantItem {
55
+ value: string;
56
+ link: string;
57
+ }
58
+ const restaurants = ref<RestaurantItem[]>([]);
59
+ const querySearch = (queryString: string, cb: any) => {
60
+ const results = queryString
61
+ ? restaurants.value.filter(createFilter(queryString))
62
+ : restaurants.value;
63
+ // call callback function to return suggestions
64
+ cb(results);
65
+ };
66
+ const createFilter = (queryString: string) => {
67
+ return (restaurant: RestaurantItem) => {
68
+ return (
69
+ restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
70
+ );
71
+ };
72
+ };
73
+ const loadAll = () => {
74
+ return [
75
+ { value: "vue", link: "https://github.com/vuejs/vue" },
76
+ { value: "element", link: "https://github.com/ElemeFE/element" },
77
+ { value: "cooking", link: "https://github.com/ElemeFE/cooking" },
78
+ { value: "mint-ui", link: "https://github.com/ElemeFE/mint-ui" },
79
+ { value: "vuex", link: "https://github.com/vuejs/vuex" },
80
+ { value: "vue-router", link: "https://github.com/vuejs/vue-router" },
81
+ { value: "babel", link: "https://github.com/babel/babel" },
82
+ ];
83
+ };
84
+ const handleSelect = (item: Record<string, any>) => {
85
+ console.log(item);
86
+ };
87
+
88
+ onMounted(() => {
89
+ restaurants.value = loadAll();
90
+ });
91
+ // --------------------- Autocomplete 使用的一些设置 end -------------------------
92
+
93
+ const schema: FormSchema[] = [
94
+ {
95
+ field: "undefined",
96
+ label: "undefined",
97
+ componentProps: {
98
+ placeholder: "默认输入框",
99
+ },
100
+ colProps: {
101
+ span: 24,
102
+ },
103
+ },
104
+ {
105
+ field: "Radio",
106
+ label: "Radio",
107
+ component: "Radio",
108
+ componentProps: {
109
+ options: [
110
+ {
111
+ label: "选项1",
112
+ value: "1",
113
+ },
114
+ {
115
+ label: "选项2",
116
+ value: "2",
117
+ },
118
+ ],
119
+ },
120
+ colProps: {
121
+ span: 6,
122
+ },
123
+ },
124
+ {
125
+ field: "RadioButton",
126
+ label: "RadioButton",
127
+ component: "RadioButton",
128
+ componentProps: {
129
+ options: [
130
+ {
131
+ label: "选项1",
132
+ value: "1",
133
+ },
134
+ {
135
+ label: "选项2",
136
+ value: "2",
137
+ },
138
+ ],
139
+ },
140
+ colProps: {
141
+ span: 6,
142
+ },
143
+ },
144
+ {
145
+ field: "Checkbox",
146
+ label: "Checkbox",
147
+ component: "Checkbox",
148
+ componentProps: {
149
+ options: [
150
+ {
151
+ label: "选项1",
152
+ value: "1",
153
+ },
154
+ {
155
+ label: "选项2",
156
+ value: "2",
157
+ },
158
+ ],
159
+ },
160
+ colProps: {
161
+ span: 6,
162
+ },
163
+ },
164
+ {
165
+ field: "CheckboxButton",
166
+ label: "CheckboxButton",
167
+ component: "CheckboxButton",
168
+ componentProps: {
169
+ options: [
170
+ {
171
+ label: "选项1",
172
+ value: "1",
173
+ },
174
+ {
175
+ label: "选项2",
176
+ value: "2",
177
+ },
178
+ ],
179
+ },
180
+ colProps: {
181
+ span: 6,
182
+ },
183
+ },
184
+ {
185
+ field: "Input",
186
+ label: "Input",
187
+ component: "Input",
188
+ componentProps: {
189
+ placeholder: "输入框",
190
+ },
191
+ colProps: {
192
+ span: 8,
193
+ },
194
+ },
195
+ {
196
+ field: "Autocomplete",
197
+ label: "Autocomplete",
198
+ component: "Autocomplete",
199
+ componentProps: {
200
+ placeholder: "自动补全输入框",
201
+ fetchSuggestions: querySearch,
202
+ onselect: handleSelect,
203
+ },
204
+ colProps: {
205
+ span: 8,
206
+ },
207
+ },
208
+ {
209
+ field: "InputNumber",
210
+ label: "InputNumber",
211
+ component: "InputNumber",
212
+ componentProps: {},
213
+ colProps: {
214
+ span: 8,
215
+ },
216
+ },
217
+ {
218
+ field: "Select",
219
+ label: "Select",
220
+ component: "Select",
221
+ componentProps: {
222
+ placeholder: "请选择下拉框",
223
+ options: [
224
+ {
225
+ label: "选项1",
226
+ value: "1",
227
+ },
228
+ {
229
+ label: "选项2",
230
+ value: "2",
231
+ },
232
+ ],
233
+ },
234
+ colProps: {
235
+ span: 10,
236
+ },
237
+ },
238
+ {
239
+ field: "Cascader",
240
+ label: "Cascader",
241
+ component: "Cascader",
242
+ componentProps: {
243
+ placeholder: "级联选择器",
244
+ options: [
245
+ {
246
+ label: "选项1",
247
+ value: "1",
248
+ children: [
249
+ {
250
+ label: "选项1-1",
251
+ value: "1001",
252
+ },
253
+ {
254
+ label: "选项1-2",
255
+ value: "1002",
256
+ },
257
+ {
258
+ label: "选项1-3",
259
+ value: "1003",
260
+ },
261
+ {
262
+ label: "选项1-4",
263
+ value: "1004",
264
+ },
265
+ ],
266
+ },
267
+ {
268
+ label: "选项2",
269
+ value: "2",
270
+ children: [
271
+ {
272
+ label: "选项2-1",
273
+ value: "2001",
274
+ },
275
+ {
276
+ label: "选项2-2",
277
+ value: "2002",
278
+ },
279
+ {
280
+ label: "选项2-3",
281
+ value: "2003",
282
+ },
283
+ {
284
+ label: "选项2-4",
285
+ value: "2004",
286
+ },
287
+ ],
288
+ },
289
+ {
290
+ label: "选项3",
291
+ value: "3",
292
+ children: [
293
+ {
294
+ label: "选项3-1",
295
+ value: "3001",
296
+ children: [
297
+ {
298
+ label: "选项3-1-1",
299
+ value: "3001001",
300
+ },
301
+ {
302
+ label: "选项3-1-1",
303
+ value: "3001--2",
304
+ },
305
+ ],
306
+ },
307
+ {
308
+ label: "选项3-2",
309
+ value: "3002",
310
+ },
311
+ ],
312
+ },
313
+ {
314
+ label: "选项4",
315
+ value: "4",
316
+ },
317
+ {
318
+ label: "选项5",
319
+ value: "5",
320
+ },
321
+ ],
322
+ },
323
+ colProps: {
324
+ span: 10,
325
+ },
326
+ },
327
+ {
328
+ field: "Switch",
329
+ label: "Switch",
330
+ component: "Switch",
331
+ componentProps: {},
332
+ colProps: {
333
+ span: 4,
334
+ },
335
+ },
336
+ {
337
+ field: "Slider",
338
+ label: "Slider",
339
+ component: "Slider",
340
+ componentProps: {},
341
+ colProps: {
342
+ span: 24,
343
+ },
344
+ },
345
+ {
346
+ field: "TimePicker",
347
+ label: "TimePicker",
348
+ component: "TimePicker",
349
+ componentProps: {},
350
+ colProps: {
351
+ span: 6,
352
+ },
353
+ },
354
+ {
355
+ field: "DatePicker",
356
+ label: "DatePicker",
357
+ component: "DatePicker",
358
+ componentProps: {},
359
+ colProps: {
360
+ span: 6,
361
+ },
362
+ },
363
+ {
364
+ field: "Rate",
365
+ label: "Rate",
366
+ component: "Rate",
367
+ componentProps: {},
368
+ colProps: {
369
+ span: 6,
370
+ },
371
+ },
372
+ {
373
+ field: "ColorPicker",
374
+ label: "ColorPicker",
375
+ component: "ColorPicker",
376
+ componentProps: {},
377
+ colProps: {
378
+ span: 6,
379
+ },
380
+ },
381
+ {
382
+ field: "Transfer",
383
+ label: "Transfer",
384
+ component: "Transfer",
385
+ componentProps: {},
386
+ colProps: {
387
+ span: 12,
388
+ },
389
+ },
390
+ {
391
+ field: "Divider",
392
+ label: "Divider",
393
+ component: "Divider",
394
+ componentProps: {
395
+ contentPosition: "center",
396
+ },
397
+ colProps: {
398
+ span: 12,
399
+ },
400
+ },
401
+ {
402
+ field: "TimeSelect",
403
+ label: "TimeSelect",
404
+ component: "TimeSelect",
405
+ componentProps: {},
406
+ colProps: {
407
+ span: 12,
408
+ },
409
+ },
410
+ {
411
+ field: "SelectV2",
412
+ label: "SelectV2",
413
+ component: "SelectV2",
414
+ componentProps: {
415
+ options: [
416
+ {
417
+ label: "选项1",
418
+ value: "1",
419
+ },
420
+ {
421
+ label: "选项2",
422
+ value: "2",
423
+ },
424
+ ],
425
+ },
426
+ colProps: {
427
+ span: 12,
428
+ },
429
+ },
430
+ ];
431
+
432
+ // 值
433
+ const model: any = reactive({
434
+ undefined: "12312",
435
+ });
436
+ </script>
437
+
438
+ <template>
439
+ <el-divider content-position="left">model</el-divider>
440
+ {{ model }}
441
+ <el-divider content-position="left">LElForm</el-divider>
442
+ <LElForm :schema="schema" :model="model" />
443
+ <el-divider content-position="left">LElFormItemCom</el-divider>
444
+ <LElFormItemCom :data="schema[0]" v-model="model.undefined" />
445
+ <LElFormItemCom :data="schema[1]" v-model="model[schema[1].field]" />
446
+ </template>
447
+ ```
448
+
449
+ ## 📖 API 说明
450
+
451
+ ### `LElForm` 组件
452
+
453
+ | 参数 | 说明 | 类型 | 默认值 |
454
+ | -------- | ------ | --------------------- | ---- |
455
+ | `schema` | 表单配置项 | `FormSchema[]` | `[]` |
456
+ | `model` | 表单数据对象 | `Record<string, any>` | `{}` |
457
+
458
+ ### `LElFormItemCom` 组件
459
+
460
+ | 参数 | 说明 | 类型 | 默认值 |
461
+ | --------- | ------- | ------------ | --- |
462
+ | `data` | 单个表单项配置 | `FormSchema` | - |
463
+ | `v-model` | 绑定的数据值 | `any` | - |
464
+
465
+ ## 🤝 贡献指南
466
+
467
+ 欢迎贡献代码!请提交 PR 或 Issue 进行讨论。
468
+
469
+ 1. Fork 本仓库。
470
+ 2. 创建新分支:`git checkout -b feature-branch`。
471
+ 3. 提交更改:`git commit -m 'Add some feature'`。
472
+ 4. 推送分支:`git push origin feature-branch`。
473
+ 5. 提交 Pull Request。
474
+
475
+ ## 📜 License
18
476
 
477
+ [MIT](LICENSE) License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uf_lee/leeui",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "自己的组件库",
5
5
  "main": "dist/leeui.umd.js",
6
6
  "module": "dist/leeui.es.js",