@vue-interface/dropdown-menu 2.0.0-beta.0 → 2.0.0-beta.1

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,68 +1,74 @@
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();
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();
4
4
  }
5
- function p(r, s) {
6
- return (e) => {
7
- typeof s == "function" && s(e), e.cancelBubble || r(e);
5
+ function i(e, t) {
6
+ return (n) => {
7
+ typeof t == "function" && t(n), n.cancelBubble || e(n);
8
8
  };
9
9
  }
10
- function a(r, s) {
11
- return r.attrs.on[s] || r.type && r.type.listeners && r.componentOptions.listeners[s];
10
+ function p(e, t) {
11
+ return e.attrs.on[t] || e.type && e.type.listeners && e.componentOptions.listeners[t];
12
12
  }
13
- const g = (r, s) => {
14
- const e = s.slots.default()[0].children;
15
- return e.forEach((t) => {
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);
16
20
  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;
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");
27
+ }
28
28
  return e;
29
- }, k = {
29
+ }
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;
35
+ }, C = {
30
36
  name: "DropdownMenu",
31
37
  components: {
32
- DropdownMenuItems: y
38
+ DropdownMenuItems: $
33
39
  },
34
40
  props: {
35
41
  align: {
36
42
  type: String,
37
43
  default: "left",
38
- validate(r) {
39
- return ["left", "right"].indexOf(r.toLowerCase()) !== -1;
44
+ validate(e) {
45
+ return ["left", "right"].indexOf(e.toLowerCase()) !== -1;
40
46
  }
41
47
  },
42
48
  show: Boolean
43
49
  }
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", {
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", {
48
54
  class: w(["dropdown-menu", {
49
- "dropdown-menu-left": e.align === "left",
50
- "dropdown-menu-right": e.align === "right",
51
- show: e.show
55
+ "dropdown-menu-left": n.align === "left",
56
+ "dropdown-menu-right": n.align === "right",
57
+ show: n.show
52
58
  }]),
53
- "aria-labelledby": r.$attrs.id
59
+ "aria-labelledby": e.$attrs.id
54
60
  }, [
55
- h(o, null, {
56
- default: _(() => [
57
- b(r.$slots, "default", {
58
- onClick: s[0] || (s[0] = (...c) => r.onItemClick && r.onItemClick(...c))
61
+ h(l, null, {
62
+ default: y(() => [
63
+ g(e.$slots, "default", {
64
+ onClick: t[0] || (t[0] = (...c) => e.onItemClick && e.onItemClick(...c))
59
65
  })
60
66
  ]),
61
67
  _: 3
62
68
  })
63
- ], 10, C);
69
+ ], 10, D);
64
70
  }
65
- const O = /* @__PURE__ */ $(k, [["render", D]]);
71
+ const v = /* @__PURE__ */ k(C, [["render", I]]);
66
72
  export {
67
- O as DropdownMenu
73
+ v as DropdownMenu
68
74
  };
@@ -1 +1 @@
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"}})});
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/dropdown-menu",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "A Vue dropdown menu component.",
5
5
  "files": [
6
6
  "index.js",
@@ -25,10 +25,18 @@ function listener(vnode, key) {
25
25
  );
26
26
  }
27
27
 
28
- const DropdownMenuItems = (props, context) => {
29
- const children = context.slots.default()[0].children;
28
+ function isFragment(vnode) {
29
+ // We'll go ahead and assume that if the type is a symbol, then the vnode is fragment.
30
+ // This may be a faulty assumption; if it is, it'll need to be changed.
31
+ return vnode && vnode.type && (vnode.type === 'fragment' || typeof vnode.type === 'symbol');
32
+ }
33
+
34
+ function changeMenuItems(items) {
35
+ for(const vnode of items) {
36
+ if(isFragment(vnode)) {
37
+ return changeMenuItems(vnode.children);
38
+ }
30
39
 
31
- children.forEach(vnode => {
32
40
  vnode.props = Object.assign({ class: undefined }, vnode.props);
33
41
  vnode.attrs = Object.assign({}, vnode.attrs);
34
42
 
@@ -58,10 +66,12 @@ const DropdownMenuItems = (props, context) => {
58
66
  else if(!isDropdownItem && !isDropdownDivider) {
59
67
  appendClass(vnode, 'dropdown-item');
60
68
  }
61
- });
69
+ }
70
+
71
+ return items;
72
+ }
62
73
 
63
- return h('div', {}, children);
64
- };
74
+ const DropdownMenuItems = (props, context) => h('div', {}, changeMenuItems(context.slots.default()));
65
75
 
66
76
  export default DropdownMenuItems;
67
77
  </script>