@v-c/menu 1.0.6 → 1.0.8
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/Menu.d.ts +1 -0
- package/dist/Menu.js +20 -8
- package/dist/SubMenu/index.d.ts +1 -2
- package/dist/SubMenu/index.js +25 -11
- package/dist/context/MenuContext.js +1 -1
- package/dist/interface.d.ts +4 -1
- package/dist/utils/commonUtil.js +2 -8
- package/dist/utils/nodeUtil.d.ts +1 -0
- package/dist/utils/nodeUtil.js +3 -0
- package/package.json +5 -5
- package/dist/Divider.cjs +0 -38
- package/dist/Icon.cjs +0 -45
- package/dist/Menu.cjs +0 -526
- package/dist/MenuItem.cjs +0 -338
- package/dist/MenuItemGroup.cjs +0 -124
- package/dist/SubMenu/InlineSubMenuList.cjs +0 -63
- package/dist/SubMenu/PopupTrigger.cjs +0 -145
- package/dist/SubMenu/SubMenuList.cjs +0 -23
- package/dist/SubMenu/index.cjs +0 -508
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/context/IdContext.cjs +0 -26
- package/dist/context/MenuContext.cjs +0 -196
- package/dist/context/PathContext.cjs +0 -76
- package/dist/context/PrivateContext.cjs +0 -19
- package/dist/hooks/useAccessibility.cjs +0 -193
- package/dist/hooks/useActive.cjs +0 -31
- package/dist/hooks/useDirectionStyle.cjs +0 -17
- package/dist/hooks/useKeyRecords.cjs +0 -78
- package/dist/hooks/useMemoCallback.cjs +0 -15
- package/dist/index.cjs +0 -24
- package/dist/interface.cjs +0 -1
- package/dist/placements.cjs +0 -80
- package/dist/utils/commonUtil.cjs +0 -28
- package/dist/utils/motionUtil.cjs +0 -6
- package/dist/utils/nodeUtil.cjs +0 -55
- package/dist/utils/timeUtil.cjs +0 -6
- package/dist/utils/warnUtil.cjs +0 -11
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
let _v_c_util_dist_omit = require("@v-c/util/dist/omit");
|
|
8
|
-
_v_c_util_dist_omit = require_rolldown_runtime.__toESM(_v_c_util_dist_omit);
|
|
9
|
-
var MenuContextKey = Symbol("MenuContextKey");
|
|
10
|
-
function mergeProps(origin, target) {
|
|
11
|
-
const clone = { ...origin };
|
|
12
|
-
Object.keys(target).forEach((key) => {
|
|
13
|
-
const value = target[key];
|
|
14
|
-
if (value !== void 0) target[key] = value;
|
|
15
|
-
});
|
|
16
|
-
return clone;
|
|
17
|
-
}
|
|
18
|
-
function useMenuContext() {
|
|
19
|
-
return (0, vue.inject)(MenuContextKey, null);
|
|
20
|
-
}
|
|
21
|
-
function useMenuContextProvider(context) {
|
|
22
|
-
(0, vue.provide)(MenuContextKey, context);
|
|
23
|
-
}
|
|
24
|
-
var InheritableContextProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
25
|
-
const context = useMenuContext();
|
|
26
|
-
useMenuContextProvider((0, vue.computed)(() => {
|
|
27
|
-
return mergeProps(context?.value ?? {}, (0, _v_c_util_dist_omit.default)(props, ["locked"]));
|
|
28
|
-
}));
|
|
29
|
-
return () => {
|
|
30
|
-
return slots?.default?.();
|
|
31
|
-
};
|
|
32
|
-
}, {
|
|
33
|
-
props: {
|
|
34
|
-
locked: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
required: false,
|
|
37
|
-
default: void 0
|
|
38
|
-
},
|
|
39
|
-
prefixCls: {
|
|
40
|
-
type: String,
|
|
41
|
-
required: false,
|
|
42
|
-
default: void 0
|
|
43
|
-
},
|
|
44
|
-
classes: {
|
|
45
|
-
type: Object,
|
|
46
|
-
required: false,
|
|
47
|
-
default: void 0
|
|
48
|
-
},
|
|
49
|
-
styles: {
|
|
50
|
-
type: Object,
|
|
51
|
-
required: false,
|
|
52
|
-
default: void 0
|
|
53
|
-
},
|
|
54
|
-
rootClass: {
|
|
55
|
-
type: String,
|
|
56
|
-
required: false,
|
|
57
|
-
default: void 0
|
|
58
|
-
},
|
|
59
|
-
openKeys: {
|
|
60
|
-
type: Array,
|
|
61
|
-
required: false,
|
|
62
|
-
default: void 0
|
|
63
|
-
},
|
|
64
|
-
rtl: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
required: false,
|
|
67
|
-
default: void 0
|
|
68
|
-
},
|
|
69
|
-
mode: {
|
|
70
|
-
type: String,
|
|
71
|
-
required: false,
|
|
72
|
-
default: void 0
|
|
73
|
-
},
|
|
74
|
-
disabled: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
required: false,
|
|
77
|
-
default: void 0
|
|
78
|
-
},
|
|
79
|
-
overflowDisabled: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
required: false,
|
|
82
|
-
default: void 0
|
|
83
|
-
},
|
|
84
|
-
activeKey: {
|
|
85
|
-
type: String,
|
|
86
|
-
required: false,
|
|
87
|
-
default: void 0
|
|
88
|
-
},
|
|
89
|
-
onActive: {
|
|
90
|
-
type: Function,
|
|
91
|
-
required: false,
|
|
92
|
-
default: void 0
|
|
93
|
-
},
|
|
94
|
-
onInactive: {
|
|
95
|
-
type: Function,
|
|
96
|
-
required: false,
|
|
97
|
-
default: void 0
|
|
98
|
-
},
|
|
99
|
-
selectedKeys: {
|
|
100
|
-
type: Array,
|
|
101
|
-
required: false,
|
|
102
|
-
default: void 0
|
|
103
|
-
},
|
|
104
|
-
inlineIndent: {
|
|
105
|
-
type: Number,
|
|
106
|
-
required: false,
|
|
107
|
-
default: void 0
|
|
108
|
-
},
|
|
109
|
-
motion: {
|
|
110
|
-
type: Object,
|
|
111
|
-
required: false,
|
|
112
|
-
default: void 0
|
|
113
|
-
},
|
|
114
|
-
defaultMotions: {
|
|
115
|
-
type: Object,
|
|
116
|
-
required: false,
|
|
117
|
-
default: void 0
|
|
118
|
-
},
|
|
119
|
-
subMenuOpenDelay: {
|
|
120
|
-
type: Number,
|
|
121
|
-
required: false,
|
|
122
|
-
default: void 0
|
|
123
|
-
},
|
|
124
|
-
subMenuCloseDelay: {
|
|
125
|
-
type: Number,
|
|
126
|
-
required: false,
|
|
127
|
-
default: void 0
|
|
128
|
-
},
|
|
129
|
-
forceSubMenuRender: {
|
|
130
|
-
type: Boolean,
|
|
131
|
-
required: false,
|
|
132
|
-
default: void 0
|
|
133
|
-
},
|
|
134
|
-
builtinPlacements: {
|
|
135
|
-
type: Object,
|
|
136
|
-
required: false,
|
|
137
|
-
default: void 0
|
|
138
|
-
},
|
|
139
|
-
triggerSubMenuAction: {
|
|
140
|
-
type: String,
|
|
141
|
-
required: false,
|
|
142
|
-
default: void 0
|
|
143
|
-
},
|
|
144
|
-
popupRender: {
|
|
145
|
-
type: Function,
|
|
146
|
-
required: false,
|
|
147
|
-
default: void 0
|
|
148
|
-
},
|
|
149
|
-
itemIcon: {
|
|
150
|
-
type: [
|
|
151
|
-
Object,
|
|
152
|
-
Function,
|
|
153
|
-
String,
|
|
154
|
-
Number,
|
|
155
|
-
null,
|
|
156
|
-
Boolean,
|
|
157
|
-
Array
|
|
158
|
-
],
|
|
159
|
-
required: false,
|
|
160
|
-
default: void 0
|
|
161
|
-
},
|
|
162
|
-
expandIcon: {
|
|
163
|
-
type: [
|
|
164
|
-
Object,
|
|
165
|
-
Function,
|
|
166
|
-
String,
|
|
167
|
-
Number,
|
|
168
|
-
null,
|
|
169
|
-
Boolean,
|
|
170
|
-
Array
|
|
171
|
-
],
|
|
172
|
-
required: false,
|
|
173
|
-
default: void 0
|
|
174
|
-
},
|
|
175
|
-
onItemClick: {
|
|
176
|
-
type: Function,
|
|
177
|
-
required: false,
|
|
178
|
-
default: void 0
|
|
179
|
-
},
|
|
180
|
-
onOpenChange: {
|
|
181
|
-
type: Function,
|
|
182
|
-
required: false,
|
|
183
|
-
default: void 0
|
|
184
|
-
},
|
|
185
|
-
getPopupContainer: {
|
|
186
|
-
type: Function,
|
|
187
|
-
required: false,
|
|
188
|
-
default: void 0
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
inheritAttrs: false
|
|
192
|
-
});
|
|
193
|
-
var MenuContext_default = InheritableContextProvider;
|
|
194
|
-
exports.default = MenuContext_default;
|
|
195
|
-
exports.useMenuContext = useMenuContext;
|
|
196
|
-
exports.useMenuContextProvider = useMenuContextProvider;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
-
let vue = require("vue");
|
|
4
|
-
var EmptyList = [];
|
|
5
|
-
var PathRegisterContextKey = Symbol("PathRegisterContext");
|
|
6
|
-
function useMeasure() {
|
|
7
|
-
return (0, vue.inject)(PathRegisterContextKey, null);
|
|
8
|
-
}
|
|
9
|
-
function useMeasureProvider(context) {
|
|
10
|
-
(0, vue.provide)(PathRegisterContextKey, context);
|
|
11
|
-
}
|
|
12
|
-
const MeasureProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
13
|
-
useMeasureProvider(props);
|
|
14
|
-
return () => {
|
|
15
|
-
return slots?.default?.();
|
|
16
|
-
};
|
|
17
|
-
}, { props: {
|
|
18
|
-
registerPath: {
|
|
19
|
-
type: Function,
|
|
20
|
-
required: true,
|
|
21
|
-
default: void 0
|
|
22
|
-
},
|
|
23
|
-
unregisterPath: {
|
|
24
|
-
type: Function,
|
|
25
|
-
required: true,
|
|
26
|
-
default: void 0
|
|
27
|
-
}
|
|
28
|
-
} });
|
|
29
|
-
var PathTrackerContextKey = Symbol("PathTrackerContext");
|
|
30
|
-
function useFullPath(eventKey) {
|
|
31
|
-
const parentKeyPath = (0, vue.inject)(PathTrackerContextKey, (0, vue.ref)(EmptyList));
|
|
32
|
-
return (0, vue.computed)(() => {
|
|
33
|
-
return eventKey !== void 0 ? [...parentKeyPath.value, eventKey.value] : parentKeyPath.value;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const PathTrackerProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
37
|
-
(0, vue.provide)(PathTrackerContextKey, (0, vue.computed)(() => props.value));
|
|
38
|
-
return () => {
|
|
39
|
-
return slots?.default?.();
|
|
40
|
-
};
|
|
41
|
-
}, { props: { value: {
|
|
42
|
-
type: Array,
|
|
43
|
-
required: true,
|
|
44
|
-
default: void 0
|
|
45
|
-
} } });
|
|
46
|
-
var PathUserContextKey = Symbol("PathUserContext");
|
|
47
|
-
function usePathUserContextProvider(context) {
|
|
48
|
-
(0, vue.provide)(PathUserContextKey, context);
|
|
49
|
-
}
|
|
50
|
-
function usePathUserContext() {
|
|
51
|
-
return (0, vue.inject)(PathUserContextKey, { isSubPathKey: () => false });
|
|
52
|
-
}
|
|
53
|
-
const PathUserProvider = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
54
|
-
usePathUserContextProvider(props);
|
|
55
|
-
return () => {
|
|
56
|
-
return slots?.default?.();
|
|
57
|
-
};
|
|
58
|
-
}, { props: { isSubPathKey: {
|
|
59
|
-
type: Function,
|
|
60
|
-
required: true,
|
|
61
|
-
default: void 0
|
|
62
|
-
} } });
|
|
63
|
-
const PathTrackerContext = { Provider: PathTrackerProvider };
|
|
64
|
-
const PathRegisterContext = { Provider: MeasureProvider };
|
|
65
|
-
const PathUserContext = { Provider: PathUserProvider };
|
|
66
|
-
exports.MeasureProvider = MeasureProvider;
|
|
67
|
-
exports.PathRegisterContext = PathRegisterContext;
|
|
68
|
-
exports.PathTrackerContext = PathTrackerContext;
|
|
69
|
-
exports.PathTrackerProvider = PathTrackerProvider;
|
|
70
|
-
exports.PathUserContext = PathUserContext;
|
|
71
|
-
exports.PathUserProvider = PathUserProvider;
|
|
72
|
-
exports.useFullPath = useFullPath;
|
|
73
|
-
exports.useMeasure = useMeasure;
|
|
74
|
-
exports.useMeasureProvider = useMeasureProvider;
|
|
75
|
-
exports.usePathUserContext = usePathUserContext;
|
|
76
|
-
exports.usePathUserContextProvider = usePathUserContextProvider;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
-
let vue = require("vue");
|
|
4
|
-
var PrivateContextKey = Symbol("PrivateContext");
|
|
5
|
-
function usePrivateProvider(context) {
|
|
6
|
-
(0, vue.provide)(PrivateContextKey, context);
|
|
7
|
-
}
|
|
8
|
-
function usePrivateContext() {
|
|
9
|
-
return (0, vue.inject)(PrivateContextKey, {});
|
|
10
|
-
}
|
|
11
|
-
const PrivateContextProvider = (0, vue.defineComponent)((props, { slots }) => {
|
|
12
|
-
usePrivateProvider(props);
|
|
13
|
-
return () => {
|
|
14
|
-
return slots?.default?.();
|
|
15
|
-
};
|
|
16
|
-
}, { props: ["_internalRenderMenuItem", "_internalRenderSubMenuItem"] });
|
|
17
|
-
exports.PrivateContextProvider = PrivateContextProvider;
|
|
18
|
-
exports.usePrivateContext = usePrivateContext;
|
|
19
|
-
exports.usePrivateProvider = usePrivateProvider;
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_IdContext = require("../context/IdContext.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
let _v_c_util_dist_KeyCode = require("@v-c/util/dist/KeyCode");
|
|
9
|
-
_v_c_util_dist_KeyCode = require_rolldown_runtime.__toESM(_v_c_util_dist_KeyCode);
|
|
10
|
-
var { LEFT, RIGHT, UP, DOWN, ENTER, ESC, HOME, END } = _v_c_util_dist_KeyCode.default;
|
|
11
|
-
var ArrowKeys = [
|
|
12
|
-
UP,
|
|
13
|
-
DOWN,
|
|
14
|
-
LEFT,
|
|
15
|
-
RIGHT
|
|
16
|
-
];
|
|
17
|
-
function getOffset(mode, isRootLevel, isRtl, which) {
|
|
18
|
-
const prev = "prev";
|
|
19
|
-
const next = "next";
|
|
20
|
-
const children = "children";
|
|
21
|
-
const parent = "parent";
|
|
22
|
-
if (mode === "inline" && which === ENTER) return { inlineTrigger: true };
|
|
23
|
-
const inline = {
|
|
24
|
-
[UP]: prev,
|
|
25
|
-
[DOWN]: next
|
|
26
|
-
};
|
|
27
|
-
const horizontal = {
|
|
28
|
-
[LEFT]: isRtl ? next : prev,
|
|
29
|
-
[RIGHT]: isRtl ? prev : next,
|
|
30
|
-
[DOWN]: children,
|
|
31
|
-
[ENTER]: children
|
|
32
|
-
};
|
|
33
|
-
const vertical = {
|
|
34
|
-
[UP]: prev,
|
|
35
|
-
[DOWN]: next,
|
|
36
|
-
[ENTER]: children,
|
|
37
|
-
[ESC]: parent,
|
|
38
|
-
[LEFT]: isRtl ? children : parent,
|
|
39
|
-
[RIGHT]: isRtl ? parent : children
|
|
40
|
-
};
|
|
41
|
-
switch ({
|
|
42
|
-
inline,
|
|
43
|
-
horizontal,
|
|
44
|
-
vertical,
|
|
45
|
-
inlineSub: inline,
|
|
46
|
-
horizontalSub: vertical,
|
|
47
|
-
verticalSub: vertical
|
|
48
|
-
}[`${mode}${isRootLevel ? "" : "Sub"}`]?.[which]) {
|
|
49
|
-
case prev: return {
|
|
50
|
-
offset: -1,
|
|
51
|
-
sibling: true
|
|
52
|
-
};
|
|
53
|
-
case next: return {
|
|
54
|
-
offset: 1,
|
|
55
|
-
sibling: true
|
|
56
|
-
};
|
|
57
|
-
case parent: return {
|
|
58
|
-
offset: -1,
|
|
59
|
-
sibling: false
|
|
60
|
-
};
|
|
61
|
-
case children: return {
|
|
62
|
-
offset: 1,
|
|
63
|
-
sibling: false
|
|
64
|
-
};
|
|
65
|
-
default: return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function findContainerUL(element) {
|
|
69
|
-
let current = element;
|
|
70
|
-
while (current) {
|
|
71
|
-
if (current.getAttribute("data-menu-list")) return current;
|
|
72
|
-
current = current.parentElement;
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
function getFocusNodeList(container, includeDisabled) {
|
|
77
|
-
const selector = includeDisabled ? "[tabindex]" : "[tabindex]:not([tabindex=\"-1\"]):not([disabled]):not([aria-disabled=\"true\"])";
|
|
78
|
-
return Array.from(container.querySelectorAll(selector));
|
|
79
|
-
}
|
|
80
|
-
function getFocusElement(activeElement, elements) {
|
|
81
|
-
let current = activeElement || document.activeElement;
|
|
82
|
-
while (current) {
|
|
83
|
-
if (elements.has(current)) return current;
|
|
84
|
-
current = current.parentElement;
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
function getFocusableElements(container, elements) {
|
|
89
|
-
if (!container) return [];
|
|
90
|
-
return getFocusNodeList(container, true).filter((ele) => elements.has(ele));
|
|
91
|
-
}
|
|
92
|
-
function getNextFocusElement(parentQueryContainer, elements, focusMenuElement, offset = 1) {
|
|
93
|
-
if (!parentQueryContainer) return null;
|
|
94
|
-
const sameLevelFocusableMenuElementList = getFocusableElements(parentQueryContainer, elements);
|
|
95
|
-
const count = sameLevelFocusableMenuElementList.length;
|
|
96
|
-
let focusIndex = sameLevelFocusableMenuElementList.findIndex((ele) => focusMenuElement === ele);
|
|
97
|
-
if (offset < 0) if (focusIndex === -1) focusIndex = count - 1;
|
|
98
|
-
else focusIndex -= 1;
|
|
99
|
-
else if (offset > 0) focusIndex += 1;
|
|
100
|
-
focusIndex = (focusIndex + count) % count;
|
|
101
|
-
return sameLevelFocusableMenuElementList[focusIndex];
|
|
102
|
-
}
|
|
103
|
-
function refreshElements(keys, id) {
|
|
104
|
-
const elements = /* @__PURE__ */ new Set();
|
|
105
|
-
const key2element = /* @__PURE__ */ new Map();
|
|
106
|
-
const element2key = /* @__PURE__ */ new Map();
|
|
107
|
-
keys.forEach((key) => {
|
|
108
|
-
const element = document.querySelector(`[data-menu-id='${require_IdContext.getMenuId(id, key)}']`);
|
|
109
|
-
if (element) {
|
|
110
|
-
elements.add(element);
|
|
111
|
-
element2key.set(element, key);
|
|
112
|
-
key2element.set(key, element);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return {
|
|
116
|
-
elements,
|
|
117
|
-
key2element,
|
|
118
|
-
element2key
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function useAccessibility(mode, activeKey, isRtl, id, containerRef, getKeys, getKeyPath, triggerActiveKey, triggerAccessibilityOpen, originOnKeyDown) {
|
|
122
|
-
const rafRef = (0, vue.shallowRef)();
|
|
123
|
-
const activeRef = (0, vue.shallowRef)();
|
|
124
|
-
const cleanRaf = () => {
|
|
125
|
-
if (rafRef.value !== void 0) cancelAnimationFrame(rafRef.value);
|
|
126
|
-
};
|
|
127
|
-
(0, vue.onBeforeUnmount)(() => {
|
|
128
|
-
cleanRaf();
|
|
129
|
-
});
|
|
130
|
-
return (e) => {
|
|
131
|
-
activeRef.value = activeKey.value;
|
|
132
|
-
const { which } = e;
|
|
133
|
-
if ([
|
|
134
|
-
...ArrowKeys,
|
|
135
|
-
ENTER,
|
|
136
|
-
ESC,
|
|
137
|
-
HOME,
|
|
138
|
-
END
|
|
139
|
-
].includes(which)) {
|
|
140
|
-
const keys = getKeys();
|
|
141
|
-
let refreshedElements = refreshElements(keys, id);
|
|
142
|
-
const { elements, key2element, element2key } = refreshedElements;
|
|
143
|
-
const focusMenuElement = getFocusElement(key2element.get(activeKey.value) || null, elements);
|
|
144
|
-
const focusMenuKey = element2key.get(focusMenuElement);
|
|
145
|
-
const offsetObj = getOffset(mode.value, getKeyPath(focusMenuKey, true).length === 1, isRtl.value, which);
|
|
146
|
-
if (!offsetObj && which !== HOME && which !== END) return;
|
|
147
|
-
if (ArrowKeys.includes(which) || [HOME, END].includes(which)) e.preventDefault();
|
|
148
|
-
const tryFocus = (menuElement) => {
|
|
149
|
-
if (menuElement) {
|
|
150
|
-
let focusTargetElement = menuElement;
|
|
151
|
-
const link = menuElement.querySelector("a");
|
|
152
|
-
if (link?.getAttribute("href")) focusTargetElement = link;
|
|
153
|
-
const targetKey = element2key.get(menuElement);
|
|
154
|
-
if (targetKey) triggerActiveKey(targetKey);
|
|
155
|
-
cleanRaf();
|
|
156
|
-
rafRef.value = requestAnimationFrame(() => {
|
|
157
|
-
if (activeRef.value === targetKey) focusTargetElement.focus();
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
if ([HOME, END].includes(which) || offsetObj?.sibling || !focusMenuElement) {
|
|
162
|
-
let parentQueryContainer;
|
|
163
|
-
if (!focusMenuElement || mode.value === "inline") parentQueryContainer = containerRef.value;
|
|
164
|
-
else parentQueryContainer = findContainerUL(focusMenuElement);
|
|
165
|
-
let targetElement;
|
|
166
|
-
const focusableElements = getFocusableElements(parentQueryContainer, elements);
|
|
167
|
-
if (which === HOME) targetElement = focusableElements[0];
|
|
168
|
-
else if (which === END) targetElement = focusableElements[focusableElements.length - 1];
|
|
169
|
-
else targetElement = getNextFocusElement(parentQueryContainer, elements, focusMenuElement, offsetObj?.offset);
|
|
170
|
-
tryFocus(targetElement);
|
|
171
|
-
} else if (offsetObj.inlineTrigger) triggerAccessibilityOpen(focusMenuKey);
|
|
172
|
-
else if (offsetObj.offset > 0) {
|
|
173
|
-
triggerAccessibilityOpen(focusMenuKey, true);
|
|
174
|
-
cleanRaf();
|
|
175
|
-
rafRef.value = requestAnimationFrame(() => {
|
|
176
|
-
refreshedElements = refreshElements(keys, id);
|
|
177
|
-
const controlId = focusMenuElement.getAttribute("aria-controls");
|
|
178
|
-
tryFocus(getNextFocusElement(controlId ? document.getElementById(controlId) : null, refreshedElements.elements));
|
|
179
|
-
});
|
|
180
|
-
} else if (offsetObj.offset < 0) {
|
|
181
|
-
const keyPath = getKeyPath(focusMenuKey, true);
|
|
182
|
-
const parentKey = keyPath[keyPath.length - 2];
|
|
183
|
-
const parentMenuElement = key2element.get(parentKey);
|
|
184
|
-
triggerAccessibilityOpen(parentKey, false);
|
|
185
|
-
tryFocus(parentMenuElement);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
originOnKeyDown?.(e);
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
exports.default = useAccessibility;
|
|
192
|
-
exports.getFocusableElements = getFocusableElements;
|
|
193
|
-
exports.refreshElements = refreshElements;
|
package/dist/hooks/useActive.cjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_MenuContext = require("../context/MenuContext.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
function useActive(eventKey, disabled, onMouseEnter, onMouseLeave) {
|
|
9
|
-
const menuContext = require_MenuContext.useMenuContext();
|
|
10
|
-
const ret = { active: (0, vue.computed)(() => menuContext?.value?.activeKey === eventKey.value) };
|
|
11
|
-
(0, vue.watchEffect)(() => {
|
|
12
|
-
if (!disabled.value) {
|
|
13
|
-
ret.onMouseEnter = (domEvent) => {
|
|
14
|
-
onMouseEnter?.({
|
|
15
|
-
key: eventKey.value,
|
|
16
|
-
domEvent
|
|
17
|
-
});
|
|
18
|
-
menuContext?.value?.onActive?.(eventKey.value);
|
|
19
|
-
};
|
|
20
|
-
ret.onMouseLeave = (domEvent) => {
|
|
21
|
-
onMouseLeave?.({
|
|
22
|
-
key: eventKey.value,
|
|
23
|
-
domEvent
|
|
24
|
-
});
|
|
25
|
-
menuContext?.value?.onInactive?.(eventKey.value);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
return ret;
|
|
30
|
-
}
|
|
31
|
-
exports.default = useActive;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_MenuContext = require("../context/MenuContext.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
function useDirectionStyle(level) {
|
|
9
|
-
const menuContext = require_MenuContext.useMenuContext();
|
|
10
|
-
return (0, vue.computed)(() => {
|
|
11
|
-
const { mode, rtl, inlineIndent } = menuContext?.value ?? {};
|
|
12
|
-
if (mode !== "inline") return null;
|
|
13
|
-
const len = level.value;
|
|
14
|
-
return rtl ? { paddingRight: `${len * inlineIndent}px` } : { paddingLeft: `${len * inlineIndent}px` };
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
exports.default = useDirectionStyle;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_timeUtil = require("../utils/timeUtil.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
var PATH_SPLIT = "__VC_UTIL_PATH_SPLIT__";
|
|
9
|
-
var getPathStr = (keyPath) => keyPath.join(PATH_SPLIT);
|
|
10
|
-
var getPathKeys = (keyPathStr) => keyPathStr.split(PATH_SPLIT);
|
|
11
|
-
const OVERFLOW_KEY = "vc-menu-more";
|
|
12
|
-
function useKeyRecords() {
|
|
13
|
-
const forceUpdateCount = (0, vue.ref)(0);
|
|
14
|
-
const key2pathRef = (0, vue.shallowRef)(/* @__PURE__ */ new Map());
|
|
15
|
-
const path2keyRef = (0, vue.shallowRef)(/* @__PURE__ */ new Map());
|
|
16
|
-
const overflowKeys = (0, vue.ref)([]);
|
|
17
|
-
const updateRef = (0, vue.ref)(0);
|
|
18
|
-
const destroyRef = (0, vue.ref)(false);
|
|
19
|
-
const forceUpdate = () => {
|
|
20
|
-
if (!destroyRef.value) forceUpdateCount.value += 1;
|
|
21
|
-
};
|
|
22
|
-
const registerPath = (key, keyPath) => {
|
|
23
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24
|
-
if (key2pathRef.value.has(key)) console.warn(`Duplicated key '${key}' used in Menu by path [${keyPath.join(" > ")}]`);
|
|
25
|
-
}
|
|
26
|
-
const connectedPath = getPathStr(keyPath);
|
|
27
|
-
path2keyRef.value.set(connectedPath, key);
|
|
28
|
-
key2pathRef.value.set(key, connectedPath);
|
|
29
|
-
updateRef.value += 1;
|
|
30
|
-
const id = updateRef.value;
|
|
31
|
-
require_timeUtil.nextSlice(() => {
|
|
32
|
-
if (id === updateRef.value) forceUpdate();
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
const unregisterPath = (key, keyPath) => {
|
|
36
|
-
const connectedPath = getPathStr(keyPath);
|
|
37
|
-
path2keyRef.value.delete(connectedPath);
|
|
38
|
-
key2pathRef.value.delete(key);
|
|
39
|
-
};
|
|
40
|
-
const refreshOverflowKeys = (keys) => {
|
|
41
|
-
overflowKeys.value = keys;
|
|
42
|
-
};
|
|
43
|
-
const getKeyPath = (eventKey, includeOverflow) => {
|
|
44
|
-
const keys = getPathKeys(key2pathRef.value.get(eventKey) || "");
|
|
45
|
-
if (includeOverflow && overflowKeys.value.includes(keys[0])) keys.unshift(OVERFLOW_KEY);
|
|
46
|
-
return keys;
|
|
47
|
-
};
|
|
48
|
-
const isSubPathKey = (pathKeys, eventKey) => pathKeys.filter((item) => item !== void 0).some((pathKey) => {
|
|
49
|
-
return getKeyPath(pathKey, true).includes(eventKey);
|
|
50
|
-
});
|
|
51
|
-
const getKeys = () => {
|
|
52
|
-
const keys = [...key2pathRef.value.keys()];
|
|
53
|
-
if (overflowKeys.value.length) keys.push(OVERFLOW_KEY);
|
|
54
|
-
return keys;
|
|
55
|
-
};
|
|
56
|
-
const getSubPathKeys = (key) => {
|
|
57
|
-
const connectedPath = `${key2pathRef.value.get(key)}${PATH_SPLIT}`;
|
|
58
|
-
const pathKeys = /* @__PURE__ */ new Set();
|
|
59
|
-
[...path2keyRef.value.keys()].forEach((pathKey) => {
|
|
60
|
-
if (pathKey.startsWith(connectedPath)) pathKeys.add(path2keyRef.value.get(pathKey));
|
|
61
|
-
});
|
|
62
|
-
return pathKeys;
|
|
63
|
-
};
|
|
64
|
-
(0, vue.onBeforeUnmount)(() => {
|
|
65
|
-
destroyRef.value = true;
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
registerPath,
|
|
69
|
-
unregisterPath,
|
|
70
|
-
refreshOverflowKeys,
|
|
71
|
-
isSubPathKey,
|
|
72
|
-
getKeyPath,
|
|
73
|
-
getKeys,
|
|
74
|
-
getSubPathKeys
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
exports.OVERFLOW_KEY = OVERFLOW_KEY;
|
|
78
|
-
exports.default = useKeyRecords;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
function useMemoCallback(callback) {
|
|
8
|
-
const fnRef = (0, vue.ref)(callback);
|
|
9
|
-
fnRef.value = callback;
|
|
10
|
-
const memoFn = ((...args) => {
|
|
11
|
-
return fnRef.value(...args);
|
|
12
|
-
});
|
|
13
|
-
return memoFn;
|
|
14
|
-
}
|
|
15
|
-
exports.default = useMemoCallback;
|
package/dist/index.cjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_PathContext = require("./context/PathContext.cjs");
|
|
6
|
-
const require_Divider = require("./Divider.cjs");
|
|
7
|
-
const require_MenuItem = require("./MenuItem.cjs");
|
|
8
|
-
const require_index = require("./SubMenu/index.cjs");
|
|
9
|
-
const require_MenuItemGroup = require("./MenuItemGroup.cjs");
|
|
10
|
-
const require_Menu = require("./Menu.cjs");
|
|
11
|
-
var ExportMenu = require_Menu.default;
|
|
12
|
-
ExportMenu.Item = require_MenuItem.default;
|
|
13
|
-
ExportMenu.SubMenu = require_index.default;
|
|
14
|
-
ExportMenu.ItemGroup = require_MenuItemGroup.default;
|
|
15
|
-
ExportMenu.Divider = require_Divider.default;
|
|
16
|
-
var src_default = ExportMenu;
|
|
17
|
-
exports.Divider = require_Divider.default;
|
|
18
|
-
exports.Item = require_MenuItem.default;
|
|
19
|
-
exports.MenuItem = require_MenuItem.default;
|
|
20
|
-
exports.ItemGroup = require_MenuItemGroup.default;
|
|
21
|
-
exports.MenuItemGroup = require_MenuItemGroup.default;
|
|
22
|
-
exports.SubMenu = require_index.default;
|
|
23
|
-
exports.default = src_default;
|
|
24
|
-
exports.useFullPath = require_PathContext.useFullPath;
|
package/dist/interface.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|