@vue-interface/dropdown-menu 2.0.0-beta.3 → 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,41 +1,24 @@
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
- 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 _(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);
20
- t.props = Object.assign({ class: void 0 }, t.props), t.attrs = Object.assign({}, t.attrs), t.attrs.on || (t.attrs.on = {});
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");
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");
27
10
  }
28
11
  return e;
29
12
  }
30
- 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) => {
31
14
  const n = e.__vccOpts || e;
32
- for (const [r, o] of t)
33
- n[r] = o;
15
+ for (const [t, r] of o)
16
+ n[t] = r;
34
17
  return n;
35
18
  }, C = {
36
19
  name: "DropdownMenu",
37
20
  components: {
38
- DropdownMenuItems: $
21
+ DropdownMenuItems: v
39
22
  },
40
23
  props: {
41
24
  align: {
@@ -48,27 +31,27 @@ const b = (e, t) => d("div", {}, a(t.slots.default())), $ = b, k = (e, t) => {
48
31
  show: Boolean
49
32
  }
50
33
  }, D = ["aria-labelledby"];
51
- function I(e, t, n, r, o, M) {
52
- const l = m("dropdown-menu-items");
53
- return u(), f("div", {
54
- class: w(["dropdown-menu", {
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", {
55
38
  "dropdown-menu-left": n.align === "left",
56
39
  "dropdown-menu-right": n.align === "right",
57
40
  show: n.show
58
41
  }]),
59
42
  "aria-labelledby": e.$attrs.id
60
43
  }, [
61
- h(l, null, {
62
- default: y(() => [
44
+ w(p, null, {
45
+ default: h(() => [
63
46
  g(e.$slots, "default", {
64
- onClick: t[0] || (t[0] = (...c) => e.onItemClick && e.onItemClick(...c))
47
+ onClick: o[0] || (o[0] = (...a) => e.onItemClick && e.onItemClick(...a))
65
48
  })
66
49
  ]),
67
50
  _: 3
68
51
  })
69
52
  ], 10, D);
70
53
  }
71
- const v = /* @__PURE__ */ k(C, [["render", I]]);
54
+ const I = /* @__PURE__ */ y(C, [["render", $]]);
72
55
  export {
73
- v as DropdownMenu
56
+ I as DropdownMenu
74
57
  };
@@ -1 +1 @@
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"}})});
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.3",
3
+ "version": "2.0.0-beta.5",
4
4
  "description": "A Vue dropdown menu component.",
5
5
  "files": [
6
6
  "index.js",
@@ -1,44 +1,14 @@
1
1
  <script>
2
- import { h, isVNode } from 'vue';
2
+ import { Fragment, h } from 'vue';
3
3
 
4
4
  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
- function isDropdownItem(vnode) {
29
- return vnode && vnode.type && vnode.type.name === 'DropdownItem';
30
- }
31
-
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
- }
37
-
38
- function changeMenuItems(items) {
8
+ function changeMenuItems(items) {
39
9
  for(const vnode of items) {
40
- if(isFragment(vnode)) {
41
- return changeMenuItems(vnode.children);
10
+ if(vnode.type === Fragment) {
11
+ changeMenuItems(vnode.children);
42
12
  }
43
13
 
44
14
  vnode.props = Object.assign({ class: undefined }, vnode.props);
@@ -51,14 +21,6 @@ function changeMenuItems(items) {
51
21
  const isDropdownItem = vnode.props.class && vnode.props.class.match(/dropdown-item/);
52
22
  const isDropdownDivider = vnode.props.class && vnode.props.class.match(/dropdown-divider/);
53
23
 
54
- vnode.attrs.on.click = wrap(e => {
55
- context.parent.$emit('click-item', e, vnode);
56
- }, listener(vnode, 'click'));
57
-
58
- vnode.attrs.on.blur = wrap(e => {
59
- context.parent.$emit('blur-item', e, vnode);
60
- }, listener(vnode, 'blur'));
61
-
62
24
  if(typeof vnode.type === 'string' && vnode.type.match(/^h\d$/)) {
63
25
  appendClass(vnode, 'dropdown-header');
64
26
  }