@elementplus-kit/uikit 1.7.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 (36) hide show
  1. package/components/button/index.ts +2 -4
  2. package/components/button/src/index.ts +58 -53
  3. package/components/button/src/type.ts +15 -0
  4. package/components/dialog/index.ts +2 -6
  5. package/components/dialog/src/index.ts +3 -3
  6. package/components/dialog/src/type.ts +1 -0
  7. package/components/dictLabel/src/type.ts +1 -0
  8. package/components/drawer/index.ts +2 -4
  9. package/components/drawer/src/index.ts +3 -3
  10. package/components/drawer/src/type.ts +1 -0
  11. package/components/form/index.ts +2 -4
  12. package/components/form/src/FormItem.ts +24 -16
  13. package/components/form/src/index.ts +4 -4
  14. package/components/form/src/type.ts +68 -0
  15. package/components/importText/index.ts +2 -0
  16. package/components/importText/src/index.ts +1 -0
  17. package/components/importText/src/type.ts +3 -0
  18. package/components/index.ts +10 -31
  19. package/components/pagination/index.ts +2 -4
  20. package/components/pagination/src/index.ts +4 -4
  21. package/components/pagination/src/type.ts +1 -0
  22. package/components/search/index.ts +2 -4
  23. package/components/search/src/index.tsx +47 -35
  24. package/components/search/src/type.ts +2 -0
  25. package/components/table/index.ts +2 -4
  26. package/components/table/src/index.ts +5 -4
  27. package/components/table/src/type.ts +19 -0
  28. package/dist/index.css +1 -0
  29. package/dist/index.mjs +1079 -0
  30. package/dist/index.umd.js +1 -0
  31. package/package.json +1 -1
  32. package/build.log +0 -0
  33. package/components/form/src/types.ts +0 -39
  34. package/components/table/src/index2.ts +0 -219
  35. package/components/table/src/index3.ts +0 -233
  36. package/components/table/src/tableaa.ts +0 -71
@@ -1,4 +1,2 @@
1
- import Button from "./src/index";
2
- export * from "./src/index";
3
- export { Button };
4
- export default Button;
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, PropType } from "vue";
1
+ import { defineComponent, h, type PropType, type ExtractPropTypes } from "vue";
2
2
  import {
3
3
  ElButton,
4
4
  ElDropdown,
@@ -8,58 +8,63 @@ import {
8
8
  } from "element-plus";
9
9
 
10
10
  import "../style/index.scss";
11
- import { typeActiveMap } from "./constants.ts";
12
11
  import { has, isBoolean, isFunction, isArray } from "lodash-es";
13
- import { tr } from "element-plus/es/locales.mjs";
14
- export default defineComponent({
15
- props: {
16
- params: {
17
- // 用于验证自定义函数的外部数据
18
- type: Object,
19
- default: () => ({}),
20
- },
21
- btnOptions: {
22
- type: Array,
23
- default: () => [],
24
- },
25
- // 权限验证函数
26
- permit: {
27
- type: Function,
28
- },
29
- size: {
30
- type: String as PropType<"large" | "default" | "small">,
31
- default: undefined,
32
- },
33
- plain: {
34
- type: Boolean,
35
- default: undefined,
36
- },
37
- text: {
38
- type: Boolean,
39
- default: undefined,
40
- },
41
- link: {
42
- type: Boolean,
43
- default: undefined,
44
- },
45
- // 折叠
46
- fold: {
47
- type: Boolean,
48
- default: false,
49
- },
50
- // 折叠数量
51
- foldNum: {
52
- type: Number,
53
- default: 0,
54
- },
55
- // // 权限函数
56
- // hasRole: {
57
- // type: Function,
58
- // default: () => true
59
- // },
12
+ import { typeActiveMap } from "./constants.ts";
13
+
14
+ import { type BtnOptions } from "./type.ts";
15
+ const buttonAttrs = {
16
+ params: {
17
+ // 用于验证自定义函数的外部数据
18
+ type: Object,
19
+ default: () => ({}),
20
+ },
21
+ // 权限验证函数
22
+ permit: {
23
+ type: Function,
24
+ },
25
+ // 折叠
26
+ fold: {
27
+ type: Boolean,
28
+ default: false,
29
+ },
30
+ // 折叠数量
31
+ foldNum: {
32
+ type: Number,
33
+ default: 0,
34
+ },
35
+ btnOptions: {
36
+ type: Array as PropType<BtnOptions[]>,
37
+ default: () => [],
38
+ },
39
+ // 按钮常用全局属性
40
+ size: {
41
+ type: String as PropType<"large" | "default" | "small">,
42
+ default: undefined,
43
+ },
44
+ plain: {
45
+ type: Boolean,
46
+ default: undefined,
60
47
  },
48
+ text: {
49
+ type: Boolean,
50
+ default: undefined,
51
+ },
52
+ link: {
53
+ type: Boolean,
54
+ default: undefined,
55
+ },
56
+
57
+ // // 权限函数
58
+ // hasRole: {
59
+ // type: Function,
60
+ // default: () => true
61
+ // },
62
+ };
63
+ export type ButtonAttrs = ExtractPropTypes<typeof buttonAttrs>;
64
+ export default defineComponent({
65
+ props: buttonAttrs,
61
66
  emits: ["btnAction"],
62
- setup(props, { emit, slots, attrs, expose }) {
67
+ setup(props: ButtonAttrs, { emit, slots, attrs, expose }) {
63
68
  // console.log('slots', slots);
64
69
  // console.log('attrs', attrs);
65
70
 
@@ -171,7 +176,7 @@ export default defineComponent({
171
176
  },
172
177
  {
173
178
  default: () => item?.label,
174
- }
179
+ },
175
180
  );
176
181
  };
177
182
  // 下拉菜单生成函数
@@ -236,11 +241,11 @@ export default defineComponent({
236
241
  },
237
242
  {
238
243
  default: () => item?.label,
239
- }
244
+ },
240
245
  );
241
246
  });
242
247
  },
243
- }
248
+ },
244
249
  );
