@vue-interface/dropdown-menu 0.9.8 → 1.0.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.
package/babel.config.js CHANGED
@@ -1,7 +1,5 @@
1
1
  module.exports = {
2
2
  presets: [
3
- ['@vue/cli-plugin-babel/preset', {
4
- "modules": false
5
- }]
3
+ 'vue'
6
4
  ]
7
5
  };
@@ -0,0 +1,144 @@
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();
54
+ }
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
+ }
63
+ };
64
+ }
65
+ function listener(vnode, key) {
66
+ return vnode.data.on[key] || vnode.componentOptions && vnode.componentOptions.listeners && vnode.componentOptions.listeners[key];
67
+ }
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) {
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 mb-3", 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 = {
119
+ name: "DropdownMenu",
120
+ components: {
121
+ DropdownMenuItems
122
+ },
123
+ props: {
124
+ align: {
125
+ type: String,
126
+ default: "left",
127
+ validate(value) {
128
+ return ["left", "right"].indexOf(value.toLowerCase()) !== -1;
129
+ }
130
+ },
131
+ show: Boolean
132
+ }
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
+ }
140
+ }
141
+ var DropdownMenu = /* @__PURE__ */ function() {
142
+ return __component__.exports;
143
+ }();
144
+ export { DropdownMenu };
@@ -0,0 +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||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 mb-3",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"});
Binary file
package/index.css ADDED
@@ -0,0 +1,3 @@
1
+ @import "tailwindcss/base";
2
+ @import "tailwindcss/components";
3
+ @import "tailwindcss/utilities";
package/index.html CHANGED
@@ -4,15 +4,12 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
6
  <title>DropdownMenu</title>
7
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap-reboot.min.css">
8
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap-grid.min.css">
9
- <link rel="stylesheet" href="./dist/DropdownMenu.css">
10
7
  </head>
11
8
  <body>
12
- <div id="app" class="container">
13
- <h1>dropdown-menu</h1>
9
+ <div id="app" class="container mx-auto">
10
+ <h1 class="text-4xl mb-6">dropdown-menu</h1>
14
11
 
15
- <h3>Basic Usage</h3>
12
+ <h3 class="text-2xl">Basic Usage</h3>
16
13
 
17
14
  <span v-if="hasClicked">Item #4 was clicked!</span>
18
15
 
@@ -30,10 +27,14 @@
30
27
  </div>
31
28
  </div>
32
29
 
33
- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
34
- <script src="https://cdn.jsdelivr.net/npm/vue-router/dist/vue-router.js"></script>
35
- <script type="text/javascript" src="./dist/DropdownMenu.umd.js"></script>
36
- <script type="text/javascript">
30
+ <script type="module">
31
+ import './index.css';
32
+ import Vue from 'vue/dist/vue';
33
+ import VueRouter from 'vue-router';
34
+ import { DropdownMenu } from './index';
35
+
36
+ Vue.config.devtools = false;
37
+ Vue.config.productionTip = false;
37
38
  Vue.use(VueRouter);
38
39
 
39
40
  const router = new VueRouter({
@@ -42,7 +43,7 @@
42
43
  name: 'Home'
43
44
  }]
44
45
  });
45
-
46
+
46
47
  const vue = new Vue({
47
48
  el: '#app',
48
49
  router,
@@ -53,7 +54,7 @@
53
54
  return {
54
55
  hasClicked: false,
55
56
  hasClicked2: false
56
- }
57
+ };
57
58
  }
58
59
  });
59
60
  </script>
package/index.js CHANGED
@@ -1,2 +1,5 @@
1
- import DropdownMenu from './src/DropdownMenu';
2
- export default DropdownMenu;
1
+ import DropdownMenu from './src/DropdownMenu.vue';
2
+
3
+ export {
4
+ DropdownMenu
5
+ };
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@vue-interface/dropdown-menu",
3
- "version": "0.9.8",
3
+ "version": "1.0.0",
4
4
  "description": "A Vue dropdown menu component.",
5
5
  "main": "index.js",
6
+ "module": "index.js",
7
+ "browserslist": "last 2 versions, > 0.5%, ie >= 11",
6
8
  "scripts": {
9
+ "dev": "vite",
10
+ "build": "vite build",
11
+ "preview": "vite preview",
7
12
  "watch": "npm run serve",
8
13
  "serve": "vue-cli-service build --target lib --name=DropdownMenu ./main.vue --watch",
9
- "build": "vue-cli-service build --target lib --name=DropdownMenu ./main.vue",
10
14
  "lint": "vue-cli-service lint",
11
15
  "fix": "vue-cli-service lint --fix",
12
16
  "pre-release": "npm run build; git add . -A; git commit -m 'pre-release commit'",
@@ -37,28 +41,23 @@
37
41
  },
38
42
  "homepage": "https://github.com/vue-interface/dropdown-menu/docs#readme",
