@elementplus-kit/uikit 1.10.0 → 1.12.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[]>,
@@ -113,12 +102,16 @@ export default defineComponent({
113
102
  const defaultAttrs = {
114
103
  splitButton: true,
115
104
  };
105
+ // 禁用时有下拉不禁用
106
+ // if(item.disabled && dropdownItemList.length > 0) {
107
+ // defaultAttrs.class = `is-disabled-down ${item.class}`
108
+ // }
116
109
  // 过滤下拉菜单属性
117
110
  const l = [
118
111
  "type",
119
112
  "size",
120
113
  "splitButton",
121
- "disabled",
114
+ // "disabled",
122
115
  "placement",
123
116
  "effect",
124
117
  "trigger",
@@ -184,11 +177,22 @@ export default defineComponent({
184
177
  const dropdownList = []; // 不折叠的按钮
185
178
  const dropdownMain = []; // 下拉占位
186
179
  const dropdownItemList = []; // 折叠的按钮
187
-
180
+ let foldSun = 1;
181
+ if (!isBoolean(props.fold)) {
182
+ const s = props.fold * 1;
183
+ console.log("🚀 ~ createDropdown ~ s:", s);
184
+ if (s) {
185
+ if (isNumber(s)) {
186
+ foldSun = props.fold;
187
+ } else {
188
+ console.error("fold 类型错误");
189
+ }
190
+ }
191
+ }
188
192
  finalList.map((itm, idx) => {
189
- if (idx < props.foldNum) {
193
+ if (idx < foldSun - 1) {
190
194
  dropdownList.push(itm);
191
- } else if (idx === props.foldNum) {
195
+ } else if (idx === foldSun - 1) {
192
196
  dropdownMain.push(itm);
193
197
  } else {
194
198
  dropdownItemList.push(itm);
@@ -218,29 +222,19 @@ export default defineComponent({
218
222
  {
219
223
  ...getDropdownAttrs(dropdownMain[0]),
220
224
  class: "c-btn-dropdown",
221
- buttonProps: getAttrs(dropdownMain[0]),
222
- splitButton: true,
223
- // splitButton: dropdownItemList.length > 0,
224
- onClick: () => {
225
- emit("btnAction", dropdownMain[0].alias, props.params);
226
- },
227
- onCommand: (command: string) => {
228
- emit("btnAction", command, props.params);
229
- },
225
+ popperClass: "c-btn-dropdown-popper",
230
226
  },
231
227
  {
232
- default: () => {
233
- return dropdownMain[0].label;
234
- },
228
+ default: () => createBtn(dropdownMain[0]),
235
229
  dropdown: () => {
236
230
  return dropdownItemList.map((item) => {
237
231
  return h(
238
232
  ElDropdownItem,
239
233
  {
240
- command: item.alias,
234
+ // command: item.alias,
241
235
  },
242
236
  {
243
- default: () => item?.label,
237
+ default: () => createBtn(item),
244
238
  },
245
239
  );
246
240
  });
@@ -255,14 +249,34 @@ export default defineComponent({
255
249
  const render = () => {
256
250
  const finalList = filterOptions(); // 最终列表
257
251
  // 是否折叠 折叠
258
- if (props.fold) {
259
- return createDropdown(finalList);
260
- } else {
261
- // 不折叠
262
- return finalList.map((item) => {
263
- return createBtn(item);
264
- });
252
+ console.log("🚀 ~ render ~ props:", props);
253
+ let isFold = false;
254
+ if (isBoolean(props.fold)) {
255
+ isFold = props.fold;
256
+ } else if (isNumber(props.fold)) {
257
+ isFold = true;
258
+ } else if (isString(props.fold)) {
259
+ isFold = true;
265
260
  }
261
+
262
+ return h(
263
+ "div",
264
+ {
265
+ class: "c-button",
266
+ },
267
+ {
268
+ default: () => {
269
+ if (isFold) {
270
+ return createDropdown(finalList);
271
+ } else {
272
+ // 不折叠
273
+ return finalList.map((item) => {
274
+ return createBtn(item);
275
+ });
276
+ }
277
+ },
278
+ },
279
+ );
266
280
  };
267
281
  return () => render();
268
282
  },
@@ -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,3 +1,44 @@
1
- .el-button + .el-dropdown {
2
- margin-left: 10px;
1
+ .c-button {
2
+ display: inline-block;
3
+ .el-button + .el-dropdown {
4
+ margin-left: 10px;
5
+ }
6
+ > .el-button + .el-button {
7
+ margin-left: 10px;
8
+ }
9
+ .c-btn-dropdown {
10
+ .el-button-group {
11
+ > .el-button:nth-child(1) {
12
+ // 格式第一个按钮
13
+ padding: 0;
14
+ border: none;
15
+ background-color: transparent;
16
+ .el-button {
17
+ border-bottom-right-radius: 0;
18
+ border-top-right-radius: 0;
19
+ }
20
+ }
21
+ }
22
+ // 按钮聚焦外轮廓阴影
23
+ .el-button:focus-visible {
24
+ outline: none;
25
+ }
26
+ }
27
+ }
28
+ // 下拉悬浮窗
29
+ .c-btn-dropdown-popper {
30
+ .el-dropdown-menu__item {
31
+ padding: 0;
32
+ }
33
+ .el-button {
34
+ width: 100%;
35
+ border: none;
36
+ border-radius: 0;
37
+ }
38
+ .el-dropdown-menu__item + .el-dropdown-menu__item {
39
+ margin-top: 1px;
40
+ }
41
+ }
42
+ .c-btn-dropdown-popper.is-light {
43
+ border: none;
3
44
  }
@@ -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";
@@ -15,10 +15,6 @@ import {
15
15
  } from "./constants.ts";
16
16
  import { isArray, isObject, isFunction } from "lodash-es";
17
17
  const tableAttrs = {
18
- module: {
19
- type: Object,
20
- default: () => {},
21
- },
22
18
  params: {
23
19
  // 额外业务全局参数
24
20
  type: Object,
@@ -54,13 +50,12 @@ export type TableAttrs = ExtractPropTypes<typeof tableAttrs>;
54
50
 
55
51
  export default defineComponent({
56
52
  props: tableAttrs,
57
- // emits: eventList,
58
53
 
59
54
  // attrs, emit会继承, slots需要设置
60
55
  setup(props: TableAttrs, { attrs, emit, slots, expose }) {
61
56
  // 暴露elTable组件上的方法
62
- const vm = getCurrentInstance(); // 获取虚拟DOM实例
63
- const cTableFnRef = (el) => {
57
+ const vm: any = getCurrentInstance(); // 获取虚拟DOM实例
58
+ const cTableFnRef = (el: any) => {
64
59
  if (!el) return;
65
60
  vm.exposed = el; // 设置暴露对象
66
61
  vm.exposeProxy = el; // 设置代理暴露对象
@@ -71,40 +66,6 @@ export default defineComponent({
71
66
  // // tableRef,
72
67
  // });
73
68
 
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
69
  // 渲染表格列
109
70
  const renderTableColumn = () => {
110
71
  const list = [];
@@ -217,7 +178,7 @@ export default defineComponent({
217
178
 
218
179
  // 插槽处理
219
180
  const getSlots = () => {
220
- const obj = {};
181
+ const obj: any = {};
221
182
  tableSlots.map((name) => {
222
183
  if (slots[name]) {
223
184
  obj[name] = slots[name];
@@ -227,9 +188,6 @@ export default defineComponent({
227
188
  };
228
189
  // 渲染表格组件
229
190
  const renderTable = () => {
230
- // getColumnList();
231
- // console.log("props", props);
232
- // console.log("attrs", attrs);
233
191
  // 先拼接好子数据不然会重复执行多次
234
192
  const columnList = renderTableColumn();
235
193
  return h(
@@ -12,6 +12,8 @@ export type TableProps = Expand<Partial<TableAttrs>> &
12
12
 
13
13
  // 表格项属性
14
14
  export type TableColumnProps = {
15
+ label: string;
16
+ prop?: string | undefined;
15
17
  vIf?: (params: any) => boolean;
16
18
  render?: (scope: any) => any;
17
19
  options?: Array<{ label: string; value: any }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementplus-kit/uikit",
3
- "version": "1.10.0",
3
+ "version": "1.12.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";