245
250
  renderVdom = renderVdom.concat(dropdownVdom);
246
251
  }
@@ -0,0 +1,15 @@
1
+ import type { ButtonProps as ElButtonProps } from "element-plus";
2
+ import { type ButtonAttrs } from "./index.ts";
3
+ type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never; // 展开类型工具
4
+
5
+ export type ButtonProps = Expand<Partial<ButtonAttrs>>;
6
+
7
+ export type BtnOptions = Expand<
8
+ {
9
+ label: string;
10
+ alias: string;
11
+ permit?: string[];
12
+ vIf?: (params: any) => boolean;
13
+ disable?: boolean | ((params: any) => boolean);
14
+ } & Partial<ElButtonProps>
15
+ >;
@@ -1,6 +1,2 @@
1
- import Dialog from "./src/index";
2
- export * from "./src/index";
3
- // 把变量 Dialog 导出为 CDialog
4
- // export { Dialog, Dialog as CDialog };
5
- export { Dialog };
6
- export default Dialog;
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -9,9 +9,9 @@ import {
9
9
  import { ElDialog } from "element-plus";
10
10
  import { defaultAttrs } from "./constants.ts";
11
11
  import { prefix } from "../../config.ts";
12
- const propsAttrs = {};
12
+ const dialogAttrs = {};
13
13
 
14
- export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
14
+ export type DialogAttrs = ExtractPropTypes<typeof dialogAttrs>;
15
15
 
16
16
  export default defineComponent({
17
17
  name: `${prefix}Dialog`,
@@ -19,7 +19,7 @@ export default defineComponent({
19
19
  // emits: eventList,
20
20
 
21
21
  // attrs, emit会继承, slots需要设置
22
- setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
22
+ setup(props: DialogAttrs, { attrs, emit, slots, expose }) {
23
23
  // const dialogRef = ref();
24
24
 
25
25
  // 暴露方法
@@ -0,0 +1 @@
1
+ export type {}
@@ -0,0 +1 @@
1
+ export type {}
@@ -1,4 +1,2 @@
1
- import Drawer from "./src/index";
2
- export * from "./src/index";
3
- export { Drawer };
4
- export default Drawer;
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -9,16 +9,16 @@ import {
9
9
  import { ElDrawer } from "element-plus";
10
10
  import { defaultAttrs } from "./constants.ts";
11
11
 
12
- const propsAttrs = {};
12
+ const drawerAttrs = {};
13
13
 
14
- export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
14
+ export type DrawerAttrs = ExtractPropTypes<typeof drawerAttrs>;
15
15
 
16
16
  export default defineComponent({
17
17
  // props: propsAttrs,
18
18
  // emits: eventList,
19
19
 
20
20
  // attrs, emit会继承, slots需要设置
21
- setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
21
+ setup(props: DrawerAttrs, { attrs, emit, slots, expose }) {
22
22
  // const drawerRef = ref();
23
23
 
24
24
  // 暴露方法
@@ -0,0 +1 @@
1
+ export type {}
@@ -1,4 +1,2 @@
1
- import Form from "./src/index";
2
- export * from "./src/index";
3
- export { Form };
4
- export default Form;
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -1,4 +1,11 @@
1
- import { defineComponent, h, toRefs, inject, type PropType } from "vue";
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ toRefs,
5
+ inject,
6
+ type PropType,
7
+ type ExtractPropTypes,
8
+ } from "vue";
2
9
  import {
3
10
  ElFormItem,
4
11
  ElInput,
@@ -22,12 +29,12 @@ import {
22
29
  ElSwitch,
23
30
  ElText,
24
31
  } from "element-plus";
25
-
32
+ import { type FormItemProps } from "element-plus";
26
33
  import { isFunction, isBoolean } from "lodash-es";
27
34
  import { formTypeCfg } from "./constants";
28
35
  import { formatEventName } from "./utils";
29
36
 
30
- const propsAttrs = {
37
+ const formItemAttrs = {
31
38
  model: { type: Object, default: () => {} },
32
39
  // 表单名称
33
40
  label: { type: String, default: "" },
@@ -41,7 +48,7 @@ const propsAttrs = {
41
48
  // allReadonly: { type: Boolean<PropType<Boolean | Object>>, default: false },
42
49
  allReadonly: { type: Object, default: null }, // todo 上面传的类型是null报警告
43
50
  // formItem 属性
44
- formItem: { type: Object, default: () => {} },
51
+ formItem: { type: Object as PropType<FormItemProps>, default: () => {} },
45
52
  // 表单类型属性
46
53
  attrs: { type: Object, default: () => {} },
47
54
  // 字典
@@ -52,10 +59,11 @@ const propsAttrs = {
52
59
  optionsRef: { type: Object, default: () => {} },
53
60
  mergeParams: { type: Object, default: () => {} },
54
61
  };
62
+ export type FormItemAttrs = ExtractPropTypes<typeof formItemAttrs>;
55
63
 
56
64
  export default defineComponent({
57
- props: propsAttrs,
58
- setup(props, { attrs: $attrs, emit, slots, expose }) {
65
+ props: formItemAttrs,
66
+ setup(props: FormItemAttrs, { attrs: $attrs, emit, slots, expose }) {
59
67
  // 事件插槽透传
60
68
  const { formSlots, events } = inject("formContext");
61
69
 
@@ -156,7 +164,7 @@ export default defineComponent({
156
164
  ...handleAttrs(),
157
165
  ...handleEvents(),
158
166
  },
159
- { ...handleSlots() }
167
+ { ...handleSlots() },
160
168
  );
161
169
  },
162
170
  textarea: () => {
@@ -173,7 +181,7 @@ export default defineComponent({
173
181
  ...handleAttrs(),
174
182
  ...handleEvents(),
175
183
  },
176
- { ...handleSlots() }
184
+ { ...handleSlots() },
177
185
  );
178
186
  },
179
187
  select: () => {
@@ -193,7 +201,7 @@ export default defineComponent({
193
201
  key: item.value,
194
202
  });
195
203
  });
196
- }
204
+ },
197
205
  );
198
206
  },
199
207
  "select-v2": () => {
@@ -213,7 +221,7 @@ export default defineComponent({
213
221
  ...handleAttrs(),
214
222
  ...handleEvents(),
215
223
  },
216
- { ...handleSlots() }
224
+ { ...handleSlots() },
217
225
  );
218
226
  },
219
227
  "tree-select": () => {
@@ -225,7 +233,7 @@ export default defineComponent({
225
233
  ...handleAttrs(),
226
234
  ...handleEvents(),
227
235
  },
228
- { ...handleSlots() }
236
+ { ...handleSlots() },
229
237
  );
230
238
  },
231
239
  radio: () => {
@@ -247,7 +255,7 @@ export default defineComponent({
247
255
  });
248
256
  return v;
249
257
  },
250
- }
258
+ },
251
259
  );
252
260
  },
253
261
  checkbox: () => {
@@ -269,7 +277,7 @@ export default defineComponent({
269
277
  });
270
278
  return v;
271
279
  },
272
- }
280
+ },
273
281
  );
274
282
  },
275
283
  "time-select": () => {
@@ -294,7 +302,7 @@ export default defineComponent({
294
302
  ...handleAttrs(),
295
303
  ...handleEvents(),
296
304
  },
297
- { ...handleSlots() }
305
+ { ...handleSlots() },
298
306
  );
299
307
  },
300
308
  "time-picker": () => {
@@ -329,7 +337,7 @@ export default defineComponent({
329
337
  ...handleAttrs(),
330
338
  ...handleEvents(),
331
339
  },
332
- { ...handleSlots() }
340
+ { ...handleSlots() },
333
341
  );
334
342
  },
335
343
  text: () => {
@@ -389,7 +397,7 @@ export default defineComponent({
389
397
  },
390
398
  {
391
399
  default: () => renderTypeVdom,
392
- }
400
+ },
393
401
  );
394
402
  };
395
403
  // 返回表单类型
@@ -15,7 +15,7 @@ import CFormItem from "./FormItem.ts";
15
15
  import { has, isFunction } from "lodash-es";
16
16
  import { getEmits } from "./constants"; // 获取所有的事件
17
17
  import "../style/index.scss";
18
- const propsAttrs = {
18
+ const formAttrs = {
19
19
  // 表单数据
20
20
  model: { type: Object, default: () => ({}) },
21
21
  // 表单项
@@ -34,12 +34,12 @@ const propsAttrs = {
34
34
  params: { type: Object, default: () => ({}) },
35
35
  };
36
36
 
37
- export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
37
+ export type FormAttrs = ExtractPropTypes<typeof formAttrs>;
38
38
 
39
39
  export default defineComponent({
40
- props: propsAttrs,
40
+ props: formAttrs,
41
41
  emits: [...getEmits()],
42
- setup(props: PropsAttrs, { attrs: $attrs, emit, slots, expose }) {
42
+ setup(props: FormAttrs, { attrs: $attrs, emit, slots, expose }) {
43
43
  provide("formContext", {
44
44
  formSlots: slots,
45
45
  events: (eProp, ...args: any) => {
@@ -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,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";
@@ -1,4 +1,2 @@
1
- import Pagination from "./src/index";
2
- export * from "./src/index";
3
- export { Pagination };
4
- export default Pagination;
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -10,16 +10,16 @@ import { ElPagination } from "element-plus";
10
10
  import { get, has, isArray, isBoolean, isFunction, isNumber } from "lodash-es";
11
11
  import { defaultAttrs } from "./constants.ts";
12
12
 
13
- const propsAttrs = {};
13
+ const paginationAttrs = {};
14
14
 
15
- export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
15
+ export type PaginationAttrs = ExtractPropTypes<typeof paginationAttrs>;
16
16
 
17
17
  export default defineComponent({
18
- // props: propsAttrs,
18
+ // props: paginationAttrs,
19
19
  // emits: eventList,
20
20
 
21
21
  // attrs, emit会继承, slots需要设置
22
- setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
22
+ setup(props: PaginationAttrs, { attrs, emit, slots, expose }) {
23
23
  // const pageRef = ref();
24
24
 
25
25
  // 暴露方法
@@ -0,0 +1 @@
1
+ export type {}
@@ -1,4 +1,2 @@
1
- import Search from "./src/index.tsx";
2
- export * from "./src/index.tsx";
3
- export { Search };
4
- export default Search;
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.tsx";