39
43
  "dependencies": {
40
- "@vue-interface/tailwindcss": "^0.2.5",
41
- "@vue-interface/utils": "^0.9.13",
42
- "@vue-interface/variant": "^1.0.12",
43
- "color": "^3.1.2",
44
- "core-js": "^3.6.4",
45
- "hex-to-rgba": "^2.0.1",
46
- "tailwindcss": "^1.7.3",
47
44
  "vue": "^2.6.12"
48
45
  },
49
46
  "devDependencies": {
50
- "@vue/cli-plugin-babel": "^4.5.4",
51
- "@vue/cli-plugin-eslint": "^4.5.4",
52
- "@vue/cli-service": "^4.5.4",
53
- "@vuepress/plugin-register-components": "^1.5.4",
47
+ "@rollup/plugin-babel": "^5.3.0",
48
+ "@vue-interface/tailwindcss": "^0.2.10",
49
+ "autoprefixer": "^10.4.2",
54
50
  "babel-eslint": "^10.1.0",
51
+ "babel-preset-vue": "^2.0.2",
52
+ "change-case": "^4.1.2",
53
+ "color": "^4.2.0",
55
54
  "eslint": "^6.7.2",
56
55
  "eslint-plugin-vue": "^6.2.2",
57
- "markdown-it-meta": "0.0.1",
58
- "postcss-cli": "^7.1.1",
59
- "vue-template-compiler": "^2.6.12",
60
- "vuepress": "^1.5.4",
61
- "vuepress-plugin-template-constants": "^0.2.1",
62
- "webpack-manifest-plugin": "^2.2.0"
56
+ "pascalcase": "^2.0.0",
57
+ "postcss": "^8.4.6",
58
+ "tailwindcss": "^3.0.18",
59
+ "vite": "^2.7.2",
60
+ "vite-plugin-vue2": "^1.9.3",
61
+ "vue-router": "^3.5.3"
63
62
  }
64
63
  }
package/postcss.config.js CHANGED
@@ -1 +1,6 @@
1
- module.exports = {};
1
+ module.exports = {
2
+ plugins: [
3
+ require('tailwindcss'),
4
+ require('autoprefixer'),
5
+ ]
6
+ };
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <hr class="dropdown-divider">
3
+ </template>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <h3 class="dropdown-header">
3
+ <slot />
4
+ </h3>
5
+ </template>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div class="dropdown-item">
3
+ <slot />
4
+ </div>
5
+ </template>
@@ -1,8 +1,12 @@
1
1
  <template>
2
2
  <div
3
- class="dropdown-menu"
4
- :class="{'dropdown-menu-left': align === 'left', 'dropdown-menu-right': align === 'right', 'show': show}"
5
- :aria-labelledby="$attrs.id">
3
+ class="dropdown-menu mb-3"
4
+ :aria-labelledby="$attrs.id"
5
+ :class="{
6
+ 'dropdown-menu-left': align === 'left',
7
+ 'dropdown-menu-right': align === 'right',
8
+ 'show': show
9
+ }">
6
10
  <dropdown-menu-items>
7
11
  <slot @click="onItemClick" />
8
12
  </dropdown-menu-items>
@@ -10,7 +14,7 @@
10
14
  </template>
11
15
 
12
16
  <script>
13
- import DropdownMenuItems from './DropdownMenuItems';
17
+ import DropdownMenuItems from './DropdownMenuItems.vue';
14
18
 
15
19
  export default {
16
20
 
@@ -45,10 +49,4 @@ export default {
45
49
  }
46
50
 
47
51
  };
48
- </script>
49
-
50
- <style>
51
- .dropdown-menu a.dropdown-item {
52
- cursor: pointer;
53
- }
54
- </style>
52
+ </script>
@@ -1,6 +1,4 @@
1
1
  <script>
2
- import { isUndefined } from '@vue-interface/utils';
3
-
4
2
  function appendClass(vnode, str) {
5
3
  vnode.data.staticClass = `${vnode.data.staticClass || ''} ${str}`.trim();
6
4
  }
@@ -37,8 +35,8 @@ export default {
37
35
  vnode.data.on = {};
38
36
  }
39
37
 
40
- const isDropdownItem = vnode.data.staticClass && !vnode.data.staticClass.match(/dropdown-item/);
41
- const isDropdownDivider = vnode.data.staticClass && !vnode.data.staticClass.match(/dropdown-divider/);
38
+ const isDropdownItem = vnode.data.staticClass && vnode.data.staticClass.match(/dropdown-item/);
39
+ const isDropdownDivider = vnode.data.staticClass && vnode.data.staticClass.match(/dropdown-divider/);
42
40
 
