gi-component 0.0.11 → 0.0.13
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/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { DrawerInstance } from '../index'
|
|
2
|
+
import ElementPlus from 'element-plus'
|
|
3
|
+
import { createApp, h, ref } from 'vue'
|
|
4
|
+
import GiDrawer from './drawer.vue'
|
|
5
|
+
|
|
6
|
+
export type DrawerOptions = Partial<DrawerInstance['$props']>
|
|
7
|
+
|
|
8
|
+
export interface DrawerReturnObject {
|
|
9
|
+
close: () => void
|
|
10
|
+
update: (newProps?: Record<string, any>) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const DEF_OPTIONS: DrawerOptions = {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createDrawer() {
|
|
18
|
+
const Drawer = {
|
|
19
|
+
_context: {},
|
|
20
|
+
// 核心创建方法
|
|
21
|
+
create(options: DrawerOptions): DrawerReturnObject {
|
|
22
|
+
const mergedOptions = { ...DEF_OPTIONS, ...options }
|
|
23
|
+
// 创建容器
|
|
24
|
+
const container = document.createElement('div')
|
|
25
|
+
document.body.appendChild(container)
|
|
26
|
+
|
|
27
|
+
// 状态管理
|
|
28
|
+
const visible = ref(true)
|
|
29
|
+
const dialogOptions = ref(mergedOptions || {})
|
|
30
|
+
|
|
31
|
+
// 创建弹窗应用
|
|
32
|
+
const drawerApp = createApp({
|
|
33
|
+
setup() {
|
|
34
|
+
// 关闭处理
|
|
35
|
+
const closed = () => {
|
|
36
|
+
drawerApp.unmount()
|
|
37
|
+
container.remove()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return () =>
|
|
41
|
+
h(GiDrawer, {
|
|
42
|
+
...dialogOptions.value,
|
|
43
|
+
'modelValue': visible.value,
|
|
44
|
+
'onUpdate:modelValue': (val: boolean) => (visible.value = val),
|
|
45
|
+
'onClosed': () => closed()
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
drawerApp.use(ElementPlus)
|
|
51
|
+
|
|
52
|
+
// 继承主应用的上下文
|
|
53
|
+
Object.assign(drawerApp._context, Drawer._context)
|
|
54
|
+
|
|
55
|
+
// 挂载
|
|
56
|
+
drawerApp.mount(container)
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
/** 关闭抽屉 */
|
|
60
|
+
close: () => {
|
|
61
|
+
visible.value = false
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
drawerApp.unmount()
|
|
64
|
+
container.remove()
|
|
65
|
+
}, 300)
|
|
66
|
+
},
|
|
67
|
+
/** 更新抽屉 */
|
|
68
|
+
update: (newProps?: Record<string, any>) => {
|
|
69
|
+
dialogOptions.value = { ...dialogOptions.value, ...newProps }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/** 抽屉-打开 */
|
|
75
|
+
open(options: DrawerOptions) {
|
|
76
|
+
return this.create(options)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return Drawer
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 默认导出实例
|
|
84
|
+
export const Drawer = createDrawer()
|
|
@@ -17,21 +17,6 @@ const { b } = useBemClass()
|
|
|
17
17
|
margin-left: 0;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
:deep(.el-select__wrapper) {
|
|
21
|
-
box-shadow: none;
|
|
22
|
-
border: 1px solid var(--el-border-color);
|
|
23
|
-
|
|
24
|
-
&.is-focused {
|
|
25
|
-
box-shadow: none;
|
|
26
|
-
border-color: var(--el-color-primary);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&.is-hovering:not(.is-focused) {
|
|
30
|
-
box-shadow: none;
|
|
31
|
-
border-color: var(--el-border-color-hover);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
20
|
.#{a.$prefix}-input-group {
|
|
36
21
|
display: flex;
|
|
37
22
|
|
|
@@ -51,7 +36,8 @@ const { b } = useBemClass()
|
|
|
51
36
|
> :deep(*:not(:first-child):not(:last-child)) {
|
|
52
37
|
border-radius: 0;
|
|
53
38
|
|
|
54
|
-
.el-input__wrapper
|
|
39
|
+
.el-input__wrapper,
|
|
40
|
+
.el-select__wrapper {
|
|
55
41
|
border-radius: 0;
|
|
56
42
|
}
|
|
57
43
|
}
|
|
@@ -83,6 +69,7 @@ const { b } = useBemClass()
|
|
|
83
69
|
}
|
|
84
70
|
|
|
85
71
|
> :deep(*) {
|
|
72
|
+
|
|
86
73
|
.el-input__wrapper.is-focus,
|
|
87
74
|
.el-select__wrapper.is-focused {
|
|
88
75
|
z-index: 2;
|