@vue-interface/dropdown-menu 1.0.14 → 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,144 +1,74 @@
1
- function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
2
- var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
3
- if (render2) {
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 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();
54
4
  }
55
- function wrap(wrapper, fn) {
56
- return (e) => {
57
- if (typeof fn === "function") {
58
- fn(e);
59
- }
60
- if (!e.cancelBubble) {
61
- wrapper(e);
62
- }
5
+ function i(e, t) {
6
+ return (n) => {
7
+ typeof t == "function" && t(n), n.cancelBubble || e(n);
63
8
  };
64
9
  }
65
- function listener(vnode, key) {
66
- return vnode.data.on[key] || vnode.componentOptions && vnode.componentOptions.listeners && vnode.componentOptions.listeners[key];
10
+ function p(e, t) {
11
+ return e.attrs.on[t] || e.type && e.type.listeners && e.componentOptions.listeners[t];
67
12
  }
68
- const __vue2_script$1 = {
69
- functional: true,
70
- render(h, context) {
71
- context.children.filter((vnode) => !!vnode.tag).forEach((vnode, i) => {
72
- vnode.data = Object.assign({ staticClass: void 0 }, vnode.data);
73
- if (!vnode.data.on) {
74
- vnode.data.on = {};
75
- }
76
- const isDropdownItem = vnode.data.staticClass && vnode.data.staticClass.match(/dropdown-item/);
77
- const isDropdownDivider = vnode.data.staticClass && vnode.data.staticClass.match(/dropdown-divider/);
78
- vnode.data.on.click = wrap((e) => {
79
- context.parent.$emit("click-item", e, vnode);
80
- }, listener(vnode, "click"));
81
- vnode.data.on.blur = wrap((e) => {
82
- context.parent.$emit("blur-item", e, vnode);
83
- }, listener(vnode, "blur"));
84
- if (vnode.tag.match(/^h\d$/)) {
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];
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");
102
27
  }
28
+ return e;
103
29
  }
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 = {
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 = {
119
36
  name: "DropdownMenu",
120
37
  components: {
121
- DropdownMenuItems
38
+ DropdownMenuItems: $
122
39
  },
123
40
  props: {
124
41
  align: {
125
42
  type: String,
126
43
  default: "left",
127
- validate(value) {
128
- return ["left", "right"].indexOf(value.toLowerCase()) !== -1;
44
+ validate(e) {
45
+ return ["left", "right"].indexOf(e.toLowerCase()) !== -1;
129
46
  }
130
47
  },
131
48
  show: Boolean
132
49
  }
133
- };
134
- const __cssModules = {};
135
- var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
136
- function __vue2_injectStyles(context) {
137
- for (let o in __cssModules) {
138
- this[o] = __cssModules[o];
139
- }
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", {
54
+ class: w(["dropdown-menu", {
55
+ "dropdown-menu-left": n.align === "left",
56
+ "dropdown-menu-right": n.align === "right",
57
+ show: n.show
58
+ }]),
59
+ "aria-labelledby": e.$attrs.id
60
+ }, [
61
+ h(l, null, {
62
+ default: y(() => [
63
+ g(e.$slots, "default", {
64
+ onClick: t[0] || (t[0] = (...c) => e.onItemClick && e.onItemClick(...c))
65
+ })
66
+ ]),
67
+ _: 3
68
+ })
69
+ ], 10, D);
140
70
  }
141
- var DropdownMenu = /* @__PURE__ */ function() {
142
- return __component__.exports;
143
- }();
144
- export { DropdownMenu };
71
+ const v = /* @__PURE__ */ k(C, [["render", I]]);
72
+ export {
73
+ v as DropdownMenu
74
+ };
@@ -1 +1 @@
1
- (function(s,l){typeof exports=="object"&&typeof module!="undefined"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(s=typeof globalThis!="undefined"?globalThis:s||self,l(s.DropdownMenu={}))})(this,function(s){"use strict";function l(e,n,t,m,o,d,u,k){var i=typeof e=="function"?e.options:e;n&&(i.render=n,i.staticRenderFns=t,i._compiled=!0),m&&(i.functional=!0),d&&(i._scopeId="data-v-"+d);var a;if(u?(a=function(r){r=r||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!r&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(r=__VUE_SSR_CONTEXT__),o&&o.call(this,r),r&&r._registeredComponents&&r._registeredComponents.add(u)},i._ssrRegister=a):o&&(a=k?function(){o.call(this,(i.functional?this.parent:this).$root.$options.shadowRoot)}:o),a)if(i.functional){i._injectStyles=a;var E=i.render;i.render=function(F,C){return a.call(C),E(F,C)}}else{var w=i.beforeCreate;i.beforeCreate=w?[].concat(w,a):[a]}return{exports:e,options:i}}function f(e,n){e.data.staticClass=`${e.data.staticClass||""} ${n}`.trim()}function c(e,n){return t=>{typeof n=="function"&&n(t),t.cancelBubble||e(t)}}function _(e,n){return e.data.on[n]||e.componentOptions&&e.componentOptions.listeners&&e.componentOptions.listeners[n]}const $={functional:!0,render(e,n){return n.children.filter(t=>!!t.tag).forEach((t,m)=>{t.data=Object.assign({staticClass:void 0},t.data),t.data.on||(t.data.on={});const o=t.data.staticClass&&t.data.staticClass.match(/dropdown-item/),d=t.data.staticClass&&t.data.staticClass.match(/dropdown-divider/);t.data.on.click=c(u=>{n.parent.$emit("click-item",u,t)},_(t,"click")),t.data.on.blur=c(u=>{n.parent.$emit("blur-item",u,t)},_(t,"blur")),t.tag.match(/^h\d$/)?f(t,"dropdown-header"):t.tag==="hr"&&!d?(t.tag="div",f(t,"dropdown-divider")):!o&&!d&&f(t,"dropdown-item")}),n.children}};let g,b;const p={};var v=l($,g,b,!1,M,null,null,null);function M(e){for(let n in p)this[n]=p[n]}var y=function(){return v.exports}(),D=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{staticClass:"dropdown-menu",class:{"dropdown-menu-left":e.align==="left","dropdown-menu-right":e.align==="right",show:e.show},attrs:{"aria-labelledby":e.$attrs.id}},[t("dropdown-menu-items",[e._t("default")],2)],1)},O=[];const R={name:"DropdownMenu",components:{DropdownMenuItems:y},props:{align:{type:String,default:"left",validate(e){return["left","right"].indexOf(e.toLowerCase())!==-1}},show:Boolean}},h={};var S=l(R,D,O,!1,T,null,null,null);function T(e){for(let n in h)this[n]=h[n]}var j=function(){return S.exports}();s.DropdownMenu=j,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="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": "1.0.14",
3
+ "version": "2.0.0-beta.1",
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/docs#readme",
41
+ "homepage": "https://github.com/vue-interface/dropdown-menu",
42
42
  "dependencies": {
43
- "@vue-interface/variant": "^1.1.7",
44
- "color": "^4.2.0",
45
- "vue": "^2.6.14"
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.0",
49
- "autoprefixer": "^10.4.2",
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": "^6.7.2",
54
- "eslint-plugin-vue": "^6.2.2",
56
+ "eslint": "^8.22.0",
57
+ "eslint-plugin-vue": "^9.4.0",
55
58
  "pascalcase": "^2.0.0",
56
- "postcss": "^8.4.6",
57
- "tailwindcss": "^3.0.18",
58
- "vite": "^2.7.2",
59
- "vite-plugin-vue2": "^1.9.3",
60
- "vue-router": "^3.5.3"
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.data.staticClass = `${vnode.data.staticClass || ''} ${str}`.trim();
5
+ vnode.props.class = `${vnode.props.class || ''} ${str}`.trim();
4
6
  }
5
7
 
6
8
  function wrap(wrapper, fn) {
@@ -16,51 +18,60 @@ function wrap(wrapper, fn) {
16
18
  }
17
19
 
18
20
  function listener(vnode, key) {
19
- return vnode.data.on[key] || (
20
- vnode.componentOptions &&
21
- vnode.componentOptions.listeners &&
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
- export default {
27
- functional: true,
28
-
29
- render(h, context) {
30
- context.children.filter(vnode => !!vnode.tag)
31
- .forEach((vnode, i) => {
32
- vnode.data = Object.assign({staticClass: undefined}, vnode.data);
33
-
34
- if(!vnode.data.on) {
35
- vnode.data.on = {};
36
- }
37
-
38
- const isDropdownItem = vnode.data.staticClass && vnode.data.staticClass.match(/dropdown-item/);
39
- const isDropdownDivider = vnode.data.staticClass && vnode.data.staticClass.match(/dropdown-divider/);
40
-
41
- vnode.data.on.click = wrap(e => {
42
- context.parent.$emit('click-item', e, vnode);
43
- }, listener(vnode, 'click'));
44
-
45
- vnode.data.on.blur = wrap(e => {
46
- context.parent.$emit('blur-item', e, vnode);
47
- }, listener(vnode, 'blur'));
48
-
49
- if(vnode.tag.match(/^h\d$/)) {
50
- appendClass(vnode, 'dropdown-header');
51
- }
52
- else if(vnode.tag === 'hr' && !isDropdownDivider) {
53
- vnode.tag = 'div';
54
-
55
- appendClass(vnode, 'dropdown-divider');
56
- }
57
- else if(!isDropdownItem && !isDropdownDivider) {
58
- appendClass(vnode, 'dropdown-item');
59
- }
60
- });
61
-
62
- return context.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
+ }
39
+
40
+ vnode.props = Object.assign({ class: undefined }, vnode.props);
41
+ vnode.attrs = Object.assign({}, vnode.attrs);
42
+
43
+ if(!vnode.attrs.on) {
44
+ vnode.attrs.on = {};
45
+ }
46
+
47
+ const isDropdownItem = vnode.props.class && vnode.props.class.match(/dropdown-item/);
48
+ const isDropdownDivider = vnode.props.class && vnode.props.class.match(/dropdown-divider/);
49
+
50
+ vnode.attrs.on.click = wrap(e => {
51
+ context.parent.$emit('click-item', e, vnode);
52
+ }, listener(vnode, 'click'));
53
+
54
+ vnode.attrs.on.blur = wrap(e => {
55
+ context.parent.$emit('blur-item', e, vnode);
56
+ }, listener(vnode, 'blur'));
57
+
58
+ if(typeof vnode.type === 'string' && vnode.type.match(/^h\d$/)) {
59
+ appendClass(vnode, 'dropdown-header');
60
+ }
61
+ else if(vnode.type === 'hr' && !isDropdownDivider) {
62
+ vnode.type = 'div';
63
+
64
+ appendClass(vnode, 'dropdown-divider');
65
+ }
66
+ else if(!isDropdownItem && !isDropdownDivider) {
67
+ appendClass(vnode, 'dropdown-item');
68
+ }
63
69
  }
64
70
 
65
- };
71
+ return items;
72
+ }
73
+
74
+ const DropdownMenuItems = (props, context) => h('div', {}, changeMenuItems(context.slots.default()));
75
+
76
+ export default DropdownMenuItems;
66
77
  </script>