@elementplus-kit/uikit 1.6.0 → 1.8.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 (68) hide show
  1. package/components/button/index.ts +2 -0
  2. package/components/button/src/constants.ts +50 -0
  3. package/components/button/src/index.ts +269 -0
  4. package/components/button/src/type.ts +15 -0
  5. package/components/button/style/index.scss +3 -0
  6. package/components/config.ts +4 -0
  7. package/components/dialog/index.ts +2 -0
  8. package/components/dialog/src/constants.ts +3 -0
  9. package/components/dialog/src/index.ts +54 -0
  10. package/components/dialog/src/type.ts +1 -0
  11. package/components/dialog/style/index.scss +18 -0
  12. package/components/dictLabel/index.ts +4 -0
  13. package/components/dictLabel/src/index.vue +21 -0
  14. package/components/dictLabel/src/type.ts +1 -0
  15. package/components/drawer/index.ts +2 -0
  16. package/components/drawer/src/constants.ts +3 -0
  17. package/components/drawer/src/index.ts +53 -0
  18. package/components/drawer/src/type.ts +1 -0
  19. package/components/drawer/style/index.scss +18 -0
  20. package/components/form/index.ts +2 -0
  21. package/components/form/src/FormItem.ts +406 -0
  22. package/components/form/src/constants.ts +161 -0
  23. package/components/form/src/index.ts +198 -0
  24. package/components/form/src/type.ts +68 -0
  25. package/components/form/src/utils.ts +4 -0
  26. package/components/form/style/index.scss +5 -0
  27. package/components/importText/index.ts +2 -0
  28. package/components/importText/src/index.ts +1 -0
  29. package/components/importText/src/type.ts +3 -0
  30. package/components/index.ts +10 -31
  31. package/components/pagination/index.ts +2 -0
  32. package/components/pagination/src/constants.ts +5 -0
  33. package/components/pagination/src/index.ts +50 -0
  34. package/components/pagination/src/type.ts +1 -0
  35. package/components/search/index.ts +2 -0
  36. package/components/search/src/index.tsx +306 -0
  37. package/components/search/src/type.ts +2 -0
  38. package/components/search/style/index.scss +104 -0
  39. package/components/table/index.ts +2 -0
  40. package/components/table/src/TableColumn.ts +116 -0
  41. package/components/table/src/constants.ts +42 -0
  42. package/components/table/src/index.ts +251 -0
  43. package/components/table/src/tableDictLabel.vue +21 -0
  44. package/components/table/src/type.ts +19 -0
  45. package/components/table/type/index.scss +0 -0
  46. package/components/table2/index.ts +4 -0
  47. package/components/table2/src/config.ts +5 -0
  48. package/components/table2/src/index.ts +12 -0
  49. package/components/table2/src/render.ts +136 -0
  50. package/components/table2/src/types.ts +39 -0
  51. package/components/table2/style/index.scss +0 -0
  52. package/components//346/250/241/346/235/277/index.tsx +57 -0
  53. package/components//346/250/241/346/235/277/ttt.ts +66 -0
  54. package/components//346/250/241/346/235/277/ttt.vue +18 -0
  55. package/index.ts +2 -0
  56. package/package.json +1 -4
  57. package/vite.config.ts +30 -0
  58. package//345/205/266/344/273/226/core/dialog/elementPlus/dialogWarp.vue +151 -0
  59. package//345/205/266/344/273/226/core/dialog/index.ts +10 -0
  60. package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.ts +15 -0
  61. package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.vue +16 -0
  62. package//345/205/266/344/273/226/core/form/elementPlus/formRender.ts +55 -0
  63. package//345/205/266/344/273/226/core/form/index.ts +10 -0
  64. package//345/205/266/344/273/226/core/table/config.ts +5 -0
  65. package//345/205/266/344/273/226/core/table/render.ts +91 -0
  66. package//345/205/266/344/273/226/core/table/warp.ts +11 -0
  67. package//345/205/266/344/273/226/core/utils/fetch.ts +58 -0
  68. package//345/205/266/344/273/226/useMessage.ts +95 -0
