@elementplus-kit/uikit 1.4.0 → 1.6.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 (66) hide show
  1. package/dist/index.css +1 -0
  2. package/dist/index.mjs +1079 -0
  3. package/dist/index.umd.js +1 -0
  4. package/package.json +14 -4
  5. package/aaaindex.ts +0 -55
  6. package/build.log +0 -0
  7. package/components/button/index.ts +0 -4
  8. package/components/button/src/constants.ts +0 -50
  9. package/components/button/src/index.ts +0 -264
  10. package/components/button/style/index.scss +0 -3
  11. package/components/config.ts +0 -4
  12. package/components/dialog/index.ts +0 -6
  13. package/components/dialog/src/constants.ts +0 -3
  14. package/components/dialog/src/index.ts +0 -54
  15. package/components/dialog/style/index.scss +0 -18
  16. package/components/dictLabel/index.ts +0 -4
  17. package/components/dictLabel/src/index.vue +0 -21
  18. package/components/drawer/index.ts +0 -4
  19. package/components/drawer/src/constants.ts +0 -3
  20. package/components/drawer/src/index.ts +0 -53
  21. package/components/drawer/style/index.scss +0 -18
  22. package/components/form/index.ts +0 -4
  23. package/components/form/src/FormItem.ts +0 -397
  24. package/components/form/src/constants.ts +0 -161
  25. package/components/form/src/index.ts +0 -207
  26. package/components/form/src/types.ts +0 -39
  27. package/components/form/src/utils.ts +0 -4
  28. package/components/form/style/index.scss +0 -5
  29. package/components/pagination/index.ts +0 -4
  30. package/components/pagination/src/constants.ts +0 -5
  31. package/components/pagination/src/index.ts +0 -50
  32. package/components/search/index.ts +0 -4
  33. package/components/search/src/index.tsx +0 -276
  34. package/components/search/style/index.scss +0 -101
  35. package/components/table/index.ts +0 -4
  36. package/components/table/src/TableColumn.ts +0 -116
  37. package/components/table/src/constants.ts +0 -42
  38. package/components/table/src/index.ts +0 -250
  39. package/components/table/src/index2.ts +0 -219
  40. package/components/table/src/index3.ts +0 -233
  41. package/components/table/src/tableDictLabel.vue +0 -21
  42. package/components/table/src/tableaa.ts +0 -71
  43. package/components/table/src/type.ts +0 -0
  44. package/components/table/type/index.scss +0 -0
  45. package/components/table2/index.ts +0 -4
  46. package/components/table2/src/config.ts +0 -5
  47. package/components/table2/src/index.ts +0 -12
  48. package/components/table2/src/render.ts +0 -136
  49. package/components/table2/src/types.ts +0 -39
  50. package/components/table2/style/index.scss +0 -0
  51. package/components//346/250/241/346/235/277/index.tsx +0 -57
  52. package/components//346/250/241/346/235/277/ttt.ts +0 -66
  53. package/components//346/250/241/346/235/277/ttt.vue +0 -18
  54. package/index.ts +0 -2
  55. package/vite.config.ts +0 -26
  56. package//345/205/266/344/273/226/core/dialog/elementPlus/dialogWarp.vue +0 -151
  57. package//345/205/266/344/273/226/core/dialog/index.ts +0 -10
  58. package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.ts +0 -15
  59. package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.vue +0 -16
  60. package//345/205/266/344/273/226/core/form/elementPlus/formRender.ts +0 -55
  61. package//345/205/266/344/273/226/core/form/index.ts +0 -10
  62. package//345/205/266/344/273/226/core/table/config.ts +0 -5
  63. package//345/205/266/344/273/226/core/table/render.ts +0 -91
  64. package//345/205/266/344/273/226/core/table/warp.ts +0 -11
  65. package//345/205/266/344/273/226/core/utils/fetch.ts +0 -58
  66. package//345/205/266/344/273/226/useMessage.ts +0 -95
