vue-devui 1.0.0-rc.8 → 1.0.1
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 +188 -149
- package/alert/index.es.js +14 -9
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +8392 -418
- package/auto-complete/index.umd.js +29 -5
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +59 -74
- package/avatar/index.umd.js +1 -1
- package/badge/index.es.js +10 -4
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +191 -53
- package/button/index.umd.js +17 -17
- package/button/style.css +1 -1
- package/card/index.es.js +7 -3
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +8050 -241
- package/checkbox/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/{date-picker → collapse}/index.d.ts +0 -0
- package/collapse/index.es.js +213 -0
- package/collapse/index.umd.js +1 -0
- package/{date-picker → collapse}/package.json +1 -1
- package/collapse/style.css +1 -0
- package/countdown/index.es.js +56 -13
- package/countdown/index.umd.js +1 -1
- package/date-picker-pro/index.d.ts +7 -0
- package/date-picker-pro/index.es.js +12022 -0
- package/date-picker-pro/index.umd.js +27 -0
- package/date-picker-pro/package.json +7 -0
- package/date-picker-pro/style.css +1 -0
- package/drawer/index.es.js +24 -7
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +190 -165
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +785 -145
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +399 -300
- package/form/index.umd.js +16 -16
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +2 -2
- package/fullscreen/index.umd.js +1 -1
- package/grid/index.es.js +8 -6
- package/grid/index.umd.js +1 -1
- package/icon/index.es.js +185 -23
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -0
- package/image-preview/index.es.js +2 -2
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +8220 -45
- package/input/index.umd.js +27 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +279 -204
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +3 -3
- package/layout/index.umd.js +1 -1
- package/loading/index.es.js +53 -53
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/mention/index.d.ts +7 -0
- package/mention/index.es.js +8319 -0
- package/mention/index.umd.js +36 -0
- package/mention/package.json +7 -0
- package/mention/style.css +1 -0
- package/menu/index.d.ts +7 -0
- package/menu/index.es.js +921 -0
- package/menu/index.umd.js +1 -0
- package/menu/package.json +7 -0
- package/menu/style.css +1 -0
- package/message/index.d.ts +7 -0
- package/message/index.es.js +539 -0
- package/message/index.umd.js +1 -0
- package/message/package.json +7 -0
- package/message/style.css +1 -0
- package/modal/index.es.js +451 -173
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +212 -70
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/CheckboxButton.js +3 -0
- package/nuxt/components/Collapse.js +3 -0
- package/nuxt/components/CollapseItem.js +3 -0
- package/nuxt/components/DRangeDatePickerPro.js +3 -0
- package/nuxt/components/DatePickerPro.js +3 -0
- package/nuxt/components/Icon.js +1 -0
- package/nuxt/components/IconGroup.js +3 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/Mention.js +3 -0
- package/nuxt/components/Menu.js +3 -0
- package/nuxt/components/MenuItem.js +3 -0
- package/nuxt/components/Message.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/OptionGroup.js +3 -0
- package/nuxt/components/RadioButton.js +3 -0
- package/nuxt/components/Step.js +3 -0
- package/nuxt/components/Steps.js +3 -0
- package/nuxt/components/SubMenu.js +3 -0
- package/nuxt/components/TABLE_TOKEN.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/TimeSelect.js +3 -0
- package/nuxt/components/animationInjectionKey.js +3 -0
- package/nuxt/components/collapseItemProps.js +3 -0
- package/nuxt/components/collapseProps.js +3 -0
- package/nuxt/components/datePickerProCommonProps.js +3 -0
- package/nuxt/components/datePickerProPanelProps.js +3 -0
- package/nuxt/components/datePickerProProps.js +3 -0
- package/nuxt/components/iconProps.js +1 -0
- package/nuxt/components/mentionProps.js +3 -0
- package/nuxt/components/messageProps.js +3 -0
- package/nuxt/components/paginationInjectionKey.js +3 -0
- package/nuxt/components/roundInjectionKey.js +3 -0
- package/nuxt/components/skeletonItemProps.js +3 -0
- package/nuxt/components/stepProps.js +3 -0
- package/nuxt/components/stepsProps.js +3 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/nuxt/components/tableProps.js +3 -0
- package/nuxt/components/timerPickerPanelProps.js +3 -0
- package/nuxt/components/treeNodeProps.js +3 -0
- package/overlay/index.es.js +89 -142
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -4
- package/pagination/index.es.js +10180 -129
- package/pagination/index.umd.js +27 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +4 -0
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.es.js +262 -229
- package/popover/index.umd.js +15 -15
- package/popover/style.css +1 -1
- package/progress/index.es.js +2 -2
- package/progress/index.umd.js +2 -2
- package/progress/style.css +1 -1
- package/radio/index.es.js +7954 -156
- package/radio/index.umd.js +27 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +16 -8
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +170 -22
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/search/index.es.js +3829 -1042
- package/search/index.umd.js +18 -18
- package/search/style.css +1 -1
- package/select/index.es.js +9202 -495
- package/select/index.umd.js +27 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +89 -263
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +118 -145
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +454 -233
- package/splitter/index.umd.js +13 -13
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +34 -16
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/status/index.es.js +6 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/steps/index.d.ts +7 -0
- package/steps/index.es.js +387 -0
- package/steps/index.umd.js +1 -0
- package/steps/package.json +7 -0
- package/steps/style.css +1 -0
- package/style.css +1 -1
- package/switch/index.es.js +7787 -62
- package/switch/index.umd.js +27 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +5225 -1726
- package/table/index.umd.js +18 -18
- package/table/style.css +1 -1
- package/tabs/index.es.js +303 -102
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +11 -8
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +7876 -41
- package/textarea/index.umd.js +35 -1
- package/textarea/style.css +1 -1
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +9549 -0
- package/time-picker/index.umd.js +27 -0
- package/time-picker/package.json +7 -0
- package/time-picker/style.css +1 -0
- package/time-select/index.d.ts +7 -0
- package/time-select/index.es.js +9607 -0
- package/time-select/index.umd.js +27 -0
- package/time-select/package.json +7 -0
- package/time-select/style.css +1 -0
- package/timeline/index.es.js +170 -22
- package/timeline/index.umd.js +1 -1
- package/timeline/style.css +1 -1
- package/tooltip/index.es.js +286 -238
- package/tooltip/index.umd.js +14 -14
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +11342 -793
- package/tree/index.umd.js +27 -1
- package/tree/style.css +1 -1
- package/upload/index.es.js +458 -102
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +20475 -11072
- package/vue-devui.umd.js +31 -24
- package/date-picker/index.es.js +0 -1097
- package/date-picker/index.umd.js +0 -1
- package/date-picker/style.css +0 -1
- package/nuxt/components/DatePicker.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/Loading.js +0 -3
- package/nuxt/components/StickSlider.js +0 -3
- package/nuxt/components/formControlProps.js +0 -3
- package/nuxt/components/overlayEmits.js +0 -3
- package/nuxt/components/overlayProps.js +0 -3
package/menu/index.es.js
ADDED
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { ref, defineComponent, getCurrentInstance, inject, toRefs, computed, createVNode, watch, onMounted, Transition, withDirectives, vShow, watchEffect, provide } from "vue";
|
|
8
|
+
function createBem(namespace, element, modifier) {
|
|
9
|
+
let cls = namespace;
|
|
10
|
+
if (element) {
|
|
11
|
+
cls += `__${element}`;
|
|
12
|
+
}
|
|
13
|
+
if (modifier) {
|
|
14
|
+
cls += `--${modifier}`;
|
|
15
|
+
}
|
|
16
|
+
return cls;
|
|
17
|
+
}
|
|
18
|
+
function useNamespace(block, needDot = false) {
|
|
19
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
20
|
+
const b = () => createBem(namespace);
|
|
21
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
22
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
23
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
24
|
+
return {
|
|
25
|
+
b,
|
|
26
|
+
e,
|
|
27
|
+
m,
|
|
28
|
+
em
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const elements = [];
|
|
32
|
+
let parents = [];
|
|
33
|
+
const defaultIndent = ref(24);
|
|
34
|
+
const ns$5 = useNamespace("menu");
|
|
35
|
+
const subNs$2 = useNamespace("submenu");
|
|
36
|
+
const menuClass = ns$5.b();
|
|
37
|
+
const menuItemHorizontalWrapper = `${ns$5.b()}-item-horizontal-wrapper`;
|
|
38
|
+
const menuItemSelect$1 = `${ns$5.b()}-item-select`;
|
|
39
|
+
const menuActiveParent = `${ns$5.b()}-active-parent`;
|
|
40
|
+
function setDefaultIndent(indent) {
|
|
41
|
+
defaultIndent.value = indent;
|
|
42
|
+
}
|
|
43
|
+
function pushElement(element) {
|
|
44
|
+
elements.push(element);
|
|
45
|
+
}
|
|
46
|
+
function addLayer() {
|
|
47
|
+
parents = [];
|
|
48
|
+
elements.forEach((val) => {
|
|
49
|
+
parents.push(val.el.parentElement);
|
|
50
|
+
});
|
|
51
|
+
const stack = [...parents];
|
|
52
|
+
const getLayerFromClass = (className) => {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = /layer_(\d*)/gim.exec(className)) == null ? void 0 : _a[1];
|
|
55
|
+
};
|
|
56
|
+
while (stack.length) {
|
|
57
|
+
const shiftItem = stack.shift();
|
|
58
|
+
if (shiftItem == null ? void 0 : shiftItem.classList.contains(menuClass)) {
|
|
59
|
+
const children = shiftItem.children;
|
|
60
|
+
stack.unshift(...Array.from(children));
|
|
61
|
+
continue;
|
|
62
|
+
} else {
|
|
63
|
+
if (shiftItem.tagName === "DIV") {
|
|
64
|
+
if (shiftItem.classList.contains(`${ns$5.b()}-item-vertical-wrapper`) || shiftItem.classList.contains(`${subNs$2.b()}-menu-item-vertical-wrapper`)) {
|
|
65
|
+
const parent = shiftItem.parentElement;
|
|
66
|
+
stack.unshift(...Array.from(shiftItem.children));
|
|
67
|
+
if (parent == null ? void 0 : parent.classList.contains(menuClass)) {
|
|
68
|
+
shiftItem.classList.add("layer_1");
|
|
69
|
+
} else {
|
|
70
|
+
let layer = getLayerFromClass((parent == null ? void 0 : parent.classList.value) || "");
|
|
71
|
+
layer = Number(layer);
|
|
72
|
+
shiftItem.classList.add(`layer_${layer}`);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
const parent = shiftItem.parentElement;
|
|
76
|
+
let layer = getLayerFromClass((parent == null ? void 0 : parent.classList.value) || "");
|
|
77
|
+
layer = Number(layer);
|
|
78
|
+
shiftItem.classList.add(`layer_${layer}`);
|
|
79
|
+
shiftItem.style.paddingLeft = `${(layer === 2 ? 1 : layer - 1) * defaultIndent.value}px`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (shiftItem.tagName === "UL") {
|
|
83
|
+
const parent = shiftItem.parentElement;
|
|
84
|
+
const children = shiftItem.children;
|
|
85
|
+
for (let i = 0; i < children.length; i++) {
|
|
86
|
+
stack.unshift(children[i]);
|
|
87
|
+
}
|
|
88
|
+
const classList = (parent == null ? void 0 : parent.classList.value) || "";
|
|
89
|
+
let layer = getLayerFromClass(classList);
|
|
90
|
+
if (parent == null ? void 0 : parent.classList.contains(menuClass)) {
|
|
91
|
+
layer = 1;
|
|
92
|
+
shiftItem.classList.add(`layer_${2}`);
|
|
93
|
+
} else {
|
|
94
|
+
shiftItem.classList.add(`layer_${Number(layer) + 1}`);
|
|
95
|
+
layer = Number(layer) + 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (shiftItem.tagName === "LI") {
|
|
99
|
+
const parent = shiftItem.parentElement;
|
|
100
|
+
const parentClassList = (parent == null ? void 0 : parent.classList.value) || "";
|
|
101
|
+
let layer = getLayerFromClass(parentClassList);
|
|
102
|
+
getLayerFromClass(parentClassList);
|
|
103
|
+
layer = Number(layer);
|
|
104
|
+
shiftItem.style.padding = `0 ${layer * defaultIndent.value}px`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function getRoot(path) {
|
|
110
|
+
var _a;
|
|
111
|
+
const paths = path;
|
|
112
|
+
let rootElement = null;
|
|
113
|
+
for (let i = 0; i < paths.length; i++) {
|
|
114
|
+
const p = paths[i];
|
|
115
|
+
if ((_a = p == null ? void 0 : p.classList) == null ? void 0 : _a.contains(`${ns$5.b()}-horizontal`)) {
|
|
116
|
+
rootElement = p;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return rootElement;
|
|
120
|
+
}
|
|
121
|
+
function clearSelect_isHorizontal(ele, event) {
|
|
122
|
+
let element = event.target;
|
|
123
|
+
let stack = [];
|
|
124
|
+
const { path } = event;
|
|
125
|
+
const root = getRoot(path);
|
|
126
|
+
stack = [...Array.from(root.children)];
|
|
127
|
+
if (element.tagName === "SPAN") {
|
|
128
|
+
element = element.parentElement;
|
|
129
|
+
}
|
|
130
|
+
while (stack.length) {
|
|
131
|
+
const shiftItem = stack.shift();
|
|
132
|
+
if ((shiftItem == null ? void 0 : shiftItem.tagName) === "UL" || (shiftItem == null ? void 0 : shiftItem.classList.contains(menuItemHorizontalWrapper))) {
|
|
133
|
+
const children = shiftItem == null ? void 0 : shiftItem.children;
|
|
134
|
+
stack.unshift(...Array.from(children));
|
|
135
|
+
}
|
|
136
|
+
if (shiftItem !== element) {
|
|
137
|
+
shiftItem == null ? void 0 : shiftItem.classList.remove(menuItemSelect$1);
|
|
138
|
+
shiftItem == null ? void 0 : shiftItem.classList.remove(menuActiveParent);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function clearSelect_notHorizontal(ele, event) {
|
|
143
|
+
const stack = [];
|
|
144
|
+
const path = event.path || event.composedPath && event.composedPath();
|
|
145
|
+
for (let i = 0; i < path.length; i++) {
|
|
146
|
+
const e = path[i];
|
|
147
|
+
if (!e.classList.contains(menuClass)) {
|
|
148
|
+
stack.push(...Array.from(e.children));
|
|
149
|
+
} else {
|
|
150
|
+
stack.push(...Array.from(e.children));
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
while (stack.length) {
|
|
155
|
+
const shiftItem = stack.shift();
|
|
156
|
+
if ((shiftItem == null ? void 0 : shiftItem.tagName) === "UL" || (shiftItem == null ? void 0 : shiftItem.classList.contains(menuItemHorizontalWrapper))) {
|
|
157
|
+
stack.push(...Array.from(shiftItem == null ? void 0 : shiftItem.children));
|
|
158
|
+
}
|
|
159
|
+
if (shiftItem !== ele) {
|
|
160
|
+
if ((shiftItem == null ? void 0 : shiftItem.tagName) === "DIV") {
|
|
161
|
+
stack.unshift(...Array.from(shiftItem == null ? void 0 : shiftItem.children));
|
|
162
|
+
}
|
|
163
|
+
shiftItem == null ? void 0 : shiftItem.classList.remove(menuItemSelect$1);
|
|
164
|
+
shiftItem == null ? void 0 : shiftItem.classList.remove(menuActiveParent);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function clearSelect(ele, event, isHorizontal = false) {
|
|
169
|
+
if (isHorizontal) {
|
|
170
|
+
clearSelect_isHorizontal(ele, event);
|
|
171
|
+
} else {
|
|
172
|
+
clearSelect_notHorizontal(ele, event);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function getLayer(el) {
|
|
176
|
+
var _a;
|
|
177
|
+
const getLayerReg = /layer_(\d{1,})/gim;
|
|
178
|
+
const className = el.className;
|
|
179
|
+
return (_a = getLayerReg.exec(className)) == null ? void 0 : _a[1];
|
|
180
|
+
}
|
|
181
|
+
const menuItemProps = {
|
|
182
|
+
disabled: {
|
|
183
|
+
type: Boolean,
|
|
184
|
+
default: false
|
|
185
|
+
},
|
|
186
|
+
href: {
|
|
187
|
+
type: String,
|
|
188
|
+
default: ""
|
|
189
|
+
},
|
|
190
|
+
route: {
|
|
191
|
+
type: [String, Object]
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const ns$4 = useNamespace("menu");
|
|
195
|
+
function initSelect(defaultSelectKeys, keys, isMultiple, disabled) {
|
|
196
|
+
const isSelect = ref(false);
|
|
197
|
+
if (!isMultiple) {
|
|
198
|
+
if (defaultSelectKeys[0] === keys && !disabled.value) {
|
|
199
|
+
isSelect.value = true;
|
|
200
|
+
} else {
|
|
201
|
+
isSelect.value = false;
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
if (defaultSelectKeys.includes(keys)) {
|
|
205
|
+
isSelect.value = true;
|
|
206
|
+
} else {
|
|
207
|
+
isSelect.value = false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return isSelect.value;
|
|
211
|
+
}
|
|
212
|
+
function addActiveParent(ele) {
|
|
213
|
+
var _a, _b;
|
|
214
|
+
let cur = ele.parentElement;
|
|
215
|
+
while (!cur.classList.contains(ns$4.b())) {
|
|
216
|
+
if (((_a = cur.firstElementChild) == null ? void 0 : _a.tagName) === "DIV") {
|
|
217
|
+
(_b = cur == null ? void 0 : cur.firstElementChild) == null ? void 0 : _b.classList.add(`${ns$4.b()}-active-parent`);
|
|
218
|
+
}
|
|
219
|
+
cur = cur.parentElement;
|
|
220
|
+
}
|
|
221
|
+
return cur;
|
|
222
|
+
}
|
|
223
|
+
function changeRoute(props, router, useRouter, key) {
|
|
224
|
+
if (useRouter && router) {
|
|
225
|
+
const route = props.route || key;
|
|
226
|
+
const routerResult = router.push(route).then((res) => {
|
|
227
|
+
return res;
|
|
228
|
+
});
|
|
229
|
+
return { route, routerResult };
|
|
230
|
+
}
|
|
231
|
+
return void 0;
|
|
232
|
+
}
|
|
233
|
+
const ns$3 = useNamespace("menu");
|
|
234
|
+
function useClick(e) {
|
|
235
|
+
const paths = e.path;
|
|
236
|
+
for (let i = 0; i < paths.length; i++) {
|
|
237
|
+
const path = paths[i];
|
|
238
|
+
if (path.classList.contains(`${ns$3.b()}-horizontal`)) {
|
|
239
|
+
break;
|
|
240
|
+
} else if (path.classList.contains(`${ns$3.b()}-item-horizontal-wrapper`)) {
|
|
241
|
+
continue;
|
|
242
|
+
} else {
|
|
243
|
+
if (path.tagName !== "SPAN") {
|
|
244
|
+
path.classList.add(`${ns$3.b()}-item-select`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const ns$2 = useNamespace("menu");
|
|
250
|
+
const menuItemSelect = `${ns$2.b()}-item-select`;
|
|
251
|
+
const menuItemDisabled = `${ns$2.b()}-item-disabled`;
|
|
252
|
+
var MenuItem = defineComponent({
|
|
253
|
+
name: "DMenuItem",
|
|
254
|
+
props: menuItemProps,
|
|
255
|
+
setup(props, ctx) {
|
|
256
|
+
var _a, _b;
|
|
257
|
+
const instance = getCurrentInstance();
|
|
258
|
+
const key = String(instance == null ? void 0 : instance.vnode.key);
|
|
259
|
+
const menuStore = inject("menuStore");
|
|
260
|
+
const mode = inject("mode");
|
|
261
|
+
const multiple = inject("multiple");
|
|
262
|
+
const indent = inject("defaultIndent");
|
|
263
|
+
const isCollapsed = inject("isCollapsed");
|
|
264
|
+
const defaultSelectKey = inject("defaultSelectKey");
|
|
265
|
+
const {
|
|
266
|
+
disabled
|
|
267
|
+
} = toRefs(props);
|
|
268
|
+
const isSelect = ref(initSelect(defaultSelectKey, key, multiple, disabled));
|
|
269
|
+
const isLayer1 = ref(true);
|
|
270
|
+
const rootMenuEmit = inject("rootMenuEmit");
|
|
271
|
+
const useRouter = inject("useRouter");
|
|
272
|
+
const router = instance == null ? void 0 : instance.appContext.config.globalProperties.$router;
|
|
273
|
+
const classObject = computed(() => ({
|
|
274
|
+
[`${ns$2.b()}-item`]: true,
|
|
275
|
+
[`${ns$2.b()}-item-isCollapsed`]: isCollapsed.value,
|
|
276
|
+
[menuItemSelect]: isSelect.value,
|
|
277
|
+
[menuItemDisabled]: disabled.value
|
|
278
|
+
}));
|
|
279
|
+
menuStore.on("menuItem:clear:select", () => {
|
|
280
|
+
isSelect.value = false;
|
|
281
|
+
});
|
|
282
|
+
const onClick = (e) => {
|
|
283
|
+
var _a2;
|
|
284
|
+
e.stopPropagation();
|
|
285
|
+
const ele = e.currentTarget;
|
|
286
|
+
let changeRouteResult = void 0;
|
|
287
|
+
if (!props.disabled) {
|
|
288
|
+
if (!multiple) {
|
|
289
|
+
menuStore.emit("menuItem:clear:select");
|
|
290
|
+
clearSelect(ele, e, mode.value === "horizontal");
|
|
291
|
+
if (mode.value === "horizontal") {
|
|
292
|
+
useClick(e);
|
|
293
|
+
}
|
|
294
|
+
isSelect.value = true;
|
|
295
|
+
changeRouteResult = changeRoute(props, router, useRouter, key);
|
|
296
|
+
} else {
|
|
297
|
+
if (ele.classList.contains(menuItemSelect)) {
|
|
298
|
+
rootMenuEmit("deselect", {
|
|
299
|
+
type: "deselect",
|
|
300
|
+
key,
|
|
301
|
+
el: ele,
|
|
302
|
+
e
|
|
303
|
+
});
|
|
304
|
+
isSelect.value = false;
|
|
305
|
+
return;
|
|
306
|
+
} else {
|
|
307
|
+
isSelect.value = true;
|
|
308
|
+
ele.classList.add(menuItemSelect);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (changeRouteResult === void 0) {
|
|
312
|
+
rootMenuEmit("select", {
|
|
313
|
+
type: "select",
|
|
314
|
+
key,
|
|
315
|
+
el: ele,
|
|
316
|
+
e
|
|
317
|
+
});
|
|
318
|
+
} else {
|
|
319
|
+
rootMenuEmit("select", {
|
|
320
|
+
type: "select",
|
|
321
|
+
key,
|
|
322
|
+
el: ele,
|
|
323
|
+
e,
|
|
324
|
+
route: changeRouteResult
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (mode.value === "vertical") {
|
|
329
|
+
const target = e.currentTarget;
|
|
330
|
+
addActiveParent(target);
|
|
331
|
+
}
|
|
332
|
+
if (mode.value === "horizontal") {
|
|
333
|
+
const ul = (_a2 = ele.parentElement) == null ? void 0 : _a2.parentElement;
|
|
334
|
+
ul == null ? void 0 : ul.classList.add(`${ns$2.b()}-active-parent`);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const icons = createVNode("span", {
|
|
338
|
+
"class": `${ns$2.b()}-icon`
|
|
339
|
+
}, [(_b = (_a = ctx.slots).icon) == null ? void 0 : _b.call(_a)]);
|
|
340
|
+
const menuItems = ref(null);
|
|
341
|
+
watch(disabled, () => {
|
|
342
|
+
classObject.value[menuItemSelect] = false;
|
|
343
|
+
});
|
|
344
|
+
watch(() => defaultSelectKey, (n) => {
|
|
345
|
+
isSelect.value = initSelect(n, key, multiple, disabled);
|
|
346
|
+
classObject.value[menuItemSelect] = isSelect.value;
|
|
347
|
+
});
|
|
348
|
+
onMounted(() => {
|
|
349
|
+
var _a2, _b2;
|
|
350
|
+
let oldPadding = "";
|
|
351
|
+
const ele = menuItems.value;
|
|
352
|
+
if (mode.value === "vertical") {
|
|
353
|
+
if ((_b2 = (_a2 = ele.parentElement) == null ? void 0 : _a2.parentElement) == null ? void 0 : _b2.classList.contains(ns$2.b())) {
|
|
354
|
+
isLayer1.value = true;
|
|
355
|
+
if (isLayer1.value) {
|
|
356
|
+
ele.style.paddingRight = ``;
|
|
357
|
+
ele.style.paddingLeft = `${indent}px`;
|
|
358
|
+
}
|
|
359
|
+
watch(isCollapsed, (val) => {
|
|
360
|
+
if (val) {
|
|
361
|
+
if (ele.style.padding !== "0") {
|
|
362
|
+
oldPadding = ele.style.padding;
|
|
363
|
+
}
|
|
364
|
+
setTimeout(() => {
|
|
365
|
+
ele.style.padding = "0";
|
|
366
|
+
ele.style.width = "";
|
|
367
|
+
ele.style.textAlign = `center`;
|
|
368
|
+
}, 300);
|
|
369
|
+
ele.style.display = `block`;
|
|
370
|
+
} else {
|
|
371
|
+
ele.style.padding = `${oldPadding}`;
|
|
372
|
+
ele.style.textAlign = ``;
|
|
373
|
+
ele.style.display = `flex`;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
} else {
|
|
377
|
+
isLayer1.value = false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
return () => {
|
|
382
|
+
return mode.value === "vertical" ? createVNode("div", {
|
|
383
|
+
"class": `${ns$2.b()}-item-vertical-wrapper`
|
|
384
|
+
}, [createVNode("li", {
|
|
385
|
+
"class": classObject.value,
|
|
386
|
+
"onClick": onClick,
|
|
387
|
+
"ref": menuItems
|
|
388
|
+
}, [ctx.slots.icon !== void 0 && icons, props.href === "" ? createVNode(Transition, {
|
|
389
|
+
"name": "fade"
|
|
390
|
+
}, {
|
|
391
|
+
default: () => {
|
|
392
|
+
var _a2, _b2;
|
|
393
|
+
return [withDirectives(createVNode("span", null, [(_b2 = (_a2 = ctx.slots).default) == null ? void 0 : _b2.call(_a2)]), [[vShow, !isCollapsed.value]])];
|
|
394
|
+
}
|
|
395
|
+
}) : createVNode("a", {
|
|
396
|
+
"href": props.href
|
|
397
|
+
}, [createVNode(Transition, {
|
|
398
|
+
"name": "fade"
|
|
399
|
+
}, {
|
|
400
|
+
default: () => {
|
|
401
|
+
var _a2, _b2;
|
|
402
|
+
return [(_b2 = (_a2 = ctx.slots).default) == null ? void 0 : _b2.call(_a2)];
|
|
403
|
+
}
|
|
404
|
+
})])])]) : createVNode("li", {
|
|
405
|
+
"class": classObject.value,
|
|
406
|
+
"onClick": onClick,
|
|
407
|
+
"ref": menuItems
|
|
408
|
+
}, [ctx.slots.icon !== void 0 && icons, props.href === "" ? createVNode(Transition, {
|
|
409
|
+
"name": "fade"
|
|
410
|
+
}, {
|
|
411
|
+
default: () => {
|
|
412
|
+
var _a2, _b2;
|
|
413
|
+
return [withDirectives(createVNode("span", null, [(_b2 = (_a2 = ctx.slots).default) == null ? void 0 : _b2.call(_a2)]), [[vShow, !isCollapsed.value]])];
|
|
414
|
+
}
|
|
415
|
+
}) : createVNode("a", {
|
|
416
|
+
"href": props.href
|
|
417
|
+
}, [createVNode(Transition, {
|
|
418
|
+
"name": "fade"
|
|
419
|
+
}, {
|
|
420
|
+
default: () => {
|
|
421
|
+
var _a2, _b2;
|
|
422
|
+
return [(_b2 = (_a2 = ctx.slots).default) == null ? void 0 : _b2.call(_a2)];
|
|
423
|
+
}
|
|
424
|
+
})])]);
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
const ns$1 = useNamespace("menu");
|
|
429
|
+
const subNs$1 = useNamespace("submenu");
|
|
430
|
+
const menuItemHorizontalWrapperHidden = `${ns$1.b()}-item-horizontal-wrapper-hidden`;
|
|
431
|
+
const menuItemHorizontalWrapperShow = `${ns$1.b()}-item-horizontal-wrapper-show`;
|
|
432
|
+
function useShowSubMenu(eventName, e, wrapper) {
|
|
433
|
+
const target = e.currentTarget;
|
|
434
|
+
const targetParent = target.parentElement;
|
|
435
|
+
const wrapperChildren = wrapper.children;
|
|
436
|
+
wrapper.style.padding = `0 20px !important`;
|
|
437
|
+
if (eventName === "mouseenter") {
|
|
438
|
+
if ((targetParent == null ? void 0 : targetParent.tagName) === "DIV") {
|
|
439
|
+
wrapper.classList.add(`${ns$1.b()}-item-horizontal-wrapper-level`);
|
|
440
|
+
const { width } = target.getClientRects()[0];
|
|
441
|
+
wrapper.style.top = `0px`;
|
|
442
|
+
wrapper.style.left = `${width}px`;
|
|
443
|
+
} else {
|
|
444
|
+
wrapper.style.top = `26px`;
|
|
445
|
+
wrapper.style.left = `0px`;
|
|
446
|
+
}
|
|
447
|
+
wrapper.classList.remove(menuItemHorizontalWrapperHidden);
|
|
448
|
+
wrapper.classList.add(menuItemHorizontalWrapperShow);
|
|
449
|
+
for (let i = 0; i < wrapperChildren.length; i++) {
|
|
450
|
+
const ul = wrapperChildren[i];
|
|
451
|
+
if (ul.tagName === "UL" && ul.classList.contains(subNs$1.b())) {
|
|
452
|
+
const levelUlWrapper = ul.getElementsByClassName(`${ns$1.b()}-item-horizontal-wrapper`)[0];
|
|
453
|
+
ul.addEventListener("mouseenter", (ev) => {
|
|
454
|
+
ev.stopPropagation();
|
|
455
|
+
useShowSubMenu("mouseenter", ev, levelUlWrapper);
|
|
456
|
+
levelUlWrapper.classList.remove(menuItemHorizontalWrapperHidden);
|
|
457
|
+
levelUlWrapper.classList.add(menuItemHorizontalWrapperShow);
|
|
458
|
+
});
|
|
459
|
+
ul.addEventListener("mouseleave", (ev) => {
|
|
460
|
+
ev.stopPropagation();
|
|
461
|
+
useShowSubMenu("mouseleave", ev, levelUlWrapper);
|
|
462
|
+
levelUlWrapper.classList.remove(menuItemHorizontalWrapperShow);
|
|
463
|
+
levelUlWrapper.classList.add(menuItemHorizontalWrapperHidden);
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if (eventName === "mouseleave") {
|
|
469
|
+
wrapper.classList.remove(menuItemHorizontalWrapperShow);
|
|
470
|
+
wrapper.classList.add(menuItemHorizontalWrapperHidden);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
const subMenuProps = {
|
|
474
|
+
title: {
|
|
475
|
+
type: String,
|
|
476
|
+
default: ""
|
|
477
|
+
},
|
|
478
|
+
disabled: {
|
|
479
|
+
type: Boolean,
|
|
480
|
+
default: false
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
const elTransition = "0.3s height ease-in-out, 0.3s padding-top ease-in-out, 0.3s padding-bottom ease-in-out";
|
|
484
|
+
const TransitionObj = {
|
|
485
|
+
"before-enter"(el) {
|
|
486
|
+
el.style.transition = elTransition;
|
|
487
|
+
el.setAttribute("data-oldPadding", el.style.padding);
|
|
488
|
+
el.setAttribute("data-oldMargin", el.style.margin);
|
|
489
|
+
el.style.height = "0";
|
|
490
|
+
el.style.padding = "0";
|
|
491
|
+
el.style.margin = "0";
|
|
492
|
+
},
|
|
493
|
+
enter(el) {
|
|
494
|
+
el.dataset.oldOverflow = el.style.overflow;
|
|
495
|
+
if (el.scrollHeight !== 0) {
|
|
496
|
+
el.style.height = el.scrollHeight + "px";
|
|
497
|
+
} else {
|
|
498
|
+
el.style.height = "";
|
|
499
|
+
}
|
|
500
|
+
el.style.padding = el.getAttribute("data-oldPadding");
|
|
501
|
+
el.style.margin = el.getAttribute("data-oldMargin");
|
|
502
|
+
el.style.overflow = "hidden";
|
|
503
|
+
},
|
|
504
|
+
"after-enter"(el) {
|
|
505
|
+
el.style.transition = "";
|
|
506
|
+
el.style.transition = "";
|
|
507
|
+
el.style.height = "";
|
|
508
|
+
el.style.overflow = el.getAttribute("data-overflow");
|
|
509
|
+
},
|
|
510
|
+
"before-leave"(el) {
|
|
511
|
+
if (!el.dataset) {
|
|
512
|
+
el.dataset = {};
|
|
513
|
+
}
|
|
514
|
+
el.dataset.oldPaddingTop = el.style.paddingTop;
|
|
515
|
+
el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
|
516
|
+
el.dataset.oldOverflow = el.style.overflow;
|
|
517
|
+
el.style.height = el.scrollHeight + "px";
|
|
518
|
+
el.style.overflow = "hidden";
|
|
519
|
+
},
|
|
520
|
+
leave(el) {
|
|
521
|
+
if (el.scrollHeight !== 0) {
|
|
522
|
+
el.style.transition = elTransition;
|
|
523
|
+
el.style.height = "0";
|
|
524
|
+
el.style.paddingTop = "0";
|
|
525
|
+
el.style.paddingBottom = "0";
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
"after-leave"(el) {
|
|
529
|
+
el.style.transition = "";
|
|
530
|
+
el.style.height = "";
|
|
531
|
+
el.style.overflow = el.dataset.oldOverflow;
|
|
532
|
+
el.style.paddingTop = el.dataset.oldPaddingTop;
|
|
533
|
+
el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
var MenuTransition = defineComponent({
|
|
537
|
+
name: "DMenuTransition",
|
|
538
|
+
setup(prop, ctx) {
|
|
539
|
+
return () => {
|
|
540
|
+
return createVNode(Transition, {
|
|
541
|
+
"onBeforeEnter": (e) => TransitionObj["before-enter"](e),
|
|
542
|
+
"onBeforeLeave": (e) => TransitionObj["before-leave"](e),
|
|
543
|
+
"onEnter": (e) => TransitionObj["enter"](e),
|
|
544
|
+
"onAfterEnter": (e) => TransitionObj["after-enter"](e),
|
|
545
|
+
"onLeave": (e) => TransitionObj["leave"](e),
|
|
546
|
+
"onAfterLeave": (e) => TransitionObj["after-leave"](e)
|
|
547
|
+
}, {
|
|
548
|
+
default: () => {
|
|
549
|
+
var _a, _b;
|
|
550
|
+
return [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)];
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
const ns = useNamespace("menu");
|
|
557
|
+
const subNs = useNamespace("submenu");
|
|
558
|
+
const subMenuClass = subNs.b();
|
|
559
|
+
var SubMenu = defineComponent({
|
|
560
|
+
name: "DSubMenu",
|
|
561
|
+
props: subMenuProps,
|
|
562
|
+
setup(props, ctx) {
|
|
563
|
+
const isShow = ref(true);
|
|
564
|
+
const {
|
|
565
|
+
vnode: {
|
|
566
|
+
key
|
|
567
|
+
}
|
|
568
|
+
} = getCurrentInstance();
|
|
569
|
+
const key_ = String(key);
|
|
570
|
+
const isOpen = ref(false);
|
|
571
|
+
const defaultOpenKeys = inject("openKeys");
|
|
572
|
+
const indent = inject("defaultIndent");
|
|
573
|
+
const isCollapsed = inject("isCollapsed");
|
|
574
|
+
const mode = inject("mode");
|
|
575
|
+
const subMenuItemContainer = ref(null);
|
|
576
|
+
const parentEmit = inject("rootMenuEmit");
|
|
577
|
+
const isHorizontal = mode.value === "horizontal";
|
|
578
|
+
if (key_ === "null") {
|
|
579
|
+
console.warn(`[devui][menu]: Key can not be null`);
|
|
580
|
+
} else {
|
|
581
|
+
if (defaultOpenKeys.value.includes(key_)) {
|
|
582
|
+
isOpen.value = true;
|
|
583
|
+
} else {
|
|
584
|
+
isOpen.value = false;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
const clickHandle = (e) => {
|
|
588
|
+
e.preventDefault();
|
|
589
|
+
e.stopPropagation();
|
|
590
|
+
const ele = e.currentTarget;
|
|
591
|
+
if (ele.classList.contains(subMenuClass) && isHorizontal) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
if (isHorizontal) {
|
|
595
|
+
clearSelect(ele, e, true);
|
|
596
|
+
useClick(e);
|
|
597
|
+
}
|
|
598
|
+
if (!props.disabled && mode.value !== "horizontal") {
|
|
599
|
+
const target = e.target;
|
|
600
|
+
let cur = e.target;
|
|
601
|
+
if (target.tagName === "UL") {
|
|
602
|
+
if (target.classList.contains(`${subMenuClass}-open`)) {
|
|
603
|
+
isOpen.value = !isOpen.value;
|
|
604
|
+
} else {
|
|
605
|
+
isOpen.value = isOpen.value;
|
|
606
|
+
}
|
|
607
|
+
} else {
|
|
608
|
+
while (cur && cur.tagName !== "UL") {
|
|
609
|
+
if (cur.tagName === "LI") {
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
cur = cur.parentElement;
|
|
613
|
+
}
|
|
614
|
+
if (cur.tagName === "UL") {
|
|
615
|
+
isOpen.value = !isOpen.value;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
parentEmit("submenu-change", {
|
|
619
|
+
type: "submenu-change",
|
|
620
|
+
state: isOpen.value,
|
|
621
|
+
key: key_,
|
|
622
|
+
el: cur
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
const wrapper = ref(null);
|
|
627
|
+
let wrapperDom;
|
|
628
|
+
const subMenu = ref(null);
|
|
629
|
+
const title = ref(null);
|
|
630
|
+
let oldPadding = "";
|
|
631
|
+
const class_layer = ref("");
|
|
632
|
+
watchEffect(() => {
|
|
633
|
+
wrapperDom = wrapper.value;
|
|
634
|
+
pushElement({
|
|
635
|
+
el: subMenu.value
|
|
636
|
+
});
|
|
637
|
+
}, {
|
|
638
|
+
flush: "post"
|
|
639
|
+
});
|
|
640
|
+
watch(() => defaultOpenKeys, (n) => {
|
|
641
|
+
if (n.value.includes(key_)) {
|
|
642
|
+
isOpen.value = true;
|
|
643
|
+
} else {
|
|
644
|
+
isOpen.value = false;
|
|
645
|
+
}
|
|
646
|
+
}, {
|
|
647
|
+
deep: true
|
|
648
|
+
});
|
|
649
|
+
onMounted(() => {
|
|
650
|
+
var _a;
|
|
651
|
+
const el = title.value;
|
|
652
|
+
const e = subMenu.value;
|
|
653
|
+
addLayer();
|
|
654
|
+
class_layer.value = `layer_${(_a = Array.from(e.classList).at(-1)) == null ? void 0 : _a.replace("layer_", "")}`;
|
|
655
|
+
if (isHorizontal) {
|
|
656
|
+
subMenu.value.addEventListener("mouseenter", (ev) => {
|
|
657
|
+
ev.stopPropagation();
|
|
658
|
+
useShowSubMenu("mouseenter", ev, wrapperDom);
|
|
659
|
+
});
|
|
660
|
+
subMenu.value.addEventListener("mouseleave", (ev) => {
|
|
661
|
+
ev.stopPropagation();
|
|
662
|
+
useShowSubMenu("mouseleave", ev, wrapperDom);
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
watch(isCollapsed, (newValue) => {
|
|
666
|
+
const layer = Number(getLayer(e));
|
|
667
|
+
if (!Number.isNaN(layer)) {
|
|
668
|
+
layer > 2 && (isShow.value = !isCollapsed.value);
|
|
669
|
+
}
|
|
670
|
+
if (newValue) {
|
|
671
|
+
el.style.padding !== "0" && (oldPadding = el.style.padding);
|
|
672
|
+
setTimeout(() => {
|
|
673
|
+
el.style.padding = "0";
|
|
674
|
+
el.style.width = "";
|
|
675
|
+
el.style.textAlign = `center`;
|
|
676
|
+
}, 300);
|
|
677
|
+
el.style.display = `block`;
|
|
678
|
+
} else {
|
|
679
|
+
el.style.padding = `${oldPadding}`;
|
|
680
|
+
el.style.textAlign = ``;
|
|
681
|
+
el.style.display = `flex`;
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
});
|
|
685
|
+
return () => {
|
|
686
|
+
var _a, _b, _c, _d;
|
|
687
|
+
return withDirectives(createVNode("ul", {
|
|
688
|
+
"onClick": clickHandle,
|
|
689
|
+
"class": [subMenuClass, class_layer.value],
|
|
690
|
+
"ref": subMenu
|
|
691
|
+
}, [createVNode("div", {
|
|
692
|
+
"class": [`${subMenuClass}-title`, props["disabled"] && `${subMenuClass}-disabled`],
|
|
693
|
+
"style": `padding: 0 ${indent}px`,
|
|
694
|
+
"ref": title
|
|
695
|
+
}, [createVNode("span", {
|
|
696
|
+
"class": `${ns.b()}-icon`
|
|
697
|
+
}, [(_b = (_a = ctx.slots) == null ? void 0 : _a.icon) == null ? void 0 : _b.call(_a)]), withDirectives(createVNode("span", {
|
|
698
|
+
"class": `${subMenuClass}-title-content`
|
|
699
|
+
}, [props.title]), [[vShow, !isCollapsed.value]]), withDirectives(createVNode("i", {
|
|
700
|
+
"class": {
|
|
701
|
+
"icon icon-chevron-up": class_layer.value !== `layer_${subMenuClass}`,
|
|
702
|
+
"icon icon-chevron-right": class_layer.value === `layer_${subMenuClass}`,
|
|
703
|
+
"is-opened": isOpen.value
|
|
704
|
+
}
|
|
705
|
+
}, null), [[vShow, !isCollapsed.value && key !== "overflowContainer"]])]), isHorizontal ? createVNode("div", {
|
|
706
|
+
"class": `${ns.b()}-item-horizontal-wrapper ${ns.b()}-item-horizontal-wrapper-hidden`,
|
|
707
|
+
"ref": wrapper
|
|
708
|
+
}, [(_d = (_c = ctx.slots).default) == null ? void 0 : _d.call(_c)]) : createVNode(MenuTransition, null, {
|
|
709
|
+
default: () => {
|
|
710
|
+
var _a2, _b2;
|
|
711
|
+
return [withDirectives(createVNode("div", {
|
|
712
|
+
"class": [`${subMenuClass}-menu-item-vertical-wrapper`],
|
|
713
|
+
"ref": subMenuItemContainer
|
|
714
|
+
}, [(_b2 = (_a2 = ctx.slots).default) == null ? void 0 : _b2.call(_a2)]), [[vShow, isOpen.value]])];
|
|
715
|
+
}
|
|
716
|
+
})]), [[vShow, isShow.value]]);
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
const menuProps = {
|
|
721
|
+
width: {
|
|
722
|
+
type: String,
|
|
723
|
+
default: ""
|
|
724
|
+
},
|
|
725
|
+
collapsed: {
|
|
726
|
+
type: Boolean,
|
|
727
|
+
default: false
|
|
728
|
+
},
|
|
729
|
+
collapsedIndent: {
|
|
730
|
+
type: Number,
|
|
731
|
+
default: 24
|
|
732
|
+
},
|
|
733
|
+
indentSize: {
|
|
734
|
+
type: Number,
|
|
735
|
+
default: 24
|
|
736
|
+
},
|
|
737
|
+
multiple: {
|
|
738
|
+
type: Boolean,
|
|
739
|
+
default: false
|
|
740
|
+
},
|
|
741
|
+
openKeys: {
|
|
742
|
+
type: Array,
|
|
743
|
+
default: []
|
|
744
|
+
},
|
|
745
|
+
defaultSelectKeys: {
|
|
746
|
+
type: Array,
|
|
747
|
+
default: []
|
|
748
|
+
},
|
|
749
|
+
mode: {
|
|
750
|
+
type: String,
|
|
751
|
+
default: "vertical"
|
|
752
|
+
},
|
|
753
|
+
router: {
|
|
754
|
+
type: Boolean,
|
|
755
|
+
default: false
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
var menu = "";
|
|
759
|
+
function randomId(n = 8) {
|
|
760
|
+
const str = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
761
|
+
let result = "";
|
|
762
|
+
for (let i = 0; i < n; i++) {
|
|
763
|
+
result += str[parseInt((Math.random() * str.length).toString())];
|
|
764
|
+
}
|
|
765
|
+
return result;
|
|
766
|
+
}
|
|
767
|
+
const recordTable = {};
|
|
768
|
+
class Store {
|
|
769
|
+
constructor(rootName) {
|
|
770
|
+
__publicField(this, "rootMenuName");
|
|
771
|
+
this.rootMenuName = rootName;
|
|
772
|
+
}
|
|
773
|
+
on(eventName, fn) {
|
|
774
|
+
var _a;
|
|
775
|
+
if (!((_a = recordTable == null ? void 0 : recordTable[this.rootMenuName]) == null ? void 0 : _a[eventName])) {
|
|
776
|
+
Reflect.set(recordTable[this.rootMenuName], eventName, []);
|
|
777
|
+
}
|
|
778
|
+
recordTable[this.rootMenuName][eventName].push(fn);
|
|
779
|
+
}
|
|
780
|
+
emit(eventName, ...args) {
|
|
781
|
+
recordTable[this.rootMenuName][eventName].forEach((fn) => fn(...args));
|
|
782
|
+
}
|
|
783
|
+
off(eventName, fn) {
|
|
784
|
+
const idx = recordTable[this.rootMenuName][eventName].indexOf(fn);
|
|
785
|
+
if (idx >= 0) {
|
|
786
|
+
recordTable[this.rootMenuName][eventName].splice(idx, 1);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function useStore(rootName) {
|
|
791
|
+
if (!recordTable[rootName]) {
|
|
792
|
+
Reflect.set(recordTable, rootName, {});
|
|
793
|
+
}
|
|
794
|
+
return new Store(rootName);
|
|
795
|
+
}
|
|
796
|
+
var Menu = defineComponent({
|
|
797
|
+
name: "DMenu",
|
|
798
|
+
props: menuProps,
|
|
799
|
+
emits: ["select", "deselect", "submenu-change"],
|
|
800
|
+
setup(props, ctx) {
|
|
801
|
+
const ns2 = useNamespace("menu");
|
|
802
|
+
const {
|
|
803
|
+
openKeys,
|
|
804
|
+
mode,
|
|
805
|
+
collapsed
|
|
806
|
+
} = toRefs(props);
|
|
807
|
+
const menuId = randomId(16);
|
|
808
|
+
const store = useStore(menuId);
|
|
809
|
+
provide("menuStore", store);
|
|
810
|
+
provide("isCollapsed", collapsed);
|
|
811
|
+
provide("defaultIndent", props["indentSize"]);
|
|
812
|
+
provide("multiple", props["multiple"]);
|
|
813
|
+
provide("openKeys", openKeys);
|
|
814
|
+
provide("defaultSelectKey", props.defaultSelectKeys);
|
|
815
|
+
provide("mode", mode);
|
|
816
|
+
provide("collapsedIndent", props["collapsedIndent"]);
|
|
817
|
+
provide("rootMenuEmit", ctx.emit);
|
|
818
|
+
provide("useRouter", props.router);
|
|
819
|
+
setDefaultIndent(props["indentSize"]);
|
|
820
|
+
const menuRoot = ref(null);
|
|
821
|
+
const overflow_container = ref(null);
|
|
822
|
+
const overflowItemLength = ref(0);
|
|
823
|
+
const rootClassName = computed(() => ({
|
|
824
|
+
[`${ns2.b()}`]: true,
|
|
825
|
+
[`${ns2.b()}-vertical`]: mode.value === "vertical",
|
|
826
|
+
[`${ns2.b()}-horizontal`]: mode.value === "horizontal",
|
|
827
|
+
[`${ns2.b()}-collapsed`]: collapsed.value
|
|
828
|
+
}));
|
|
829
|
+
onMounted(() => {
|
|
830
|
+
var _a;
|
|
831
|
+
if (props["mode"] === "horizontal") {
|
|
832
|
+
let flag = false;
|
|
833
|
+
const overflowContainer = (_a = overflow_container.value) == null ? void 0 : _a.$el;
|
|
834
|
+
const root = menuRoot.value;
|
|
835
|
+
const children = root.children;
|
|
836
|
+
const container = overflowContainer.children[1];
|
|
837
|
+
const ob = new IntersectionObserver((entries) => {
|
|
838
|
+
entries.forEach((v) => {
|
|
839
|
+
if (!v.isIntersecting) {
|
|
840
|
+
const cloneNode = v.target.cloneNode(true);
|
|
841
|
+
if (v.target.classList.contains(`${ns2.b()}-overflow-container`)) {
|
|
842
|
+
if (flag && v.target.previousElementSibling && container.children.length) {
|
|
843
|
+
root.appendChild(v.target.previousElementSibling);
|
|
844
|
+
} else {
|
|
845
|
+
flag = true;
|
|
846
|
+
}
|
|
847
|
+
} else {
|
|
848
|
+
overflowItemLength.value += 1;
|
|
849
|
+
v.target.style.visibility = "hidden";
|
|
850
|
+
if (overflowContainer.nextSibling) {
|
|
851
|
+
root.insertBefore(v.target, overflowContainer.nextSibling);
|
|
852
|
+
} else {
|
|
853
|
+
root.appendChild(v.target);
|
|
854
|
+
}
|
|
855
|
+
container.appendChild(cloneNode);
|
|
856
|
+
}
|
|
857
|
+
} else {
|
|
858
|
+
if (!v.target.classList.contains(`${ns2.b()}-overflow-container`) && v.target.style.visibility === "hidden") {
|
|
859
|
+
ob.unobserve(v.target);
|
|
860
|
+
const el = container.lastChild;
|
|
861
|
+
if (el) {
|
|
862
|
+
root.insertBefore(el, overflowContainer);
|
|
863
|
+
}
|
|
864
|
+
const obItem = overflowContainer.previousElementSibling;
|
|
865
|
+
if (obItem) {
|
|
866
|
+
ob.observe(obItem);
|
|
867
|
+
}
|
|
868
|
+
if (obItem == null ? void 0 : obItem.classList.contains("devui-submenu")) {
|
|
869
|
+
const sub = obItem;
|
|
870
|
+
const wrapper = obItem.children[1];
|
|
871
|
+
sub.addEventListener("mouseenter", (ev) => {
|
|
872
|
+
ev.stopPropagation();
|
|
873
|
+
useShowSubMenu("mouseenter", ev, wrapper);
|
|
874
|
+
});
|
|
875
|
+
sub.addEventListener("mouseleave", (ev) => {
|
|
876
|
+
ev.stopPropagation();
|
|
877
|
+
useShowSubMenu("mouseleave", ev, wrapper);
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
v.target.style.visibility = "";
|
|
881
|
+
v.target.remove();
|
|
882
|
+
overflowItemLength.value -= 1;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
}, {
|
|
887
|
+
root,
|
|
888
|
+
threshold: 1,
|
|
889
|
+
rootMargin: "8px"
|
|
890
|
+
});
|
|
891
|
+
for (let i = 0; i < children.length; i++) {
|
|
892
|
+
ob.observe(children[i]);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
return () => {
|
|
897
|
+
var _a, _b;
|
|
898
|
+
return createVNode("ul", {
|
|
899
|
+
"ref": menuRoot,
|
|
900
|
+
"class": rootClassName.value,
|
|
901
|
+
"style": [props["collapsed"] ? `width:${props["collapsedIndent"] * 2}px` : `width: ${props["width"]}`, "white-space: nowrap"]
|
|
902
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a), withDirectives(createVNode(SubMenu, {
|
|
903
|
+
"ref": overflow_container,
|
|
904
|
+
"key": "overflowContainer",
|
|
905
|
+
"title": "...",
|
|
906
|
+
"class": `${ns2.b()}-overflow-container`
|
|
907
|
+
}, null), [[vShow, overflowItemLength.value > 0 && mode.value === "horizontal"]])]);
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
var index = {
|
|
912
|
+
title: "Menu \u83DC\u5355",
|
|
913
|
+
category: "\u5BFC\u822A",
|
|
914
|
+
status: "100%",
|
|
915
|
+
install(app) {
|
|
916
|
+
app.component(Menu.name, Menu);
|
|
917
|
+
app.component(MenuItem.name, MenuItem);
|
|
918
|
+
app.component(SubMenu.name, SubMenu);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
export { Menu, MenuItem, SubMenu, index as default };
|