@vue-interface/dropdown-menu 2.0.0-beta.2 → 2.0.0-beta.3
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/dropdown-menu.es.js +33 -30
- package/dist/dropdown-menu.umd.js +1 -1
- package/package.json +1 -1
- package/src/DropdownMenuItems.vue +10 -9
package/dist/dropdown-menu.es.js
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
import { h as
|
|
1
|
+
import { h as d, resolveComponent as m, openBlock as u, createElementBlock as f, normalizeClass as w, createVNode as h, withCtx as y, renderSlot as g } from "vue";
|
|
2
2
|
function s(e, t) {
|
|
3
3
|
e.props.class = `${e.props.class || ""} ${t}`.trim();
|
|
4
4
|
}
|
|
5
5
|
function i(e, t) {
|
|
6
|
-
return (
|
|
7
|
-
typeof t == "function" && t(
|
|
6
|
+
return (n) => {
|
|
7
|
+
typeof t == "function" && t(n), n.cancelBubble || e(n);
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
function p(e, t) {
|
|
11
11
|
return e.attrs.on[t] || e.type && e.type.listeners && e.componentOptions.listeners[t];
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
function _(e) {
|
|
14
|
+
return e && e.type && (e.type === "fragment" || typeof e.type == "symbol");
|
|
15
|
+
}
|
|
16
|
+
function a(e) {
|
|
17
|
+
for (const t of e) {
|
|
18
|
+
if (_(t))
|
|
19
|
+
return a(t.children);
|
|
17
20
|
t.props = Object.assign({ class: void 0 }, t.props), t.attrs = Object.assign({}, t.attrs), t.attrs.on || (t.attrs.on = {});
|
|
18
|
-
const
|
|
19
|
-
t.attrs.on.click = i((
|
|
20
|
-
context.parent.$emit("click-item",
|
|
21
|
-
}, p(t, "click")), t.attrs.on.blur = i((
|
|
22
|
-
context.parent.$emit("blur-item",
|
|
23
|
-
}, p(t, "blur")), typeof t.type == "string" && t.type.match(/^h\d$/) ? s(t, "dropdown-header") : t.type === "hr" && !r ? (t.type = "div", s(t, "dropdown-divider")) : !
|
|
21
|
+
const n = t.props.class && t.props.class.match(/dropdown-item/), r = t.props.class && t.props.class.match(/dropdown-divider/);
|
|
22
|
+
t.attrs.on.click = i((o) => {
|
|
23
|
+
context.parent.$emit("click-item", o, t);
|
|
24
|
+
}, p(t, "click")), t.attrs.on.blur = i((o) => {
|
|
25
|
+
context.parent.$emit("blur-item", o, t);
|
|
26
|
+
}, p(t, "blur")), typeof t.type == "string" && t.type.match(/^h\d$/) ? s(t, "dropdown-header") : t.type === "hr" && !r ? (t.type = "div", s(t, "dropdown-divider")) : !n && !r && s(t, "dropdown-item");
|
|
24
27
|
}
|
|
25
28
|
return e;
|
|
26
29
|
}
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
for (const [r,
|
|
30
|
-
|
|
31
|
-
return
|
|
30
|
+
const b = (e, t) => d("div", {}, a(t.slots.default())), $ = b, k = (e, t) => {
|
|
31
|
+
const n = e.__vccOpts || e;
|
|
32
|
+
for (const [r, o] of t)
|
|
33
|
+
n[r] = o;
|
|
34
|
+
return n;
|
|
32
35
|
}, C = {
|
|
33
36
|
name: "DropdownMenu",
|
|
34
37
|
components: {
|
|
@@ -44,28 +47,28 @@ const y = (e, t) => c("div", {}, b(t.slots.default())), $ = y, k = (e, t) => {
|
|
|
44
47
|
},
|
|
45
48
|
show: Boolean
|
|
46
49
|
}
|
|
47
|
-
},
|
|
48
|
-
function
|
|
49
|
-
const l =
|
|
50
|
-
return
|
|
50
|
+
}, D = ["aria-labelledby"];
|
|
51
|
+
function I(e, t, n, r, o, M) {
|
|
52
|
+
const l = m("dropdown-menu-items");
|
|
53
|
+
return u(), f("div", {
|
|
51
54
|
class: w(["dropdown-menu", {
|
|
52
|
-
"dropdown-menu-left":
|
|
53
|
-
"dropdown-menu-right":
|
|
54
|
-
show:
|
|
55
|
+
"dropdown-menu-left": n.align === "left",
|
|
56
|
+
"dropdown-menu-right": n.align === "right",
|
|
57
|
+
show: n.show
|
|
55
58
|
}]),
|
|
56
59
|
"aria-labelledby": e.$attrs.id
|
|
57
60
|
}, [
|
|
58
61
|
h(l, null, {
|
|
59
|
-
default:
|
|
62
|
+
default: y(() => [
|
|
60
63
|
g(e.$slots, "default", {
|
|
61
|
-
onClick: t[0] || (t[0] = (...
|
|
64
|
+
onClick: t[0] || (t[0] = (...c) => e.onItemClick && e.onItemClick(...c))
|
|
62
65
|
})
|
|
63
66
|
]),
|
|
64
67
|
_: 3
|
|
65
68
|
})
|
|
66
|
-
], 10,
|
|
69
|
+
], 10, D);
|
|
67
70
|
}
|
|
68
|
-
const
|
|
71
|
+
const v = /* @__PURE__ */ k(C, [["render", I]]);
|
|
69
72
|
export {
|
|
70
|
-
|
|
73
|
+
v as DropdownMenu
|
|
71
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.DropdownMenu={},r.Vue))})(this,function(r,n){"use strict";function p(t,e){t.props.class=`${t.props.class||""} ${e}`.trim()}function d(t,e){return o=>{typeof e=="function"&&e(o),o.cancelBubble||t(o)}}function l(t,e){return t.attrs.on[e]||t.type&&t.type.listeners&&t.componentOptions.listeners[e]}function c(t){return t&&t.type&&(t.type==="fragment"||typeof t.type=="symbol")}function a(t){for(const e of t){if(c(e))return a(e.children);e.props=Object.assign({class:void 0},e.props),e.attrs=Object.assign({},e.attrs),e.attrs.on||(e.attrs.on={});const o=e.props.class&&e.props.class.match(/dropdown-item/),i=e.props.class&&e.props.class.match(/dropdown-divider/);e.attrs.on.click=d(s=>{context.parent.$emit("click-item",s,e)},l(e,"click")),e.attrs.on.blur=d(s=>{context.parent.$emit("blur-item",s,e)},l(e,"blur")),typeof e.type=="string"&&e.type.match(/^h\d$/)?p(e,"dropdown-header"):e.type==="hr"&&!i?(e.type="div",p(e,"dropdown-divider")):!o&&!i&&p(e,"dropdown-item")}return t}const u=(t,e)=>n.h("div",{},a(e.slots.default())),f=(t,e)=>{const o=t.__vccOpts||t;for(const[i,s]of e)o[i]=s;return o},m={name:"DropdownMenu",components:{DropdownMenuItems:u},props:{align:{type:String,default:"left",validate(t){return["left","right"].indexOf(t.toLowerCase())!==-1}},show:Boolean}},w=["aria-labelledby"];function h(t,e,o,i,s,D){const g=n.resolveComponent("dropdown-menu-items");return n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["dropdown-menu",{"dropdown-menu-left":o.align==="left","dropdown-menu-right":o.align==="right",show:o.show}]),"aria-labelledby":t.$attrs.id},[n.createVNode(g,null,{default:n.withCtx(()=>[n.renderSlot(t.$slots,"default",{onClick:e[0]||(e[0]=(..._)=>t.onItemClick&&t.onItemClick(..._))})]),_:3})],10,w)}const y=f(m,[["render",h]]);r.DropdownMenu=y,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -24,20 +24,21 @@ function listener(vnode, key) {
|
|
|
24
24
|
vnode.componentOptions.listeners[key]
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
+
|
|
27
28
|
function isDropdownItem(vnode) {
|
|
28
29
|
return vnode && vnode.type && vnode.type.name === 'DropdownItem';
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
function isFragment(vnode) {
|
|
33
|
+
// We'll go ahead and assume that if the type is a symbol, then the vnode is fragment.
|
|
34
|
+
// This may be a faulty assumption; if it is, it'll need to be changed.
|
|
35
|
+
return vnode && vnode.type && (vnode.type === 'fragment' || typeof vnode.type === 'symbol');
|
|
36
|
+
}
|
|
36
37
|
|
|
37
|
-
function changeMenuItems(items) {
|
|
38
|
-
for(const vnode of items
|
|
39
|
-
if(
|
|
40
|
-
|
|
38
|
+
function changeMenuItems(items) {
|
|
39
|
+
for(const vnode of items) {
|
|
40
|
+
if(isFragment(vnode)) {
|
|
41
|
+
return changeMenuItems(vnode.children);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
vnode.props = Object.assign({ class: undefined }, vnode.props);
|