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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gi-component",
3
3
  "type": "module",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "description": "Vue3中基于Element Plus二次封装基础组件库",
6
6
  "author": "lin",
7
7
  "license": "MIT",
@@ -48,7 +48,8 @@ const props = withDefaults(defineProps<DialogProps>(), {
48
48
  okText: '确认',
49
49
  cancelText: '取消',
50
50
  width: 'calc(100% - 20px)',
51
- alignCenter: true
51
+ alignCenter: true,
52
+ lockScroll: true
52
53
  })
53
54
 
54
55
  defineSlots<{
@@ -1,5 +1,6 @@
1
1
  import Drawer from './src/drawer.vue'
2
2
 
3
3
  export type DrawerInstance = InstanceType<typeof Drawer>
4
+ export * from './src/drawer'
4
5
  export * from './src/type'
5
6
  export default Drawer
@@ -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;
@@ -215,6 +215,10 @@ body {
215
215
  box-sizing: border-box;
216
216
  }
217
217
 
218
+ .el-drawer__body {
219
+ font-size: 14px;
220
+ }
221
+
218
222
  .el-drawer__footer {
219
223
  padding-top: 12px;
220
224
  padding-bottom: 12px;