@elementplus-kit/uikit 1.10.0 → 1.11.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.
@@ -1,50 +0,0 @@
1
- export const typeActiveMap = {
2
- reset: {
3
- name: "重置",
4
- type: "info",
5
- },
6
- search: {
7
- name: "查询",
8
- type: "primary",
9
- },
10
- submit: {
11
- name: "提交",
12
- type: "primary",
13
- },
14
- save: {
15
- name: "保存",
16
- type: "primary",
17
- },
18
- create: {
19
- name: "新增",
20
- type: "primary",
21
- },
22
- delete: {
23
- name: "删除",
24
- type: "danger",
25
- },
26
- edit: {
27
- name: "编辑",
28
- type: "primary",
29
- },
30
- view: {
31
- name: "查看",
32
- type: "primary",
33
- },
34
- publish: {
35
- name: "发布",
36
- type: "primary",
37
- },
38
- import: {
39
- name: "导入",
40
- type: "primary",
41
- },
42
- export: {
43
- name: "导出",
44
- type: "primary",
45
- },
46
- exportAll: {
47
- name: "导出全部",
48
- type: "primary",
49
- },
50
- };
@@ -1,17 +1,11 @@
1
1
  import { defineComponent, h, type PropType, type ExtractPropTypes } from "vue";
2
- import {
3
- ElButton,
4
- ElDropdown,
5
- ElDropdownMenu,
6
- ElDropdownItem,
7
- buttonProps,
8
- } from "element-plus";
2
+ import { ElButton, ElDropdown, ElDropdownItem } from "element-plus";
9
3
 
10
4
  import "../style/index.scss";
11
- import { has, isBoolean, isFunction, isArray } from "lodash-es";
12
- import { typeActiveMap } from "./constants.ts";
5
+ import { has, isBoolean, isFunction, isArray, isNumber } from "lodash-es";
13
6
 
14
7
  import { type BtnOptions } from "./type.ts";
