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

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,71 @@
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 c, isVNode as d, resolveComponent as u, openBlock as m, createElementBlock as f, normalizeClass as w, createVNode as h, withCtx as _, 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 (o) => {
7
+ typeof t == "function" && t(o), o.cancelBubble || e(o);
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 b(e) {
14
+ for (const t of e[0].children) {
15
+ if (!d(t))
16
+ continue;
16
17
  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;
18
+ const o = t.props.class && t.props.class.match(/dropdown-item/), r = t.props.class && t.props.class.match(/dropdown-divider/);
19
+ t.attrs.on.click = i((n) => {
20
+ context.parent.$emit("click-item", n, t);
21
+ }, p(t, "click")), t.attrs.on.blur = i((n) => {
22
+ context.parent.$emit("blur-item", n, t);
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")) : !o && !r && s(t, "dropdown-item");
24
+ }
28
25
  return e;
29
- }, k = {
26
+ }
27
+ const y = (e, t) => c("div", {}, b(t.slots.default())), $ = y, k = (e, t) => {
28
+ const o = e.__vccOpts || e;
29
+ for (const [r, n] of t)
30
+ o[r] = n;
31
+ return o;
32
+ }, C = {
30
33
  name: "DropdownMenu",
31
34
  components: {
32
- DropdownMenuItems: y
35
+ DropdownMenuItems: $
33
36
  },
34
37
  props: {
35
38
  align: {
36
39
  type: String,
37
40
  default: "left",
38
- validate(r) {
39
- return ["left", "right"].indexOf(r.toLowerCase()) !== -1;
41
+ validate(e) {
42
+ return ["left", "right"].indexOf(e.toLowerCase()) !== -1;
40
43
  }
41
44
  },
42
45
  show: Boolean
43
46
  }
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", {
47
+ }, v = ["aria-labelledby"];
48
+ function D(e, t, o, r, n, I) {
49
+ const l = u("dropdown-menu-items");
50
+ return m(), f("div", {
48
51
  class: w(["dropdown-menu", {
49
- "dropdown-menu-left": e.align === "left",
50
- "dropdown-menu-right": e.align === "right",
51
- show: e.show
52
+ "dropdown-menu-left": o.align === "left",
53
+ "dropdown-menu-right": o.align === "right",
54
+ show: o.show
52
55
  }]),
53
- "aria-labelledby": r.$attrs.id
56
+ "aria-labelledby": e.$attrs.id
54
57
  }, [
55
- h(o, null, {
58
+ h(l, null, {
56
59
  default: _(() => [
57
- b(r.$slots, "default", {
58
- onClick: s[0] || (s[0] = (...c) => r.onItemClick && r.onItemClick(...c))
60
+ g(e.$slots, "default", {
61
+ onClick: t[0] || (t[0] = (...a) => e.onItemClick && e.onItemClick(...a))
59
62
  })
60
63
  ]),
61
64
  _: 3
62
65
  })
63
- ], 10, C);
66
+ ], 10, v);
64
67
  }
65
- const O = /* @__PURE__ */ $(k, [["render", D]]);
68
+ const O = /* @__PURE__ */ k(C, [["render", D]]);
66
69
  export {
67
70
  O as DropdownMenu
68
71
  };
@@ -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(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 c(t){for(const e of t[0].children){if(!n.isVNode(e))continue;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 a=(t,e)=>n.h("div",{},c(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:a},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,g){const _=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(_,null,{default:n.withCtx(()=>[n.renderSlot(t.$slots,"default",{onClick:e[0]||(e[0]=(...y)=>t.onItemClick&&t.onItemClick(...y))})]),_:3})],10,m)}const h=u(f,[["render",w]]);s.DropdownMenu=h,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.0",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "A Vue dropdown menu component.",
5
5
  "files": [
6
6
  "index.js",
@@ -47,19 +47,19 @@
47
47
  "vue": "^3.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@rollup/plugin-babel": "^5.3.1",
51
- "@vitejs/plugin-vue": "^3.0.3",
52
- "autoprefixer": "^10.4.8",
50
+ "@rollup/plugin-babel": "^6.0.0",
51
+ "@vitejs/plugin-vue": "^3.1.2",
52
+ "autoprefixer": "^10.4.12",
53
53
  "babel-eslint": "^10.1.0",
54
54
  "babel-preset-vue": "^2.0.2",
55
55
  "change-case": "^4.1.2",
56
- "eslint": "^8.22.0",
57
- "eslint-plugin-vue": "^9.4.0",
56
+ "eslint": "^8.25.0",
57
+ "eslint-plugin-vue": "^9.6.0",
58
58
  "pascalcase": "^2.0.0",
59
- "postcss": "^8.4.16",
59
+ "postcss": "^8.4.18",
60
60
  "tailwindcss": "^3.1.8",
61
- "vite": "^3.0.9",
62
- "vue": "^3.2.37",
63
- "vue-router": "^4.1.4"
61
+ "vite": "^3.1.7",
62
+ "vue": "^3.2.40",
63
+ "vue-router": "^4.1.5"
64
64
  }
65
65
  }
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { h } from 'vue';
2
+ import { h, isVNode } from 'vue';
3
3
 
4
4
  function appendClass(vnode, str) {
5
5
  vnode.props.class = `${vnode.props.class || ''} ${str}`.trim();
@@ -24,11 +24,22 @@ function listener(vnode, key) {
24
24
  vnode.componentOptions.listeners[key]
25
25
  );
26
26
  }
27
+ function isDropdownItem(vnode) {
28
+ return vnode && vnode.type && vnode.type.name === 'DropdownItem';
29
+ }
30
+
31
+ // function isSymbol(vnode) {
32
+ // // We'll go ahead and assume that if the type is a symbol, then the vnode is fragment.
33
+ // // This may be a faulty assumption; if it is, it'll need to be changed.
34
+ // return vnode && vnode.type && (vnode.type === 'fragment' || typeof vnode.type === 'symbol');
35
+ // }
27
36
 
28
- const DropdownMenuItems = (props, context) => {
29
- const children = context.slots.default()[0].children;
37
+ function changeMenuItems(items) {
38
+ for(const vnode of items[0].children) {
39
+ if(!isVNode(vnode)) {
40
+ continue;
41
+ }
30
42
 
31
- children.forEach(vnode => {
32
43
  vnode.props = Object.assign({ class: undefined }, vnode.props);
33
44
  vnode.attrs = Object.assign({}, vnode.attrs);
34
45
 
@@ -58,10 +69,12 @@ const DropdownMenuItems = (props, context) => {
58
69
  else if(!isDropdownItem && !isDropdownDivider) {
59
70
  appendClass(vnode, 'dropdown-item');
60
71
  }
61
- });
72
+ }
73
+
74
+ return items;
75
+ }
62
76
 
63
- return h('div', {}, children);
64
- };
77
+ const DropdownMenuItems = (props, context) => h('div', {}, changeMenuItems(context.slots.default()));
65
78
 
66
79
  export default DropdownMenuItems;
67
80
  </script>