@@ -0,0 +1,198 @@
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ h,
5
+ computed,
6
+ toRefs,
7
+ getCurrentInstance,
8
+ provide,
9
+ type ExtractPropTypes,
10
+ type PropType,
11
+ } from "vue";
12
+ import { ElForm, ElRow, ElCol } from "element-plus";
13
+ // import zhCn from "element-plus/es/locale/lang/zh-cn";
14
+ import CFormItem from "./FormItem.ts";
15
+ import { has, isFunction } from "lodash-es";
16
+ import { getEmits } from "./constants"; // 获取所有的事件
17
+ import "../style/index.scss";
18
+ const formAttrs = {
19
+ // 表单数据
20
+ model: { type: Object, default: () => ({}) },
21
+ // 表单项
22
+ formOptions: { type: Array, default: () => [] },
23
+ // 只读
24
+ readonly: { type: Boolean, default: false },
25
+ // row 间距
26
+ gutter: {
27
+ // tode 类型错误警告
28
+ type: (Number as PropType<number>) || (String as PropType<string>),
29
+ default: undefined,
30
+ },
31
+ // row 列数
32
+ col: { type: Number, default: undefined },
33
+ // 额外业务全局参数
34
+ params: { type: Object, default: () => ({}) },
35
+ };
36
+
37
+ export type FormAttrs = ExtractPropTypes<typeof formAttrs>;
38
+
39
+ export default defineComponent({
40
+ props: formAttrs,
41
+ emits: [...getEmits()],
42
+ setup(props: FormAttrs, { attrs: $attrs, emit, slots, expose }) {
43
+ provide("formContext", {
44
+ formSlots: slots,
45
+ events: (eProp, ...args: any) => {
46
+ // 按钮 reset 事件
47
+ // if (e == 'reset') {
48
+ // formRef.value?.resetFields()
49
+ // }
50
+ emit(eProp, ...args);
51
+ },
52
+ });
53
+
54
+ // 各个表单组件的 ref
55
+ const optionsRef = ref<any>({});
56
+
57
+ // 暴露方法
58
+ expose({
59
+ optionsRef,
60
+ });
61
+
62
+ // 解构props
63
+ const { model, formOptions, readonly, gutter, col } = toRefs(props);
64
+
65
+ // 暴露elForm组件上的方法
66
+ const vm = getCurrentInstance(); // 获取虚拟DOM实例
67
+ const cFormFnRef = (el) => {
68
+ if (!el) return;
69
+ vm.exposed = el; // 设置暴露对象
70
+ vm.exposeProxy = el; // 设置代理暴露对象
71
+ };
72
+
73
+ // 全部只读
74
+ const allReadonly = computed(() => readonly.value);
75
+
76
+ // 是否 row 布局 || ['', 0].includes(gutter.value)
77
+ const isLayout = computed(
78
+ () =>
79
+ ["", 0].includes(gutter?.value) ||
80
+ col?.value ||
81
+ formOptions?.value.some((item) => has(item, "col"))
82
+ );
83
+
84
+ // 渲染 row
85
+ const renderRow = () => {
86
+ const formItemVdom = renderFormItem();
87
+ if (isLayout.value) {
88
+ return h(
89
+ ElRow,
90
+ {
91
+ class: "c-row",
92
+ // gutter: gutter.value === 0 || gutter.value ? gutter.value : 10,
93
+ gutter: gutter.value || 20,
94
+ ...$attrs,
95
+ },
96
+ {
97
+ default: () => formItemVdom,
98
+ }
99
+ );
100
+ } else {
101
+ return formItemVdom;
102
+ }
103
+ };
104
+ // 合并 formData 和 params
105
+ const mergeParams = computed(() => {
106
+ return { formData: model.value, params: props.params };
107
+ });
108
+ // 渲染表单项
109
+ const renderFormItem = () => {
110
+ // 过滤权限
111
+ const list = [];
112
+
113
+ formOptions.value.map((item) => {
114
+ // 处理 vIf true 显示 false 隐藏
115
+ if (
116
+ isFunction(item?.vIf) &&
117
+ item.vIf(mergeParams.value) !== undefined
118
+ ) {
119
+ if (item.vIf(mergeParams.value)) {
120
+ list.push(item);
121
+ }
122
+ } else {
123
+ list.push(item);
124
+ }
125
+ });
126
+ return list.map((item) => {
127
+ // const { label, prop, type, required, col, formItem, attrs } = item
128
+ // const { label, prop, type, required, col, formItem, attrs, ...args } = item
129
+ const rFormItem = () => {
130
+ return h(CFormItem, {
131
+ class: "c-form-itme",
132
+ model: model.value,
133
+ allReadonly,
134
+ mergeParams: mergeParams.value,
135
+ ...item,
136
+ optionsRef: optionsRef.value,
137
+ });
138
+ };
139
+ if (isLayout.value) {
140
+ // 是否有 col 插槽
141
+ let colSlot = undefined;
142
+ let colSlotName = `col.${item.prop}`;
143
+ // 手动开启 col 插槽
144
+ if (item?.colSlot) {
145
+ if (has(slots, colSlotName)) {
146
+ colSlot = slots[colSlotName];
147
+ } else {
148
+ colSlot = () => "col插槽模板未定义";
149
+ }
150
+ } else {
151
+ // 自动开启 col 插槽
152
+ if (has(slots, colSlotName)) {
153
+ colSlot = slots[colSlotName];
154
+ }
155
+ }
156
+
157
+ return h(
158
+ ElCol,
159
+ {
160
+ class: "c-col",
161
+ span: has(item, "col")
162
+ ? item.col
163
+ : col?.value
164
+ ? col?.value
165
+ : isLayout.value
166
+ ? 8
167
+ : undefined,
168
+ },
169
+ {
170
+ default: () => (colSlot ? colSlot() : rFormItem()),
171
+ }
172
+ );
173
+ } else {
174
+ return rFormItem();
175
+ }
176
+ });
177
+ };
178
+
179
+ // 渲染表单
180
+ const renderForm = () => {
181
+ return h(
182
+ ElForm,
183
+ {
184
+ ref: cFormFnRef,
185
+ ...$attrs,
186
+ model: model.value,
187
+ class: allReadonly.value ? "isReadonly c-form" : "c-form", // 放在 $attrs 后面可自动合并 放在 $attrs 前面会被 $attrs.class 覆盖, h函数渲染的是标签就会覆盖 是组件就会合并不用管顺序
188
+ },
189
+ {
190
+ default: () => renderRow(),
191
+ }
192
+ );
193
+ };
194
+
195
+ // 返回渲染函数
196
+ return () => renderForm();
197
+ },
198
+ });
@@ -0,0 +1,68 @@
1
+ import { type ExtractPropTypes } from "vue";
2
+ import { formProps, type FormItemProps as ElFormItemProps } from "element-plus";
3
+ import { type FormAttrs } from "./index.ts";
4
+
5
+ type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
6
+
7
+ // 表单类型
8
+ export type FormType =
9
+ | "input"
10
+ | "textarea"
11
+ | "input-number"
12
+ | "select"
13
+ | "select-v2"
14
+ | "cascader"
15
+ | "tree-select"
16
+ | "radio"
17
+ | "checkbox"
18
+ | "time-select"
19
+ | "date-picker"
20
+ | "time-picker"
21
+ | "rate"
22
+ | "color-picker"
23
+ | "slider"
24
+ | "switch"
25
+ | "text"
26
+ | "html"
27
+ | "slot";
28
+
29
+ // 表单属性
30
+ type ElFormProps = ExtractPropTypes<typeof formProps>;
31
+ export type FormProps = Expand<Partial<FormAttrs>> &
32
+ Expand<Partial<ElFormProps>>;
33
+
34
+ // 跟FormItem组件不同步,不用组件props生成
35
+ export type FormOptions = Array<{
36
+ type:
37
+ | "input"
38
+ | "textarea"
39
+ | "input-number"
40
+ | "select"
41
+ | "select-v2"
42
+ | "cascader"
43
+ | "tree-select"
44
+ | "radio"
45
+ | "checkbox"
46
+ | "time-select"
47
+ | "date-picker"
48
+ | "time-picker"
49
+ | "rate"
50
+ | "color-picker"
51
+ | "slider"
52
+ | "switch"
53
+ | "text"
54
+ | "html"
55
+ | "slot";
56
+ label?: string;
57
+ prop: string;
58
+ required?: boolean;
59
+ vIf?: boolean | (() => boolean);
60
+ dictType?: string;
61
+ options?: Array<{
62
+ label: string;
63
+ value: string | number | boolean;
64
+ }>;
65
+ col?: Number;
66
+ formItem?: { disabled?: boolean | (() => boolean) } & ElFormItemProps;
67
+ attrs?: Object;
68
+ }>;
@@ -0,0 +1,4 @@
1
+ // 字符串转大驼峰
2
+ export const formatEventName = (name: string) => {
3
+ return name.replace(/(?:^|-)(\w)/g, (_, c) => c.toUpperCase())
4
+ }
@@ -0,0 +1,5 @@
1
+ .c-form.el-form--inline {
2
+ .el-select {
3
+ --el-select-width: 220px;
4
+ }
5
+ }
@@ -0,0 +1,2 @@
1
+ export type textType2 = "1" | "2" | "3";
2
+ export type textType3 = "2" | "3" | "4";
@@ -0,0 +1 @@
1
+ import { TableProps, TableColumnProps } from "@elementplus-kit/uikit";
@@ -0,0 +1,3 @@
1
+ type textType1 = "a" | "b" | "c";
2
+ export type textType2 = "1" | "2" | "3";
3
+ export type textType3 = "2" | "3" | "4";
@@ -1,45 +1,24 @@
1
- // 表单
2
- import Form from "./form/index.ts";
3
- export * from "./form/index.ts";
4
- export const CForm = Form;
5
1
 