8
+ import { isString } from "element-plus/es/utils/types.mjs";
15
9
  const buttonAttrs = {
16
10
  params: {
17
11
  // 用于验证自定义函数的外部数据
@@ -22,15 +16,10 @@ const buttonAttrs = {
22
16
  permit: {
23
17
  type: Function,
24
18
  },
25
- // 折叠
19
+ // 折叠与数量
26
20
  fold: {
27
- type: Boolean,
28
- default: false,
29
- },
30
- // 折叠数量
31
- foldNum: {
32
- type: Number,
33
- default: 0,
21
+ type: [Number, String, Boolean, undefined],
22
+ default: undefined,
34
23
  },
35
24
  btnOptions: {
36
25
  type: Array as PropType<BtnOptions[]>,
@@ -184,11 +173,22 @@ export default defineComponent({
184
173
  const dropdownList = []; // 不折叠的按钮
185
174
  const dropdownMain = []; // 下拉占位
186
175
  const dropdownItemList = []; // 折叠的按钮
187
-
176
+ let foldSun = 1;
177
+ if (!isBoolean(props.fold)) {
178
+ const s = props.fold * 1;
179
+ console.log("🚀 ~ createDropdown ~ s:", s);
180
+ if (s) {
181
+ if (isNumber(s)) {
182
+ foldSun = props.fold;
183
+ } else {
184
+ console.error("fold 类型错误");
185
+ }
186
+ }
187
+ }
188
188
  finalList.map((itm, idx) => {
189
- if (idx < props.foldNum) {
189
+ if (idx < foldSun - 1) {
190
190
  dropdownList.push(itm);
191
- } else if (idx === props.foldNum) {
191
+ } else if (idx === foldSun - 1) {
192
192
  dropdownMain.push(itm);
193
193
  } else {
194
194
  dropdownItemList.push(itm);
@@ -255,7 +255,16 @@ export default defineComponent({
255
255
  const render = () => {
256
256
  const finalList = filterOptions(); // 最终列表
257
257
  // 是否折叠 折叠
258
- if (props.fold) {
258
+ console.log("🚀 ~ render ~ props:", props);
259
+ let isFold = false;
260
+ if (isBoolean(props.fold)) {
261
+ isFold = props.fold;
262
+ } else if (isNumber(props.fold)) {
263
+ isFold = true;
264
+ } else if (isString(props.fold)) {
265
+ isFold = true;
266
+ }
267
+ if (isFold) {
259
268
  return createDropdown(finalList);
260
269
  } else {
261
270
  // 不折叠
@@ -8,6 +8,8 @@ export type BtnOptions = Expand<
8
8
  {
9
9
  label: string;
10
10
  alias: string;
11
+ type: string;
12
+ icon?: any;
11
13
  permit?: string[];
12
14
  vIf?: (params: any) => boolean;
13
15
  disable?: boolean | ((params: any) => boolean);
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  defineComponent,
3
- ref,
4
3
  h,
5
- computed,
6
- toRefs,
7
4
  type ExtractPropTypes,
8
5
  } from "vue";
9
6
  import { ElDialog } from "element-plus";
@@ -15,18 +12,9 @@ export type DialogAttrs = ExtractPropTypes<typeof dialogAttrs>;
15
12
 
16
13
  export default defineComponent({
17
14
  name: `${prefix}Dialog`,
18
- // props: propsAttrs,
19
- // emits: eventList,
20
15
 
21
16
  // attrs, emit会继承, slots需要设置
22
17
  setup(props: DialogAttrs, { attrs, emit, slots, expose }) {
23
- // const dialogRef = ref();
24
-
25
- // 暴露方法
26
- // expose({
27
- // dialogRef,
28
- // });
29
-
30
18
  // 属性处理
31
19
  const getAttrs = () => {
32
20
  const obj = {
@@ -40,11 +28,10 @@ export default defineComponent({
40
28
  return h(
41
29
  ElDialog,
42
30
  {
43
- // ref: dialogRef,
44
31
  ...getAttrs(),
45
32
  class: "c-dialog",
46
33
  },
47
- slots
34
+ slots,
48
35
  );
49
36
  };
50
37
 
@@ -14,18 +14,8 @@ const drawerAttrs = {};
14
14
  export type DrawerAttrs = ExtractPropTypes<typeof drawerAttrs>;
15
15
 
16
16
  export default defineComponent({
17
- // props: propsAttrs,
18
- // emits: eventList,
19
-
20
17
  // attrs, emit会继承, slots需要设置
21
18
  setup(props: DrawerAttrs, { attrs, emit, slots, expose }) {
22
- // const drawerRef = ref();
23
-
24
- // 暴露方法
25
- // expose({
26
- // drawerRef,
27
- // });
28
-
29
19
  // 属性处理
30
20
  const getAttrs = () => {
31
21
  const obj = {
@@ -39,11 +29,10 @@ export default defineComponent({
39
29
  return h(
40
30
  ElDrawer,
41
31
  {
42
- // ref: drawerRef,
43
32
  ...getAttrs(),
44
33
  class: "c-drawer",
45
34
  },
46
- slots
35
+ slots,
47
36
  );
48
37
  };
49
38
 
@@ -63,8 +63,8 @@ export default defineComponent({
63
63
  const { model, formOptions, readonly, gutter, col } = toRefs(props);
64
64
 
65
65
  // 暴露elForm组件上的方法
66
- const vm = getCurrentInstance(); // 获取虚拟DOM实例
67
- const cFormFnRef = (el) => {
66
+ const vm: any = getCurrentInstance(); // 获取虚拟DOM实例
67
+ const cFormFnRef = (el: any) => {
68
68
  if (!el) return;
69
69
  vm.exposed = el; // 设置暴露对象
70
70
  vm.exposeProxy = el; // 设置代理暴露对象
@@ -78,7 +78,7 @@ export default defineComponent({
78
78
  () =>
79
79
  ["", 0].includes(gutter?.value) ||
80
80
  col?.value ||
81
- formOptions?.value.some((item) => has(item, "col"))
81
+ formOptions?.value.some((item) => has(item, "col")),
82
82
  );
83
83
 
84
84
  // 渲染 row
@@ -95,7 +95,7 @@ export default defineComponent({
95
95
  },
96
96
  {
97
97
  default: () => formItemVdom,
98
- }
98
+ },
99
99
  );
100
100
  } else {
101
101
  return formItemVdom;
@@ -161,14 +161,14 @@ export default defineComponent({
161
161
  span: has(item, "col")
162
162
  ? item.col
163
163
  : col?.value
164
- ? col?.value
165
- : isLayout.value
166
- ? 8
167
- : undefined,
164
+ ? col?.value
165
+ : isLayout.value
166
+ ? 8
167
+ : undefined,
168
168
  },
169
169
  {
170
170
  default: () => (colSlot ? colSlot() : rFormItem()),
171
- }
171
+ },
172
172
  );
173
173
  } else {
174
174
  return rFormItem();
@@ -188,7 +188,7 @@ export default defineComponent({
188
188
  },
189
189
  {
190
190
  default: () => renderRow(),
191
- }
191
+ },
192
192
  );
193
193
  };
194
194
 
@@ -1,4 +1,4 @@
1
- // 字符串转大驼峰
2
- export const formatEventName = (name: string) => {
3
- return name.replace(/(?:^|-)(\w)/g, (_, c) => c.toUpperCase())
4
- }
1
+ // 字符串转大驼峰
2
+ export const formatEventName = (name: string) => {
3
+ return name.replace(/(?:^|-)(\w)/g, (_, c) => c.toUpperCase());
4
+ };
@@ -1,8 +1,8 @@
1
- export * from "./table/index.ts";
2
- export * from "./form/index.ts";
3
- export * from "./pagination/index.ts";
4
- export * from "./dialog/index.ts";
5
- export * from "./drawer/index.ts";
6
- export * from "./search/index.ts";
7
- export * from "./button/index.ts";
8
- export * from "./dictLabel/index.ts";
1
+ export * from "./table/index.ts"; // 表格
2
+ export * from "./form/index.ts"; // 表单
3
+ export * from "./pagination/index.ts"; // 分页
4
+ export * from "./dialog/index.ts"; // 弹窗
5
+ export * from "./drawer/index.ts"; // 抽屉
6
+ export * from "./search/index.ts"; // 搜索
7
+ export * from "./button/index.ts"; // 按钮
8
+ export * from "./dictLabel/index.ts"; // 字典标签
@@ -15,18 +15,8 @@ const paginationAttrs = {};
15
15
  export type PaginationAttrs = ExtractPropTypes<typeof paginationAttrs>;
16
16
 
17
17
  export default defineComponent({
18
- // props: paginationAttrs,
19
- // emits: eventList,
20
-
21
18
  // attrs, emit会继承, slots需要设置
22
19
  setup(props: PaginationAttrs, { attrs, emit, slots, expose }) {
23
- // const pageRef = ref();
24
-
25
- // 暴露方法
26
- // expose({
27
- // pageRef,
28
- // });
29
-
30
20
  // 属性处理
31
21
  const getAttrs = () => {
32
22
  const obj = {
@@ -38,7 +28,6 @@ export default defineComponent({
38
28
  // 渲染表单
39
29
  const render = () => {
40
30
  return h(ElPagination, {
41
- // ref: pageRef,
42
31
  ...getAttrs(),
43
32
  class: "c-pagination",
44
33
  });
@@ -197,6 +197,7 @@ export default defineComponent({
197
197
 
198
198
  return () => {
199
199
  return (
200
+ // c-search 使用中需要设置动态宽度
200
201
  <div className="c-search">
201
202
  <div className="c-search-simple" ref={simpleRef}>
202
203
  <div className="c-search-simple-form" ref={simpleFormRef}>
@@ -1,2 +1 @@
1
1
  export type { SearchAttrs as SearchProps } from "./index.tsx";
2
- export default "./index.tsx";
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  defineComponent,
3
3
  h,
4
- getCurrentInstance,
5
4
  type ExtractPropTypes,
6
5
  } from "vue";
7
6
  import { ElTableColumn } from "element-plus";
@@ -54,13 +54,12 @@ export type TableAttrs = ExtractPropTypes<typeof tableAttrs>;
54
54
 
55
55
  export default defineComponent({
56
56
  props: tableAttrs,
57
- // emits: eventList,
58
57
 
59
58
  // attrs, emit会继承, slots需要设置
60
59
  setup(props: TableAttrs, { attrs, emit, slots, expose }) {
61
60
  // 暴露elTable组件上的方法
62
- const vm = getCurrentInstance(); // 获取虚拟DOM实例
63
- const cTableFnRef = (el) => {
61
+ const vm: any = getCurrentInstance(); // 获取虚拟DOM实例
62
+ const cTableFnRef = (el: any) => {
64
63
  if (!el) return;
65
64
  vm.exposed = el; // 设置暴露对象
66
65
  vm.exposeProxy = el; // 设置代理暴露对象
@@ -71,40 +70,6 @@ export default defineComponent({
71
70
  // // tableRef,
72
71
  // });
73
72
 
74
- // // 属性处理
75
- // const getAttrs = () => {
76
- // const obj = {
77
- // ...defaultAttrs, // 设置默认值
78
- // };
79
- // return obj;
80
- // };
81
- // // 事件处理
82
- // const getEvents = () => {
83
- // const obj = {
84
- // ...defaultAttrs, // 设置默认值
85
- // };
86
- // return obj;
87
- // };
88
-
89
- // // 处理列数据-数组
90
- // const getArrayColumn = () => {
91
- // // 递归处理数据
92
- // const list = [];
93
-
94
- // const columnsRecursion = (columns, list) => {
95
- // columns?.map((item) => {
96
- // const { children, ...p } = item;
97
- // // 递归处理子列
98
- // if (isArray(item.children)) {
99
- // item.children = c(item.children, list);
100
- // }
101
- // list.push(p);
102
- // });
103
- // };
104
- // columnsRecursion(props.columns, list);
105
- // return list;
106
- // };
107
-
108
73
  // 渲染表格列
109
74
  const renderTableColumn = () => {
110
75
  const list = [];
@@ -217,7 +182,7 @@ export default defineComponent({
217
182
 
218
183
  // 插槽处理
219
184
  const getSlots = () => {
220
- const obj = {};
185
+ const obj: any = {};
221
186
  tableSlots.map((name) => {
222
187
  if (slots[name]) {
223
188
  obj[name] = slots[name];
@@ -227,9 +192,6 @@ export default defineComponent({
227
192
  };
228
193
  // 渲染表格组件
229
194
  const renderTable = () => {
230
- // getColumnList();
231
- // console.log("props", props);
232
- // console.log("attrs", attrs);
233
195
  // 先拼接好子数据不然会重复执行多次
234
196
  const columnList = renderTableColumn();
235
197
  return h(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementplus-kit/uikit",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "",
5
5
  "main": "./components/index.ts",
6
6
  "peerDependencies": {
@@ -1,2 +0,0 @@
1
- export type textType2 = "1" | "2" | "3";
2
- export type textType3 = "2" | "3" | "4";
@@ -1 +0,0 @@
1
- import { TableProps, TableColumnProps } from "@elementplus-kit/uikit";
@@ -1,3 +0,0 @@
1
- type textType1 = "a" | "b" | "c";
2
- export type textType2 = "1" | "2" | "3";
3
- export type textType3 = "2" | "3" | "4";