@ebiz/designer-components 0.1.4 → 0.1.5
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/dist/designer-components.css +1 -1
- package/dist/index.mjs +13417 -12742
- package/package.json +1 -1
- package/src/components/EbizDropdown.vue +136 -0
- package/src/components/EbizDropdownItem.vue +86 -0
- package/src/index.js +7 -1
package/package.json
CHANGED
@@ -0,0 +1,136 @@
|
|
1
|
+
<template>
|
2
|
+
<t-dropdown :disabled="disabled" :direction="direction" :hideAfterItemClick="hideAfterItemClick"
|
3
|
+
:max-column-width="maxColumnWidth" :max-height="maxHeight" :min-column-width="minColumnWidth" :options="options"
|
4
|
+
:placement="placement" :trigger="trigger" @click="handleClick">
|
5
|
+
<!-- 默认触发器内容插槽 -->
|
6
|
+
<template v-if="$slots.default" #default>
|
7
|
+
<slot></slot>
|
8
|
+
</template>
|
9
|
+
|
10
|
+
<template v-if="$slots.dropdown" #dropdown>
|
11
|
+
<slot name="dropdown">
|
12
|
+
</slot>
|
13
|
+
</template>
|
14
|
+
|
15
|
+
<!-- 自定义选项内容插槽 -->
|
16
|
+
<template v-if="$slots.options" #options>
|
17
|
+
<slot name="options"></slot>
|
18
|
+
</template>
|
19
|
+
</t-dropdown>
|
20
|
+
</template>
|
21
|
+
|
22
|
+
<script>
|
23
|
+
export default {
|
24
|
+
name: "EbizDropdown"
|
25
|
+
}
|
26
|
+
</script>
|
27
|
+
|
28
|
+
<script setup>
|
29
|
+
import { defineProps, defineEmits } from 'vue';
|
30
|
+
import { Dropdown as TDropdown } from 'tdesign-vue-next';
|
31
|
+
|
32
|
+
defineProps({
|
33
|
+
// 是否禁用组件
|
34
|
+
disabled: {
|
35
|
+
type: Boolean,
|
36
|
+
default: false
|
37
|
+
},
|
38
|
+
// 多层级操作时,子层级展开方向
|
39
|
+
direction: {
|
40
|
+
type: String,
|
41
|
+
default: 'right',
|
42
|
+
validator: (val) => ['left', 'right'].includes(val)
|
43
|
+
},
|
44
|
+
// 点击选项后是否自动隐藏弹层
|
45
|
+
hideAfterItemClick: {
|
46
|
+
type: Boolean,
|
47
|
+
default: true
|
48
|
+
},
|
49
|
+
// 选项最大宽度,内容超出时,显示为省略号
|
50
|
+
maxColumnWidth: {
|
51
|
+
type: String,
|
52
|
+
default: '100px'
|
53
|
+
},
|
54
|
+
// 弹窗最大高度,单位:px
|
55
|
+
maxHeight: {
|
56
|
+
type: Number,
|
57
|
+
default: 300
|
58
|
+
},
|
59
|
+
// 选项最小宽度
|
60
|
+
minColumnWidth: {
|
61
|
+
type: String,
|
62
|
+
default: '10px'
|
63
|
+
},
|
64
|
+
// 下拉操作项
|
65
|
+
options: {
|
66
|
+
type: Array,
|
67
|
+
default: () => []
|
68
|
+
},
|
69
|
+
// 弹窗出现位置
|
70
|
+
placement: {
|
71
|
+
type: String,
|
72
|
+
default: 'bottom-left',
|
73
|
+
validator: (val) => [
|
74
|
+
'top', 'top-left', 'top-right',
|
75
|
+
'bottom', 'bottom-left', 'bottom-right',
|
76
|
+
'left', 'left-top', 'left-bottom',
|
77
|
+
'right', 'right-top', 'right-bottom'
|
78
|
+
].includes(val)
|
79
|
+
},
|
80
|
+
|
81
|
+
// 触发下拉显示的方式
|
82
|
+
trigger: {
|
83
|
+
type: String,
|
84
|
+
default: 'hover',
|
85
|
+
validator: (val) => ['hover', 'click', 'focus', 'context-menu'].includes(val)
|
86
|
+
}
|
87
|
+
});
|
88
|
+
|
89
|
+
const emit = defineEmits(['click']);
|
90
|
+
|
91
|
+
const handleClick = (...args) => {
|
92
|
+
emit('click', ...args);
|
93
|
+
};
|
94
|
+
</script>
|
95
|
+
|
96
|
+
<style lang="less" scoped>
|
97
|
+
/* TDesign主题样式定制 */
|
98
|
+
:deep(.t-dropdown) {
|
99
|
+
.t-dropdown__trigger {
|
100
|
+
cursor: pointer;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
:deep(.t-dropdown__menu) {
|
105
|
+
max-height: 300px;
|
106
|
+
overflow-y: auto;
|
107
|
+
|
108
|
+
/* 解决嵌套菜单层级问题 */
|
109
|
+
.t-dropdown__menu {
|
110
|
+
z-index: 9999;
|
111
|
+
position: absolute;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
/* 嵌套菜单项样式优化 */
|
116
|
+
:deep(.t-dropdown-item) {
|
117
|
+
position: relative;
|
118
|
+
|
119
|
+
/* 当有子菜单时,添加指示箭头 */
|
120
|
+
&:has(.t-dropdown__menu) {
|
121
|
+
&:after {
|
122
|
+
content: '';
|
123
|
+
position: absolute;
|
124
|
+
right: 8px;
|
125
|
+
top: 50%;
|
126
|
+
transform: translateY(-50%);
|
127
|
+
width: 0;
|
128
|
+
height: 0;
|
129
|
+
border-left: 4px solid currentColor;
|
130
|
+
border-top: 4px solid transparent;
|
131
|
+
border-bottom: 4px solid transparent;
|
132
|
+
opacity: 0.6;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
</style>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<template>
|
2
|
+
<t-dropdown-item :content="content" :disabled="disabled" :divider="divider" :value="value" @click="handleClick">
|
3
|
+
<!-- 默认内容插槽 -->
|
4
|
+
<template v-if="$slots.default" #default>
|
5
|
+
<slot></slot>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<!-- 前缀图标插槽 -->
|
9
|
+
<template v-if="$slots.prefixIcon" #prefixIcon>
|
10
|
+
<slot name="prefixIcon"></slot>
|
11
|
+
</template>
|
12
|
+
|
13
|
+
<!-- 后缀图标插槽 -->
|
14
|
+
<template v-if="$slots.suffixIcon" #suffixIcon>
|
15
|
+
<slot name="suffixIcon"></slot>
|
16
|
+
</template>
|
17
|
+
|
18
|
+
<!-- 嵌套的下拉菜单 -->
|
19
|
+
<t-dropdown-menu v-if="$slots.submenu">
|
20
|
+
<slot name="submenu"></slot>
|
21
|
+
</t-dropdown-menu>
|
22
|
+
</t-dropdown-item>
|
23
|
+
</template>
|
24
|
+
|
25
|
+
<script>
|
26
|
+
export default {
|
27
|
+
name: "EbizDropdownItem"
|
28
|
+
}
|
29
|
+
</script>
|
30
|
+
|
31
|
+
<script setup>
|
32
|
+
import { defineProps, defineEmits } from 'vue';
|
33
|
+
import { DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu } from 'tdesign-vue-next';
|
34
|
+
|
35
|
+
defineProps({
|
36
|
+
// 下拉操作项内容
|
37
|
+
content: {
|
38
|
+
type: [String, Function],
|
39
|
+
default: ''
|
40
|
+
},
|
41
|
+
// 是否禁用
|
42
|
+
disabled: {
|
43
|
+
type: Boolean,
|
44
|
+
default: false
|
45
|
+
},
|
46
|
+
// 是否显示操作项之间的分隔线(分隔线默认在下方)
|
47
|
+
divider: {
|
48
|
+
type: Boolean,
|
49
|
+
default: false
|
50
|
+
},
|
51
|
+
// 下拉操作项唯一标识
|
52
|
+
value: {
|
53
|
+
type: [String, Number, Object],
|
54
|
+
default: undefined
|
55
|
+
}
|
56
|
+
});
|
57
|
+
|
58
|
+
const emit = defineEmits(['click']);
|
59
|
+
|
60
|
+
const handleClick = (data, context) => {
|
61
|
+
emit('click', data, context);
|
62
|
+
};
|
63
|
+
</script>
|
64
|
+
|
65
|
+
<style lang="less" scoped>
|
66
|
+
/* TDesign主题样式定制 */
|
67
|
+
:deep(.t-dropdown-item) {
|
68
|
+
&:hover {
|
69
|
+
background-color: var(--td-bg-color-container-hover);
|
70
|
+
}
|
71
|
+
|
72
|
+
&.t-is-disabled {
|
73
|
+
color: var(--td-text-color-disabled);
|
74
|
+
cursor: not-allowed;
|
75
|
+
|
76
|
+
&:hover {
|
77
|
+
background-color: transparent;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
:deep(.t-dropdown-item__divider) {
|
83
|
+
margin: 4px 0;
|
84
|
+
border-bottom: 1px solid var(--td-border-level-1-color);
|
85
|
+
}
|
86
|
+
</style>
|
package/src/index.js
CHANGED
@@ -92,6 +92,8 @@ import EbizSFormItem from './components/senior/EbizSForm/item.vue';
|
|
92
92
|
import EbizSDialog from "./components/senior/EbizSDialog/index.vue";
|
93
93
|
import EbizMeetingRoomSelector from './components/EbizMeetingRoomSelector.vue';
|
94
94
|
import EbizMobileMeetingRoomSelector from './components/EbizMobileMeetingRoomSelector.vue';
|
95
|
+
import EbizDropdown from './components/EbizDropdown.vue';
|
96
|
+
import EbizDropdownItem from './components/EbizDropdownItem.vue';
|
95
97
|
|
96
98
|
|
97
99
|
// 导出组件
|
@@ -217,8 +219,12 @@ export {
|
|
217
219
|
// 新增 EbizApproval 组件
|
218
220
|
EbizApproval,
|
219
221
|
EbizDiv,
|
222
|
+
// 下拉菜单组件
|
223
|
+
EbizDropdown,
|
224
|
+
// 下拉菜单项组件
|
225
|
+
EbizDropdownItem,
|
220
226
|
// 会议室选择器组件
|
221
227
|
EbizMeetingRoomSelector,
|
222
228
|
// 新增 EbizMobileMeetingRoomSelector 组件
|
223
229
|
EbizMobileMeetingRoomSelector
|
224
|
-
}
|
230
|
+
}
|