@@ -1,397 +0,0 @@
1
- import { defineComponent, ref, h, toRefs, inject, type PropType } from "vue";
2
- import {
3
- ElFormItem,
4
- ElInput,
5
- ElInputNumber,
6
- ElSelect,
7
- ElOption,
8
- ElSelectV2,
9
- ElCascader,
10
- ElTreeSelect,
11
- ElRate,
12
- ElCheckboxGroup,
13
- ElCheckbox,
14
- ElTimeSelect,
15
- ElTimePicker,
16
- ElDatePicker,
17
- ElRadioGroup,
18
- ElRadio,
19
- ElRadioButton,
20
- ElColorPicker,
21
- ElSlider,
22
- ElSwitch,
23
- ElText,
24
- } from "element-plus";
25
-
26
- import { isFunction, isBoolean } from "lodash-es";
27
- import { formTypeCfg } from "./constants";
28
- import { formatEventName } from "./utils";
29
-
30
- const propsAttrs = {
31
- model: { type: Object, default: () => {} },
32
- // 表单名称
33
- label: { type: String, default: "" },
34
- // 表单类型
35
- type: { type: String, default: "" },
36
- // 表单key
37
- prop: { type: String, default: "" },
38
- // 必填
39
- required: { type: Boolean, default: false },
40
- // 全部只读
41
- // allReadonly: { type: Boolean<PropType<Boolean | Object>>, default: false },
42
- allReadonly: { type: Object, default: null }, // todo 上面传的类型是null报警告
43
- // formItem 属性
44
- formItem: { type: Object, default: () => {} },
45
- // 表单类型属性
46
- attrs: { type: Object, default: () => {} },
47
- // 字典
48
- dictType: { type: String, default: undefined },
49
- // 字典选项
50
- options: { type: Array, default: () => [] },
51
- // 字典选项
52
- optionsRef: { type: Object, default: () => {} },
53
- mergeParams: { type: Object, default: () => {} },
54
- };
55
-
56
- export default defineComponent({
57
- props: propsAttrs,
58
- setup(props, { attrs: $attrs, emit, slots, expose }) {
59
- // 事件插槽透传
60
- const { formSlots, events } = inject("formContext");
61
-
62
- // 解构props
63
- const {
64
- model,
65
- type,
66
- label,
67
- prop,
68
- required,
69
- allReadonly,
70
- formItem,
71
- attrs,
72
- dictType,
73
- options,
74
- } = toRefs(props);
75
-
76
- // 处理组件自带插槽
77
- const handleSlots = () => {
78
- const compSlots = {};
79
- // 遍历传进来的所有插槽匹配约定名称 例如:input.prefix
80
- const formTypeSlots = formTypeCfg[type.value]?.slots;
81
- formTypeSlots?.forEach((name) => {
82
- const slotName = `${prop.value}.${name}`;
83
- // 根据父组件插槽名称生成子组件插槽
84
- Object.keys(formSlots).map((key) => {
85
- if (key === slotName) {
86
- compSlots[name] = formSlots[key];
87
- }
88
- });
89
- });
90
- return compSlots;
91
- };
92
-
93
- // 处理事件 只有自定义事件才能被vue组件捕获进$attrs中 所有不能实现根据父组件事件动态按需注册子组件事件
94
- const handleEvents = () => {
95
- const compEvents = {};
96
- const formTypeEvents = formTypeCfg[type.value]?.events;
97
- // 当前类型的事件
98
- formTypeEvents?.forEach((event) => {
99
- const eventName = `on${formatEventName(event)}`; // 字符串转大驼峰, 转成 h 函数需要格式
100
- // events 第一个参数是事件名称,是h函数的写法规则,父组件provide events 中的e是第二个参数
101
- compEvents[eventName] = (...arg: any) =>
102
- events(event, prop.value, ...arg);
103
- });
104
- return compEvents;
105
- };
106
-
107
- // 获取禁用状态
108
- const getDisabled = () => {
109
- let disabled = false;
110
- if (isFunction(attrs.value?.disabled)) {
111
- disabled = attrs.value.disabled(props.mergeParams);
112
- }
113
- if (isBoolean(attrs.value?.disabled)) { // 在 attrs 后面结构, 也要处理直接赋值的情况,不然会覆盖
114
- disabled = attrs.value.disabled;
115
- }
116
- // 全部只读
117
- if (allReadonly.value) {
118
- disabled = true;
119
- }
120
- return { disabled };
121
- };
122
- // 处理属性 v-model绑定
123
- const handleAttrs = () => {
124
- // 获取默认属性
125
- const defaultAttrs = formTypeCfg[type.value]?.defaultAttrs || {};
126
- const typeAttrs = {
127
- ref: (vEl) => setElRef(vEl, prop.value),
128
- // modelValue: model.value[prop.value],
129
- // 'onUpdate:modelValue': (val) => (model.value[prop.value] = val),
130
- ...defaultAttrs,
131
- ...attrs.value,
132
- ...getDisabled(),
133
- };
134
-
135
- // 数据双向绑定,并过滤不需要双向绑定的组件
136
- if (!["html"].includes(type.value)) {
137
- typeAttrs.modelValue = model.value[prop.value];
138
- typeAttrs["onUpdate:modelValue"] = (val) =>
139
- (model.value[prop.value] = val);
140
- }
141
- return typeAttrs;
142
- };
143
-
144
- // 设置元素 Ref
145
- const setElRef = (vEl: any, value: string) => {
146
- props.optionsRef[`${value}Ref`] = vEl;
147
- };
148
-
149
- const getFormType = {
150
- input: () => {
151
- return h(
152
- ElInput,
153
- {
154
- clearable: true,
155
- ...handleAttrs(),
156
- ...handleEvents(),
157
- },
158
- { ...handleSlots() }
159
- );
160
- },
161
- textarea: () => {
162
- return h(ElInput, {
163
- ...handleAttrs(),
164
- ...handleEvents(),
165
- type: "textarea",
166
- });
167
- },
168
- "input-number": () => {
169
- return h(
170
- ElInputNumber,
171
- {
172
- ...handleAttrs(),
173
- ...handleEvents(),
174
- },
175
- { ...handleSlots() }
176
- );
177
- },
178
- select: () => {
179
- return h(
180
- ElSelect,
181
- {
182
- clearable: true,
183
- ...handleAttrs(),
184
- ...handleEvents(),
185
- },
186
- () => {
187
- return options?.value?.map((item) => {
188
- return h(ElOption, {
189
- ...item,
190
- label: item.label,
191
- value: item.value,
192
- key: item.value,
193
- });
194
- });
195
- }
196
- );
197
- },
198
- "select-v2": () => {
199
- return h(ElSelectV2, {
200
- options: options.value,
201
- clearable: true,
202
- ...handleAttrs(),
203
- ...handleEvents(),
204
- });
205
- },
206
- cascader: () => {
207
- return h(
208
- ElCascader,
209
- {
210
- options: options.value,
211
- clearable: true,
212
- ...handleAttrs(),
213
- ...handleEvents(),
214
- },
215
- { ...handleSlots() }
216
- );
217
- },
218
- "tree-select": () => {
219
- return h(
220
- ElTreeSelect,
221
- {
222
- data: options.value,
223
- clearable: true,
224
- ...handleAttrs(),
225
- ...handleEvents(),
226
- },
227
- { ...handleSlots() }
228
- );
229
- },
230
- radio: () => {
231
- return h(
232
- ElRadioGroup,
233
- {
234
- ...handleAttrs(),
235
- ...handleEvents(),
236
- },
237
- {
238
- default: () => {
239
- const v = options?.value?.map((item) => {
240
- return h(item.radioButton ? ElRadioButton : ElRadio, {
241
- ...item,
242
- label: item.label,
243
- value: item.value,
244
- key: item.value,
245
- });
246
- });
247
- return v;
248
- },
249
- }
250
- );
251
- },
252
- checkbox: () => {
253
- return h(
254
- ElCheckboxGroup,
255
- {
256
- ...handleAttrs(),
257
- ...handleEvents(),
258
- },
259
- {
260
- default: () => {
261
- const v = options?.value?.map((item) => {
262
- return h(ElCheckbox, {
263
- ...item,
264
- label: item.label,
265
- value: item.value,
266
- key: item.value,
267
- });
268
- });
269
- return v;
270
- },
271
- }
272
- );
273
- },
274
- "time-select": () => {
275
- return h(ElTimeSelect, {
276
- ...handleAttrs(),
277
- ...handleEvents(),
278
- });
279
- },
280
- "date-picker": () => {
281
- const type = attrs.value?.type || "date";
282
- const valueFormatMap = {
283
- year: "YYYY",
284
- month: "YYYY-MM",
285
- date: "YYYY-MM-DD",
286
- };
287
- const valueFormat = valueFormatMap[type];
288
- return h(
289
- ElDatePicker,
290
- {
291
- type,
292
- valueFormat: valueFormat,
293
- ...handleAttrs(),
294
- ...handleEvents(),
295
- },
296
- { ...handleSlots() }
297
- );
298
- },
299
- "time-picker": () => {
300
- return h(ElTimePicker, {
301
- valueFormat: "HH:mm:ss",
302
- ...handleAttrs(),
303
- ...handleEvents(),
304
- });
305
- },
306
- rate: () => {
307
- return h(ElRate, {
308
- ...handleAttrs(),
309
- ...handleEvents(),
310
- });
311
- },
312
- "color-picker": () => {
313
- return h(ElColorPicker, {
314
- ...handleAttrs(),
315
- ...handleEvents(),
316
- });
317
- },
318
- slider: () => {
319
- return h(ElSlider, {
320
- ...handleAttrs(),
321
- ...handleEvents(),
322
- });
323
- },
324
- switch: () => {
325
- return h(
326
- ElSwitch,
327
- {
328
- ...handleAttrs(),
329
- ...handleEvents(),
330
- },
331
- { ...handleSlots() }
332
- );
333
- },
334
- text: () => {
335
- return h(ElText, {
336
- ...handleAttrs(),
337
- });
338
- },
339
- html: () => {
340
- return h("div", {
341
- innerHTML: model.value[prop.value],
342
- ...handleAttrs(),
343
- });
344
- },
345
- slot: () => {
346
- return formSlots[prop.value]?.(model.value);
347
- },
348
- };
349
-
350
- const renderType = () => {
351
- // 自动启动插槽
352
- if (formSlots[prop.value]) {
353
- return getFormType["slot"]();
354
- } else {
355
- // solt类型未定义插槽时提示
356
- if (type.value === "slot") {
357
- return `表单属性 ${prop.value} 插槽模板未定义`;
358
- }
359
- }
360
-
361
- // 判断非插槽且不支持的类型
362
- if (!getFormType[type.value]) {
363
- console.error(`不支持的表单类型 ${type.value}`);
364
- return `不支持的表单类型 ${type.value}`;
365
- }
366
-
367
- // 非插槽类型
368
- return getFormType[type.value]();
369
- };
370
-
371
- const render = () => {
372
- const renderTypeVdom = renderType();
373
- return h(
374
- ElFormItem,
375
- {
376
- label: label.value,
377
- prop: prop.value,
378
- rules: required.value
379
- ? [
380
- {
381
- required: true,
382
- message: `${label.value} 必填`,
383
- trigger: "blur",
384
- },
385
- ]
386
- : undefined,
387
- ...formItem.value,
388
- },
389
- {
390
- default: () => renderTypeVdom,
391
- }
392
- );
393
- };
394
- // 返回表单类型
395
- return () => render();
396
- },
397
- });
@@ -1,161 +0,0 @@
1
- export const formTypeCfg = {
2
- input: {
3
- elName: 'input',
4
- defaultAttrs: {},
5
- events: [
6
- 'blur',
7
- 'focus',
8
- 'change',
9
- 'input',
10
- 'clear',
11
- 'keydown',
12
- 'mouseleave',
13
- 'mouseenter',
14
- 'compositionstart',
15
- 'compositionupdate',
16
- 'compositionend',
17
- ],
18
- slots: ['prefix', 'suffix', 'prepend', 'append'],
19
- },
20
- textarea: {
21
- elName: 'textarea',
22
- defaultAttrs: {},
23
- events: ['blur', 'focus', 'change', 'input'],
24
- },
25
-
26
- 'input-number': {
27
- elName: 'input-number',
28
- defaultAttrs: {},
29
- events: ['change', 'Function', 'blur', 'focus'],
30
- slots: ['decrease-icon', 'increase-icon', 'prefix', 'suffix'],
31
- },
32
- select: {
33
- elName: 'select',
34
- defaultAttrs: {},
35
- events: ['change', 'visible-change', 'remove-tag', 'clear', 'blur', 'focus', 'popup-scroll'],
36
- slots: ['default', 'header', 'footer', 'prefix', 'empty', 'tag', 'loading', 'label'],
37
- },
38
- 'select-v2': {
39
- elName: 'select-v2',
40
- defaultAttrs: {},
41
- events: ['focus', 'blur', 'selectedLabel'],
42
- slots: ['default', 'header', 'footer', 'prefix', 'empty', 'tag', 'loading', 'label'],
43
- },
44
- cascader: {
45
- elName: 'cascader',
46
- defaultAttrs: {},
47
- events: ['change', 'expand-change', 'blur', 'focus', 'clear', 'visible-change', 'remove-tag'],
48
- slots: ['default', 'empty', 'prefix', 'suggestion-item', 'tag'],
49
- },
50
- 'tree-select': {
51
- elName: 'tree-select',
52
- defaultAttrs: {},
53
- events: ['change', 'clear', 'blur', 'focus'],
54
- slots: ['default'],
55
- },
56
- radio: {
57
- elName: 'radio',
58
- defaultAttrs: {},
59
- events: ['change'],
60
- // slots: ['default'],
61
- },
62
- checkbox: {
63
- elName: 'checkbox',
64
- defaultAttrs: {},
65
- events: ['change'],
66
- // slots: ['default'],
67
- },
68
- 'time-select': {
69
- elName: 'time-select',
70
- defaultAttrs: {},
71
- events: ['change', 'blur', 'focus', 'clear'],
72
- },
73
- 'date-picker': {
74
- elName: 'date-picker',
75
- defaultAttrs: {},
76
- events: [
77
- 'change',
78
- 'blur',
79
- 'focus',
80
- 'clear',
81
- 'calendar-change',
82
- 'panel-change',
83
- 'visible-change',
84
- ],
85
- slots: ['default', 'range-separator', 'prev-month', 'next-month', 'prev-year', 'next-year'],
86
- },
87
- 'time-picker': {
88
- elName: 'time-picker',
89
- defaultAttrs: {},
90
- events: ['change', 'blur', 'focus', 'clear', 'visible-change'],
91
- slots: [],
92
- },
93
- rate: {
94
- elName: 'rate',
95
- defaultAttrs: {},
96
- events: ['change'],
97
- },
98
- 'color-picker': {
99
- elName: 'color-picker',
100
- defaultAttrs: {},
101
- events: ['change', 'active-change', 'focus', 'blur'],
102
- },
103
- slider: {
104
- elName: 'slider',
105
- defaultAttrs: {},
106
- events: ['change', 'input'],
107
- },
108
- switch: {
109
- elName: 'switch',
110
- defaultAttrs: {},
111
- events: ['change'],
112
- slots: ['active-action', 'inactive-action'],
113
- },
114
- text: {
115
- elName: 'text',
116
- defaultAttrs: {},
117
- slots: ['default'],
118
- },
119
- html: {},
120
- slot: {},
121
- }
122
-
123
- enum formItemType2 {
124
- input = 'input', // 文本
125
- textarea = 'textarea', // 文本域
126
- inputNumber = 'inputNumber', // 数字
127
-
128
- select = 'select', // 下拉
129
- selectV2 = 'selectV2', // 虚拟下拉
130
- cascader = 'cascader', // 联级选择器
131
- treeSelect = 'treeSelect', // 下拉树
132
-
133
- radio = 'radio', // 单选
134
- checkbox = 'checkbox', // 多选
135
-
136
- datePicker = 'datePicker', // 日期选择器
137
- dateTimePicker = 'dateTimePicker', // 日期时间选择器
138
- timePicker = 'timePicker', // 联级时间选择
139
- timeSelect = 'timeSelect', // 下拉时间选择
140
-
141
- colorPicker = 'colorPicker', // 颜色选择器
142
- switch = 'switch', // 开关
143
- rate = 'rate', // 评分
144
- slider = 'slider', // 滑块
145
-
146
- html = 'html', // html
147
- slot = 'slot', // slot插槽
148
- }
149
-
150
- // 获取所有的事件
151
- export const getEmits = () => {
152
- let emits = []
153
- Object.keys(formTypeCfg).map((key) => {
154
- const events = formTypeCfg[key]?.events
155
- if (events?.length > 0) {
156
- emits.push(...events)
157
- }
158
- })
159
- emits = [...new Set(emits)]
160
- return emits
161
- }