@vue-interface/btn-dropdown 0.9.13 → 1.0.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.
Files changed (47) hide show
  1. package/package.json +26 -30
  2. package/src/BtnDropdown.vue +16 -10
  3. package/src/BtnDropdownSingle.vue +20 -17
  4. package/src/BtnDropdownSplit.vue +46 -39
  5. package/src/DropdownHandler.js +46 -44
  6. package/.eslintrc.js +0 -53
  7. package/babel.config.js +0 -7
  8. package/dist/BtnDropdown.common.js +0 -6902
  9. package/dist/BtnDropdown.common.js.map +0 -1
  10. package/dist/BtnDropdown.css +0 -1
  11. package/dist/BtnDropdown.umd.js +0 -6912
  12. package/dist/BtnDropdown.umd.js.map +0 -1
  13. package/dist/BtnDropdown.umd.min.js +0 -2
  14. package/dist/BtnDropdown.umd.min.js.map +0 -1
  15. package/dist/demo.html +0 -19
  16. package/docs/.vuepress/config.js +0 -44
  17. package/docs/.vuepress/dist/404.html +0 -19
  18. package/docs/.vuepress/dist/assets/css/0.styles.275ee968.css +0 -1
  19. package/docs/.vuepress/dist/assets/img/search.83621669.svg +0 -1
  20. package/docs/.vuepress/dist/assets/js/10.5d93d289.js +0 -1
  21. package/docs/.vuepress/dist/assets/js/11.97ab3884.js +0 -1
  22. package/docs/.vuepress/dist/assets/js/2.f3d148c3.js +0 -1
  23. package/docs/.vuepress/dist/assets/js/3.81681fff.js +0 -1
  24. package/docs/.vuepress/dist/assets/js/4.82fa7382.js +0 -1
  25. package/docs/.vuepress/dist/assets/js/5.3dae6ad4.js +0 -1
  26. package/docs/.vuepress/dist/assets/js/6.6a04f815.js +0 -1
  27. package/docs/.vuepress/dist/assets/js/7.c033cb49.js +0 -1
  28. package/docs/.vuepress/dist/assets/js/8.6d6eb599.js +0 -1
  29. package/docs/.vuepress/dist/assets/js/9.eaefe866.js +0 -1
  30. package/docs/.vuepress/dist/assets/js/app.7ed065d3.js +0 -13
  31. package/docs/.vuepress/dist/examples/index.html +0 -21
  32. package/docs/.vuepress/dist/examples/test.html +0 -17
  33. package/docs/.vuepress/dist/index.html +0 -53
  34. package/docs/.vuepress/dist/options.html +0 -41
  35. package/docs/.vuepress/dist/tailwindcss.html +0 -85
  36. package/docs/README.md +0 -17
  37. package/docs/examples/README.md +0 -3
  38. package/docs/options.md +0 -44
  39. package/index.html +0 -328
  40. package/index.js +0 -3
  41. package/main.vue +0 -5
  42. package/postcss.config.js +0 -1
  43. package/public/favicon.ico +0 -0
  44. package/public/index.html +0 -17
  45. package/src/css/BtnDropdown.css +0 -1
  46. package/tailwind.config.js +0 -13
  47. package/vue.config.js +0 -11
