yj-kikimore 0.1.3 → 0.1.4
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.
- package/README.md +16 -48
- package/package.json +10 -20
- package/src/FormDialog/index.vue +28 -50
- package/src/PopButton/index.vue +1 -3
- package/src/PopSwitch/index.vue +18 -26
- package/src/Select/index.vue +8 -14
- package/src/src/utils.d.ts +2 -2
- package/src/utils.ts +3 -20
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<h1 align="center">yj-Kikimore</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
|
|
4
|
+
基于 Vue 3 + Element Plus 的组件封装。
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<br>
|
|
@@ -72,49 +72,9 @@ app
|
|
|
72
72
|
|
|
73
73
|
<br>
|
|
74
74
|
|
|
75
|
-
### Element (Vue 2)
|
|
76
|
-
|
|
77
|
-
#### 局部注册
|
|
78
|
-
|
|
79
|
-
```vue
|
|
80
|
-
<script>
|
|
81
|
-
import { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect } from 'yj-kikimore'
|
|
82
|
-
|
|
83
|
-
export default {
|
|
84
|
-
components: { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect },
|
|
85
|
-
}
|
|
86
|
-
</script>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
#### 全局注册
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
import Vue from 'vue'
|
|
93
|
-
import { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect } from 'yj-kikimore'
|
|
94
|
-
|
|
95
|
-
Vue.use(FormDialog, {
|
|
96
|
-
// 全局配置
|
|
97
|
-
})
|
|
98
|
-
Vue.use(KiPopButton, {
|
|
99
|
-
// 全局配置
|
|
100
|
-
})
|
|
101
|
-
Vue.use(KiPopSwitch, {
|
|
102
|
-
// 全局配置
|
|
103
|
-
})
|
|
104
|
-
Vue.use(KiSelect, {
|
|
105
|
-
// 全局配置
|
|
106
|
-
})
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
#### ~~CDN~~
|
|
110
|
-
|
|
111
|
-
⚠ 暂不支持。
|
|
112
|
-
|
|
113
|
-
<br>
|
|
114
|
-
|
|
115
75
|
## FormDialog
|
|
116
76
|
|
|
117
|
-
[el-dialog](https://element.
|
|
77
|
+
[el-dialog](https://element-plus.org/zh-CN/component/dialog.html) + [el-form](https://element-plus.org/zh-CN/component/form.html) 组合拳。
|
|
118
78
|
|
|
119
79
|
### 特性
|
|
120
80
|
|
|
@@ -130,8 +90,8 @@ Vue.use(KiSelect, {
|
|
|
130
90
|
| 名称 | 说明 | 类型 | 默认值 |
|
|
131
91
|
| ----------------------------------------------- | ----------------------------------- | -------- | ----------- |
|
|
132
92
|
| title | 对话框标题 | string | |
|
|
133
|
-
| v-model:show
|
|
134
|
-
| modelValue
|
|
93
|
+
| v-model:show | 是否显示 | boolean | `false` |
|
|
94
|
+
| modelValue | 表单数据对象 (`el-form` 的 `model`) | any | |
|
|
135
95
|
| elFormProps | `el-form` 的属性 | object | |
|
|
136
96
|
| retrieve | 读取数据 | Function | |
|
|
137
97
|
| loading | 读取状态 | boolean | `false` |
|
|
@@ -157,7 +117,7 @@ Vue.use(KiSelect, {
|
|
|
157
117
|
| validateCatch | 表单校验失败时触发 | 同element表单 校验失败时的参数 |
|
|
158
118
|
|
|
159
119
|
|
|
160
|
-
#### modelValue
|
|
120
|
+
#### modelValue / v-model
|
|
161
121
|
|
|
162
122
|
如果是 plain object 类型,将用于 `el-form` 的 `model`。
|
|
163
123
|
|
|
@@ -405,12 +365,12 @@ Vue.use(KiSelect, {
|
|
|
405
365
|
|
|
406
366
|
| 名称 | 说明 | 类型 | 默认值 |
|
|
407
367
|
| ------------------------------------------------- | --------------------------------- | --------------------------------------------- | -------------- |
|
|
408
|
-
| modelValue
|
|
409
|
-
| v-model:options
|
|
368
|
+
| modelValue | 绑定值 | any | |
|
|
369
|
+
| v-model:options | 选项 | any[] | |
|
|
410
370
|
| props | 定位选项的各项属性 | object | |
|
|
411
371
|
| search | 远程搜索 (`remote-method` 封装) | (query: string) =><br>Promise<any[]> \| any[] | |
|
|
412
372
|
| searchImmediately | 是否立即执行远程搜索 | boolean | `true` |
|
|
413
|
-
| v-model:label
|
|
373
|
+
| v-model:label | 绑定值对应的 `label` (单向数据流) | string \| string[] | |
|
|
414
374
|
| showSelectAllCheckbox | 多选时是否显示全选框 | boolean | `true` |
|
|
415
375
|
| selectAllCheckboxLabel | 全选框的文案 | string | `'Select All'` |
|
|
416
376
|
| ... | `el-select` 的属性 | | |
|
|
@@ -483,3 +443,11 @@ interface Props {
|
|
|
483
443
|
UI 组件库的标杆 Ant Design 也是使用 `value` 与 `label` 命名。
|
|
484
444
|
|
|
485
445
|
<br>
|
|
446
|
+
|
|
447
|
+
## 升级日志
|
|
448
|
+
|
|
449
|
+
### v0.13.4
|
|
450
|
+
修复Select组件全选时未触发事件
|
|
451
|
+
|
|
452
|
+
### v0.13.3
|
|
453
|
+
FormDialog增加校验失败事件
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yj-kikimore",
|
|
3
3
|
"PascalCasedName": "YjKikimore",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"private": false,
|
|
6
|
-
"
|
|
7
|
-
"description": "Several components wrapper for Element Plus / Element.",
|
|
6
|
+
"description": "Several component wrappers for Element Plus (Vue 3).",
|
|
8
7
|
"author": "yunjing",
|
|
9
8
|
"license": "MIT",
|
|
10
9
|
"keywords": [
|
|
11
10
|
"vue",
|
|
12
|
-
"vue-demi",
|
|
13
11
|
"element",
|
|
14
|
-
"element-ui",
|
|
15
12
|
"element-plus"
|
|
16
13
|
],
|
|
17
14
|
"exports": {
|
|
@@ -32,28 +29,21 @@
|
|
|
32
29
|
"src"
|
|
33
30
|
],
|
|
34
31
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"dev": "vite --config ./demo/vue2.6/vite.config.ts --open",
|
|
38
|
-
"build": "vite build",
|
|
32
|
+
"dev": "vite --config ./demo/vite.config.ts --open",
|
|
33
|
+
"build": "npx vite build",
|
|
39
34
|
"release": "npx lint-staged && pnpm build && cl release"
|
|
40
35
|
},
|
|
41
36
|
"peerDependencies": {
|
|
42
37
|
"element-plus": ">=2",
|
|
43
|
-
"
|
|
44
|
-
"vue": "2||3"
|
|
38
|
+
"vue": ">=3"
|
|
45
39
|
},
|
|
46
40
|
"peerDependenciesMeta": {
|
|
47
41
|
"element-plus": {
|
|
48
42
|
"optional": true
|
|
49
|
-
},
|
|
50
|
-
"element-ui": {
|
|
51
|
-
"optional": true
|
|
52
43
|
}
|
|
53
44
|
},
|
|
54
45
|
"dependencies": {
|
|
55
46
|
"lodash-es": "latest",
|
|
56
|
-
"vue-demi": "latest",
|
|
57
47
|
"vue-global-config": "0.4.0"
|
|
58
48
|
},
|
|
59
49
|
"devDependencies": {
|
|
@@ -61,10 +51,11 @@
|
|
|
61
51
|
"@commitlint/config-conventional": "latest",
|
|
62
52
|
"@types/lodash-es": "latest",
|
|
63
53
|
"@types/node": "latest",
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
54
|
+
"@element-plus/icons-vue": "latest",
|
|
55
|
+
"@vitejs/plugin-vue": "latest",
|
|
56
|
+
"@vue/test-utils": "latest",
|
|
66
57
|
"case-police": "latest",
|
|
67
|
-
"element-
|
|
58
|
+
"element-plus": "latest",
|
|
68
59
|
"husky": "latest",
|
|
69
60
|
"lint-staged": "latest",
|
|
70
61
|
"rome": "latest",
|
|
@@ -81,8 +72,7 @@
|
|
|
81
72
|
"vite-plugin-dts": "latest",
|
|
82
73
|
"vls": "latest",
|
|
83
74
|
"vti": "latest",
|
|
84
|
-
"vue": "
|
|
85
|
-
"vue-template-compiler": "2.7",
|
|
75
|
+
"vue": "latest",
|
|
86
76
|
"vue-tsc": "latest",
|
|
87
77
|
"zhlint": "latest"
|
|
88
78
|
},
|
package/src/FormDialog/index.vue
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
ref="elDialogRef"
|
|
8
8
|
:key="key"
|
|
9
9
|
v-model="show"
|
|
10
|
-
:visible="show"
|
|
11
10
|
:title="Title"
|
|
12
11
|
:destroyOnClose="false"
|
|
13
12
|
:appendToBody="false"
|
|
@@ -16,37 +15,27 @@
|
|
|
16
15
|
@closed="onClosed"
|
|
17
16
|
>
|
|
18
17
|
<!-- 向 el-dialog 传递 slot -->
|
|
19
|
-
<template #
|
|
18
|
+
<template #header>
|
|
20
19
|
<!-- 接收 slot -->
|
|
21
|
-
<component v-if="isGlobalSlot(Slots
|
|
22
|
-
<slot v-else
|
|
20
|
+
<component v-if="isGlobalSlot(Slots.header)" :is="Slots.header()" />
|
|
21
|
+
<slot v-else name="header">
|
|
23
22
|
<span>{{ Title }}</span>
|
|
24
23
|
</slot>
|
|
25
24
|
<div style="display: flex; align-items: center">
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
</el-icon>
|
|
41
|
-
</template>
|
|
42
|
-
<template v-else>
|
|
43
|
-
<i
|
|
44
|
-
v-if="ShowFullscreenToggle"
|
|
45
|
-
:class="fullscreen ? 'el-icon-copy-document' : 'el-icon-full-screen'"
|
|
46
|
-
@click="toggleFullscreen()"
|
|
47
|
-
/>
|
|
48
|
-
<i v-if="ElDialogProps.showClose !== false" class="el-icon-close" @click="onCancel" />
|
|
49
|
-
</template>
|
|
25
|
+
<el-icon
|
|
26
|
+
v-if="ShowFullscreenToggle"
|
|
27
|
+
:class="fullscreen ? 'el-icon-copy-document' : 'el-icon-full-screen'"
|
|
28
|
+
@click="toggleFullscreen()"
|
|
29
|
+
>
|
|
30
|
+
<Component :is="fullscreen ? 'CopyDocument' : 'FullScreen'" />
|
|
31
|
+
</el-icon>
|
|
32
|
+
<el-icon
|
|
33
|
+
v-if="ElDialogProps.showClose !== false"
|
|
34
|
+
class="el-icon-close"
|
|
35
|
+
@click="onCancel"
|
|
36
|
+
>
|
|
37
|
+
<Close />
|
|
38
|
+
</el-icon>
|
|
50
39
|
</div>
|
|
51
40
|
</template>
|
|
52
41
|
<div v-loading="Loading" style="display: flex; flex-direction: column; overflow-y: hidden">
|
|
@@ -157,7 +146,6 @@
|
|
|
157
146
|
</template>
|
|
158
147
|
|
|
159
148
|
<script>
|
|
160
|
-
import { isVue3 } from 'vue-demi'
|
|
161
149
|
import { conclude, resolveConfig } from 'vue-global-config'
|
|
162
150
|
import { cloneDeep, isPlainObject } from 'lodash-es'
|
|
163
151
|
import { getListeners, isGlobalSlot } from '../utils'
|
|
@@ -168,11 +156,6 @@ const globalAttrs = {}
|
|
|
168
156
|
const globalListeners = {}
|
|
169
157
|
const globalSlots = {}
|
|
170
158
|
|
|
171
|
-
const model = {
|
|
172
|
-
prop: isVue3 ? 'modelValue' : 'value',
|
|
173
|
-
event: isVue3 ? 'update:modelValue' : 'input'
|
|
174
|
-
}
|
|
175
|
-
|
|
176
159
|
const boolProps = [
|
|
177
160
|
'show',
|
|
178
161
|
'readonly',
|
|
@@ -196,7 +179,7 @@ export default {
|
|
|
196
179
|
app.component(this.name, this)
|
|
197
180
|
},
|
|
198
181
|
props: {
|
|
199
|
-
|
|
182
|
+
modelValue: {},
|
|
200
183
|
title: {},
|
|
201
184
|
elFormProps: {},
|
|
202
185
|
retrieve: {},
|
|
@@ -217,7 +200,7 @@ export default {
|
|
|
217
200
|
])
|
|
218
201
|
)
|
|
219
202
|
},
|
|
220
|
-
emits: [
|
|
203
|
+
emits: ['update:modelValue', 'update:show', 'fullscreen-change'],
|
|
221
204
|
data() {
|
|
222
205
|
return {
|
|
223
206
|
initialValue: undefined,
|
|
@@ -230,8 +213,7 @@ export default {
|
|
|
230
213
|
beforeCloseIsPassed: false,
|
|
231
214
|
fullscreen: false,
|
|
232
215
|
labelWidth: undefined,
|
|
233
|
-
key: 0
|
|
234
|
-
isVue3
|
|
216
|
+
key: 0
|
|
235
217
|
}
|
|
236
218
|
},
|
|
237
219
|
computed: {
|
|
@@ -239,10 +221,7 @@ export default {
|
|
|
239
221
|
return getListeners.call(this, globalListeners)
|
|
240
222
|
},
|
|
241
223
|
Slots() {
|
|
242
|
-
return conclude([
|
|
243
|
-
},
|
|
244
|
-
headerSlotName() {
|
|
245
|
-
return isVue3 ? 'header' : 'title'
|
|
224
|
+
return conclude([this.$slots, globalSlots])
|
|
246
225
|
},
|
|
247
226
|
ConfirmButtonText() {
|
|
248
227
|
return conclude([this.confirmButtonText, globalProps.confirmButtonText, 'OK'], {
|
|
@@ -295,7 +274,7 @@ export default {
|
|
|
295
274
|
})
|
|
296
275
|
},
|
|
297
276
|
ValueIsPlainObject() {
|
|
298
|
-
return isPlainObject(this
|
|
277
|
+
return isPlainObject(this.modelValue)
|
|
299
278
|
},
|
|
300
279
|
Title() {
|
|
301
280
|
return conclude([this.title, globalProps.title], {
|
|
@@ -363,7 +342,7 @@ export default {
|
|
|
363
342
|
},
|
|
364
343
|
ElFormProps() {
|
|
365
344
|
return {
|
|
366
|
-
model: this
|
|
345
|
+
model: this.modelValue,
|
|
367
346
|
...conclude(
|
|
368
347
|
[
|
|
369
348
|
this.elFormProps,
|
|
@@ -373,7 +352,7 @@ export default {
|
|
|
373
352
|
ref: 'elFormRef',
|
|
374
353
|
labelWidth: this.labelWidth
|
|
375
354
|
// model 不能写在这里因为会被深拷贝,将导致无法重置
|
|
376
|
-
// model: this
|
|
355
|
+
// model: this.modelValue,
|
|
377
356
|
}
|
|
378
357
|
],
|
|
379
358
|
{
|
|
@@ -431,7 +410,7 @@ export default {
|
|
|
431
410
|
}
|
|
432
411
|
},
|
|
433
412
|
mounted() {
|
|
434
|
-
this.initialValue = cloneDeep(this
|
|
413
|
+
this.initialValue = cloneDeep(this.modelValue)
|
|
435
414
|
},
|
|
436
415
|
updated() {
|
|
437
416
|
this.computeLabelWidth()
|
|
@@ -486,7 +465,7 @@ export default {
|
|
|
486
465
|
this.$refs[this.ElFormProps.ref].resetFields()
|
|
487
466
|
},
|
|
488
467
|
onClosed() {
|
|
489
|
-
this.$emit(
|
|
468
|
+
this.$emit('update:modelValue', cloneDeep(this.initialValue))
|
|
490
469
|
this.$refs[this.ElFormProps.ref]?.clearValidate()
|
|
491
470
|
this.confirming = false
|
|
492
471
|
this.denying = false
|
|
@@ -642,9 +621,8 @@ export default {
|
|
|
642
621
|
</style>
|
|
643
622
|
|
|
644
623
|
<style lang="scss" scoped>
|
|
645
|
-
//
|
|
646
|
-
|
|
647
|
-
::v-deep .el-dialog__wrapper {
|
|
624
|
+
// Vue 3 中保留旧写法,避免 scoped 深选择器行为变化
|
|
625
|
+
:deep() .el-dialog__wrapper {
|
|
648
626
|
display: flex;
|
|
649
627
|
|
|
650
628
|
.el-dialog {
|
package/src/PopButton/index.vue
CHANGED
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
v-bind="ElPopconfirmConfig.attrs"
|
|
50
50
|
v-on="ElPopconfirmConfig.listeners"
|
|
51
51
|
@confirm="$emit('click', $event)"
|
|
52
|
-
@on-confirm="$emit('click', $event)"
|
|
53
52
|
>
|
|
54
53
|
<template #reference>
|
|
55
54
|
<el-button
|
|
@@ -72,7 +71,6 @@
|
|
|
72
71
|
</template>
|
|
73
72
|
|
|
74
73
|
<script>
|
|
75
|
-
import { isVue3 } from 'vue-demi'
|
|
76
74
|
import { conclude, resolveConfig } from 'vue-global-config'
|
|
77
75
|
import { getListeners, isGlobalSlot } from '../utils'
|
|
78
76
|
|
|
@@ -102,7 +100,7 @@ export default {
|
|
|
102
100
|
return getListeners.call(this, globalListeners)
|
|
103
101
|
},
|
|
104
102
|
Slots() {
|
|
105
|
-
return conclude([
|
|
103
|
+
return conclude([this.$slots, globalSlots])
|
|
106
104
|
},
|
|
107
105
|
ElTooltipProps() {
|
|
108
106
|
const result = conclude([
|
package/src/PopSwitch/index.vue
CHANGED
|
@@ -49,16 +49,15 @@
|
|
|
49
49
|
v-bind="ElPopconfirmConfig.attrs"
|
|
50
50
|
v-on="ElPopconfirmConfig.listeners"
|
|
51
51
|
@confirm="onConfirm"
|
|
52
|
-
@on-confirm="onConfirm"
|
|
53
52
|
>
|
|
54
53
|
<template #reference>
|
|
55
54
|
<el-switch
|
|
56
55
|
v-bind="ElSwitchProps"
|
|
56
|
+
class="ki-switch"
|
|
57
57
|
:class="{
|
|
58
|
-
'ki-switch': !isVue3,
|
|
59
58
|
'inline-prompt': InlinePrompt,
|
|
60
59
|
}"
|
|
61
|
-
@click
|
|
60
|
+
@click="onClick"
|
|
62
61
|
/>
|
|
63
62
|
</template>
|
|
64
63
|
</el-popconfirm>
|
|
@@ -70,7 +69,6 @@
|
|
|
70
69
|
</template>
|
|
71
70
|
|
|
72
71
|
<script>
|
|
73
|
-
import { isVue3 } from 'vue-demi'
|
|
74
72
|
import { conclude, resolveConfig } from 'vue-global-config'
|
|
75
73
|
import { getListeners, isGlobalSlot } from '../utils'
|
|
76
74
|
import { getCharCount } from './utils'
|
|
@@ -80,11 +78,6 @@ const globalAttrs = {}
|
|
|
80
78
|
const globalListeners = {}
|
|
81
79
|
const globalSlots = {}
|
|
82
80
|
|
|
83
|
-
const model = {
|
|
84
|
-
prop: isVue3 ? 'modelValue' : 'value',
|
|
85
|
-
event: isVue3 ? 'update:modelValue' : 'change',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
81
|
const boolProps = [
|
|
89
82
|
'inlinePrompt',
|
|
90
83
|
]
|
|
@@ -99,9 +92,8 @@ export default {
|
|
|
99
92
|
Object.assign(globalSlots, slots)
|
|
100
93
|
app.component(this.name, this)
|
|
101
94
|
},
|
|
102
|
-
model,
|
|
103
95
|
props: {
|
|
104
|
-
|
|
96
|
+
modelValue: {},
|
|
105
97
|
elPopconfirmProps: {},
|
|
106
98
|
elTooltipProps: {},
|
|
107
99
|
elPopoverProps: {},
|
|
@@ -110,18 +102,13 @@ export default {
|
|
|
110
102
|
default: undefined,
|
|
111
103
|
}])),
|
|
112
104
|
},
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
isVue3,
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
emits: [model.event, 'confirm'],
|
|
105
|
+
emits: ['update:modelValue', 'confirm', 'change'],
|
|
119
106
|
computed: {
|
|
120
107
|
Listeners() {
|
|
121
108
|
return getListeners.call(this, globalListeners)
|
|
122
109
|
},
|
|
123
110
|
Slots() {
|
|
124
|
-
return conclude([
|
|
111
|
+
return conclude([this.$slots, globalSlots])
|
|
125
112
|
},
|
|
126
113
|
ElTooltipProps() {
|
|
127
114
|
return conclude([
|
|
@@ -170,12 +157,15 @@ export default {
|
|
|
170
157
|
})
|
|
171
158
|
},
|
|
172
159
|
ElSwitchProps() {
|
|
160
|
+
const attrs = { ...this.$attrs }
|
|
161
|
+
delete attrs.onChange
|
|
162
|
+
|
|
173
163
|
return conclude([
|
|
174
164
|
{
|
|
175
|
-
|
|
165
|
+
modelValue: this.modelValue,
|
|
176
166
|
inlinePrompt: this.InlinePrompt,
|
|
177
167
|
},
|
|
178
|
-
|
|
168
|
+
attrs,
|
|
179
169
|
globalAttrs,
|
|
180
170
|
{ ref: 'elSwitchRef' },
|
|
181
171
|
], {
|
|
@@ -209,19 +199,21 @@ export default {
|
|
|
209
199
|
}
|
|
210
200
|
},
|
|
211
201
|
onConfirm(...e) {
|
|
212
|
-
this.$
|
|
213
|
-
this.$emit(model.event, this.$refs[this.ElSwitchProps.ref].checked
|
|
202
|
+
const nextValue = this.$refs[this.ElSwitchProps.ref].checked
|
|
214
203
|
? (this.ElSwitchProps.inactiveValue ?? false)
|
|
215
|
-
: (this.ElSwitchProps.activeValue ?? true)
|
|
204
|
+
: (this.ElSwitchProps.activeValue ?? true)
|
|
205
|
+
|
|
206
|
+
this.$emit('confirm', ...e)
|
|
207
|
+
this.$emit('update:modelValue', nextValue)
|
|
208
|
+
this.$emit('change', nextValue)
|
|
216
209
|
},
|
|
217
210
|
},
|
|
218
211
|
}
|
|
219
212
|
</script>
|
|
220
213
|
|
|
221
214
|
<style lang="scss" scoped>
|
|
222
|
-
//
|
|
223
|
-
|
|
224
|
-
::v-deep .ki-switch.inline-prompt {
|
|
215
|
+
// Vue 3 中保留旧写法,避免 scoped 深选择器行为变化
|
|
216
|
+
:deep() .ki-switch.inline-prompt {
|
|
225
217
|
.el-switch__label * {
|
|
226
218
|
font-size: 12px;
|
|
227
219
|
}
|
package/src/Select/index.vue
CHANGED
|
@@ -149,7 +149,6 @@
|
|
|
149
149
|
</template>
|
|
150
150
|
|
|
151
151
|
<script>
|
|
152
|
-
import { isVue3 } from 'vue-demi'
|
|
153
152
|
import { conclude, resolveConfig } from 'vue-global-config'
|
|
154
153
|
import { cloneDeep, isPlainObject } from 'lodash-es'
|
|
155
154
|
import { getListeners, isEmpty, isObject, notEmpty, unwrap, isGlobalSlot } from '../utils'
|
|
@@ -159,11 +158,6 @@ const globalAttrs = {}
|
|
|
159
158
|
const globalListeners = {}
|
|
160
159
|
const globalSlots = {}
|
|
161
160
|
|
|
162
|
-
const model = {
|
|
163
|
-
prop: isVue3 ? 'modelValue' : 'value',
|
|
164
|
-
event: isVue3 ? 'update:modelValue' : 'input',
|
|
165
|
-
}
|
|
166
|
-
|
|
167
161
|
const boolProps = [
|
|
168
162
|
'searchImmediately',
|
|
169
163
|
'showSelectAllCheckbox',
|
|
@@ -180,7 +174,7 @@ export default {
|
|
|
180
174
|
app.component(this.name, this)
|
|
181
175
|
},
|
|
182
176
|
props: {
|
|
183
|
-
|
|
177
|
+
modelValue: {},
|
|
184
178
|
label: [String, Array],
|
|
185
179
|
options: Array,
|
|
186
180
|
props: {},
|
|
@@ -191,10 +185,10 @@ export default {
|
|
|
191
185
|
default: undefined,
|
|
192
186
|
}])),
|
|
193
187
|
},
|
|
194
|
-
emits: [
|
|
188
|
+
emits: ['update:modelValue', 'update:options', 'update:label', 'change'],
|
|
195
189
|
data() {
|
|
196
190
|
return {
|
|
197
|
-
innerValue: this
|
|
191
|
+
innerValue: this.modelValue,
|
|
198
192
|
initialValue: undefined,
|
|
199
193
|
loading: undefined,
|
|
200
194
|
// 在组件内部维护一份 innerOptions 的目的:search 时可以不绑定 options
|
|
@@ -211,7 +205,7 @@ export default {
|
|
|
211
205
|
return getListeners.call(this, globalListeners)
|
|
212
206
|
},
|
|
213
207
|
Slots() {
|
|
214
|
-
return conclude([
|
|
208
|
+
return conclude([this.$slots, globalSlots])
|
|
215
209
|
},
|
|
216
210
|
ShowSelectAllCheckbox() {
|
|
217
211
|
return conclude([this.showSelectAllCheckbox, globalProps.showSelectAllCheckbox, true], {
|
|
@@ -273,7 +267,7 @@ export default {
|
|
|
273
267
|
this.setInnerOptions(newOptions)
|
|
274
268
|
},
|
|
275
269
|
},
|
|
276
|
-
|
|
270
|
+
modelValue: {
|
|
277
271
|
handler(newValue) {
|
|
278
272
|
this.innerValue = newValue
|
|
279
273
|
this.updateSelectAllStatus()
|
|
@@ -286,7 +280,7 @@ export default {
|
|
|
286
280
|
if (isEmpty(newInnerValue)) {
|
|
287
281
|
this.remoteMethod()
|
|
288
282
|
}
|
|
289
|
-
this.$emit(
|
|
283
|
+
this.$emit('update:modelValue', newInnerValue)
|
|
290
284
|
},
|
|
291
285
|
},
|
|
292
286
|
},
|
|
@@ -296,7 +290,7 @@ export default {
|
|
|
296
290
|
}
|
|
297
291
|
},
|
|
298
292
|
mounted() {
|
|
299
|
-
this.initialValue = cloneDeep(this
|
|
293
|
+
this.initialValue = cloneDeep(this.modelValue)
|
|
300
294
|
},
|
|
301
295
|
methods: {
|
|
302
296
|
isGlobalSlot,
|
|
@@ -360,7 +354,7 @@ export default {
|
|
|
360
354
|
this.$nextTick(() => {
|
|
361
355
|
if (this.isMultiple) {
|
|
362
356
|
const label = []
|
|
363
|
-
this.$refs[this.ElSelectProps.ref].selected
|
|
357
|
+
this.$refs[this.ElSelectProps.ref].selected?.forEach((v) => {
|
|
364
358
|
if (!v.currentLabel) {
|
|
365
359
|
v.currentLabel = this.getLabel(v.value)
|
|
366
360
|
}
|
package/src/src/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentPublicInstance } from 'vue
|
|
2
|
-
export declare function getListeners(this: ComponentPublicInstance,
|
|
1
|
+
import { ComponentPublicInstance } from 'vue';
|
|
2
|
+
export declare function getListeners(this: ComponentPublicInstance, _globalListeners: Record<string, any>): any;
|
|
3
3
|
export declare function isGlobalSlot(slot: any): any;
|
|
4
4
|
export declare function isEmpty(value: any): boolean;
|
|
5
5
|
export declare function notEmpty(value: any): boolean;
|
package/src/utils.ts
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import { conclude, getLocalListeners } from 'vue-global-config'
|
|
2
1
|
import { at, isPlainObject } from 'lodash-es'
|
|
3
|
-
import {
|
|
4
|
-
import type { ComponentPublicInstance } from 'vue-demi'
|
|
2
|
+
import type { ComponentPublicInstance } from 'vue'
|
|
5
3
|
|
|
6
|
-
export function getListeners(this: ComponentPublicInstance,
|
|
7
|
-
|
|
8
|
-
return {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
for (const k in globalListeners) {
|
|
12
|
-
globalListeners[k] = globalListeners[k].bind(this)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return conclude([getLocalListeners(this.$listeners)], {
|
|
16
|
-
default: globalListeners,
|
|
17
|
-
mergeFunction:
|
|
18
|
-
(localEventListener: Function, globalEventListener: Function) => (...args: any) => {
|
|
19
|
-
localEventListener(...args)
|
|
20
|
-
globalEventListener(...args)
|
|
21
|
-
},
|
|
22
|
-
})
|
|
4
|
+
export function getListeners(this: ComponentPublicInstance, _globalListeners: Record<string, any>) {
|
|
5
|
+
return {}
|
|
23
6
|
}
|
|
24
7
|
|
|
25
8
|
export function isGlobalSlot(slot: any) {
|