vft 0.0.345 → 0.0.346
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/index.css +1 -1
- package/es/components/dropdown/dropdown-item-impl.vue.d.ts +106 -60
- package/es/components/dropdown/dropdown-item-impl.vue.js +34 -2
- package/es/components/dropdown/dropdown-item-impl.vue2.js +50 -72
- package/es/components/dropdown/dropdown-item.vue.js +33 -2
- package/es/components/dropdown/dropdown-item.vue2.js +40 -61
- package/es/components/dropdown/dropdown-menu.vue.d.ts +26 -21
- package/es/components/dropdown/dropdown-menu.vue.js +22 -2
- package/es/components/dropdown/dropdown-menu.vue2.js +68 -76
- package/es/components/dropdown/dropdown.js +182 -0
- package/es/components/dropdown/dropdown.vue.js +126 -2
- package/es/components/dropdown/dropdown.vue2.js +112 -231
- package/es/components/dropdown/index.js +13 -12
- package/es/components/dropdown/instance.d.ts +2 -0
- package/es/components/dropdown/instance.js +1 -0
- package/es/components/dropdown/tokens.d.ts +5 -4
- package/es/components/dropdown/tokens.js +3 -2
- package/es/components/dropdown/useDropdown.d.ts +1 -2
- package/es/components/dropdown/useDropdown.js +10 -51
- package/es/components/index.js +179 -178
- package/es/components/roving-focus-group/index.js +14 -14
- package/es/components/roving-focus-group/roving-focus-group.vue.js +19 -2
- package/es/components/roving-focus-group/roving-focus-group.vue2.js +7 -21
- package/es/index.js +247 -246
- package/es/package.json.d.ts +1 -1
- package/es/package.json.js +1 -1
- package/lib/components/dropdown/dropdown-item-impl.vue.cjs +1 -1
- package/lib/components/dropdown/dropdown-item-impl.vue.d.ts +106 -60
- package/lib/components/dropdown/dropdown-item-impl.vue2.cjs +1 -1
- package/lib/components/dropdown/dropdown-item.vue.cjs +1 -1
- package/lib/components/dropdown/dropdown-item.vue2.cjs +1 -1
- package/lib/components/dropdown/dropdown-menu.vue.cjs +1 -1
- package/lib/components/dropdown/dropdown-menu.vue.d.ts +26 -21
- package/lib/components/dropdown/dropdown-menu.vue2.cjs +1 -1
- package/lib/components/dropdown/dropdown.cjs +1 -0
- package/lib/components/dropdown/dropdown.vue.cjs +1 -1
- package/lib/components/dropdown/dropdown.vue2.cjs +1 -1
- package/lib/components/dropdown/index.cjs +1 -1
- package/lib/components/dropdown/instance.cjs +1 -0
- package/lib/components/dropdown/instance.d.ts +2 -0
- package/lib/components/dropdown/tokens.cjs +1 -1
- package/lib/components/dropdown/tokens.d.ts +5 -4
- package/lib/components/dropdown/useDropdown.cjs +1 -1
- package/lib/components/dropdown/useDropdown.d.ts +1 -2
- package/lib/components/index.cjs +1 -1
- package/lib/components/roving-focus-group/index.cjs +1 -1
- package/lib/components/roving-focus-group/roving-focus-group.vue.cjs +1 -1
- package/lib/components/roving-focus-group/roving-focus-group.vue2.cjs +1 -1
- package/lib/index.cjs +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/package.json +3 -3
- package/theme-style/index.css +1 -1
- package/theme-style/src/dropdown.scss +49 -45
- package/theme-style/vft-dropdown.css +1 -1
- package/web-types.json +1 -1
- package/es/components/dropdown/dropdown-item.vue.d.ts +0 -61
- package/es/components/dropdown/dropdown.vue.d.ts +0 -86
- package/es/components/dropdown/index.d.ts +0 -596
- package/es/components/dropdown/types.js +0 -21
- package/es/components/roving-focus-group/roving-focus-group.vue.d.ts +0 -11
- package/lib/components/dropdown/dropdown-item.vue.d.ts +0 -61
- package/lib/components/dropdown/dropdown.vue.d.ts +0 -86
- package/lib/components/dropdown/index.d.ts +0 -596
- package/lib/components/dropdown/types.cjs +0 -1
- package/lib/components/roving-focus-group/roving-focus-group.vue.d.ts +0 -11
|
@@ -1,269 +1,150 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import "../
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { defineComponent as A, getCurrentInstance as G, ref as o, computed as i, watch as H, onBeforeUnmount as K, provide as g, toRef as C, unref as P } from "vue";
|
|
2
|
+
import { VftButton as E } from "../button/index.js";
|
|
3
|
+
import { VftTooltip as x } from "../tooltip/index.js";
|
|
4
|
+
import { VftScrollbar as U } from "../scrollbar/index.js";
|
|
5
|
+
import { VftIcon as z } from "../icon/index.js";
|
|
6
|
+
import J from "../roving-focus-group/roving-focus-group.vue.js";
|
|
6
7
|
import "../roving-focus-group/roving-focus-group-impl.vue2.js";
|
|
7
8
|
import "../roving-focus-group/roving-focus-item.vue2.js";
|
|
8
9
|
import "../roving-focus-group/types.js";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { OnlyChild as se } from "../slot/only-child.js";
|
|
12
|
-
import { VftTooltip as pe } from "../tooltip/index.js";
|
|
10
|
+
import { OnlyChild as M } from "../slot/only-child.js";
|
|
11
|
+
import "../form/index.js";
|
|
13
12
|
import "@vueuse/core";
|
|
14
|
-
import
|
|
15
|
-
import { addUnit as
|
|
13
|
+
import "@vft/utils";
|
|
14
|
+
import { addUnit as W, castArray as Y } from "../../utils/helper.js";
|
|
16
15
|
import "lodash-es";
|
|
17
|
-
import { useId as
|
|
18
|
-
import { useNamespace as
|
|
16
|
+
import { useId as j } from "../../hooks/use-id/index.js";
|
|
17
|
+
import { useNamespace as q } from "../../hooks/use-namespace/index.js";
|
|
19
18
|
import "../../hooks/use-model-toggle/index.js";
|
|
20
19
|
import "@popperjs/core";
|
|
21
20
|
import "../../hooks/use-z-index/index.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { useFormSize as
|
|
25
|
-
const
|
|
26
|
-
name: "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
size: {},
|
|
37
|
-
splitButton: { type: Boolean },
|
|
38
|
-
hideOnClick: { type: Boolean, default: !0 },
|
|
39
|
-
loop: { type: Boolean, default: !0 },
|
|
40
|
-
showTimeout: { default: 150 },
|
|
41
|
-
hideTimeout: { default: 150 },
|
|
42
|
-
tabindex: { default: 0 },
|
|
43
|
-
maxHeight: { default: "" },
|
|
44
|
-
popperClass: { default: "" },
|
|
45
|
-
disabled: { type: Boolean, default: !1 },
|
|
46
|
-
role: { default: "menu" },
|
|
47
|
-
buttonProps: {},
|
|
48
|
-
teleported: { type: Boolean, default: !0 }
|
|
21
|
+
import { dropdownProps as Q, VftCollection as X } from "./dropdown.js";
|
|
22
|
+
import { DROPDOWN_INJECTION_KEY as Z, DROPDOWN_INSTANCE_INJECTION_KEY as ee } from "./tokens.js";
|
|
23
|
+
import { useFormSize as oe } from "../form/hooks/use-form-common-props.js";
|
|
24
|
+
const { ButtonGroup: ne } = E, $e = A({
|
|
25
|
+
name: "VftDropdown",
|
|
26
|
+
components: {
|
|
27
|
+
VftButton: E,
|
|
28
|
+
VftButtonGroup: ne,
|
|
29
|
+
VftScrollbar: U,
|
|
30
|
+
DropdownCollection: X,
|
|
31
|
+
VftTooltip: x,
|
|
32
|
+
RovingFocusGroup: J,
|
|
33
|
+
OnlyChild: M,
|
|
34
|
+
VftIcon: z
|
|
49
35
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
props: Q,
|
|
37
|
+
emits: ["visible-change", "click", "command"],
|
|
38
|
+
setup(n, { emit: l }) {
|
|
39
|
+
const I = G(), s = q("dropdown"), t = o(), T = o(), u = o(), r = o(), w = o(null), a = o(null), m = o(!1), O = i(() => ({
|
|
40
|
+
maxHeight: W(n.maxHeight)
|
|
41
|
+
})), S = i(() => [s.m(f.value)]), p = i(() => Y(n.trigger)), L = j().value, d = i(() => n.id || L);
|
|
42
|
+
H(
|
|
43
|
+
[t, p],
|
|
44
|
+
([e, F], [h]) => {
|
|
45
|
+
h?.$el?.removeEventListener && h.$el.removeEventListener(
|
|
60
46
|
"pointerenter",
|
|
61
|
-
|
|
47
|
+
c
|
|
62
48
|
), e?.$el?.removeEventListener && e.$el.removeEventListener(
|
|
63
49
|
"pointerenter",
|
|
64
|
-
|
|
65
|
-
), e?.$el?.addEventListener &&
|
|
50
|
+
c
|
|
51
|
+
), e?.$el?.addEventListener && F.includes("hover") && e.$el.addEventListener(
|
|
66
52
|
"pointerenter",
|
|
67
|
-
|
|
53
|
+
c
|
|
68
54
|
);
|
|
69
55
|
},
|
|
70
56
|
{ immediate: !0 }
|
|
71
|
-
),
|
|
72
|
-
|
|
57
|
+
), K(() => {
|
|
58
|
+
t.value?.$el?.removeEventListener && t.value.$el.removeEventListener(
|
|
73
59
|
"pointerenter",
|
|
74
|
-
|
|
60
|
+
c
|
|
75
61
|
);
|
|
76
62
|
});
|
|
77
|
-
function
|
|
78
|
-
|
|
63
|
+
function N() {
|
|
64
|
+
v();
|
|
79
65
|
}
|
|
80
|
-
function
|
|
66
|
+
function v() {
|
|
81
67
|
u.value?.onClose();
|
|
82
68
|
}
|
|
83
|
-
function
|
|
69
|
+
function R() {
|
|
84
70
|
u.value?.onOpen();
|
|
85
71
|
}
|
|
86
|
-
const
|
|
87
|
-
function
|
|
88
|
-
|
|
72
|
+
const f = oe();
|
|
73
|
+
function $(...e) {
|
|
74
|
+
l("command", ...e);
|
|
89
75
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
76
|
+
function c() {
|
|
77
|
+
t.value?.$el?.focus({
|
|
78
|
+
preventScroll: !0
|
|
79
|
+
});
|
|
92
80
|
}
|
|
93
|
-
function
|
|
81
|
+
function b() {
|
|
94
82
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
83
|
+
function k() {
|
|
84
|
+
const e = P(r);
|
|
85
|
+
p.value.includes("hover") && e?.focus({
|
|
86
|
+
preventScroll: !0
|
|
87
|
+
}), a.value = null;
|
|
97
88
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
89
|
+
function B(e) {
|
|
90
|
+
a.value = e;
|
|
100
91
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
92
|
+
function D(e) {
|
|
93
|
+
m.value || (e.preventDefault(), e.stopImmediatePropagation());
|
|
103
94
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
95
|
+
function V() {
|
|
96
|
+
l("visible-change", !0);
|
|
106
97
|
}
|
|
107
|
-
function
|
|
108
|
-
e?.type === "keydown" &&
|
|
98
|
+
function _(e) {
|
|
99
|
+
e?.type === "keydown" && r.value?.focus();
|
|
109
100
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
101
|
+
function y() {
|
|
102
|
+
l("visible-change", !1);
|
|
112
103
|
}
|
|
113
|
-
|
|
114
|
-
contentRef:
|
|
115
|
-
role:
|
|
116
|
-
triggerId:
|
|
117
|
-
isUsingKeyboard:
|
|
118
|
-
onItemEnter:
|
|
119
|
-
onItemLeave:
|
|
120
|
-
}),
|
|
121
|
-
instance:
|
|
122
|
-
dropdownSize:
|
|
123
|
-
handleClick:
|
|
124
|
-
commandHandler:
|
|
125
|
-
trigger:
|
|
126
|
-
hideOnClick:
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
104
|
+
return g(Z, {
|
|
105
|
+
contentRef: r,
|
|
106
|
+
role: i(() => n.role),
|
|
107
|
+
triggerId: d,
|
|
108
|
+
isUsingKeyboard: m,
|
|
109
|
+
onItemEnter: b,
|
|
110
|
+
onItemLeave: k
|
|
111
|
+
}), g(ee, {
|
|
112
|
+
instance: I,
|
|
113
|
+
dropdownSize: f,
|
|
114
|
+
handleClick: N,
|
|
115
|
+
commandHandler: $,
|
|
116
|
+
trigger: C(n, "trigger"),
|
|
117
|
+
hideOnClick: C(n, "hideOnClick")
|
|
118
|
+
}), {
|
|
119
|
+
ns: s,
|
|
120
|
+
scrollbar: w,
|
|
121
|
+
wrapStyle: O,
|
|
122
|
+
dropdownTriggerKls: S,
|
|
123
|
+
dropdownSize: f,
|
|
124
|
+
triggerId: d,
|
|
125
|
+
currentTabId: a,
|
|
126
|
+
handleCurrentTabIdChange: B,
|
|
127
|
+
handlerMainButtonClick: (e) => {
|
|
128
|
+
l("click", e);
|
|
129
|
+
},
|
|
130
|
+
handleEntryFocus: D,
|
|
131
|
+
handleClose: v,
|
|
132
|
+
handleOpen: R,
|
|
133
|
+
handleBeforeShowTooltip: V,
|
|
134
|
+
handleShowTooltip: _,
|
|
135
|
+
handleBeforeHideTooltip: y,
|
|
136
|
+
onFocusAfterTrapped: (e) => {
|
|
137
|
+
e.preventDefault(), r.value?.focus?.({
|
|
138
|
+
preventScroll: !0
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
popperRef: u,
|
|
142
|
+
contentRef: r,
|
|
143
|
+
triggeringElementRef: t,
|
|
144
|
+
referenceElementRef: T
|
|
134
145
|
};
|
|
135
|
-
return R({
|
|
136
|
-
handleClose: k,
|
|
137
|
-
handleOpen: F,
|
|
138
|
-
// Todo
|
|
139
|
-
onFocusAfterTrapped: q
|
|
140
|
-
}), (e, f) => (T(), ee("div", {
|
|
141
|
-
class: $([t(n).b(), t(n).is("disabled", e.disabled)])
|
|
142
|
-
}, [
|
|
143
|
-
r(t(pe), {
|
|
144
|
-
ref_key: "popperRef",
|
|
145
|
-
ref: u,
|
|
146
|
-
role: e.role,
|
|
147
|
-
effect: e.effect,
|
|
148
|
-
"fallback-placements": ["bottom", "top"],
|
|
149
|
-
"popper-options": e.popperOptions,
|
|
150
|
-
"gpu-acceleration": !1,
|
|
151
|
-
"hide-after": e.trigger === "hover" ? e.hideTimeout : 0,
|
|
152
|
-
"manual-mode": !0,
|
|
153
|
-
placement: e.placement,
|
|
154
|
-
"popper-class": [t(n).e("popper"), e.popperClass],
|
|
155
|
-
"reference-element": w.value?.$el,
|
|
156
|
-
trigger: e.trigger,
|
|
157
|
-
"trigger-keys": D,
|
|
158
|
-
"trigger-target-el": s.value,
|
|
159
|
-
"show-after": e.trigger === "hover" ? e.showTimeout : 0,
|
|
160
|
-
"stop-popper-mouse-event": !1,
|
|
161
|
-
"virtual-ref": l.value,
|
|
162
|
-
"virtual-triggering": e.splitButton,
|
|
163
|
-
disabled: e.disabled,
|
|
164
|
-
transition: `${t(n).namespace.value}-zoom-in-top`,
|
|
165
|
-
teleported: e.teleported,
|
|
166
|
-
pure: "",
|
|
167
|
-
persistent: "",
|
|
168
|
-
onBeforeShow: W,
|
|
169
|
-
onShow: Y,
|
|
170
|
-
onBeforeHide: j
|
|
171
|
-
}, re({
|
|
172
|
-
content: o(() => [
|
|
173
|
-
r(t(ae), {
|
|
174
|
-
ref_key: "scrollbar",
|
|
175
|
-
ref: N,
|
|
176
|
-
"wrap-style": H.value,
|
|
177
|
-
tag: "div",
|
|
178
|
-
"view-class": [t(n).e("list"), "test"]
|
|
179
|
-
}, {
|
|
180
|
-
default: o(() => [
|
|
181
|
-
r(t(ie), {
|
|
182
|
-
loop: e.loop,
|
|
183
|
-
"current-tab-id": m.value,
|
|
184
|
-
orientation: "horizontal",
|
|
185
|
-
onCurrentTabIdChange: J,
|
|
186
|
-
onEntryFocus: M
|
|
187
|
-
}, {
|
|
188
|
-
default: o(() => [
|
|
189
|
-
r(t(ve), null, {
|
|
190
|
-
default: o(() => [
|
|
191
|
-
h(e.$slots, "dropdown")
|
|
192
|
-
]),
|
|
193
|
-
_: 3
|
|
194
|
-
})
|
|
195
|
-
]),
|
|
196
|
-
_: 3
|
|
197
|
-
}, 8, ["loop", "current-tab-id"])
|
|
198
|
-
]),
|
|
199
|
-
_: 3
|
|
200
|
-
}, 8, ["wrap-style", "view-class"])
|
|
201
|
-
]),
|
|
202
|
-
_: 2
|
|
203
|
-
}, [
|
|
204
|
-
e.splitButton ? void 0 : {
|
|
205
|
-
name: "default",
|
|
206
|
-
fn: o(() => [
|
|
207
|
-
r(t(se), {
|
|
208
|
-
id: c.value,
|
|
209
|
-
ref_key: "triggeringElementRef",
|
|
210
|
-
ref: l,
|
|
211
|
-
role: "button",
|
|
212
|
-
tabindex: e.tabindex
|
|
213
|
-
}, {
|
|
214
|
-
default: o(() => [
|
|
215
|
-
h(e.$slots, "default")
|
|
216
|
-
]),
|
|
217
|
-
_: 3
|
|
218
|
-
}, 8, ["id", "tabindex"])
|
|
219
|
-
]),
|
|
220
|
-
key: "0"
|
|
221
|
-
}
|
|
222
|
-
]), 1032, ["role", "effect", "popper-options", "hide-after", "placement", "popper-class", "reference-element", "trigger", "trigger-target-el", "show-after", "virtual-ref", "virtual-triggering", "disabled", "transition", "teleported"]),
|
|
223
|
-
e.splitButton ? (T(), te(t(ne), { key: 0 }, {
|
|
224
|
-
default: o(() => [
|
|
225
|
-
r(t(O), I({
|
|
226
|
-
ref_key: "referenceElementRef",
|
|
227
|
-
ref: w
|
|
228
|
-
}, e.buttonProps, {
|
|
229
|
-
size: t(v),
|
|
230
|
-
type: e.type,
|
|
231
|
-
disabled: e.disabled,
|
|
232
|
-
tabindex: e.tabindex,
|
|
233
|
-
onClick: Q
|
|
234
|
-
}), {
|
|
235
|
-
default: o(() => [
|
|
236
|
-
h(e.$slots, "default")
|
|
237
|
-
]),
|
|
238
|
-
_: 3
|
|
239
|
-
}, 16, ["size", "type", "disabled", "tabindex"]),
|
|
240
|
-
r(t(O), I({
|
|
241
|
-
id: c.value,
|
|
242
|
-
ref_key: "triggeringElementRef",
|
|
243
|
-
ref: l
|
|
244
|
-
}, e.buttonProps, {
|
|
245
|
-
role: "button",
|
|
246
|
-
size: t(v),
|
|
247
|
-
type: e.type,
|
|
248
|
-
class: t(n).e("caret-button"),
|
|
249
|
-
disabled: e.disabled,
|
|
250
|
-
tabindex: e.tabindex,
|
|
251
|
-
"aria-label": "切换下拉菜单"
|
|
252
|
-
}), {
|
|
253
|
-
default: o(() => [
|
|
254
|
-
r(t(le), {
|
|
255
|
-
class: $(t(n).e("icon")),
|
|
256
|
-
icon: "icon-arrow-down"
|
|
257
|
-
}, null, 8, ["class"])
|
|
258
|
-
]),
|
|
259
|
-
_: 1
|
|
260
|
-
}, 16, ["id", "size", "type", "class", "disabled", "tabindex"])
|
|
261
|
-
]),
|
|
262
|
-
_: 3
|
|
263
|
-
})) : oe("", !0)
|
|
264
|
-
], 2));
|
|
265
146
|
}
|
|
266
147
|
});
|
|
267
148
|
export {
|
|
268
|
-
|
|
149
|
+
$e as default
|
|
269
150
|
};
|
|
@@ -2,20 +2,21 @@ import "@vueuse/core";
|
|
|
2
2
|
import "@vft/utils";
|
|
3
3
|
import "../config-provider/hooks/use-global-config.js";
|
|
4
4
|
import "vue";
|
|
5
|
-
import { withInstall as
|
|
5
|
+
import { withInstall as p, withNoopInstall as o } from "../../utils/vue/install.js";
|
|
6
6
|
import "lodash-es";
|
|
7
|
-
import
|
|
8
|
-
import t from "./dropdown-item.
|
|
9
|
-
import r from "./dropdown-menu.
|
|
10
|
-
import { DROPDOWN_INJECTION_KEY as
|
|
11
|
-
const
|
|
7
|
+
import m from "./dropdown.vue.js";
|
|
8
|
+
import t from "./dropdown-item.vue.js";
|
|
9
|
+
import r from "./dropdown-menu.vue.js";
|
|
10
|
+
import { DROPDOWN_INJECTION_KEY as a, DROPDOWN_INSTANCE_INJECTION_KEY as c } from "./tokens.js";
|
|
11
|
+
const s = p(m, {
|
|
12
12
|
DropdownItem: t,
|
|
13
13
|
DropdownMenu: r
|
|
14
|
-
}),
|
|
14
|
+
}), O = o(t), l = o(r);
|
|
15
15
|
export {
|
|
16
|
-
|
|
17
|
-
c as
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
a as DROPDOWN_INJECTION_KEY,
|
|
17
|
+
c as DROPDOWN_INSTANCE_INJECTION_KEY,
|
|
18
|
+
s as VftDropdown,
|
|
19
|
+
O as VftDropdownItem,
|
|
20
|
+
l as VftDropdownMenu,
|
|
21
|
+
s as default
|
|
21
22
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ComputedRef, InjectionKey, Ref } from 'vue';
|
|
2
|
-
export type
|
|
3
|
-
contentRef: Ref<HTMLElement |
|
|
4
|
-
role:
|
|
2
|
+
export type ElDropdownInjectionContext = {
|
|
3
|
+
contentRef: Ref<HTMLElement | undefined>;
|
|
4
|
+
role: any;
|
|
5
5
|
triggerId: ComputedRef<string>;
|
|
6
6
|
isUsingKeyboard: Ref<boolean>;
|
|
7
7
|
onItemLeave: (e: PointerEvent) => void;
|
|
8
8
|
onItemEnter: (e: PointerEvent) => void;
|
|
9
9
|
};
|
|
10
|
-
export declare const DROPDOWN_INJECTION_KEY: InjectionKey<
|
|
10
|
+
export declare const DROPDOWN_INJECTION_KEY: InjectionKey<ElDropdownInjectionContext>;
|
|
11
|
+
export declare const DROPDOWN_INSTANCE_INJECTION_KEY = "vftDropdown";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { IElDropdownInstance } from './
|
|
1
|
+
import type { IElDropdownInstance } from './dropdown';
|
|
2
2
|
export declare const useDropdown: () => {
|
|
3
3
|
elDropdown: IElDropdownInstance;
|
|
4
4
|
_elDropdownSize: import("vue").ComputedRef<import("vue").ComputedRef<string> | undefined>;
|
|
5
5
|
};
|
|
6
|
-
export declare const initDropdownDomEvent: (dropdownChildren: any, triggerElm: any, _instance: any) => void;
|
|
@@ -1,56 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "../../hooks/use-model-toggle/index.js";
|
|
9
|
-
import "@popperjs/core";
|
|
10
|
-
import "../../hooks/use-z-index/index.js";
|
|
11
|
-
const F = () => {
|
|
12
|
-
const r = C("elDropdown", {}), o = O(() => r?.dropdownSize);
|
|
1
|
+
import { inject as e, computed as n } from "vue";
|
|
2
|
+
import { DROPDOWN_INSTANCE_INJECTION_KEY as t } from "./tokens.js";
|
|
3
|
+
const c = () => {
|
|
4
|
+
const o = e(
|
|
5
|
+
t,
|
|
6
|
+
{}
|
|
7
|
+
), r = n(() => o?.dropdownSize);
|
|
13
8
|
return {
|
|
14
|
-
elDropdown:
|
|
15
|
-
_elDropdownSize:
|
|
9
|
+
elDropdown: o,
|
|
10
|
+
_elDropdownSize: r
|
|
16
11
|
};
|
|
17
|
-
}, V = (r, o, i) => {
|
|
18
|
-
const x = S("dropdown"), u = p(null), d = p(null), s = p(null), f = p(`dropdown-menu-${k()}`);
|
|
19
|
-
s.value = r?.subTree.el;
|
|
20
|
-
function c() {
|
|
21
|
-
o.setAttribute("tabindex", "-1"), d.value?.forEach((e) => {
|
|
22
|
-
e.setAttribute("tabindex", "-1");
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function b(e) {
|
|
26
|
-
c(), e?.setAttribute("tabindex", "0");
|
|
27
|
-
}
|
|
28
|
-
function D(e) {
|
|
29
|
-
const n = e.code;
|
|
30
|
-
[t.up, t.down].includes(n) ? (c(), b(u.value[0]), u.value[0].focus(), e.preventDefault(), e.stopPropagation()) : n === t.enter ? i.handleClick() : [t.tab, t.esc].includes(n) && i.hide();
|
|
31
|
-
}
|
|
32
|
-
function A(e) {
|
|
33
|
-
const n = e.code, v = e.target, l = d.value.indexOf(v), w = d.value.length - 1;
|
|
34
|
-
let a;
|
|
35
|
-
[t.up, t.down].includes(n) ? (n === t.up ? a = l !== 0 ? l - 1 : 0 : a = l < w ? l + 1 : w, c(), b(u.value[a]), u.value[a].focus(), e.preventDefault(), e.stopPropagation()) : n === t.enter ? (m(), v.click(), i.props.hideOnClick && i.hide()) : [t.tab, t.esc].includes(n) && (i.hide(), m());
|
|
36
|
-
}
|
|
37
|
-
function h() {
|
|
38
|
-
s.value.setAttribute("id", f.value), o.setAttribute("aria-haspopup", "list"), o.setAttribute("aria-controls", f.value), i.props.splitButton || (o.setAttribute("role", "button"), o.setAttribute("tabindex", i.props.tabindex), T(o, x.b("selfdefine")));
|
|
39
|
-
}
|
|
40
|
-
function y() {
|
|
41
|
-
o?.addEventListener("keydown", D), s.value?.addEventListener("keydown", A, !0);
|
|
42
|
-
}
|
|
43
|
-
function I() {
|
|
44
|
-
u.value = s.value.querySelectorAll(
|
|
45
|
-
"[tabindex='-1']"
|
|
46
|
-
), d.value = Array.from(u.value), y(), h();
|
|
47
|
-
}
|
|
48
|
-
function m() {
|
|
49
|
-
o.focus();
|
|
50
|
-
}
|
|
51
|
-
I();
|
|
52
12
|
};
|
|
53
13
|
export {
|
|
54
|
-
|
|
55
|
-
F as useDropdown
|
|
14
|
+
c as useDropdown
|
|
56
15
|
};
|