@vue-interface/dropdown-menu 1.0.14 → 2.0.0-beta.0
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 +51 -127
- package/dist/dropdown-menu.umd.js +1 -1
- package/package.json +17 -14
- package/src/DropdownMenuItems.vue +37 -36
package/dist/dropdown-menu.es.js
CHANGED
|
@@ -1,144 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
options.render = render2;
|
|
5
|
-
options.staticRenderFns = staticRenderFns2;
|
|
6
|
-
options._compiled = true;
|
|
7
|
-
}
|
|
8
|
-
if (functionalTemplate) {
|
|
9
|
-
options.functional = true;
|
|
10
|
-
}
|
|
11
|
-
if (scopeId) {
|
|
12
|
-
options._scopeId = "data-v-" + scopeId;
|
|
13
|
-
}
|
|
14
|
-
var hook;
|
|
15
|
-
if (moduleIdentifier) {
|
|
16
|
-
hook = function(context) {
|
|
17
|
-
context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
|
|
18
|
-
if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
|
|
19
|
-
context = __VUE_SSR_CONTEXT__;
|
|
20
|
-
}
|
|
21
|
-
if (injectStyles) {
|
|
22
|
-
injectStyles.call(this, context);
|
|
23
|
-
}
|
|
24
|
-
if (context && context._registeredComponents) {
|
|
25
|
-
context._registeredComponents.add(moduleIdentifier);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
options._ssrRegister = hook;
|
|
29
|
-
} else if (injectStyles) {
|
|
30
|
-
hook = shadowMode ? function() {
|
|
31
|
-
injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
|
|
32
|
-
} : injectStyles;
|
|
33
|
-
}
|
|
34
|
-
if (hook) {
|
|
35
|
-
if (options.functional) {
|
|
36
|
-
options._injectStyles = hook;
|
|
37
|
-
var originalRender = options.render;
|
|
38
|
-
options.render = function renderWithStyleInjection(h, context) {
|
|
39
|
-
hook.call(context);
|
|
40
|
-
return originalRender(h, context);
|
|
41
|
-
};
|
|
42
|
-
} else {
|
|
43
|
-
var existing = options.beforeCreate;
|
|
44
|
-
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
exports: scriptExports,
|
|
49
|
-
options
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function appendClass(vnode, str) {
|
|
53
|
-
vnode.data.staticClass = `${vnode.data.staticClass || ""} ${str}`.trim();
|
|
1
|
+
import { h as m, resolveComponent as u, openBlock as d, createElementBlock as f, normalizeClass as w, createVNode as h, withCtx as _, renderSlot as b } from "vue";
|
|
2
|
+
function l(r, s) {
|
|
3
|
+
r.props.class = `${r.props.class || ""} ${s}`.trim();
|
|
54
4
|
}
|
|
55
|
-
function
|
|
5
|
+
function p(r, s) {
|
|
56
6
|
return (e) => {
|
|
57
|
-
|
|
58
|
-
fn(e);
|
|
59
|
-
}
|
|
60
|
-
if (!e.cancelBubble) {
|
|
61
|
-
wrapper(e);
|
|
62
|
-
}
|
|
7
|
+
typeof s == "function" && s(e), e.cancelBubble || r(e);
|
|
63
8
|
};
|
|
64
9
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
10
|
+
function a(r, s) {
|
|
11
|
+
return r.attrs.on[s] || r.type && r.type.listeners && r.componentOptions.listeners[s];
|
|
67
12
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
appendClass(vnode, "dropdown-header");
|
|
86
|
-
} else if (vnode.tag === "hr" && !isDropdownDivider) {
|
|
87
|
-
vnode.tag = "div";
|
|
88
|
-
appendClass(vnode, "dropdown-divider");
|
|
89
|
-
} else if (!isDropdownItem && !isDropdownDivider) {
|
|
90
|
-
appendClass(vnode, "dropdown-item");
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return context.children;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
let __vue2_render, __vue2_staticRenderFns;
|
|
97
|
-
const __cssModules$1 = {};
|
|
98
|
-
var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles$1, null, null, null);
|
|
99
|
-
function __vue2_injectStyles$1(context) {
|
|
100
|
-
for (let o in __cssModules$1) {
|
|
101
|
-
this[o] = __cssModules$1[o];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
var DropdownMenuItems = /* @__PURE__ */ function() {
|
|
105
|
-
return __component__$1.exports;
|
|
106
|
-
}();
|
|
107
|
-
var render = function() {
|
|
108
|
-
var _vm = this;
|
|
109
|
-
var _h = _vm.$createElement;
|
|
110
|
-
var _c = _vm._self._c || _h;
|
|
111
|
-
return _c("div", { staticClass: "dropdown-menu", class: {
|
|
112
|
-
"dropdown-menu-left": _vm.align === "left",
|
|
113
|
-
"dropdown-menu-right": _vm.align === "right",
|
|
114
|
-
"show": _vm.show
|
|
115
|
-
}, attrs: { "aria-labelledby": _vm.$attrs.id } }, [_c("dropdown-menu-items", [_vm._t("default")], 2)], 1);
|
|
116
|
-
};
|
|
117
|
-
var staticRenderFns = [];
|
|
118
|
-
const __vue2_script = {
|
|
13
|
+
const g = (r, s) => {
|
|
14
|
+
const e = s.slots.default()[0].children;
|
|
15
|
+
return e.forEach((t) => {
|
|
16
|
+
t.props = Object.assign({ class: void 0 }, t.props), t.attrs = Object.assign({}, t.attrs), t.attrs.on || (t.attrs.on = {});
|
|
17
|
+
const n = t.props.class && t.props.class.match(/dropdown-item/), i = t.props.class && t.props.class.match(/dropdown-divider/);
|
|
18
|
+
t.attrs.on.click = p((o) => {
|
|
19
|
+
s.parent.$emit("click-item", o, t);
|
|
20
|
+
}, a(t, "click")), t.attrs.on.blur = p((o) => {
|
|
21
|
+
s.parent.$emit("blur-item", o, t);
|
|
22
|
+
}, a(t, "blur")), typeof t.type == "string" && t.type.match(/^h\d$/) ? l(t, "dropdown-header") : t.type === "hr" && !i ? (t.type = "div", l(t, "dropdown-divider")) : !n && !i && l(t, "dropdown-item");
|
|
23
|
+
}), m("div", {}, e);
|
|
24
|
+
}, y = g, $ = (r, s) => {
|
|
25
|
+
const e = r.__vccOpts || r;
|
|
26
|
+
for (const [t, n] of s)
|
|
27
|
+
e[t] = n;
|
|
28
|
+
return e;
|
|
29
|
+
}, k = {
|
|
119
30
|
name: "DropdownMenu",
|
|
120
31
|
components: {
|
|
121
|
-
DropdownMenuItems
|
|
32
|
+
DropdownMenuItems: y
|
|
122
33
|
},
|
|
123
34
|
props: {
|
|
124
35
|
align: {
|
|
125
36
|
type: String,
|
|
126
37
|
default: "left",
|
|
127
|
-
validate(
|
|
128
|
-
return ["left", "right"].indexOf(
|
|
38
|
+
validate(r) {
|
|
39
|
+
return ["left", "right"].indexOf(r.toLowerCase()) !== -1;
|
|
129
40
|
}
|
|
130
41
|
},
|
|
131
42
|
show: Boolean
|
|
132
43
|
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
44
|
+
}, C = ["aria-labelledby"];
|
|
45
|
+
function D(r, s, e, t, n, i) {
|
|
46
|
+
const o = u("dropdown-menu-items");
|
|
47
|
+
return d(), f("div", {
|
|
48
|
+
class: w(["dropdown-menu", {
|
|
49
|
+
"dropdown-menu-left": e.align === "left",
|
|
50
|
+
"dropdown-menu-right": e.align === "right",
|
|
51
|
+
show: e.show
|
|
52
|
+
}]),
|
|
53
|
+
"aria-labelledby": r.$attrs.id
|
|
54
|
+
}, [
|
|
55
|
+
h(o, null, {
|
|
56
|
+
default: _(() => [
|
|
57
|
+
b(r.$slots, "default", {
|
|
58
|
+
onClick: s[0] || (s[0] = (...c) => r.onItemClick && r.onItemClick(...c))
|
|
59
|
+
})
|
|
60
|
+
]),
|
|
61
|
+
_: 3
|
|
62
|
+
})
|
|
63
|
+
], 10, C);
|
|
140
64
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
65
|
+
const O = /* @__PURE__ */ $(k, [["render", D]]);
|
|
66
|
+
export {
|
|
67
|
+
O as DropdownMenu
|
|
68
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(o=typeof globalThis<"u"?globalThis:o||self,r(o.DropdownMenu={},o.Vue))})(this,function(o,r){"use strict";function l(e,s){e.props.class=`${e.props.class||""} ${s}`.trim()}function c(e,s){return n=>{typeof s=="function"&&s(n),n.cancelBubble||e(n)}}function d(e,s){return e.attrs.on[s]||e.type&&e.type.listeners&&e.componentOptions.listeners[s]}const u=(e,s)=>{const n=s.slots.default()[0].children;return n.forEach(t=>{t.props=Object.assign({class:void 0},t.props),t.attrs=Object.assign({},t.attrs),t.attrs.on||(t.attrs.on={});const p=t.props.class&&t.props.class.match(/dropdown-item/),a=t.props.class&&t.props.class.match(/dropdown-divider/);t.attrs.on.click=c(i=>{s.parent.$emit("click-item",i,t)},d(t,"click")),t.attrs.on.blur=c(i=>{s.parent.$emit("blur-item",i,t)},d(t,"blur")),typeof t.type=="string"&&t.type.match(/^h\d$/)?l(t,"dropdown-header"):t.type==="hr"&&!a?(t.type="div",l(t,"dropdown-divider")):!p&&!a&&l(t,"dropdown-item")}),r.h("div",{},n)},f=(e,s)=>{const n=e.__vccOpts||e;for(const[t,p]of s)n[t]=p;return n},m={name:"DropdownMenu",components:{DropdownMenuItems:u},props:{align:{type:String,default:"left",validate(e){return["left","right"].indexOf(e.toLowerCase())!==-1}},show:Boolean}},w=["aria-labelledby"];function h(e,s,n,t,p,a){const i=r.resolveComponent("dropdown-menu-items");return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["dropdown-menu",{"dropdown-menu-left":n.align==="left","dropdown-menu-right":n.align==="right",show:n.show}]),"aria-labelledby":e.$attrs.id},[r.createVNode(i,null,{default:r.withCtx(()=>[r.renderSlot(e.$slots,"default",{onClick:s[0]||(s[0]=(...y)=>e.onItemClick&&e.onItemClick(...y))})]),_:3})],10,w)}const _=f(m,[["render",h]]);o.DropdownMenu=_,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-interface/dropdown-menu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "A Vue dropdown menu component.",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.js",
|
|
@@ -38,25 +38,28 @@
|
|
|
38
38
|
"bugs": {
|
|
39
39
|
"url": "https://github.com/vue-interface/dropdown-menu/issues"
|
|
40
40
|
},
|
|
41
|
-
"homepage": "https://github.com/vue-interface/dropdown-menu
|
|
41
|
+
"homepage": "https://github.com/vue-interface/dropdown-menu",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@vue-interface/variant": "^
|
|
44
|
-
"color": "^4.2.0"
|
|
45
|
-
|
|
43
|
+
"@vue-interface/variant": "^2.0.0-beta.0",
|
|
44
|
+
"color": "^4.2.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"vue": "^3.0.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@rollup/plugin-babel": "^5.3.
|
|
49
|
-
"
|
|
50
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
51
|
+
"@vitejs/plugin-vue": "^3.0.3",
|
|
52
|
+
"autoprefixer": "^10.4.8",
|
|
50
53
|
"babel-eslint": "^10.1.0",
|
|
51
54
|
"babel-preset-vue": "^2.0.2",
|
|
52
55
|
"change-case": "^4.1.2",
|
|
53
|
-
"eslint": "^
|
|
54
|
-
"eslint-plugin-vue": "^
|
|
56
|
+
"eslint": "^8.22.0",
|
|
57
|
+
"eslint-plugin-vue": "^9.4.0",
|
|
55
58
|
"pascalcase": "^2.0.0",
|
|
56
|
-
"postcss": "^8.4.
|
|
57
|
-
"tailwindcss": "^3.
|
|
58
|
-
"vite": "^
|
|
59
|
-
"
|
|
60
|
-
"vue-router": "^
|
|
59
|
+
"postcss": "^8.4.16",
|
|
60
|
+
"tailwindcss": "^3.1.8",
|
|
61
|
+
"vite": "^3.0.9",
|
|
62
|
+
"vue": "^3.2.37",
|
|
63
|
+
"vue-router": "^4.1.4"
|
|
61
64
|
}
|
|
62
65
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { h } from 'vue';
|
|
3
|
+
|
|
2
4
|
function appendClass(vnode, str) {
|
|
3
|
-
vnode.
|
|
5
|
+
vnode.props.class = `${vnode.props.class || ''} ${str}`.trim();
|
|
4
6
|
}
|
|
5
7
|
|
|
6
8
|
function wrap(wrapper, fn) {
|
|
@@ -16,51 +18,50 @@ function wrap(wrapper, fn) {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
function listener(vnode, key) {
|
|
19
|
-
return vnode.
|
|
20
|
-
vnode.
|
|
21
|
-
vnode.
|
|
21
|
+
return vnode.attrs.on[key] || (
|
|
22
|
+
vnode.type &&
|
|
23
|
+
vnode.type.listeners &&
|
|
22
24
|
vnode.componentOptions.listeners[key]
|
|
23
25
|
);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
const DropdownMenuItems = (props, context) => {
|
|
29
|
+
const children = context.slots.default()[0].children;
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
vnode.data = Object.assign({staticClass: undefined}, vnode.data);
|
|
33
|
-
|
|
34
|
-
if(!vnode.data.on) {
|
|
35
|
-
vnode.data.on = {};
|
|
36
|
-
}
|
|
31
|
+
children.forEach(vnode => {
|
|
32
|
+
vnode.props = Object.assign({ class: undefined }, vnode.props);
|
|
33
|
+
vnode.attrs = Object.assign({}, vnode.attrs);
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
vnode.data.on.click = wrap(e => {
|
|
42
|
-
context.parent.$emit('click-item', e, vnode);
|
|
43
|
-
}, listener(vnode, 'click'));
|
|
35
|
+
if(!vnode.attrs.on) {
|
|
36
|
+
vnode.attrs.on = {};
|
|
37
|
+
}
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, listener(vnode, 'blur'));
|
|
39
|
+
const isDropdownItem = vnode.props.class && vnode.props.class.match(/dropdown-item/);
|
|
40
|
+
const isDropdownDivider = vnode.props.class && vnode.props.class.match(/dropdown-divider/);
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
else if(vnode.tag === 'hr' && !isDropdownDivider) {
|
|
53
|
-
vnode.tag = 'div';
|
|
42
|
+
vnode.attrs.on.click = wrap(e => {
|
|
43
|
+
context.parent.$emit('click-item', e, vnode);
|
|
44
|
+
}, listener(vnode, 'click'));
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
appendClass(vnode, 'dropdown-item');
|
|
59
|
-
}
|
|
60
|
-
});
|
|
46
|
+
vnode.attrs.on.blur = wrap(e => {
|
|
47
|
+
context.parent.$emit('blur-item', e, vnode);
|
|
48
|
+
}, listener(vnode, 'blur'));
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
if(typeof vnode.type === 'string' && vnode.type.match(/^h\d$/)) {
|
|
51
|
+
appendClass(vnode, 'dropdown-header');
|
|
52
|
+
}
|
|
53
|
+
else if(vnode.type === 'hr' && !isDropdownDivider) {
|
|
54
|
+
vnode.type = 'div';
|
|
64
55
|
|
|
56
|
+
appendClass(vnode, 'dropdown-divider');
|
|
57
|
+
}
|
|
58
|
+
else if(!isDropdownItem && !isDropdownDivider) {
|
|
59
|
+
appendClass(vnode, 'dropdown-item');
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return h('div', {}, children);
|
|
65
64
|
};
|
|
65
|
+
|
|
66
|
+
export default DropdownMenuItems;
|
|
66
67
|
</script>
|