43
41
  vnode.data.on.click = wrap(e => {
44
42
  context.parent.$emit('click-item', e, vnode);
@@ -51,12 +49,12 @@ export default {
51
49
  if(vnode.tag.match(/^h\d$/)) {
52
50
  appendClass(vnode, 'dropdown-header');
53
51
  }
54
- else if(vnode.tag === 'hr') {
52
+ else if(vnode.tag === 'hr' && !isDropdownDivider) {
55
53
  vnode.tag = 'div';
56
54
 
57
55
  appendClass(vnode, 'dropdown-divider');
58
56
  }
59
- else if(!isDropdownItem && !isDropdownDivider) {
57
+ else if(!isDropdownItem) {
60
58
  appendClass(vnode, 'dropdown-item');
61
59
  }
62
60
  });
@@ -1,12 +1,12 @@
1
- const plugin = require('tailwindcss/plugin');
2
-
3
1
  module.exports = {
4
- purge: false,
5
- corePlugins: {
6
- container: false,
2
+ content: [
3
+ "./index.html",
4
+ "./src/**/*.{vue,js,ts,jsx,tsx}",
5
+ ],
6
+ theme: {
7
+ extend: {},
7
8
  },
8
9
  plugins: [
9
- require('@vue-interface/variant/tailwindcss'),
10
10
  require('./tailwindcss')
11
- ]
12
- };
11
+ ],
12
+ };
@@ -1,14 +1,13 @@
1
1
  const Color = require('color');
2
- const rgba = require('hex-to-rgba');
3
2
  const plugin = require('tailwindcss/plugin');
4
- const { colors } = require('tailwindcss/defaultTheme');
3
+ const colors = require('tailwindcss/colors');
5
4
  const defaultVariations = require('@vue-interface/tailwindcss/defaultVariations');
6
5
 
7
6
  function darken(color, ...args) {
8
7
  return Color(color).darken(...args).hex();
9
8
  }
10
9
 
11
- module.exports = plugin(function({ addComponents, theme, postcss }) {
10
+ module.exports = plugin(function({ addComponents, theme }) {
12
11
  const component = {
13
12
  ':root': {
14
13
  '--dropdown-menu-z-index': theme('dropdownMenu.zIndex'),
@@ -186,13 +185,13 @@ module.exports = plugin(function({ addComponents, theme, postcss }) {
186
185
  backgroundColor: theme('dropdownMenu.link.hover.backgroundColor')
187
186
  },
188
187
 
189
- 'dropdown-item.active, dropdown-item:active': {
188
+ '.dropdown-item.active, .dropdown-item:active': {
190
189
  color: theme('dropdownMenu.link.active.color'),
191
190
  textDecoration: 'none',
192
191
  backgroundColor: theme('dropdownMenu.link.active.backgroundColor')
193
192
  },
194
193
 
195
- 'dropdown-item.disabled, dropdown-item:disabled': {
194
+ '.dropdown-item.disabled, .dropdown-item:disabled': {
196
195
  color: theme('dropdownMenu.link.disabled.color'),
197
196
  pointerEvents: 'none',
198
197
  backgroundColor: 'transparent',
@@ -256,10 +255,10 @@ module.exports = plugin(function({ addComponents, theme, postcss }) {
256
255
  fontSize: '1rem',
257
256
  color: 'inherit',
258
257
  backgroundColor: theme('colors.white', colors.white),
259
- borderColor: rgba(theme('colors.black', colors.black), .15),
258
+ borderColor: Color(theme('colors.black', colors.black)).fade(.85),
260
259
  borderRadius: '.25rem',
261
260
  borderWidth: '1px',
262
- boxShadow: `0 .5rem 1rem ${rgba(theme('colors.black', colors.black), .15)}`,
261
+ boxShadow: `0 .5rem 1rem ${Color(theme('colors.black', colors.black)).fade(.85)}`,
263
262
 
264
263
  inner: {
265
264
  borderRadius: 'calc(.25rem - 1px)'
@@ -273,7 +272,7 @@ module.exports = plugin(function({ addComponents, theme, postcss }) {
273
272
  color: theme('colors.gray.800', colors.gray[800]),
274
273
 
275
274
  hover: {
276
- color: darken(theme('colors.gray.800', colors.gray[800]), .5),
275
+ color: Color(theme('colors.gray.800', colors.gray[800])).darken(.5).hex(),
277
276
  backgroundColor: theme('colors.gray.100', colors.gray[100])
278
277
  },
279
278
 
package/vite.config.js ADDED
@@ -0,0 +1,38 @@
1
+ import { defineConfig } from 'vite';
2
+ import { createVuePlugin } from 'vite-plugin-vue2';
3
+ import { name } from './package.json';
4
+ import { pascalCase } from "change-case";
5
+ import { babel } from '@rollup/plugin-babel';
6
+
7
+ const filename = name.split('/')[1];
8
+
9
+ export default defineConfig({
10
+ build: {
11
+ lib: {
12
+ entry: 'index.js',
13
+ name: pascalCase(filename),
14
+ fileName: (format) => `${filename}.${format}.js`,
15
+ },
16
+ rollupOptions: {
17
+ external: ['vue'],
18
+ output: {
19
+ globals: {
20
+ vue: 'Vue'
21
+ },
22
+ },
23
+ plugins: [
24
+ babel({
25
+ babelHelpers: 'bundled'
26
+ })
27
+ ]
28
+ },
29
+ watch: {
30
+ include: [
31
+ './tailwindcss/**/*.js'
32
+ ]
33
+ }
34
+ },
35
+ plugins: [
36
+ createVuePlugin()
37
+ ],
38
+ });