6
- // 表格
7
- import Table from "./table/index.ts";
8
2
  export * from "./table/index.ts";
9
- export const CTable = Table;
3
+ export { default as CTable } from "./table/index.ts";
10
4
 
11
- // 表格2
12
- import Table2 from "./table2/index.ts";
13
- export * from "./table2/index.ts";
14
- export const CTable2 = Table2;
5
+ export * from "./form/index.ts";
6
+ export { default as CForm } from "./form/index.ts";
15
7
 
16
- // 分页
17
- import Pagination from "./pagination/index.ts";
18
8
  export * from "./pagination/index.ts";
19
- export const CPagination = Pagination;
9
+ export { default as CPagination } from "./pagination/index.ts";
20
10
 
21
- // 弹窗
22
- import Dialog from "./dialog/index.ts";
11
+ export { default as CDialog } from "./dialog/index.ts";
23
12
  export * from "./dialog/index.ts";
24
- export const CDialog = Dialog;
25
13
 
26
- // 抽屉
27
- import Drawer from "./drawer/index.ts";
14
+ export { default as CDrawer } from "./drawer/index.ts";
28
15
  export * from "./drawer/index.ts";
29
- export const CDrawer = Drawer;
30
16
 
31
- // 搜索
32
- import Search from "./search/index.ts";
17
+ export { default as CSearch } from "./search/index.ts";
33
18
  export * from "./search/index.ts";
