@v-c/menu 0.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/LICENSE +21 -0
- package/dist/Divider.cjs +38 -0
- package/dist/Divider.d.ts +4 -0
- package/dist/Divider.js +38 -0
- package/dist/Icon.cjs +38 -0
- package/dist/Icon.d.ts +7 -0
- package/dist/Icon.js +38 -0
- package/dist/Menu.cjs +580 -0
- package/dist/Menu.d.ts +77 -0
- package/dist/Menu.js +580 -0
- package/dist/MenuItem.cjs +350 -0
- package/dist/MenuItem.d.ts +14 -0
- package/dist/MenuItem.js +350 -0
- package/dist/MenuItemGroup.cjs +120 -0
- package/dist/MenuItemGroup.d.ts +16 -0
- package/dist/MenuItemGroup.js +120 -0
- package/dist/SubMenu/InlineSubMenuList.cjs +84 -0
- package/dist/SubMenu/InlineSubMenuList.d.ts +7 -0
- package/dist/SubMenu/InlineSubMenuList.js +84 -0
- package/dist/SubMenu/PopupTrigger.cjs +168 -0
- package/dist/SubMenu/PopupTrigger.d.ts +16 -0
- package/dist/SubMenu/PopupTrigger.js +168 -0
- package/dist/SubMenu/SubMenuList.cjs +28 -0
- package/dist/SubMenu/SubMenuList.d.ts +2 -0
- package/dist/SubMenu/SubMenuList.js +28 -0
- package/dist/SubMenu/index.cjs +532 -0
- package/dist/SubMenu/index.d.ts +18 -0
- package/dist/SubMenu/index.js +532 -0
- package/dist/context/IdContext.cjs +33 -0
- package/dist/context/IdContext.d.ts +12 -0
- package/dist/context/IdContext.js +33 -0
- package/dist/context/MenuContext.cjs +184 -0
- package/dist/context/MenuContext.d.ts +42 -0
- package/dist/context/MenuContext.js +184 -0
- package/dist/context/PathContext.cjs +100 -0
- package/dist/context/PathContext.d.ts +33 -0
- package/dist/context/PathContext.js +100 -0
- package/dist/context/PrivateContext.cjs +24 -0
- package/dist/context/PrivateContext.d.ts +8 -0
- package/dist/context/PrivateContext.js +24 -0
- package/dist/hooks/useAccessibility.cjs +210 -0
- package/dist/hooks/useAccessibility.d.ts +12 -0
- package/dist/hooks/useAccessibility.js +210 -0
- package/dist/hooks/useActive.cjs +31 -0
- package/dist/hooks/useActive.d.ts +9 -0
- package/dist/hooks/useActive.js +31 -0
- package/dist/hooks/useDirectionStyle.cjs +20 -0
- package/dist/hooks/useDirectionStyle.d.ts +2 -0
- package/dist/hooks/useDirectionStyle.js +20 -0
- package/dist/hooks/useKeyRecords.cjs +93 -0
- package/dist/hooks/useKeyRecords.d.ts +10 -0
- package/dist/hooks/useKeyRecords.js +93 -0
- package/dist/hooks/useMemoCallback.cjs +12 -0
- package/dist/hooks/useMemoCallback.d.ts +4 -0
- package/dist/hooks/useMemoCallback.js +12 -0
- package/dist/index.cjs +21 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +21 -0
- package/dist/interface.cjs +1 -0
- package/dist/interface.d.ts +94 -0
- package/dist/interface.js +1 -0
- package/dist/placements.cjs +77 -0
- package/dist/placements.d.ts +117 -0
- package/dist/placements.js +77 -0
- package/dist/utils/commonUtil.cjs +29 -0
- package/dist/utils/commonUtil.d.ts +1 -0
- package/dist/utils/commonUtil.js +29 -0
- package/dist/utils/motionUtil.cjs +12 -0
- package/dist/utils/motionUtil.d.ts +2 -0
- package/dist/utils/motionUtil.js +12 -0
- package/dist/utils/nodeUtil.cjs +82 -0
- package/dist/utils/nodeUtil.d.ts +3 -0
- package/dist/utils/nodeUtil.js +82 -0
- package/dist/utils/timeUtil.cjs +6 -0
- package/dist/utils/timeUtil.d.ts +1 -0
- package/dist/utils/timeUtil.js +6 -0
- package/dist/utils/warnUtil.cjs +16 -0
- package/dist/utils/warnUtil.d.ts +7 -0
- package/dist/utils/warnUtil.js +16 -0
- package/package.json +37 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const omit = require("@v-c/util/dist/omit.ts");
|
|
4
|
+
const vue = require("vue");
|
|
5
|
+
const MenuContextKey = Symbol("MenuContextKey");
|
|
6
|
+
function mergeProps(origin, target) {
|
|
7
|
+
const clone = {
|
|
8
|
+
...origin
|
|
9
|
+
};
|
|
10
|
+
Object.keys(target).forEach((key) => {
|
|
11
|
+
const value = target[key];
|
|
12
|
+
if (value !== void 0) {
|
|
13
|
+
target[key] = value;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return clone;
|
|
17
|
+
}
|
|
18
|
+
function useMenuContext() {
|
|
19
|
+
return vue.inject(MenuContextKey, null);
|
|
20
|
+
}
|
|
21
|
+
function useMenuContextProvider(context) {
|
|
22
|
+
vue.provide(MenuContextKey, context);
|
|
23
|
+
}
|
|
24
|
+
const InheritableContextProvider = /* @__PURE__ */ vue.defineComponent((props, {
|
|
25
|
+
slots
|
|
26
|
+
}) => {
|
|
27
|
+
const context = useMenuContext();
|
|
28
|
+
const inheritContext = vue.computed(() => {
|
|
29
|
+
return mergeProps(context?.value ?? {}, omit(props, ["locked"]));
|
|
30
|
+
});
|
|
31
|
+
useMenuContextProvider(inheritContext);
|
|
32
|
+
return () => {
|
|
33
|
+
return slots?.default?.();
|
|
34
|
+
};
|
|
35
|
+
}, {
|
|
36
|
+
props: {
|
|
37
|
+
locked: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: false,
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
prefixCls: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: false,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
classNames: {
|
|
48
|
+
type: Object,
|
|
49
|
+
required: false,
|
|
50
|
+
default: void 0
|
|
51
|
+
},
|
|
52
|
+
styles: {
|
|
53
|
+
type: Object,
|
|
54
|
+
required: false,
|
|
55
|
+
default: void 0
|
|
56
|
+
},
|
|
57
|
+
rootClassName: {
|
|
58
|
+
type: String,
|
|
59
|
+
required: false,
|
|
60
|
+
default: void 0
|
|
61
|
+
},
|
|
62
|
+
openKeys: {
|
|
63
|
+
type: Array,
|
|
64
|
+
required: false,
|
|
65
|
+
default: void 0
|
|
66
|
+
},
|
|
67
|
+
rtl: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
required: false,
|
|
70
|
+
default: void 0
|
|
71
|
+
},
|
|
72
|
+
mode: {
|
|
73
|
+
type: String,
|
|
74
|
+
required: false,
|
|
75
|
+
default: void 0
|
|
76
|
+
},
|
|
77
|
+
disabled: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
required: false,
|
|
80
|
+
default: void 0
|
|
81
|
+
},
|
|
82
|
+
overflowDisabled: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
required: false,
|
|
85
|
+
default: void 0
|
|
86
|
+
},
|
|
87
|
+
activeKey: {
|
|
88
|
+
type: String,
|
|
89
|
+
required: false,
|
|
90
|
+
default: void 0
|
|
91
|
+
},
|
|
92
|
+
onActive: {
|
|
93
|
+
type: Function,
|
|
94
|
+
required: false,
|
|
95
|
+
default: void 0
|
|
96
|
+
},
|
|
97
|
+
onInactive: {
|
|
98
|
+
type: Function,
|
|
99
|
+
required: false,
|
|
100
|
+
default: void 0
|
|
101
|
+
},
|
|
102
|
+
selectedKeys: {
|
|
103
|
+
type: Array,
|
|
104
|
+
required: false,
|
|
105
|
+
default: void 0
|
|
106
|
+
},
|
|
107
|
+
inlineIndent: {
|
|
108
|
+
type: Number,
|
|
109
|
+
required: false,
|
|
110
|
+
default: void 0
|
|
111
|
+
},
|
|
112
|
+
motion: {
|
|
113
|
+
type: Object,
|
|
114
|
+
required: false,
|
|
115
|
+
default: void 0
|
|
116
|
+
},
|
|
117
|
+
defaultMotions: {
|
|
118
|
+
type: Object,
|
|
119
|
+
required: false,
|
|
120
|
+
default: void 0
|
|
121
|
+
},
|
|
122
|
+
subMenuOpenDelay: {
|
|
123
|
+
type: Number,
|
|
124
|
+
required: false,
|
|
125
|
+
default: void 0
|
|
126
|
+
},
|
|
127
|
+
subMenuCloseDelay: {
|
|
128
|
+
type: Number,
|
|
129
|
+
required: false,
|
|
130
|
+
default: void 0
|
|
131
|
+
},
|
|
132
|
+
forceSubMenuRender: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
required: false,
|
|
135
|
+
default: void 0
|
|
136
|
+
},
|
|
137
|
+
builtinPlacements: {
|
|
138
|
+
type: Object,
|
|
139
|
+
required: false,
|
|
140
|
+
default: void 0
|
|
141
|
+
},
|
|
142
|
+
triggerSubMenuAction: {
|
|
143
|
+
type: String,
|
|
144
|
+
required: false,
|
|
145
|
+
default: void 0
|
|
146
|
+
},
|
|
147
|
+
popupRender: {
|
|
148
|
+
type: Function,
|
|
149
|
+
required: false,
|
|
150
|
+
default: void 0
|
|
151
|
+
},
|
|
152
|
+
itemIcon: {
|
|
153
|
+
type: [String, Number, null, Array, Function, Boolean],
|
|
154
|
+
required: false,
|
|
155
|
+
skipCheck: true,
|
|
156
|
+
default: void 0
|
|
157
|
+
},
|
|
158
|
+
expandIcon: {
|
|
159
|
+
type: [String, Number, null, Array, Function, Boolean],
|
|
160
|
+
required: false,
|
|
161
|
+
skipCheck: true,
|
|
162
|
+
default: void 0
|
|
163
|
+
},
|
|
164
|
+
onItemClick: {
|
|
165
|
+
type: Function,
|
|
166
|
+
required: false,
|
|
167
|
+
default: void 0
|
|
168
|
+
},
|
|
169
|
+
onOpenChange: {
|
|
170
|
+
type: Function,
|
|
171
|
+
required: false,
|
|
172
|
+
default: void 0
|
|
173
|
+
},
|
|
174
|
+
getPopupContainer: {
|
|
175
|
+
type: Function,
|
|
176
|
+
required: false,
|
|
177
|
+
default: void 0
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
inheritAttrs: false
|
|
181
|
+
});
|
|
182
|
+
exports.default = InheritableContextProvider;
|
|
183
|
+
exports.useMenuContext = useMenuContext;
|
|
184
|
+
exports.useMenuContextProvider = useMenuContextProvider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
import { BuiltinPlacements, MenuClickEventHandler, MenuMode, PopupRender, RenderIconType, TriggerSubMenuAction } from '../interface.ts';
|
|
4
|
+
import { SubMenuProps } from '../SubMenu';
|
|
5
|
+
export interface MenuContextProps {
|
|
6
|
+
prefixCls: string;
|
|
7
|
+
classNames?: SubMenuProps['classNames'];
|
|
8
|
+
styles?: SubMenuProps['styles'];
|
|
9
|
+
rootClassName?: string;
|
|
10
|
+
openKeys: string[];
|
|
11
|
+
rtl?: boolean;
|
|
12
|
+
mode: MenuMode;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
overflowDisabled?: boolean;
|
|
15
|
+
activeKey: string;
|
|
16
|
+
onActive: (key: string) => void;
|
|
17
|
+
onInactive: (key: string) => void;
|
|
18
|
+
selectedKeys: string[];
|
|
19
|
+
inlineIndent: number;
|
|
20
|
+
motion?: CSSMotionProps;
|
|
21
|
+
defaultMotions?: Partial<{
|
|
22
|
+
[key in MenuMode | 'other']: CSSMotionProps;
|
|
23
|
+
}>;
|
|
24
|
+
subMenuOpenDelay: number;
|
|
25
|
+
subMenuCloseDelay: number;
|
|
26
|
+
forceSubMenuRender?: boolean;
|
|
27
|
+
builtinPlacements?: BuiltinPlacements;
|
|
28
|
+
triggerSubMenuAction?: TriggerSubMenuAction;
|
|
29
|
+
popupRender?: PopupRender;
|
|
30
|
+
itemIcon?: RenderIconType;
|
|
31
|
+
expandIcon?: RenderIconType;
|
|
32
|
+
onItemClick: MenuClickEventHandler;
|
|
33
|
+
onOpenChange: (key: string, open: boolean) => void;
|
|
34
|
+
getPopupContainer: (node: HTMLElement) => HTMLElement;
|
|
35
|
+
}
|
|
36
|
+
export interface InheritableContextProps extends Partial<MenuContextProps> {
|
|
37
|
+
locked?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function useMenuContext(): Ref<MenuContextProps, MenuContextProps> | null;
|
|
40
|
+
export declare function useMenuContextProvider(context: Ref<MenuContextProps>): void;
|
|
41
|
+
declare const InheritableContextProvider: import('vue').DefineSetupFnComponent<InheritableContextProps, {}, {}, InheritableContextProps & {}, import('vue').PublicProps>;
|
|
42
|
+
export default InheritableContextProvider;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import omit from "@v-c/util/dist/omit.ts";
|
|
2
|
+
import { defineComponent, provide, computed, inject } from "vue";
|
|
3
|
+
const MenuContextKey = Symbol("MenuContextKey");
|
|
4
|
+
function mergeProps(origin, target) {
|
|
5
|
+
const clone = {
|
|
6
|
+
...origin
|
|
7
|
+
};
|
|
8
|
+
Object.keys(target).forEach((key) => {
|
|
9
|
+
const value = target[key];
|
|
10
|
+
if (value !== void 0) {
|
|
11
|
+
target[key] = value;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return clone;
|
|
15
|
+
}
|
|
16
|
+
function useMenuContext() {
|
|
17
|
+
return inject(MenuContextKey, null);
|
|
18
|
+
}
|
|
19
|
+
function useMenuContextProvider(context) {
|
|
20
|
+
provide(MenuContextKey, context);
|
|
21
|
+
}
|
|
22
|
+
const InheritableContextProvider = /* @__PURE__ */ defineComponent((props, {
|
|
23
|
+
slots
|
|
24
|
+
}) => {
|
|
25
|
+
const context = useMenuContext();
|
|
26
|
+
const inheritContext = computed(() => {
|
|
27
|
+
return mergeProps(context?.value ?? {}, omit(props, ["locked"]));
|
|
28
|
+
});
|
|
29
|
+
useMenuContextProvider(inheritContext);
|
|
30
|
+
return () => {
|
|
31
|
+
return slots?.default?.();
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
props: {
|
|
35
|
+
locked: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
required: false,
|
|
38
|
+
default: void 0
|
|
39
|
+
},
|
|
40
|
+
prefixCls: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false,
|
|
43
|
+
default: void 0
|
|
44
|
+
},
|
|
45
|
+
classNames: {
|
|
46
|
+
type: Object,
|
|
47
|
+
required: false,
|
|
48
|
+
default: void 0
|
|
49
|
+
},
|
|
50
|
+
styles: {
|
|
51
|
+
type: Object,
|
|
52
|
+
required: false,
|
|
53
|
+
default: void 0
|
|
54
|
+
},
|
|
55
|
+
rootClassName: {
|
|
56
|
+
type: String,
|
|
57
|
+
required: false,
|
|
58
|
+
default: void 0
|
|
59
|
+
},
|
|
60
|
+
openKeys: {
|
|
61
|
+
type: Array,
|
|
62
|
+
required: false,
|
|
63
|
+
default: void 0
|
|
64
|
+
},
|
|
65
|
+
rtl: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
required: false,
|
|
68
|
+
default: void 0
|
|
69
|
+
},
|
|
70
|
+
mode: {
|
|
71
|
+
type: String,
|
|
72
|
+
required: false,
|
|
73
|
+
default: void 0
|
|
74
|
+
},
|
|
75
|
+
disabled: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
required: false,
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
overflowDisabled: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
required: false,
|
|
83
|
+
default: void 0
|
|
84
|
+
},
|
|
85
|
+
activeKey: {
|
|
86
|
+
type: String,
|
|
87
|
+
required: false,
|
|
88
|
+
default: void 0
|
|
89
|
+
},
|
|
90
|
+
onActive: {
|
|
91
|
+
type: Function,
|
|
92
|
+
required: false,
|
|
93
|
+
default: void 0
|
|
94
|
+
},
|
|
95
|
+
onInactive: {
|
|
96
|
+
type: Function,
|
|
97
|
+
required: false,
|
|
98
|
+
default: void 0
|
|
99
|
+
},
|
|
100
|
+
selectedKeys: {
|
|
101
|
+
type: Array,
|
|
102
|
+
required: false,
|
|
103
|
+
default: void 0
|
|
104
|
+
},
|
|
105
|
+
inlineIndent: {
|
|
106
|
+
type: Number,
|
|
107
|
+
required: false,
|
|
108
|
+
default: void 0
|
|
109
|
+
},
|
|
110
|
+
motion: {
|
|
111
|
+
type: Object,
|
|
112
|
+
required: false,
|
|
113
|
+
default: void 0
|
|
114
|
+
},
|
|
115
|
+
defaultMotions: {
|
|
116
|
+
type: Object,
|
|
117
|
+
required: false,
|
|
118
|
+
default: void 0
|
|
119
|
+
},
|
|
120
|
+
subMenuOpenDelay: {
|
|
121
|
+
type: Number,
|
|
122
|
+
required: false,
|
|
123
|
+
default: void 0
|
|
124
|
+
},
|
|
125
|
+
subMenuCloseDelay: {
|
|
126
|
+
type: Number,
|
|
127
|
+
required: false,
|
|
128
|
+
default: void 0
|
|
129
|
+
},
|
|
130
|
+
forceSubMenuRender: {
|
|
131
|
+
type: Boolean,
|
|
132
|
+
required: false,
|
|
133
|
+
default: void 0
|
|
134
|
+
},
|
|
135
|
+
builtinPlacements: {
|
|
136
|
+
type: Object,
|
|
137
|
+
required: false,
|
|
138
|
+
default: void 0
|
|
139
|
+
},
|
|
140
|
+
triggerSubMenuAction: {
|
|
141
|
+
type: String,
|
|
142
|
+
required: false,
|
|
143
|
+
default: void 0
|
|
144
|
+
},
|
|
145
|
+
popupRender: {
|
|
146
|
+
type: Function,
|
|
147
|
+
required: false,
|
|
148
|
+
default: void 0
|
|
149
|
+
},
|
|
150
|
+
itemIcon: {
|
|
151
|
+
type: [String, Number, null, Array, Function, Boolean],
|
|
152
|
+
required: false,
|
|
153
|
+
skipCheck: true,
|
|
154
|
+
default: void 0
|
|
155
|
+
},
|
|
156
|
+
expandIcon: {
|
|
157
|
+
type: [String, Number, null, Array, Function, Boolean],
|
|
158
|
+
required: false,
|
|
159
|
+
skipCheck: true,
|
|
160
|
+
default: void 0
|
|
161
|
+
},
|
|
162
|
+
onItemClick: {
|
|
163
|
+
type: Function,
|
|
164
|
+
required: false,
|
|
165
|
+
default: void 0
|
|
166
|
+
},
|
|
167
|
+
onOpenChange: {
|
|
168
|
+
type: Function,
|
|
169
|
+
required: false,
|
|
170
|
+
default: void 0
|
|
171
|
+
},
|
|
172
|
+
getPopupContainer: {
|
|
173
|
+
type: Function,
|
|
174
|
+
required: false,
|
|
175
|
+
default: void 0
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
inheritAttrs: false
|
|
179
|
+
});
|
|
180
|
+
export {
|
|
181
|
+
InheritableContextProvider as default,
|
|
182
|
+
useMenuContext,
|
|
183
|
+
useMenuContextProvider
|
|
184
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const EmptyList = [];
|
|
5
|
+
const PathRegisterContextKey = Symbol("PathRegisterContext");
|
|
6
|
+
function useMeasure() {
|
|
7
|
+
return vue.inject(PathRegisterContextKey, null);
|
|
8
|
+
}
|
|
9
|
+
function useMeasureProvider(context) {
|
|
10
|
+
vue.provide(PathRegisterContextKey, context);
|
|
11
|
+
}
|
|
12
|
+
const MeasureProvider = /* @__PURE__ */ vue.defineComponent((props, {
|
|
13
|
+
slots
|
|
14
|
+
}) => {
|
|
15
|
+
useMeasureProvider(props);
|
|
16
|
+
return () => {
|
|
17
|
+
return slots?.default?.();
|
|
18
|
+
};
|
|
19
|
+
}, {
|
|
20
|
+
props: {
|
|
21
|
+
registerPath: {
|
|
22
|
+
type: Function,
|
|
23
|
+
required: true,
|
|
24
|
+
default: void 0
|
|
25
|
+
},
|
|
26
|
+
unregisterPath: {
|
|
27
|
+
type: Function,
|
|
28
|
+
required: true,
|
|
29
|
+
default: void 0
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const PathTrackerContextKey = Symbol("PathTrackerContext");
|
|
34
|
+
function useFullPath(eventKey) {
|
|
35
|
+
const parentKeyPath = vue.inject(PathTrackerContextKey, vue.ref(EmptyList));
|
|
36
|
+
return vue.computed(() => {
|
|
37
|
+
return eventKey !== void 0 ? [...parentKeyPath.value, eventKey.value] : parentKeyPath.value;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const PathTrackerProvider = /* @__PURE__ */ vue.defineComponent((props, {
|
|
41
|
+
slots
|
|
42
|
+
}) => {
|
|
43
|
+
vue.provide(PathTrackerContextKey, vue.computed(() => props.value));
|
|
44
|
+
return () => {
|
|
45
|
+
return slots?.default?.();
|
|
46
|
+
};
|
|
47
|
+
}, {
|
|
48
|
+
props: {
|
|
49
|
+
value: {
|
|
50
|
+
type: Array,
|
|
51
|
+
required: true,
|
|
52
|
+
default: void 0
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const PathUserContextKey = Symbol("PathUserContext");
|
|
57
|
+
function usePathUserContextProvider(context) {
|
|
58
|
+
vue.provide(PathUserContextKey, context);
|
|
59
|
+
}
|
|
60
|
+
function usePathUserContext() {
|
|
61
|
+
return vue.inject(PathUserContextKey, {
|
|
62
|
+
isSubPathKey: () => false
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const PathUserProvider = /* @__PURE__ */ vue.defineComponent((props, {
|
|
66
|
+
slots
|
|
67
|
+
}) => {
|
|
68
|
+
usePathUserContextProvider(props);
|
|
69
|
+
return () => {
|
|
70
|
+
return slots?.default?.();
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
props: {
|
|
74
|
+
isSubPathKey: {
|
|
75
|
+
type: Function,
|
|
76
|
+
required: true,
|
|
77
|
+
default: void 0
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const PathTrackerContext = {
|
|
82
|
+
Provider: PathTrackerProvider
|
|
83
|
+
};
|
|
84
|
+
const PathRegisterContext = {
|
|
85
|
+
Provider: MeasureProvider
|
|
86
|
+
};
|
|
87
|
+
const PathUserContext = {
|
|
88
|
+
Provider: PathUserProvider
|
|
89
|
+
};
|
|
90
|
+
exports.MeasureProvider = MeasureProvider;
|
|
91
|
+
exports.PathRegisterContext = PathRegisterContext;
|
|
92
|
+
exports.PathTrackerContext = PathTrackerContext;
|
|
93
|
+
exports.PathTrackerProvider = PathTrackerProvider;
|
|
94
|
+
exports.PathUserContext = PathUserContext;
|
|
95
|
+
exports.PathUserProvider = PathUserProvider;
|
|
96
|
+
exports.useFullPath = useFullPath;
|
|
97
|
+
exports.useMeasure = useMeasure;
|
|
98
|
+
exports.useMeasureProvider = useMeasureProvider;
|
|
99
|
+
exports.usePathUserContext = usePathUserContext;
|
|
100
|
+
exports.usePathUserContextProvider = usePathUserContextProvider;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export interface PathRegisterContextProps {
|
|
3
|
+
registerPath: (key: string, keyPath: string[]) => void;
|
|
4
|
+
unregisterPath: (key: string, keyPath: string[]) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function useMeasure(): PathRegisterContextProps | null;
|
|
7
|
+
export declare function useMeasureProvider(context: PathRegisterContextProps): void;
|
|
8
|
+
export declare const MeasureProvider: import('vue').DefineSetupFnComponent<PathRegisterContextProps, {}, {}, PathRegisterContextProps & {}, import('vue').PublicProps>;
|
|
9
|
+
export declare function useFullPath(eventKey?: Ref<string | undefined>): import('vue').ComputedRef<(string | undefined)[]>;
|
|
10
|
+
export declare const PathTrackerProvider: import('vue').DefineSetupFnComponent<{
|
|
11
|
+
value: string[];
|
|
12
|
+
}, {}, {}, {
|
|
13
|
+
value: string[];
|
|
14
|
+
} & {}, import('vue').PublicProps>;
|
|
15
|
+
export interface PathUserContextProps {
|
|
16
|
+
isSubPathKey: (pathKeys: string[], eventKey: string) => boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function usePathUserContextProvider(context: PathUserContextProps): void;
|
|
19
|
+
export declare function usePathUserContext(): PathUserContextProps;
|
|
20
|
+
export declare const PathUserProvider: import('vue').DefineSetupFnComponent<PathUserContextProps, {}, {}, PathUserContextProps & {}, import('vue').PublicProps>;
|
|
21
|
+
export declare const PathTrackerContext: {
|
|
22
|
+
Provider: import('vue').DefineSetupFnComponent<{
|
|
23
|
+
value: string[];
|
|
24
|
+
}, {}, {}, {
|
|
25
|
+
value: string[];
|
|
26
|
+
} & {}, import('vue').PublicProps>;
|
|
27
|
+
};
|
|
28
|
+
export declare const PathRegisterContext: {
|
|
29
|
+
Provider: import('vue').DefineSetupFnComponent<PathRegisterContextProps, {}, {}, PathRegisterContextProps & {}, import('vue').PublicProps>;
|
|
30
|
+
};
|
|
31
|
+
export declare const PathUserContext: {
|
|
32
|
+
Provider: import('vue').DefineSetupFnComponent<PathUserContextProps, {}, {}, PathUserContextProps & {}, import('vue').PublicProps>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { defineComponent, inject, ref, computed, provide } from "vue";
|
|
2
|
+
const EmptyList = [];
|
|
3
|
+
const PathRegisterContextKey = Symbol("PathRegisterContext");
|
|
4
|
+
function useMeasure() {
|
|
5
|
+
return inject(PathRegisterContextKey, null);
|
|
6
|
+
}
|
|
7
|
+
function useMeasureProvider(context) {
|
|
8
|
+
provide(PathRegisterContextKey, context);
|
|
9
|
+
}
|
|
10
|
+
const MeasureProvider = /* @__PURE__ */ defineComponent((props, {
|
|
11
|
+
slots
|
|
12
|
+
}) => {
|
|
13
|
+
useMeasureProvider(props);
|
|
14
|
+
return () => {
|
|
15
|
+
return slots?.default?.();
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
props: {
|
|
19
|
+
registerPath: {
|
|
20
|
+
type: Function,
|
|
21
|
+
required: true,
|
|
22
|
+
default: void 0
|
|
23
|
+
},
|
|
24
|
+
unregisterPath: {
|
|
25
|
+
type: Function,
|
|
26
|
+
required: true,
|
|
27
|
+
default: void 0
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const PathTrackerContextKey = Symbol("PathTrackerContext");
|
|
32
|
+
function useFullPath(eventKey) {
|
|
33
|
+
const parentKeyPath = inject(PathTrackerContextKey, ref(EmptyList));
|
|
34
|
+
return computed(() => {
|
|
35
|
+
return eventKey !== void 0 ? [...parentKeyPath.value, eventKey.value] : parentKeyPath.value;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const PathTrackerProvider = /* @__PURE__ */ defineComponent((props, {
|
|
39
|
+
slots
|
|
40
|
+
}) => {
|
|
41
|
+
provide(PathTrackerContextKey, computed(() => props.value));
|
|
42
|
+
return () => {
|
|
43
|
+
return slots?.default?.();
|
|
44
|
+
};
|
|
45
|
+
}, {
|
|
46
|
+
props: {
|
|
47
|
+
value: {
|
|
48
|
+
type: Array,
|
|
49
|
+
required: true,
|
|
50
|
+
default: void 0
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const PathUserContextKey = Symbol("PathUserContext");
|
|
55
|
+
function usePathUserContextProvider(context) {
|
|
56
|
+
provide(PathUserContextKey, context);
|
|
57
|
+
}
|
|
58
|
+
function usePathUserContext() {
|
|
59
|
+
return inject(PathUserContextKey, {
|
|
60
|
+
isSubPathKey: () => false
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const PathUserProvider = /* @__PURE__ */ defineComponent((props, {
|
|
64
|
+
slots
|
|
65
|
+
}) => {
|
|
66
|
+
usePathUserContextProvider(props);
|
|
67
|
+
return () => {
|
|
68
|
+
return slots?.default?.();
|
|
69
|
+
};
|
|
70
|
+
}, {
|
|
71
|
+
props: {
|
|
72
|
+
isSubPathKey: {
|
|
73
|
+
type: Function,
|
|
74
|
+
required: true,
|
|
75
|
+
default: void 0
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const PathTrackerContext = {
|
|
80
|
+
Provider: PathTrackerProvider
|
|
81
|
+
};
|
|
82
|
+
const PathRegisterContext = {
|
|
83
|
+
Provider: MeasureProvider
|
|
84
|
+
};
|
|
85
|
+
const PathUserContext = {
|
|
86
|
+
Provider: PathUserProvider
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
MeasureProvider,
|
|
90
|
+
PathRegisterContext,
|
|
91
|
+
PathTrackerContext,
|
|
92
|
+
PathTrackerProvider,
|
|
93
|
+
PathUserContext,
|
|
94
|
+
PathUserProvider,
|
|
95
|
+
useFullPath,
|
|
96
|
+
useMeasure,
|
|
97
|
+
useMeasureProvider,
|
|
98
|
+
usePathUserContext,
|
|
99
|
+
usePathUserContextProvider
|
|
100
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const PrivateContextKey = Symbol("PrivateContext");
|
|
5
|
+
function usePrivateProvider(context) {
|
|
6
|
+
vue.provide(PrivateContextKey, context);
|
|
7
|
+
}
|
|
8
|
+
function usePrivateContext() {
|
|
9
|
+
return vue.inject(PrivateContextKey, {});
|
|
10
|
+
}
|
|
11
|
+
const PrivateContextProvider = vue.defineComponent(
|
|
12
|
+
(props, { slots }) => {
|
|
13
|
+
usePrivateProvider(props);
|
|
14
|
+
return () => {
|
|
15
|
+
return slots?.default?.();
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
props: ["_internalRenderMenuItem", "_internalRenderSubMenuItem"]
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
exports.PrivateContextProvider = PrivateContextProvider;
|
|
23
|
+
exports.usePrivateContext = usePrivateContext;
|
|
24
|
+
exports.usePrivateProvider = usePrivateProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MenuProps } from '../Menu';
|
|
2
|
+
export interface PrivateContextProps {
|
|
3
|
+
_internalRenderMenuItem?: MenuProps['_internalRenderMenuItem'];
|
|
4
|
+
_internalRenderSubMenuItem?: MenuProps['_internalRenderSubMenuItem'];
|
|
5
|
+
}
|
|
6
|
+
export declare function usePrivateProvider(context: PrivateContextProps): void;
|
|
7
|
+
export declare function usePrivateContext(): PrivateContextProps;
|
|
8
|
+
export declare const PrivateContextProvider: import('vue').DefineSetupFnComponent<PrivateContextProps, {}, {}, PrivateContextProps & {}, import('vue').PublicProps>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineComponent, provide, inject } from "vue";
|
|
2
|
+
const PrivateContextKey = Symbol("PrivateContext");
|
|
3
|
+
function usePrivateProvider(context) {
|
|
4
|
+
provide(PrivateContextKey, context);
|
|
5
|
+
}
|
|
6
|
+
function usePrivateContext() {
|
|
7
|
+
return inject(PrivateContextKey, {});
|
|
8
|
+
}
|
|
9
|
+
const PrivateContextProvider = defineComponent(
|
|
10
|
+
(props, { slots }) => {
|
|
11
|
+
usePrivateProvider(props);
|
|
12
|
+
return () => {
|
|
13
|
+
return slots?.default?.();
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
props: ["_internalRenderMenuItem", "_internalRenderSubMenuItem"]
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
export {
|
|
21
|
+
PrivateContextProvider,
|
|
22
|
+
usePrivateContext,
|
|
23
|
+
usePrivateProvider
|
|
24
|
+
};
|