vue-devui 1.0.0-beta.10 → 1.0.0-beta.14
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 +62 -45
- package/accordion/index.es.js +309 -38
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.es.js +5 -2
- package/alert/index.umd.js +1 -1
- package/auto-complete/index.d.ts +7 -0
- package/auto-complete/index.es.js +1121 -0
- package/auto-complete/index.umd.js +1 -0
- package/auto-complete/package.json +7 -0
- package/auto-complete/style.css +1 -0
- package/button/index.es.js +213 -8
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/color-picker/index.d.ts +7 -0
- package/color-picker/index.es.js +2960 -0
- package/color-picker/index.umd.js +1 -0
- package/color-picker/package.json +7 -0
- package/color-picker/style.css +1 -0
- package/dragdrop/index.es.js +135 -10
- package/dragdrop/index.umd.js +1 -1
- package/drawer/index.es.js +38 -6
- package/drawer/index.umd.js +1 -1
- package/dropdown/index.es.js +30 -22
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +67 -3
- package/editable-select/index.umd.js +11 -11
- package/form/index.es.js +59 -17
- package/form/index.umd.js +1 -1
- package/gantt/index.es.js +3 -3
- package/gantt/index.umd.js +1 -1
- package/image-preview/index.es.js +33 -15
- package/image-preview/index.umd.js +1 -1
- package/modal/index.es.js +214 -13
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nuxt/components/AutoComplete.js +3 -0
- package/nuxt/components/ColorPicker.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/overlay/index.es.js +1 -1
- package/overlay/index.umd.js +1 -1
- package/package.json +1 -16
- package/popover/index.es.js +13 -4
- package/popover/index.umd.js +1 -1
- package/progress/index.es.js +8 -8
- package/progress/index.umd.js +3 -3
- package/radio/index.es.js +5 -5
- package/radio/index.umd.js +1 -1
- package/slider/index.es.js +2 -5
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +191 -14
- package/splitter/index.umd.js +1 -1
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +4 -4
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/style.css +1 -1
- package/table/index.es.js +236 -26
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/time-picker/index.es.js +221 -11
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.es.js +8 -5
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/transfer/index.es.js +503 -59
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.es.js +6 -5
- package/tree/index.umd.js +1 -1
- package/tree-select/index.es.js +129 -34
- package/tree-select/index.umd.js +1 -1
- package/tree-select/style.css +1 -1
- package/upload/index.es.js +165 -507
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +16501 -13904
- package/vue-devui.umd.js +19 -19
- package/nuxt/components/MultiUpload.js +0 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://devui.design/home" target="_blank" rel="noopener noreferrer">
|
|
3
|
-
<img alt="DevUI Logo" src="public/logo.svg
|
|
3
|
+
<img alt="DevUI Logo" src="https://github.com/DevCloudFE/vue-devui/raw/dev/packages/devui-vue/public/logo.svg" width="180" style="max-width:100%;">
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Vue DevUI 是 Vue3 版本的 DevUI 组件库,基于 [https://github.com/devclo
|
|
|
8
8
|
|
|
9
9
|
DevUI 官方网站:[https://devui.design](https://devui.design)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## 当前状态: Beta
|
|
12
12
|
|
|
13
13
|
该项目还处于孵化和演进阶段,欢迎大家参与到 Vue DevUI 项目的建设中来!🎉🎉
|
|
14
14
|
|
|
@@ -18,11 +18,11 @@ DevUI 官方网站:[https://devui.design](https://devui.design)
|
|
|
18
18
|
- ⭐ 参与到开源社区中来
|
|
19
19
|
- 🎊 结识一群热爱学习、热爱开源的朋友
|
|
20
20
|
|
|
21
|
-
[贡献指南](https://
|
|
21
|
+
[贡献指南](https://github.com/DevCloudFE/vue-devui/wiki/%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## 快速开始
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### 1 安装依赖
|
|
26
26
|
|
|
27
27
|
```
|
|
28
28
|
yarn(推荐)
|
|
@@ -32,7 +32,7 @@ or
|
|
|
32
32
|
npm i
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
### 2 启动
|
|
36
36
|
|
|
37
37
|
```
|
|
38
38
|
yarn dev(推荐)
|
|
@@ -42,11 +42,11 @@ or
|
|
|
42
42
|
npm run dev
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### 3 访问
|
|
46
46
|
|
|
47
47
|
[http://localhost:3000/](http://localhost:3000/)
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
### 4 生产打包
|
|
50
50
|
|
|
51
51
|
```
|
|
52
52
|
yarn build(推荐)
|
|
@@ -56,16 +56,17 @@ or
|
|
|
56
56
|
npm run build
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
## 使用 Vue DevUI
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
### 1. 安装
|
|
62
62
|
|
|
63
63
|
```
|
|
64
64
|
yarn add vue-devui
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
### 2. 全量引入
|
|
68
68
|
|
|
69
|
+
在`main.ts`文件中编写以下代码:
|
|
69
70
|
```
|
|
70
71
|
import { createApp } from 'vue'
|
|
71
72
|
import App from './App.vue'
|
|
@@ -80,10 +81,11 @@ createApp(App)
|
|
|
80
81
|
.mount('#app')
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
### 3. 按需引入
|
|
84
85
|
|
|
85
86
|
除了全量引入,我们也支持单个组件按需引入。
|
|
86
87
|
|
|
88
|
+
在`main.ts`文件中编写以下代码:
|
|
87
89
|
```
|
|
88
90
|
import { createApp } from 'vue'
|
|
89
91
|
import App from './App.vue'
|
|
@@ -99,7 +101,32 @@ createApp(App)
|
|
|
99
101
|
.mount('#app')
|
|
100
102
|
```
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
### 4. 配置自动按需引入`unplugin-vue-components`(推荐)
|
|
105
|
+
|
|
106
|
+
配置`unplugin-vue-components`插件可以无需引入Vue DevUI就可以直接按需使用其中的组件,具体使用方式如下:
|
|
107
|
+
|
|
108
|
+
在`vite.config.ts`文件中添加以下代码:
|
|
109
|
+
```
|
|
110
|
+
import Components from 'unplugin-vue-components/vite'
|
|
111
|
+
import { DevUiResolver } from 'unplugin-vue-components/resolvers'
|
|
112
|
+
|
|
113
|
+
export default defineConfig({
|
|
114
|
+
plugins: [
|
|
115
|
+
vue(),
|
|
116
|
+
|
|
117
|
+
// 新增
|
|
118
|
+
Components({
|
|
119
|
+
resolvers: [
|
|
120
|
+
DevUiResolver()
|
|
121
|
+
]
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
配置了以上插件,就可以直接在代码中使用`Vue DevUI`的组件,而无需在`main.ts`文件中引入`Vue DevUI`。
|
|
128
|
+
|
|
129
|
+
### 5. 使用
|
|
103
130
|
|
|
104
131
|
```
|
|
105
132
|
<template>
|
|
@@ -107,13 +134,13 @@ createApp(App)
|
|
|
107
134
|
</template>
|
|
108
135
|
```
|
|
109
136
|
|
|
110
|
-
|
|
137
|
+
## 图标库
|
|
111
138
|
|
|
112
|
-
|
|
139
|
+
图标库推荐使用[DevUI图标库](https://devui.design/icon/ruleResource),也可以使用第三方图标库,比如:iconfont。
|
|
113
140
|
|
|
114
|
-
|
|
141
|
+
### 使用DevUI图标库
|
|
115
142
|
|
|
116
|
-
|
|
143
|
+
#### 安装
|
|
117
144
|
|
|
118
145
|
```
|
|
119
146
|
yarn add @devui-design/icons(推荐)
|
|
@@ -123,7 +150,7 @@ or
|
|
|
123
150
|
npm i @devui-design/icons
|
|
124
151
|
```
|
|
125
152
|
|
|
126
|
-
|
|
153
|
+
#### 引入
|
|
127
154
|
|
|
128
155
|
在`main.ts`文件中,编写以下代码:
|
|
129
156
|
|
|
@@ -131,42 +158,32 @@ npm i @devui-design/icons
|
|
|
131
158
|
import '@devui-design/icons/icomoon/devui-icon.css'
|
|
132
159
|
```
|
|
133
160
|
|
|
134
|
-
|
|
161
|
+
#### 使用
|
|
135
162
|
|
|
136
163
|
```
|
|
137
164
|
<d-icon name="love" color="red"></d-icon>
|
|
138
165
|
```
|
|
139
166
|
|
|
140
|
-
##
|
|
167
|
+
## Contributors ✨
|
|
141
168
|
|
|
142
|
-
|
|
169
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
143
170
|
|
|
144
|
-
|
|
171
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
172
|
+
<!-- prettier-ignore-start -->
|
|
173
|
+
<!-- markdownlint-disable -->
|
|
174
|
+
<table>
|
|
175
|
+
<tr>
|
|
176
|
+
<td align="center"><a href="https://juejin.cn/user/712139267650141"><img src="https://avatars.githubusercontent.com/u/9566362?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kagol</b></sub></a><br /><a href="#maintenance-kagol" title="Maintenance">🚧</a> <a href="https://github.com/DevCloudFE/vue-devui/commits?author=kagol" title="Code">💻</a> <a href="https://github.com/DevCloudFE/vue-devui/commits?author=kagol" title="Documentation">📖</a></td>
|
|
177
|
+
</tr>
|
|
178
|
+
</table>
|
|
145
179
|
|
|
146
|
-
|
|
180
|
+
<!-- markdownlint-restore -->
|
|
181
|
+
<!-- prettier-ignore-end -->
|
|
147
182
|
|
|
148
|
-
|
|
149
|
-
import 'your-folder/my-icon.css'
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### 使用
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
<d-icon classPrefix="my-icon" name="love" color="red"></d-icon>
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
其中的`classPrefix`参数的值,应该和你的字体图标样式文件`my-icon.css`里定义的样式前缀保持一致。
|
|
159
|
-
|
|
160
|
-
比如`my-icon.css`里的图标样式:
|
|
161
|
-
|
|
162
|
-
```css
|
|
163
|
-
.my-icon-branch-node:before {
|
|
164
|
-
content: "\E001";
|
|
165
|
-
}
|
|
166
|
-
```
|
|
183
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
167
184
|
|
|
168
|
-
|
|
185
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
169
186
|
|
|
170
|
-
|
|
187
|
+
## License
|
|
171
188
|
|
|
172
|
-
[MIT](https://
|
|
189
|
+
[MIT](https://github.com/DevCloudFE/vue-devui/blob/dev/LICENSE)
|
package/accordion/index.es.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,7 +16,8 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
17
|
-
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { createVNode, getCurrentInstance, defineComponent, toRefs, inject, computed, Fragment, mergeProps, resolveComponent, createTextVNode, provide, onMounted, watch } from "vue";
|
|
18
21
|
const accordionProps = {
|
|
19
22
|
data: {
|
|
20
23
|
type: Array,
|
|
@@ -26,8 +29,8 @@ const accordionProps = {
|
|
|
26
29
|
disabledKey: { type: String, default: "disabled" },
|
|
27
30
|
activeKey: { type: String, default: "active" },
|
|
28
31
|
openKey: { type: String, default: "open" },
|
|
29
|
-
menuItemTemplate: { type:
|
|
30
|
-
itemTemplate: { type:
|
|
32
|
+
menuItemTemplate: { type: Boolean, default: true },
|
|
33
|
+
itemTemplate: { type: Boolean, default: true },
|
|
31
34
|
menuToggle: {
|
|
32
35
|
type: Function,
|
|
33
36
|
default: null
|
|
@@ -43,9 +46,9 @@ const accordionProps = {
|
|
|
43
46
|
restrictOneOpen: { type: Boolean, default: false },
|
|
44
47
|
autoOpenActiveMenu: { type: Boolean, default: false },
|
|
45
48
|
showNoContent: { type: Boolean, default: true },
|
|
46
|
-
noContentTemplate: { type:
|
|
47
|
-
loadingTemplate: { type:
|
|
48
|
-
innerListTemplate: { type:
|
|
49
|
+
noContentTemplate: { type: Boolean, default: true },
|
|
50
|
+
loadingTemplate: { type: Boolean, default: true },
|
|
51
|
+
innerListTemplate: { type: Boolean, default: true },
|
|
49
52
|
linkType: {
|
|
50
53
|
type: String,
|
|
51
54
|
default: ""
|
|
@@ -59,8 +62,43 @@ const accordionProps = {
|
|
|
59
62
|
default: "normal"
|
|
60
63
|
}
|
|
61
64
|
};
|
|
65
|
+
const OpenIcon = () => {
|
|
66
|
+
return createVNode("svg", {
|
|
67
|
+
"width": "1em",
|
|
68
|
+
"height": "1em",
|
|
69
|
+
"viewBox": "0 0 16 16",
|
|
70
|
+
"version": "1.1",
|
|
71
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
72
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
73
|
+
}, [createVNode("g", {
|
|
74
|
+
"stroke": "none",
|
|
75
|
+
"stroke-width": "1",
|
|
76
|
+
"fill": "none",
|
|
77
|
+
"fill-rule": "evenodd"
|
|
78
|
+
}, [createVNode("path", {
|
|
79
|
+
"d": "M12.1464466,6.85355339 L8.35355339,10.6464466 C8.15829124,10.8417088 7.84170876,10.8417088 7.64644661,10.6464466 L3.85355339,6.85355339 C3.65829124,6.65829124 3.65829124,6.34170876 3.85355339,6.14644661 C3.94732158,6.05267842 4.07449854,6 4.20710678,6 L11.7928932,6 C12.0690356,6 12.2928932,6.22385763 12.2928932,6.5 C12.2928932,6.63260824 12.2402148,6.7597852 12.1464466,6.85355339 Z",
|
|
80
|
+
"fill-rule": "nonzero"
|
|
81
|
+
}, null)])]);
|
|
82
|
+
};
|
|
83
|
+
const getRootSlots = () => {
|
|
84
|
+
const rootComponentName = "DAccordion";
|
|
85
|
+
const getRootComponent = (component) => {
|
|
86
|
+
if (component && component.type.name === rootComponentName) {
|
|
87
|
+
return component;
|
|
88
|
+
}
|
|
89
|
+
if (component && component.parent) {
|
|
90
|
+
const parent = component.parent;
|
|
91
|
+
return getRootComponent(parent);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const rootComponent = getRootComponent(getCurrentInstance());
|
|
95
|
+
return rootComponent == null ? void 0 : rootComponent.slots;
|
|
96
|
+
};
|
|
62
97
|
var DAccordionMenu = defineComponent({
|
|
63
98
|
name: "DAccordionMenu",
|
|
99
|
+
components: {
|
|
100
|
+
OpenIcon
|
|
101
|
+
},
|
|
64
102
|
props: __spreadValues({
|
|
65
103
|
item: Object,
|
|
66
104
|
deepth: {
|
|
@@ -75,27 +113,167 @@ var DAccordionMenu = defineComponent({
|
|
|
75
113
|
setup(props) {
|
|
76
114
|
const {
|
|
77
115
|
item,
|
|
78
|
-
deepth
|
|
116
|
+
deepth,
|
|
117
|
+
parent,
|
|
118
|
+
openKey,
|
|
119
|
+
activeKey,
|
|
120
|
+
autoOpenActiveMenu,
|
|
121
|
+
disabledKey,
|
|
122
|
+
childrenKey,
|
|
123
|
+
titleKey,
|
|
124
|
+
menuItemTemplate
|
|
79
125
|
} = toRefs(props);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
126
|
+
const rootSlots = getRootSlots();
|
|
127
|
+
const accordionCtx = inject("accordionContext");
|
|
128
|
+
let parentValue = parent.value;
|
|
129
|
+
let deepValue = deepth.value;
|
|
130
|
+
const toggle = (itemEvent) => {
|
|
131
|
+
accordionCtx.menuToggleFn(itemEvent);
|
|
132
|
+
};
|
|
133
|
+
const hasActiveChildren = (item2) => {
|
|
134
|
+
if (item2[activeKey.value] === true)
|
|
135
|
+
return true;
|
|
136
|
+
if (item2[childrenKey.value]) {
|
|
137
|
+
return hasChildActive(item2[childrenKey.value]);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const hasChildActive = (arr) => {
|
|
141
|
+
let flag = false;
|
|
142
|
+
if (!arr.length)
|
|
143
|
+
return false;
|
|
144
|
+
for (let i = 0; i < arr.length; i++) {
|
|
145
|
+
if (arr[i][activeKey.value] === true) {
|
|
146
|
+
flag = true;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
if (arr[i][childrenKey.value]) {
|
|
150
|
+
flag = hasChildActive(arr[i][childrenKey.value]);
|
|
151
|
+
if (flag)
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return flag;
|
|
156
|
+
};
|
|
83
157
|
const keyOpen = computed(() => {
|
|
84
|
-
return item
|
|
158
|
+
return item.value && item.value[openKey.value];
|
|
159
|
+
});
|
|
160
|
+
const disabled = computed(() => {
|
|
161
|
+
return item.value && item.value[disabledKey.value];
|
|
162
|
+
});
|
|
163
|
+
const title = computed(() => {
|
|
164
|
+
return item.value && item.value[titleKey.value];
|
|
165
|
+
});
|
|
166
|
+
const children = computed(() => {
|
|
167
|
+
return item.value && item.value[childrenKey.value];
|
|
85
168
|
});
|
|
86
169
|
const childActived = computed(() => {
|
|
170
|
+
return hasActiveChildren(item.value);
|
|
171
|
+
});
|
|
172
|
+
const open = computed(() => {
|
|
173
|
+
return keyOpen.value === void 0 && autoOpenActiveMenu.value ? childActived.value : keyOpen.value;
|
|
87
174
|
});
|
|
88
175
|
return () => {
|
|
176
|
+
var _a;
|
|
89
177
|
return createVNode(Fragment, null, [createVNode("div", {
|
|
90
|
-
"class": ["devui-accordion-item-title", "devui-over-flow-ellipsis",
|
|
91
|
-
"title":
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
|
|
178
|
+
"class": ["devui-accordion-item-title", "devui-over-flow-ellipsis", open.value && "open", childActived.value && "active", disabled.value && "disabled"],
|
|
179
|
+
"title": title.value,
|
|
180
|
+
"style": {
|
|
181
|
+
textIndent: deepValue * 20 + "px"
|
|
182
|
+
},
|
|
183
|
+
"onClick": (e) => !disabled.value && toggle({
|
|
184
|
+
item: item.value,
|
|
185
|
+
open: !open.value,
|
|
186
|
+
parent: parentValue,
|
|
187
|
+
event: e
|
|
188
|
+
})
|
|
189
|
+
}, [createVNode("div", {
|
|
190
|
+
"class": ["devui-accordion-splitter", deepValue === 0 && "devui-parent-list"],
|
|
191
|
+
"style": {
|
|
192
|
+
left: deepValue * 20 + 10 + "px"
|
|
193
|
+
}
|
|
194
|
+
}, null), (!rootSlots.menuItemTemplate || menuItemTemplate.value === false) && createVNode(Fragment, null, [title.value]), rootSlots.menuItemTemplate && menuItemTemplate.value !== false && ((_a = rootSlots.menuItemTemplate) == null ? void 0 : _a.call(rootSlots, {
|
|
195
|
+
parent: parentValue,
|
|
196
|
+
deepth: deepValue,
|
|
197
|
+
item: item.value
|
|
198
|
+
})), createVNode("span", {
|
|
199
|
+
"class": "devui-accordion-open-icon"
|
|
200
|
+
}, [createVNode(OpenIcon, null, null)])]), createVNode("div", {
|
|
201
|
+
"class": [!open.value && "devui-accordion-menu-hidden", "devui-accordion-submenu", "devui-accordion-show-animate"]
|
|
202
|
+
}, [createVNode(AccordionList, mergeProps(props, {
|
|
203
|
+
"deepth": deepValue + 1,
|
|
204
|
+
"data": children.value || [],
|
|
97
205
|
"parent": item.value
|
|
98
|
-
}, null)]);
|
|
206
|
+
}), null)])]);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
var DAccordionItem = defineComponent({
|
|
211
|
+
name: "DAccordionItem",
|
|
212
|
+
props: __spreadValues({
|
|
213
|
+
item: Object,
|
|
214
|
+
deepth: {
|
|
215
|
+
type: Number,
|
|
216
|
+
default: 0
|
|
217
|
+
},
|
|
218
|
+
parent: {
|
|
219
|
+
type: Object,
|
|
220
|
+
default: null
|
|
221
|
+
}
|
|
222
|
+
}, accordionProps),
|
|
223
|
+
setup(props) {
|
|
224
|
+
const {
|
|
225
|
+
item,
|
|
226
|
+
deepth,
|
|
227
|
+
parent,
|
|
228
|
+
titleKey,
|
|
229
|
+
activeKey,
|
|
230
|
+
disabledKey,
|
|
231
|
+
itemTemplate
|
|
232
|
+
} = toRefs(props);
|
|
233
|
+
const rootSlots = getRootSlots();
|
|
234
|
+
const accordionCtx = inject("accordionContext");
|
|
235
|
+
let parentValue = parent.value;
|
|
236
|
+
let deepValue = deepth.value;
|
|
237
|
+
const disabled = computed(() => {
|
|
238
|
+
return item.value && item.value[disabledKey.value];
|
|
239
|
+
});
|
|
240
|
+
const title = computed(() => {
|
|
241
|
+
return item.value && item.value[titleKey.value];
|
|
242
|
+
});
|
|
243
|
+
const active = computed(() => {
|
|
244
|
+
return item.value && item.value[activeKey.value];
|
|
245
|
+
});
|
|
246
|
+
const childActived = computed(() => {
|
|
247
|
+
return active.value;
|
|
248
|
+
});
|
|
249
|
+
const itemClick = (itemEvent) => {
|
|
250
|
+
if (item.value && !disabled.value) {
|
|
251
|
+
accordionCtx.itemClickFn(itemEvent);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
return () => {
|
|
255
|
+
var _a;
|
|
256
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
257
|
+
"class": ["devui-accordion-item-title", "devui-over-flow-ellipsis", childActived.value && "active", disabled.value && "disabled"],
|
|
258
|
+
"title": title.value,
|
|
259
|
+
"style": {
|
|
260
|
+
textIndent: deepValue * 20 + "px"
|
|
261
|
+
},
|
|
262
|
+
"onClick": (e) => itemClick({
|
|
263
|
+
item: item.value,
|
|
264
|
+
parent: parentValue,
|
|
265
|
+
event: e
|
|
266
|
+
})
|
|
267
|
+
}, [createVNode("div", {
|
|
268
|
+
"class": ["devui-accordion-splitter", deepValue === 0 && "devui-parent-list"],
|
|
269
|
+
"style": {
|
|
270
|
+
left: deepValue * 20 + 10 + "px"
|
|
271
|
+
}
|
|
272
|
+
}, null), (!rootSlots.itemTemplate || itemTemplate.value === false) && createVNode(Fragment, null, [title.value]), rootSlots.itemTemplate && itemTemplate.value !== false && ((_a = rootSlots.itemTemplate) == null ? void 0 : _a.call(rootSlots, {
|
|
273
|
+
parent: parentValue,
|
|
274
|
+
deepth: deepValue,
|
|
275
|
+
item: item.value
|
|
276
|
+
}))])]);
|
|
99
277
|
};
|
|
100
278
|
}
|
|
101
279
|
});
|
|
@@ -103,7 +281,8 @@ var AccordionList = defineComponent({
|
|
|
103
281
|
name: "DAccordionList",
|
|
104
282
|
inheritAttrs: false,
|
|
105
283
|
components: {
|
|
106
|
-
DAccordionMenu
|
|
284
|
+
DAccordionMenu,
|
|
285
|
+
DAccordionItem
|
|
107
286
|
},
|
|
108
287
|
props: __spreadValues({
|
|
109
288
|
data: {
|
|
@@ -121,27 +300,84 @@ var AccordionList = defineComponent({
|
|
|
121
300
|
innerListTemplate: Boolean
|
|
122
301
|
}, accordionProps),
|
|
123
302
|
setup(props, {
|
|
124
|
-
attrs
|
|
125
|
-
slots
|
|
303
|
+
attrs
|
|
126
304
|
}) {
|
|
127
305
|
const {
|
|
128
306
|
childrenKey,
|
|
129
|
-
|
|
130
|
-
|
|
307
|
+
deepth,
|
|
308
|
+
parent,
|
|
309
|
+
data,
|
|
310
|
+
linkType,
|
|
311
|
+
showNoContent,
|
|
312
|
+
loadingKey,
|
|
313
|
+
titleKey,
|
|
314
|
+
loadingTemplate,
|
|
315
|
+
noContentTemplate,
|
|
316
|
+
innerListTemplate
|
|
131
317
|
} = toRefs(props);
|
|
318
|
+
let parentValue = parent.value;
|
|
319
|
+
let deepValue = deepth.value;
|
|
320
|
+
const rootSlots = getRootSlots();
|
|
321
|
+
const accordionCtx = inject("accordionContext");
|
|
322
|
+
const loading = computed(() => {
|
|
323
|
+
return parentValue && parentValue[loadingKey.value];
|
|
324
|
+
});
|
|
325
|
+
const noContent = computed(() => {
|
|
326
|
+
let dataValue = data.value;
|
|
327
|
+
return dataValue === void 0 || dataValue === null || dataValue.length === 0;
|
|
328
|
+
});
|
|
132
329
|
return () => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
330
|
+
var _a, _b, _c;
|
|
331
|
+
return createVNode(Fragment, null, [(!rootSlots.innerListTemplate || deepth.value === 0 || innerListTemplate.value === false) && createVNode("ul", mergeProps({
|
|
332
|
+
"class": ["devui-accordion-list"]
|
|
333
|
+
}, attrs), [data.value.map((item) => {
|
|
136
334
|
return createVNode("li", {
|
|
137
335
|
"class": "devui-accordion-item",
|
|
138
|
-
"key": item.
|
|
139
|
-
}, [childrenKey !== void 0 && createVNode(
|
|
336
|
+
"key": item[titleKey.value]
|
|
337
|
+
}, [item[childrenKey.value] !== void 0 && createVNode("div", {
|
|
338
|
+
"class": "devui-accordion-menu-item"
|
|
339
|
+
}, [createVNode(resolveComponent("d-accordion-menu"), mergeProps(props, {
|
|
140
340
|
"item": item,
|
|
141
|
-
"deepth":
|
|
142
|
-
"parent":
|
|
143
|
-
},
|
|
144
|
-
|
|
341
|
+
"deepth": deepValue,
|
|
342
|
+
"parent": parentValue
|
|
343
|
+
}), null)]), item[childrenKey.value] === void 0 && createVNode(Fragment, null, [(!linkType.value || linkType.value === "") && createVNode(resolveComponent("d-accordion-item"), mergeProps(props, {
|
|
344
|
+
"item": item,
|
|
345
|
+
"deepth": deepValue,
|
|
346
|
+
"parent": parentValue
|
|
347
|
+
}), null)])]);
|
|
348
|
+
})]), rootSlots.innerListTemplate && innerListTemplate.value !== false && deepValue !== 0 && ((_a = rootSlots.innerListTemplate) == null ? void 0 : _a.call(rootSlots, {
|
|
349
|
+
item: parentValue,
|
|
350
|
+
deepth: deepValue,
|
|
351
|
+
itemClickFn: accordionCtx.itemClickFn,
|
|
352
|
+
menuToggleFn: accordionCtx.menuToggleFn
|
|
353
|
+
})), (!rootSlots.innerListTemplate || innerListTemplate.value === false) && (loading.value || noContent.value && showNoContent.value) && createVNode("ul", mergeProps({
|
|
354
|
+
"class": ["devui-accordion-list"]
|
|
355
|
+
}, attrs), [
|
|
356
|
+
loading.value && (!rootSlots.loadingTemplate || loadingTemplate.value === false) && createVNode("li", {
|
|
357
|
+
"class": "devui-accordion-item"
|
|
358
|
+
}, [createVNode("div", {
|
|
359
|
+
"class": ["devui-accordion-item-title", "devui-over-flow-ellipsis"],
|
|
360
|
+
"style": {
|
|
361
|
+
textIndent: deepValue * 20 + "px"
|
|
362
|
+
}
|
|
363
|
+
}, [createTextVNode("\u52A0\u8F7D\u4E2D...")])]),
|
|
364
|
+
loading.value && rootSlots.loadingTemplate && loadingTemplate.value !== false && ((_b = rootSlots.loadingTemplate) == null ? void 0 : _b.call(rootSlots, {
|
|
365
|
+
item: parentValue,
|
|
366
|
+
deepth: deepValue
|
|
367
|
+
})),
|
|
368
|
+
showNoContent.value && !loading.value && noContent.value && (!rootSlots.noContentTemplate || noContentTemplate.value === false) && createVNode("li", {
|
|
369
|
+
"class": "devui-accordion-item"
|
|
370
|
+
}, [createVNode("div", {
|
|
371
|
+
"class": ["devui-accordion-item-title", "devui-over-flow-ellipsis disabled"],
|
|
372
|
+
"style": {
|
|
373
|
+
textIndent: deepValue * 20 + "px"
|
|
374
|
+
}
|
|
375
|
+
}, [createTextVNode("\u6CA1\u6709\u6570\u636E")])]),
|
|
376
|
+
showNoContent.value && !loading.value && noContent.value && rootSlots.noContentTemplate && noContentTemplate.value !== false && ((_c = rootSlots.noContentTemplate) == null ? void 0 : _c.call(rootSlots, {
|
|
377
|
+
item: parentValue,
|
|
378
|
+
deepth: deepValue
|
|
379
|
+
}))
|
|
380
|
+
])]);
|
|
145
381
|
};
|
|
146
382
|
}
|
|
147
383
|
});
|
|
@@ -198,28 +434,63 @@ var Accordion = defineComponent({
|
|
|
198
434
|
clickActiveItem = item;
|
|
199
435
|
emit("activeItemChange", clickActiveItem);
|
|
200
436
|
};
|
|
437
|
+
const openMenuFn = (item, open) => {
|
|
438
|
+
if (open && restrictOneOpen.value) {
|
|
439
|
+
data.value.forEach((itemtemp) => {
|
|
440
|
+
itemtemp[openKey.value] = false;
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
item[openKey.value] = open;
|
|
444
|
+
};
|
|
445
|
+
const itemClickFn = (itemEvent) => {
|
|
446
|
+
const prevActiveItem = clickActiveItem;
|
|
447
|
+
activeItemFn(itemEvent.item);
|
|
448
|
+
emit("itemClick", __spreadProps(__spreadValues({}, itemEvent), {
|
|
449
|
+
prevActiveItem
|
|
450
|
+
}));
|
|
451
|
+
};
|
|
452
|
+
const linkItemClickFn = (itemEvent) => {
|
|
453
|
+
const prevActiveItem = clickActiveItem;
|
|
454
|
+
clickActiveItem = itemEvent.item;
|
|
455
|
+
emit("linkItemClick", __spreadProps(__spreadValues({}, itemEvent), {
|
|
456
|
+
prevActiveItem
|
|
457
|
+
}));
|
|
458
|
+
};
|
|
459
|
+
const menuToggleFn = (menuEvent) => {
|
|
460
|
+
openMenuFn(menuEvent.item, menuEvent.open);
|
|
461
|
+
emit("menuToggle", menuEvent);
|
|
462
|
+
};
|
|
201
463
|
const cleanOpenData = () => {
|
|
202
464
|
flatten(data.value, childrenKey.value, true, false).forEach((item) => item[openKey.value] = void 0);
|
|
203
465
|
};
|
|
466
|
+
provide("accordionContext", {
|
|
467
|
+
itemClickFn,
|
|
468
|
+
linkItemClickFn,
|
|
469
|
+
menuToggleFn
|
|
470
|
+
});
|
|
204
471
|
onMounted(() => {
|
|
205
472
|
if (data.value) {
|
|
206
473
|
initActiveItem();
|
|
207
474
|
}
|
|
208
475
|
});
|
|
209
476
|
watch(() => autoOpenActiveMenu.value, (current, preV) => {
|
|
210
|
-
console.log("cur, new", current, preV);
|
|
211
477
|
if (current && preV === false) {
|
|
212
478
|
cleanOpenData();
|
|
213
479
|
}
|
|
214
480
|
});
|
|
481
|
+
watch(data.value, (current, preV) => {
|
|
482
|
+
initActiveItem();
|
|
483
|
+
}, {
|
|
484
|
+
deep: true
|
|
485
|
+
});
|
|
215
486
|
return () => {
|
|
216
487
|
return createVNode("div", {
|
|
217
|
-
"class":
|
|
218
|
-
}, [createVNode(AccordionList, mergeProps({
|
|
219
|
-
"data": data,
|
|
488
|
+
"class": ["devui-accordion-menu", "devui-scrollbar", "devui-accordion-show-animate", accordionType.value === "normal" && "devui-accordion-menu-normal"]
|
|
489
|
+
}, [createVNode(AccordionList, mergeProps(props, {
|
|
490
|
+
"data": data.value,
|
|
220
491
|
"deepth": 0,
|
|
221
492
|
"parent": null
|
|
222
|
-
}
|
|
493
|
+
}), null)]);
|
|
223
494
|
};
|
|
224
495
|
}
|
|
225
496
|
});
|