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

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,68 @@
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 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();
54
4
  }
55
- function wrap(wrapper, fn) {
5
+ function p(r, s) {
56
6
  return (e) => {
57
- if (typeof fn === "function") {
58
- fn(e);
59
- }
60
- if (!e.cancelBubble) {
61
- wrapper(e);
62
- }
7
+ typeof s == "function" && s(e), e.cancelBubble || r(e);
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 a(r, s) {
11
+ return r.attrs.on[s] || r.type && r.type.listeners && r.componentOptions.listeners[s];
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];
102
- }
103
- }
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 = {
13
+ const g = (r, s) => {
14
+ const e = s.slots.default()[0].children;
15
+ return e.forEach((t) => {
16
+ 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;
28
+ return e;
29
+ }, k = {
119
30
  name: "DropdownMenu",
120
31
  components: {
121
- DropdownMenuItems
32
+ DropdownMenuItems: y
122
33
  },
123
34
  props: {
124
35
  align: {
125
36
  type: String,
126
37
  default: "left",
127
- validate(value) {
128
- return ["left", "right"].indexOf(value.toLowerCase()) !== -1;
38
+ validate(r) {
39
+ return ["left", "right"].indexOf(r.toLowerCase()) !== -1;
129
40
  }
130
41
  },
131
42
  show: Boolean
132
43
  }
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
- }
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", {
48
+ class: w(["dropdown-menu", {
49
+ "dropdown-menu-left": e.align === "left",
50
+ "dropdown-menu-right": e.align === "right",
51
+ show: e.show
52
+ }]),
53
+ "aria-labelledby": r.$attrs.id
54
+ }, [
55
+ h(o, null, {
56
+ default: _(() => [
57
+ b(r.$slots, "default", {
58
+ onClick: s[0] || (s[0] = (...c) => r.onItemClick && r.onItemClick(...c))
59
+ })
60
+ ]),
61
+ _: 3
62
+ })
63
+ ], 10, C);
140
64
  }
141
- var DropdownMenu = /* @__PURE__ */ function() {
142
- return __component__.exports;
143
- }();
144
- export { DropdownMenu };
65
+ const O = /* @__PURE__ */ $(k, [["render", D]]);
66
+ export {
67
+ O as DropdownMenu
68
+ };
@@ -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(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"}})});
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.0",
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,50 @@ 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
+ const DropdownMenuItems = (props, context) => {
29
+ const children = context.slots.default()[0].children;
28
30
 
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
- }
31
+ children.forEach(vnode => {
32
+ vnode.props = Object.assign({ class: undefined }, vnode.props);
33
+ vnode.attrs = Object.assign({}, vnode.attrs);
37
34
 
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'));
35
+ if(!vnode.attrs.on) {
36
+ vnode.attrs.on = {};
37
+ }
44
38
 
45
- vnode.data.on.blur = wrap(e => {
46
- context.parent.$emit('blur-item', e, vnode);
47
- }, listener(vnode, 'blur'));
39
+ const isDropdownItem = vnode.props.class && vnode.props.class.match(/dropdown-item/);
40
+ const isDropdownDivider = vnode.props.class && vnode.props.class.match(/dropdown-divider/);
48
41
 
49
- if(vnode.tag.match(/^h\d$/)) {
50
- appendClass(vnode, 'dropdown-header');
51
- }
52
- else if(vnode.tag === 'hr' && !isDropdownDivider) {
53
- vnode.tag = 'div';
42
+ vnode.attrs.on.click = wrap(e => {
43
+ context.parent.$emit('click-item', e, vnode);
44
+ }, listener(vnode, 'click'));
54
45
 
55
- appendClass(vnode, 'dropdown-divider');
56
- }
57
- else if(!isDropdownItem && !isDropdownDivider) {
58
- appendClass(vnode, 'dropdown-item');
59
- }
60
- });
46
+ vnode.attrs.on.blur = wrap(e => {
47
+ context.parent.$emit('blur-item', e, vnode);
48
+ }, listener(vnode, 'blur'));
61
49
 
62
- return context.children;
63
- }
50
+ if(typeof vnode.type === 'string' && vnode.type.match(/^h\d$/)) {
51
+ appendClass(vnode, 'dropdown-header');
52
+ }
53
+ else if(vnode.type === 'hr' && !isDropdownDivider) {
54
+ vnode.type = 'div';
64
55
 
56
+ appendClass(vnode, 'dropdown-divider');
57
+ }
58
+ else if(!isDropdownItem && !isDropdownDivider) {
59
+ appendClass(vnode, 'dropdown-item');
60
+ }
61
+ });
62
+
63
+ return h('div', {}, children);
65
64
  };
65
+
66
+ export default DropdownMenuItems;
66
67
  </script>