package/package.json CHANGED
@@ -1,22 +1,23 @@
1
1
  {
2
2
  "name": "@vue-interface/btn-dropdown",
3
- "version": "0.9.13",
3
+ "version": "1.0.2",
4
4
  "description": "A Vue button dropdown component.",
5
- "main": "index.js",
5
+ "files": [
6
+ "dist",
7
+ "src"
8
+ ],
9
+ "main": "./dist/btn-dropdown.umd.js",
10
+ "module": "./index.js",
11
+ "browserslist": "last 2 versions, > 0.5%, ie >= 11",
6
12
  "scripts": {
7
- "watch": "npm run serve",
8
- "serve": "vue-cli-service build --target lib --name=BtnDropdown ./main.vue --watch",
9
- "build": "vue-cli-service build --target lib --name=BtnDropdown ./main.vue",
10
- "lint": "vue-cli-service lint",
11
- "fix": "vue-cli-service lint --fix",
13
+ "dev": "vite",
14
+ "build": "vite build",
15
+ "preview": "vite preview",
12
16
  "pre-release": "npm run build; git add . -A; git commit -m 'pre-release commit'",
13
17
  "release-patch": "npm run pre-release && npm version patch -m \"%s\" && npm run release;",
14
18
  "release-minor": "npm run pre-release && npm version minor -m \"%s\" && npm run release;",
15
19
  "release-major": "npm run pre-release && npm version major -m \"%s\" && npm run release;",
16
- "release": "git add . -A; git commit; git push --tags origin; npm publish;",
17
- "test": "echo \"Error: no test specified\" && exit 1",
18
- "docs:dev": "./node_modules/.bin/vuepress dev docs",
19
- "docs:build": "./node_modules/.bin/vuepress build docs"
20
+ "release": "git add . -A; git commit; git push --tags origin; npm publish;"
20
21
  },
21
22
  "repository": {
22
23
  "type": "git",
@@ -38,29 +39,24 @@
38
39
  },
39
40
  "homepage": "https://github.com/vue-interface/btn-dropdown/docs#readme",
40
41
  "dependencies": {
41
- "@popperjs/core": "^2.4.4",
42
- "@vue-interface/btn": "^0.9.8",
43
- "@vue-interface/btn-group": "^0.9.1",
44
- "@vue-interface/dropdown-menu": "^0.9.8",
45
- "@vue-interface/tailwindcss": "^0.2.5",
46
- "@vue-interface/utils": "^0.9.16",
47
- "core-js": "^3.6.4",
48
- "tailwindcss": "^1.7.6",
49
- "vue": "^2.6.12"
42
+ "@popperjs/core": "^2.11.2",
43
+ "@vue-interface/btn": "^1.0.0",
44
+ "@vue-interface/btn-group": "^1.0.0",
45
+ "@vue-interface/dropdown-menu": "^1.0.0",
46
+ "vue": "^2.6.14"
50
47
  },
51
48
  "devDependencies": {
52
- "@vue/cli-plugin-babel": "^4.0",
53
- "@vue/cli-plugin-eslint": "^4.0",
54
- "@vue/cli-service": "^4.0",
55
- "@vuepress/plugin-register-components": "^1.5.4",
49
+ "@rollup/plugin-babel": "^5.3.0",
50
+ "autoprefixer": "^10.4.2",
56
51
  "babel-eslint": "^10.1.0",
52
+ "babel-preset-vue": "^2.0.2",
53
+ "change-case": "^4.1.2",
57
54
  "eslint": "^6.7.2",
58
55
  "eslint-plugin-vue": "^6.2.2",
59
- "markdown-it-meta": "0.0.1",
60
- "postcss-cli": "^7.1.1",
61
- "vue-template-compiler": "^2.6.12",
62
- "vuepress": "^1.5.4",
63
- "vuepress-plugin-template-constants": "^0.2.1",
64
- "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"
65
61
  }
66
62
  }
@@ -17,13 +17,19 @@
17
17
  {{ $attrs.label }}
18
18
  </slot>
19
19
  </template>
20
+ <template #button="slot">
21
+ <slot name="button" v-bind="slot" />
22
+ </template>
23
+ <template #split="slot">
24
+ <slot name="split" v-bind="slot" />
25
+ </template>
20
26
  <slot />
21
27
  </component>
22
28
  </template>
23
29
 
24
30
  <script>
25
- import BtnDropdownSplit from './BtnDropdownSplit';
26
- import BtnDropdownSingle from './BtnDropdownSingle';
31
+ import BtnDropdownSplit from './BtnDropdownSplit.vue';
32
+ import BtnDropdownSingle from './BtnDropdownSingle.vue';
27
33
 
