yj-kikimore 0.1.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.
- package/LICENSE +21 -0
- package/README.md +489 -0
- package/package.json +99 -0
- package/src/FormDialog/elementIsVisible.ts +7 -0
- package/src/FormDialog/highlightError.scss +85 -0
- package/src/FormDialog/highlightError.ts +84 -0
- package/src/FormDialog/index.vue +932 -0
- package/src/PopButton/index.vue +168 -0
- package/src/PopSwitch/index.vue +271 -0
- package/src/PopSwitch/utils.ts +9 -0
- package/src/Select/index.vue +480 -0
- package/src/index.ts +6 -0
- package/src/src/FormDialog/elementIsVisible.d.ts +2 -0
- package/src/src/FormDialog/highlightError.d.ts +2 -0
- package/src/src/PopSwitch/utils.d.ts +1 -0
- package/src/src/index.d.ts +5 -0
- package/src/src/utils.d.ts +8 -0
- package/src/utils.ts +80 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-tooltip v-bind="ElTooltipProps">
|
|
3
|
+
<template #content>
|
|
4
|
+
<template v-if="Slots['tooltip-content']">
|
|
5
|
+
<component
|
|
6
|
+
v-if="isGlobalSlot(Slots['tooltip-content'])"
|
|
7
|
+
:is="Slots['tooltip-content']()"
|
|
8
|
+
/>
|
|
9
|
+
<slot
|
|
10
|
+
v-else
|
|
11
|
+
name="tooltip-content"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
<div
|
|
15
|
+
v-else-if="ElTooltipProps.rawContent"
|
|
16
|
+
v-html="ElTooltipProps.content"
|
|
17
|
+
/>
|
|
18
|
+
<div
|
|
19
|
+
v-else
|
|
20
|
+
v-text="ElTooltipProps.content"
|
|
21
|
+
/>
|
|
22
|
+
</template>
|
|
23
|
+
<span>
|
|
24
|
+
<el-popover
|
|
25
|
+
v-bind="ElPopoverConfig.attrs"
|
|
26
|
+
v-on="ElPopoverConfig.listeners"
|
|
27
|
+
>
|
|
28
|
+
<template v-if="Slots['popover-content']">
|
|
29
|
+
<component
|
|
30
|
+
v-if="isGlobalSlot(Slots['popover-content'])"
|
|
31
|
+
:is="Slots['popover-content']()"
|
|
32
|
+
/>
|
|
33
|
+
<slot
|
|
34
|
+
v-else
|
|
35
|
+
name="popover-content"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
38
|
+
<div
|
|
39
|
+
v-else-if="ElPopoverConfig.attrs.rawContent"
|
|
40
|
+
v-html="ElPopoverConfig.attrs.content"
|
|
41
|
+
/>
|
|
42
|
+
<div
|
|
43
|
+
v-else
|
|
44
|
+
v-text="ElPopoverConfig.attrs.content"
|
|
45
|
+
/>
|
|
46
|
+
<template #reference>
|
|
47
|
+
<span>
|
|
48
|
+
<el-popconfirm
|
|
49
|
+
v-bind="ElPopconfirmConfig.attrs"
|
|
50
|
+
v-on="ElPopconfirmConfig.listeners"
|
|
51
|
+
@confirm="$emit('click', $event)"
|
|
52
|
+
@on-confirm="$emit('click', $event)"
|
|
53
|
+
>
|
|
54
|
+
<template #reference>
|
|
55
|
+
<el-button
|
|
56
|
+
v-bind="ElButtonProps"
|
|
57
|
+
@click="onClick"
|
|
58
|
+
>
|
|
59
|
+
<component
|
|
60
|
+
v-if="isGlobalSlot(Slots['default'])"
|
|
61
|
+
:is="Slots['default']()"
|
|
62
|
+
/>
|
|
63
|
+
<slot v-else />
|
|
64
|
+
</el-button>
|
|
65
|
+
</template>
|
|
66
|
+
</el-popconfirm>
|
|
67
|
+
</span>
|
|
68
|
+
</template>
|
|
69
|
+
</el-popover>
|
|
70
|
+
</span>
|
|
71
|
+
</el-tooltip>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
import { isVue3 } from 'vue-demi'
|
|
76
|
+
import { conclude, resolveConfig } from 'vue-global-config'
|
|
77
|
+
import { getListeners, isGlobalSlot } from '../utils'
|
|
78
|
+
|
|
79
|
+
const globalProps = {}
|
|
80
|
+
const globalAttrs = {}
|
|
81
|
+
const globalListeners = {}
|
|
82
|
+
const globalSlots = {}
|
|
83
|
+
|
|
84
|
+
export default {
|
|
85
|
+
name: 'KiPopButton',
|
|
86
|
+
install(app, options = {}) {
|
|
87
|
+
const { props, attrs, listeners, slots } = resolveConfig(options, this.props)
|
|
88
|
+
Object.assign(globalProps, props)
|
|
89
|
+
Object.assign(globalAttrs, attrs)
|
|
90
|
+
Object.assign(globalListeners, listeners)
|
|
91
|
+
Object.assign(globalSlots, slots)
|
|
92
|
+
app.component(this.name, this)
|
|
93
|
+
},
|
|
94
|
+
props: {
|
|
95
|
+
elPopconfirmProps: {},
|
|
96
|
+
elTooltipProps: {},
|
|
97
|
+
elPopoverProps: {},
|
|
98
|
+
},
|
|
99
|
+
emits: ['click', 'confirm'],
|
|
100
|
+
computed: {
|
|
101
|
+
Listeners() {
|
|
102
|
+
return getListeners.call(this, globalListeners)
|
|
103
|
+
},
|
|
104
|
+
Slots() {
|
|
105
|
+
return conclude([isVue3 ? this.$slots : this.$scopedSlots, globalSlots])
|
|
106
|
+
},
|
|
107
|
+
ElTooltipProps() {
|
|
108
|
+
const result = conclude([
|
|
109
|
+
this.elTooltipProps,
|
|
110
|
+
globalProps.elTooltipProps,
|
|
111
|
+
{ ref: 'elTooltipRef' },
|
|
112
|
+
], {
|
|
113
|
+
type: Object,
|
|
114
|
+
camelizeObjectKeys: true,
|
|
115
|
+
})
|
|
116
|
+
return {
|
|
117
|
+
// openDelay: 400,
|
|
118
|
+
disabled: !result?.content,
|
|
119
|
+
...result,
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
ElPopoverConfig() {
|
|
123
|
+
return resolveConfig(conclude([
|
|
124
|
+
this.elPopoverProps,
|
|
125
|
+
globalProps.elPopoverProps,
|
|
126
|
+
], {
|
|
127
|
+
type: Object,
|
|
128
|
+
camelizeObjectKeys: true,
|
|
129
|
+
default: userProp => ({
|
|
130
|
+
disabled: !(userProp && (userProp.title || userProp.content)),
|
|
131
|
+
}),
|
|
132
|
+
defaultIsDynamic: true,
|
|
133
|
+
}))
|
|
134
|
+
},
|
|
135
|
+
ElPopconfirmConfig() {
|
|
136
|
+
return resolveConfig(conclude([
|
|
137
|
+
this.elPopconfirmProps,
|
|
138
|
+
globalProps.elPopconfirmProps,
|
|
139
|
+
], {
|
|
140
|
+
type: Object,
|
|
141
|
+
camelizeObjectKeys: true,
|
|
142
|
+
default: userProp => ({
|
|
143
|
+
disabled: !userProp?.title,
|
|
144
|
+
}),
|
|
145
|
+
defaultIsDynamic: true,
|
|
146
|
+
}))
|
|
147
|
+
},
|
|
148
|
+
ElButtonProps() {
|
|
149
|
+
return conclude([this.$attrs, globalAttrs], {
|
|
150
|
+
type: Object,
|
|
151
|
+
camelizeObjectKeys: true,
|
|
152
|
+
})
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
methods: {
|
|
156
|
+
isGlobalSlot,
|
|
157
|
+
onClick(...e) {
|
|
158
|
+
if (!this.$refs[this.ElTooltipProps.ref].manual) {
|
|
159
|
+
this.$refs[this.ElTooltipProps.ref].showPopper = false
|
|
160
|
+
}
|
|
161
|
+
this.$emit('confirm', ...e)
|
|
162
|
+
if (![true, ''].includes(this.ElButtonProps.disabled) && this.ElPopconfirmConfig.attrs.disabled) {
|
|
163
|
+
this.$emit('click', ...e)
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
</script>
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-tooltip v-bind="ElTooltipProps">
|
|
3
|
+
<template #content>
|
|
4
|
+
<template v-if="Slots['tooltip-content']">
|
|
5
|
+
<component
|
|
6
|
+
v-if="isGlobalSlot(Slots['tooltip-content'])"
|
|
7
|
+
:is="Slots['tooltip-content']()"
|
|
8
|
+
/>
|
|
9
|
+
<slot
|
|
10
|
+
v-else
|
|
11
|
+
name="tooltip-content"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
<div
|
|
15
|
+
v-else-if="ElTooltipProps.rawContent"
|
|
16
|
+
v-html="ElTooltipProps.content"
|
|
17
|
+
/>
|
|
18
|
+
<div
|
|
19
|
+
v-else
|
|
20
|
+
v-text="ElTooltipProps.content"
|
|
21
|
+
/>
|
|
22
|
+
</template>
|
|
23
|
+
<span>
|
|
24
|
+
<el-popover
|
|
25
|
+
v-bind="ElPopoverConfig.attrs"
|
|
26
|
+
v-on="ElPopoverConfig.listeners"
|
|
27
|
+
>
|
|
28
|
+
<template v-if="Slots['popover-content']">
|
|
29
|
+
<component
|
|
30
|
+
v-if="isGlobalSlot(Slots['popover-content'])"
|
|
31
|
+
:is="Slots['popover-content']()"
|
|
32
|
+
/>
|
|
33
|
+
<slot
|
|
34
|
+
v-else
|
|
35
|
+
name="popover-content"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
38
|
+
<div
|
|
39
|
+
v-else-if="ElPopoverConfig.attrs.rawContent"
|
|
40
|
+
v-html="ElPopoverConfig.attrs.content"
|
|
41
|
+
/>
|
|
42
|
+
<div
|
|
43
|
+
v-else
|
|
44
|
+
v-text="ElPopoverConfig.attrs.content"
|
|
45
|
+
/>
|
|
46
|
+
<template #reference>
|
|
47
|
+
<span>
|
|
48
|
+
<el-popconfirm
|
|
49
|
+
v-bind="ElPopconfirmConfig.attrs"
|
|
50
|
+
v-on="ElPopconfirmConfig.listeners"
|
|
51
|
+
@confirm="onConfirm"
|
|
52
|
+
@on-confirm="onConfirm"
|
|
53
|
+
>
|
|
54
|
+
<template #reference>
|
|
55
|
+
<el-switch
|
|
56
|
+
v-bind="ElSwitchProps"
|
|
57
|
+
:class="{
|
|
58
|
+
'ki-switch': !isVue3,
|
|
59
|
+
'inline-prompt': InlinePrompt,
|
|
60
|
+
}"
|
|
61
|
+
@click.native="onClick"
|
|
62
|
+
/>
|
|
63
|
+
</template>
|
|
64
|
+
</el-popconfirm>
|
|
65
|
+
</span>
|
|
66
|
+
</template>
|
|
67
|
+
</el-popover>
|
|
68
|
+
</span>
|
|
69
|
+
</el-tooltip>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script>
|
|
73
|
+
import { isVue3 } from 'vue-demi'
|
|
74
|
+
import { conclude, resolveConfig } from 'vue-global-config'
|
|
75
|
+
import { getListeners, isGlobalSlot } from '../utils'
|
|
76
|
+
import { getCharCount } from './utils'
|
|
77
|
+
|
|
78
|
+
const globalProps = {}
|
|
79
|
+
const globalAttrs = {}
|
|
80
|
+
const globalListeners = {}
|
|
81
|
+
const globalSlots = {}
|
|
82
|
+
|
|
83
|
+
const model = {
|
|
84
|
+
prop: isVue3 ? 'modelValue' : 'value',
|
|
85
|
+
event: isVue3 ? 'update:modelValue' : 'change',
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const boolProps = [
|
|
89
|
+
'inlinePrompt',
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
export default {
|
|
93
|
+
name: 'KiPopSwitch',
|
|
94
|
+
install(app, options = {}) {
|
|
95
|
+
const { props, attrs, listeners, slots } = resolveConfig(options, this.props)
|
|
96
|
+
Object.assign(globalProps, props)
|
|
97
|
+
Object.assign(globalAttrs, attrs)
|
|
98
|
+
Object.assign(globalListeners, listeners)
|
|
99
|
+
Object.assign(globalSlots, slots)
|
|
100
|
+
app.component(this.name, this)
|
|
101
|
+
},
|
|
102
|
+
model,
|
|
103
|
+
props: {
|
|
104
|
+
[model.prop]: {},
|
|
105
|
+
elPopconfirmProps: {},
|
|
106
|
+
elTooltipProps: {},
|
|
107
|
+
elPopoverProps: {},
|
|
108
|
+
...Object.fromEntries(Array.from(boolProps, boolProp => [boolProp, {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: undefined,
|
|
111
|
+
}])),
|
|
112
|
+
},
|
|
113
|
+
data() {
|
|
114
|
+
return {
|
|
115
|
+
isVue3,
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
emits: [model.event, 'confirm'],
|
|
119
|
+
computed: {
|
|
120
|
+
Listeners() {
|
|
121
|
+
return getListeners.call(this, globalListeners)
|
|
122
|
+
},
|
|
123
|
+
Slots() {
|
|
124
|
+
return conclude([isVue3 ? this.$slots : this.$scopedSlots, globalSlots])
|
|
125
|
+
},
|
|
126
|
+
ElTooltipProps() {
|
|
127
|
+
return conclude([
|
|
128
|
+
this.elTooltipProps,
|
|
129
|
+
globalProps.elTooltipProps,
|
|
130
|
+
{ ref: 'elTooltipRef' },
|
|
131
|
+
], {
|
|
132
|
+
type: Object,
|
|
133
|
+
camelizeObjectKeys: true,
|
|
134
|
+
default: userProp => ({
|
|
135
|
+
// openDelay: 400,
|
|
136
|
+
disabled: !(userProp?.content || this.$slots.elTooltipContent),
|
|
137
|
+
}),
|
|
138
|
+
defaultIsDynamic: true,
|
|
139
|
+
})
|
|
140
|
+
},
|
|
141
|
+
ElPopoverConfig() {
|
|
142
|
+
return resolveConfig(conclude([
|
|
143
|
+
this.elPopoverProps,
|
|
144
|
+
globalProps.elPopoverProps,
|
|
145
|
+
], {
|
|
146
|
+
type: Object,
|
|
147
|
+
camelizeObjectKeys: true,
|
|
148
|
+
default: userProp => ({
|
|
149
|
+
disabled: !(userProp && (userProp.title || userProp.content)),
|
|
150
|
+
}),
|
|
151
|
+
defaultIsDynamic: true,
|
|
152
|
+
}))
|
|
153
|
+
},
|
|
154
|
+
ElPopconfirmConfig() {
|
|
155
|
+
return resolveConfig(conclude([
|
|
156
|
+
this.elPopconfirmProps,
|
|
157
|
+
globalProps.elPopconfirmProps,
|
|
158
|
+
], {
|
|
159
|
+
type: Object,
|
|
160
|
+
camelizeObjectKeys: true,
|
|
161
|
+
default: userProp => ({
|
|
162
|
+
disabled: [true, ''].includes(this.ElSwitchProps.disabled) || !userProp?.title,
|
|
163
|
+
}),
|
|
164
|
+
defaultIsDynamic: true,
|
|
165
|
+
}))
|
|
166
|
+
},
|
|
167
|
+
InlinePrompt() {
|
|
168
|
+
return conclude([this.inlinePrompt, globalProps.inlinePrompt, false], {
|
|
169
|
+
type: Boolean,
|
|
170
|
+
})
|
|
171
|
+
},
|
|
172
|
+
ElSwitchProps() {
|
|
173
|
+
return conclude([
|
|
174
|
+
{
|
|
175
|
+
[model.prop]: this[model.prop],
|
|
176
|
+
inlinePrompt: this.InlinePrompt,
|
|
177
|
+
},
|
|
178
|
+
this.$attrs,
|
|
179
|
+
globalAttrs,
|
|
180
|
+
{ ref: 'elSwitchRef' },
|
|
181
|
+
], {
|
|
182
|
+
type: Object,
|
|
183
|
+
camelizeObjectKeys: true,
|
|
184
|
+
default: (userProp) => {
|
|
185
|
+
let maxTextWidth = 0;
|
|
186
|
+
['active-text', 'inactive-text', 'activeText', 'inactiveText'].forEach((v) => {
|
|
187
|
+
const textWidth = getCharCount(userProp[v])
|
|
188
|
+
if (textWidth > maxTextWidth) {
|
|
189
|
+
maxTextWidth = textWidth
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
return {
|
|
193
|
+
...this.InlinePrompt && { width: 30 + maxTextWidth * 6 },
|
|
194
|
+
...userProp,
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
defaultIsDynamic: true,
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
methods: {
|
|
202
|
+
isGlobalSlot,
|
|
203
|
+
onClick() {
|
|
204
|
+
if (!this.$refs[this.ElTooltipProps.ref].manual) {
|
|
205
|
+
this.$refs[this.ElTooltipProps.ref].showPopper = false
|
|
206
|
+
}
|
|
207
|
+
if (![true, ''].includes(this.ElSwitchProps.disabled) && this.ElPopconfirmConfig.attrs.disabled) {
|
|
208
|
+
this.onConfirm()
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
onConfirm(...e) {
|
|
212
|
+
this.$emit('confirm', ...e)
|
|
213
|
+
this.$emit(model.event, this.$refs[this.ElSwitchProps.ref].checked
|
|
214
|
+
? (this.ElSwitchProps.inactiveValue ?? false)
|
|
215
|
+
: (this.ElSwitchProps.activeValue ?? true))
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
}
|
|
219
|
+
</script>
|
|
220
|
+
|
|
221
|
+
<style lang="scss" scoped>
|
|
222
|
+
// 兼容 Vue 2.6
|
|
223
|
+
// TODO: Vue 3 中报警告
|
|
224
|
+
::v-deep .ki-switch.inline-prompt {
|
|
225
|
+
.el-switch__label * {
|
|
226
|
+
font-size: 12px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.el-switch__label--left,
|
|
230
|
+
.el-switch__label--right {
|
|
231
|
+
position: absolute;
|
|
232
|
+
z-index: 1;
|
|
233
|
+
margin: 0;
|
|
234
|
+
|
|
235
|
+
&:not(.is-active) {
|
|
236
|
+
display: none;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.el-switch__label--left {
|
|
241
|
+
left: 23px;
|
|
242
|
+
color: gray !important;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.el-switch__label--right {
|
|
246
|
+
left: 9px;
|
|
247
|
+
color: white !important;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.el-switch__core {
|
|
251
|
+
border-radius: 12px !important;
|
|
252
|
+
|
|
253
|
+
&:after {
|
|
254
|
+
top: 1px;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&:not(.is-checked) .el-switch__core {
|
|
259
|
+
|
|
260
|
+
&:after {
|
|
261
|
+
left: 2px;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&.is-checked .el-switch__core {
|
|
266
|
+
&:after {
|
|
267
|
+
background-color: white;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
</style>
|