34
- export const CSearch = Search;
35
19
 
36
- // 按钮
37
- import Button from "./button/index.ts";
20
+ export { default as CButton } from "./button/index.ts";
38
21
  export * from "./button/index.ts";
39
- export const CButton = Button;
40
-
41
22
 
42
- // 测试单个引入-----------------------------
43
- // export * from "./dialog/index.ts"; // 弹窗
44
- // export * from "./drawer/index.ts"; // 抽屉
45
- // 测试单个引入-----------------------------
23
+ // export { default as Table2 } from "./table2/index.ts";
24
+ // export * from "./table2/index.ts";
@@ -0,0 +1,2 @@
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -0,0 +1,5 @@
1
+ export const defaultAttrs = {
2
+ // small: false,
3
+ pageSizes: [10, 20, 50, 100, 200, 500],
4
+ layout: "total, sizes, prev, pager, next, jumper",
5
+ };
@@ -0,0 +1,50 @@
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ h,
5
+ computed,
6
+ toRefs,
7
+ type ExtractPropTypes,
8
+ } from "vue";
9
+ import { ElPagination } from "element-plus";
10
+ import { get, has, isArray, isBoolean, isFunction, isNumber } from "lodash-es";
11
+ import { defaultAttrs } from "./constants.ts";
12
+
13
+ const paginationAttrs = {};
14
+
15
+ export type PaginationAttrs = ExtractPropTypes<typeof paginationAttrs>;
16
+
17
+ export default defineComponent({
18
+ // props: paginationAttrs,
19
+ // emits: eventList,
20
+
21
+ // attrs, emit会继承, slots需要设置
22
+ setup(props: PaginationAttrs, { attrs, emit, slots, expose }) {
23
+ // const pageRef = ref();
24
+
25
+ // 暴露方法
26
+ // expose({
27
+ // pageRef,
28
+ // });
29
+
30
+ // 属性处理
31
+ const getAttrs = () => {
32
+ const obj = {
33
+ ...defaultAttrs, // 设置默认值
34
+ // ...attrs, // 当前传入覆盖默认值 第一层标签就是组件可以不用传入
35
+ };
36
+ return obj;
37
+ };
38
+ // 渲染表单
39
+ const render = () => {
40
+ return h(ElPagination, {
41
+ // ref: pageRef,
42
+ ...getAttrs(),
43
+ class: "c-pagination",
44
+ });
45
+ };
46
+
47
+ // 返回渲染函数
48
+ return () => render();
49
+ },
50
+ });
@@ -0,0 +1 @@
1
+ export type {}
@@ -0,0 +1,2 @@
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.tsx";