28
34
  export default {
29
35
 
@@ -43,10 +49,9 @@ export default {
43
49
  @keyframes btnDropdownZoomIn {
44
50
  from {
45
51
  opacity: 0;
46
- transform: scale3d(0.3, 0.3, 0.3);
47
52
  }
48
53
 
49
- 50% {
54
+ to {
50
55
  opacity: 1;
51
56
  }
52
57
  }
@@ -70,18 +75,18 @@ export default {
70
75
 
71
76
  .btn-dropdown.rounded-circle > .btn:last-child,
72
77
  .btn-dropdown.rounded-circle > .btn-group:last-child .dropdown-toggle {
73
- border-top-right-radius: 1000rem;
74
- border-bottom-right-radius: 1000rem;
78
+ border-top-right-radius: 100%;
79
+ border-bottom-right-radius: 100%;
75
80
  }
76
81
 
77
82
  .btn-dropdown.rounded-circle > .btn:first-child,
78
83
  .btn-dropdown.rounded-circle > .btn-group:first-child .dropdown-toggle {
79
- border-top-left-radius: 1000rem;
80
- border-bottom-left-radius: 1000rem;
84
+ border-top-left-radius: 100%;
85
+ border-bottom-left-radius: 100%;
81
86
  }
82
87
 
83
88
  .btn-dropdown .rounded-circle {
84
- border-radius: 1000rem;
89
+ border-radius: 100%;
85
90
  }
86
91
 
87
92
  .btn-dropdown .rotate-90 {
@@ -96,7 +101,8 @@ export default {
96
101
  }
97
102
 
98
103
  .btn-dropdown .dropdown-menu {
99
- animation-duration: 125ms;
104
+ animation-timing-function: ease-in-out;
105
+ animation-duration: 200ms;
100
106
  animation-fill-mode: both;
101
107
  }
102
108
 
@@ -1,27 +1,30 @@
1
1
  <template>
2
2
  <btn-group :class="classes">
3
- <btn-dropdown-action
4
- :id="$attrs.id"
5
- ref="button"
6
- :expanded="isDropdownShowing"
7
- :href="href"
8
- :to="to"
9
- :style="toggleStyle"
10
- :class="toggleClasses"
11
- @click.native="onClickToggle">
12
- <slot name="icon" />
13
- <slot name="label">
14
- {{ label }}
15
- </slot>
16
- </btn-dropdown-action>
3
+ <slot name="button" v-bind="this">
4
+ <btn-dropdown-action
5
+ :id="$attrs.id"
6
+ ref="button"
7
+ :expanded="expanded"
8
+ :href="href"
9
+ :to="to"
10
+ :style="toggleStyle"
11
+ :class="toggleClasses"
12
+ @blur.native="onBlur"
13
+ @click.native="onClickToggle">
14
+ <slot name="icon" />
15
+ <slot name="label">
16
+ {{ label }}
17
+ </slot>
18
+ </btn-dropdown-action>
19
+ </slot>
17
20
  <dropdown-menu
18
21
  :id="$attrs.id"
19
22
  ref="menu"
20
23
  :align="align"
21
- :show="isDropdownShowing"
24
+ :show="expanded"
22
25
  :class="{animated: triggerAnimation}"
23
- @click-item="onClickItem"
24
- @blur-item="onBlurItem">
26
+ @blur-item="onBlur"
27
+ @click-item="onClickItem">
25
28
  <slot />
26
29
  </dropdown-menu>
27
30
  </btn-group>
@@ -1,55 +1,62 @@
1
1
  <template>
2
2
  <btn-group :class="classes" class="btn-dropdown-split" @click="onClick">
3
- <btn-dropdown-action
4
- v-if="!dropleft"
5
- :id="$attrs.id"
6
- ref="button"
7
- :expanded="isDropdownShowing"
8
- :href="href"
9
- :to="to"
10
- :class="actionClasses"
11
- @click.native="e => $emit('click', e)">
12
- <slot name="icon" />
13
- <slot name="label">
14
- {{ label }}
15
- </slot>
16
- </btn-dropdown-action>
17
- <btn-group>
18
- <button
19
- v-if="split"
3
+ <slot v-if="!dropleft" name="button" v-bind="this">
4
+ <btn-dropdown-action
5
+ v-if="!dropleft"
20
6
  :id="$attrs.id"
21
- ref="split"
22
- type="button"
23
- aria-haspopup="true"
24
- :aria-expanded="isDropdownShowing"
25
- :class="toggleClasses"
26
- @click="onClickToggle" />
7
+ ref="button"
8
+ :expanded="expanded"
9
+ :href="href"
10
+ :to="to"
11
+ :class="actionClasses"
12
+ @click.native="e => $emit('click', e)">
13
+ <slot name="icon" />
14
+ <slot name="label">
15
+ {{ label }}
16
+ </slot>
17
+ </btn-dropdown-action>
18
+ </slot>
19
+
20
+ <btn-group ref="split">
21
+ <slot name="split" v-bind="this">
22
+ <button
23
+ v-if="split"
24
+ :id="$attrs.id"
25
+ type="button"
26
+ aria-haspopup="true"
27
+ :aria-expanded="expanded"
28
+ :class="toggleClasses"
29
+ @blur="onBlur"
30
+ @click="onClickToggle" />
31
+ </slot>
27
32
 
28
33
  <dropdown-menu
29
34
  :id="$attrs.id"
30
35
  ref="menu"
31
36
  :align="align"
32
- :show="isDropdownShowing"
37
+ :show="expanded"
33
38
  :class="{animated: triggerAnimation}"
34
39
  @click-item="onClickItem"
35
- @blur-item="onBlurItem">
40
+ @blur-item="onBlur">
36
41
  <slot />
37
42
  </dropdown-menu>
38
43
  </btn-group>
39
- <btn-dropdown-action
40
- v-if="dropleft"
41
- :id="$attrs.id"
42
- ref="button"
43
- :expanded="isDropdownShowing"
44
- :href="href"
45
- :to="to"
46
- :class="actionClasses"
47
- @click.native="e => $emit('click', e)">
48
- <slot name="icon" />
49
- <slot name="label">
50
- {{ label }}
51
- </slot>
52
- </btn-dropdown-action>
44
+ <slot v-if="dropleft" name="button" v-bind="this">
45
+ <btn-dropdown-action
46
+ v-if="dropleft"
47
+ :id="$attrs.id"
48
+ ref="button"
49
+ :expanded="expanded"
50
+ :href="href"
51
+ :to="to"
52
+ :class="actionClasses"
53
+ @click.native="e => $emit('click', e)">
54
+ <slot name="icon" />
55
+ <slot name="label">
56
+ {{ label }}
57
+ </slot>
58
+ </btn-dropdown-action>
59
+ </slot>
53
60
  </btn-group>
54
61
  </template>
55
62
 
@@ -1,9 +1,8 @@
1
- import BtnDropdownAction from './BtnDropdownAction';
2
1
  import { createPopper } from '@popperjs/core';
3
- import Btn from '@vue-interface/btn';
2
+ import { Btn } from '@vue-interface/btn';
4
3
  import { BtnGroup } from '@vue-interface/btn-group';
5
- import DropdownMenu from '@vue-interface/dropdown-menu';
6
- import { prefix } from '@vue-interface/utils';
4
+ import { DropdownMenu } from '@vue-interface/dropdown-menu';
5
+ import BtnDropdownAction from './BtnDropdownAction.vue';
7
6
 
8
7
  const TAB_KEYCODE = 9;
9
8
 
@@ -42,12 +41,7 @@ export default {
42
41
  default: true
43
42
  },
44
43
 
45
- /**
46
- * The button icon that appears before the label.
47
- *
48
- * @property {Boolean}
49
- */
50
- autoclose: Boolean,
44
+ // buttonClass: String,
51
45
 
52
46
  /**
53
47
  * Show the caret.
@@ -64,10 +58,11 @@ export default {
64
58
  *
65
59
  * @property Boolean
66
60
  */
67
- circle: {
68
- type: Boolean,
69
- default: false
70
- },
61
+
62
+ // circle: {
63
+ // type: Boolean,
64
+ // default: false
65
+ // },
71
66
 
72
67
  /**
73
68
  * Display as a dropup instead of a dropdown.
@@ -128,6 +123,11 @@ export default {
128
123
  */
129
124
  label: String,
130
125
 
126
+ offset: {
127
+ type: Number,
128
+ default: 5,
129
+ },
130
+
131
131
  /**
132
132
  * Should rotate the toggle button when opened.
133
133
  *
@@ -178,7 +178,7 @@ export default {
178
178
  return {
179
179
  popper: null,
180
180
  triggerAnimation: false,
181
- isDropdownShowing: false
181
+ expanded: false
182
182
  };
183
183
  },
184
184
 
@@ -215,17 +215,17 @@ export default {
215
215
  'dropleft': this.dropleft,
216
216
  'icon-only': !this.nav && !this.split && !!this.$slots.icon && !this.$slots.label,
217
217
  'hide-caret': !this.caret,
218
- 'expanded': this.isDropdownShowing,
219
- 'rounded-circle': !this.nav && this.split && this.circle,
220
- 'rotate-90': !this.nav && this.split && this.rotate && this.isDropdownShowing,
218
+ 'expanded': this.expanded,
219
+ // 'rounded-circle': !this.nav && this.split && this.circle,
220
+ 'rotate-90': !this.nav && this.split && this.rotate && this.expanded,
221
221
  };
222
222
  },
223
223
 
224
224
  actionClasses() {
225
225
  return [
226
226
  !this.nav && 'btn',
227
- !this.nav && prefix(this.size, 'btn'),
228
- !this.nav && prefix(this.variant, 'btn')
227
+ !this.nav && this.size && this.sizeableClass,
228
+ !this.nav && this.variant && this.variantClass,
229
229
  ]
230
230
  .filter(value => !!value)
231
231
  .join(' ');
@@ -240,14 +240,15 @@ export default {
240
240
 
241
241
  toggleClasses() {
242
242
  return [
243
+ // this.buttonClass,
243
244
  this.nav && 'nav-link',
244
245
  !this.nav && 'btn',
245
246
  !this.nav && this.variantClass,
246
247
  this.sizeableClass,
247
248
  this.active ? 'active' : '',
248
249
  this.block ? 'btn-block' : '',
249
- !this.split && this.circle ? 'rounded-circle' : '',
250
- !this.split && this.rotate && this.isDropdownShowing ? 'rotate-90' : '',
250
+ // !this.split && this.circle ? 'rounded-circle p-0' : '',
251
+ !this.split && this.rotate && this.expanded ? 'rotate-90' : '',
251
252
  !this.nav && this.split ? 'dropdown-toggle-split' : '',
252
253
  'dropdown-toggle',
253
254
  ]
@@ -261,23 +262,23 @@ export default {
261
262
  },
262
263
 
263
264
  mounted() {
264
- const toggle = this.$el.querySelector('.dropdown-toggle');
265
+ // const toggle = this.$el.querySelector('.dropdown-toggle');
265
266
 
266
- toggle.addEventListener('click', () => {
267
- if(!this.isDropdownShowing) {
268
- toggle.blur();
269
- }
270
- });
267
+ // toggle.addEventListener('click', () => {
268
+ // if(!this.expanded) {
269
+ // toggle.blur();
270
+ // }
271
+ // });
271
272
 
272
- toggle.addEventListener('blur', this.onBlurItem);
273
+ // toggle.addEventListener('blur', this.onBlurItem);
273
274
 
274
- const menu = this.$el.querySelector('.dropdown-menu');
275
+ // const menu = this.$el.querySelector('.dropdown-menu');
275
276
 
276
- menu.addEventListener('click', e => {
277
- if(e.target === menu) {
278
- toggle.focus();
279
- }
280
- });
277
+ // menu.addEventListener('click', e => {
278
+ // if(e.target === menu) {
279
+ // toggle.focus();
280
+ // }
281
+ // });
281
282
  },
282
283
 
283
284
  methods: {
@@ -323,7 +324,7 @@ export default {
323
324
  * @return void
324
325
  */
325
326
  toggle(e) {
326
- !this.isDropdownShowing ? this.show() : this.hide();
327
+ !this.expanded ? this.show() : this.hide();
327
328
  },
328
329
 
329
330
  /**
@@ -332,13 +333,13 @@ export default {
332
333
  * @return void
333
334
  */
334
335
  show() {
335
- this.isDropdownShowing = true;
336
+ this.expanded = true;
336
337
 
337
- const target = this.$refs.split || this.$el;
338
+ const target = this.$refs.split && this.$refs.split.$el || this.$el;
338
339
 
339
340
  // Hack for popper for align="right"
340
- this.$refs.menu.$el.style.left = 'auto';
341
- this.$refs.menu.$el.style.right = 'auto';
341
+ // this.$refs.menu.$el.style.left = 'auto';
342
+ // this.$refs.menu.$el.style.right = 'auto';
342
343
 
343
344
  if(!this.nav && !this.popper) {
344
345
  this.popper = createPopper(target, this.$refs.menu.$el, {
@@ -350,7 +351,8 @@ export default {
350
351
  {
351
352
  name: 'offset',
352
353
  options: {
353
- offset: [0, !this.nav ? 4 : 1],
354
+ offset: [0, !this.nav ? this.offset : 1]
355
+ // offset: ['.125rem', !this.nav ? 4 : 1],
354
356
  },
355
357
  },
356
358
  ]
@@ -367,7 +369,7 @@ export default {
367
369
  * @return void
368
370
  */
369
371
  hide() {
370
- this.isDropdownShowing = false;
372
+ this.expanded = false;
371
373
  },
372
374
 
373
375
  /**
@@ -375,7 +377,7 @@ export default {
375
377
  *
376
378
  * @return void
377
379
  */
378
- onBlurItem(e) {
380
+ onBlur(e) {
379
381
  if(!this.$el.contains(e.relatedTarget)) {
380
382
  this.hide();
381
383
  }
@@ -408,7 +410,7 @@ export default {
408
410
  },
409
411
 
410
412
  watch: {
411
- isDropdownShowing(value) {
413
+ expanded(value) {
412
414
  this.$nextTick(() => {
413
415
  this.$emit(value ? 'show' : 'hide');
414
416
  this.$emit('toggle', value);
package/.eslintrc.js DELETED
@@ -1,53 +0,0 @@
1
- module.exports = {
2
- extends: [
3
- 'plugin:vue/recommended'
4
- ],
5
- parserOptions: {
6
- 'parser': 'babel-eslint'
7
- },
8
- // add your custom rules here
9
- rules: {
10
- 'vue/no-v-html': 0,
11
- 'vue/require-default-prop': 0,
12
- "vue/max-attributes-per-line": ["error", {
13
- "singleline": 5,
14
- "multiline": {
15
- "max": 1,
16
- "allowFirstLine": true
17
- }
18
- }],
19
- "vue/html-indent": ["error", 4, {
20
- "attribute": 1,
21
- "baseIndent": 1,
22
- "closeBracket": 1,
23
- "alignAttributesVertically": false,
24
- "ignores": []
25
- }],
26
- "vue/html-closing-bracket-newline": ["error", {
27
- "singleline": "never",
28
- "multiline": "never"
29
- }],
30
- // Ensure no space after keywords like if.
31
- 'keyword-spacing': ["error", {
32
- "overrides": {
33
- "if": { "after": false },
34
- "for": { "after": false },
35
- "while": { "after": false }
36
- }
37
- }],
38
- // Use alternative brace style
39
- 'brace-style': ['error', 'stroustrup'],
40
- // No spaces before parens
41
- 'space-before-function-paren': ['error', 'never'],
42
- // Indent for tabs because spaces suck
43
- 'indent': ['error', 4],
44
- // Semi colons always where they need to be
45
- 'semi': [2,'always'],
46
- // allow paren-less arrow functions
47
- 'arrow-parens': 0,
48
- // allow async-await
49
- 'generator-star-spacing': 0,
50
- // allow debugger during development
51
- 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
52
- }
53
- };
package/babel.config.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- ['@vue/cli-plugin-babel/preset', {
4
- "modules": false
5
- }]
6
- ]
7
- };