@vue-interface/dropdown-menu 2.0.0-beta.4 → 2.0.0-beta.5

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