@vue-interface/btn-dropdown 0.9.11 → 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.
Files changed (51) hide show
  1. package/dist/btn-dropdown.es.js +2179 -0
  2. package/dist/btn-dropdown.umd.js +1 -0
  3. package/dist/style.css +1 -0
  4. package/package.json +26 -29
  5. package/.eslintrc.js +0 -53
  6. package/babel.config.js +0 -7
  7. package/dist/BtnDropdown.common.js +0 -6902
  8. package/dist/BtnDropdown.common.js.map +0 -1
  9. package/dist/BtnDropdown.css +0 -1
  10. package/dist/BtnDropdown.umd.js +0 -6912
  11. package/dist/BtnDropdown.umd.js.map +0 -1
  12. package/dist/BtnDropdown.umd.min.js +0 -2
  13. package/dist/BtnDropdown.umd.min.js.map +0 -1
  14. package/dist/demo.html +0 -19
  15. package/docs/.vuepress/config.js +0 -44
  16. package/docs/.vuepress/dist/404.html +0 -19
  17. package/docs/.vuepress/dist/assets/css/0.styles.275ee968.css +0 -1
  18. package/docs/.vuepress/dist/assets/img/search.83621669.svg +0 -1
  19. package/docs/.vuepress/dist/assets/js/10.5d93d289.js +0 -1
  20. package/docs/.vuepress/dist/assets/js/11.97ab3884.js +0 -1
  21. package/docs/.vuepress/dist/assets/js/2.f3d148c3.js +0 -1
  22. package/docs/.vuepress/dist/assets/js/3.81681fff.js +0 -1
  23. package/docs/.vuepress/dist/assets/js/4.82fa7382.js +0 -1
  24. package/docs/.vuepress/dist/assets/js/5.3dae6ad4.js +0 -1
  25. package/docs/.vuepress/dist/assets/js/6.6a04f815.js +0 -1
  26. package/docs/.vuepress/dist/assets/js/7.c033cb49.js +0 -1
  27. package/docs/.vuepress/dist/assets/js/8.6d6eb599.js +0 -1
  28. package/docs/.vuepress/dist/assets/js/9.eaefe866.js +0 -1
  29. package/docs/.vuepress/dist/assets/js/app.7ed065d3.js +0 -13
  30. package/docs/.vuepress/dist/examples/index.html +0 -21
  31. package/docs/.vuepress/dist/examples/test.html +0 -17
  32. package/docs/.vuepress/dist/index.html +0 -53
  33. package/docs/.vuepress/dist/options.html +0 -41
  34. package/docs/.vuepress/dist/tailwindcss.html +0 -85
  35. package/docs/README.md +0 -17
  36. package/docs/examples/README.md +0 -3
  37. package/docs/options.md +0 -44
  38. package/index.html +0 -328
  39. package/index.js +0 -3
  40. package/main.vue +0 -5
  41. package/postcss.config.js +0 -1
  42. package/public/favicon.ico +0 -0
  43. package/public/index.html +0 -17
  44. package/src/BtnDropdown.vue +0 -106
  45. package/src/BtnDropdownAction.vue +0 -38
  46. package/src/BtnDropdownSingle.vue +0 -40
  47. package/src/BtnDropdownSplit.vue +0 -66
  48. package/src/DropdownHandler.js +0 -419
  49. package/src/css/BtnDropdown.css +0 -1
  50. package/tailwind.config.js +0 -13
  51. package/vue.config.js +0 -11
@@ -1,419 +0,0 @@
1
- import BtnDropdownAction from './BtnDropdownAction';
2
- import { createPopper } from '@popperjs/core';
3
- import Btn from '@vue-interface/btn';
4
- import { BtnGroup } from '@vue-interface/btn-group';
5
- import DropdownMenu from '@vue-interface/dropdown-menu';
6
- import { prefix } from '@vue-interface/utils';
7
-
8
- const TAB_KEYCODE = 9;
9
-
10
- export default {
11
-
12
- components: {
13
- BtnDropdownAction,
14
- BtnGroup,
15
- DropdownMenu
16
- },
17
-
18
- extends: Btn,
19
-
20
- props: {
21
-
22
- /**
23
- * Display the dropdown menu aligned left or right
24
- *
25
- * @property String
26
- */
27
- align: {
28
- type: String,
29
- default: 'left',
30
- validate(value) {
31
- return ['left', 'right'].indexOf(value.toLowerCase()) !== -1;
32
- }
33
- },
34
-
35
- /**
36
- * Should animate the dropdown opening.
37
- *
38
- * @property {Boolean}
39
- */
40
- animated: {
41
- type: Boolean,
42
- default: true
43
- },
44
-
45
- /**
46
- * The button icon that appears before the label.
47
- *
48
- * @property {Boolean}
49
- */
50
- autoclose: Boolean,
51
-
52
- /**
53
- * Show the caret.
54
- *
55
- * @property {Boolean}
56
- */
57
- caret: {
58
- type: Boolean,
59
- default: true
60
- },
61
-
62
- /**
63
- * Should display the toggle button as a circle.
64
- *
65
- * @property Boolean
66
- */
67
- circle: {
68
- type: Boolean,
69
- default: false
70
- },
71
-
72
- /**
73
- * Display as a dropup instead of a dropdown.
74
- *
75
- * @property Boolean
76
- */
77
- dropup: {
78
- type: Boolean,
79
- default: false
80
- },
81
-
82
- /**
83
- * Display as a dropright instead of a dropdown.
84
- *
85
- * @property Boolean
86
- */
87
- dropright: {
88
- type: Boolean,
89
- default: false
90
- },
91
-
92
- /**
93
- * Display as a dropleft instead of a dropdown.
94
- *
95
- * @property Boolean
96
- */
97
- dropleft: {
98
- type: Boolean,
99
- default: false
100
- },
101
-
102
- /**
103
- * The action height.
104
- *
105
- * @property {String}
106
- */
107
- height: String,
108
-
109
- /**
110
- * The href action.
111
- *
112
- * @property {String}
113
- */
114
- href: String,
115
-
116
- /**
117
- * Is the dropdown a nav item?
118
- *
119
- * @property {Boolean}
120
- */
121
- nav: Boolean,
122
-
123
- /**
124
- * The toggle button's label. If not defined as an attribute,
125
- * you can override with the component's slot (inner html).
126
- *
127
- * @property {String}
128
- */
129
- label: String,
130
-
131
- /**
132
- * Should rotate the toggle button when opened.
133
- *
134
- * @property {Boolean}
135
- */
136
- rotate: {
137
- type: Boolean,
138
- default: false
139
- },
140
-
141
- /**
142
- * Display the dropdown button with a split toggle button.
143
- *
144
- * @property {Boolean}
145
- */
146
- split: {
147
- type: Boolean,
148
- default: false
149
- },
150
-
151
- /**
152
- * The "to" path, used for vue-router.
153
- *
154
- * @property {String|Object}
155
- */
156
- to: [String, Object],
157
-
158
- /**
159
- * The button type attribute.
160
- *
161
- * @property {String}
162
- */
163
- type: {
164
- type: String,
165
- default: 'button'
166
- },
167
-
168
- /**
169
- * The action width.
170
- *
171
- * @property {String}
172
- */
173
- width: String,
174
-
175
- },
176
-
177
- data() {
178
- return {
179
- popper: null,
180
- triggerAnimation: false,
181
- isDropdownShowing: false
182
- };
183
- },
184
-
185
- computed: {
186
- placement() {
187
- if(this.dropup) {
188
- return 'top';
189
- }
190
-
191
- if(this.dropleft) {
192
- return 'left';
193
- }
194
-
195
- if(this.dropright) {
196
- return 'right';
197
- }
198
-
199
- return 'bottom';
200
- },
201
-
202
- variantClassPrefix() {
203
- return 'btn' + (this.outline ? '-outline' : '');
204
- },
205
-
206
- sizeableClassPrefix() {
207
- return 'btn';
208
- },
209
-
210
- classes() {
211
- return {
212
- 'dropdown': this.dropup && this.dropright && this.dropleft,
213
- 'dropup': this.dropup,
214
- 'dropright': this.dropright,
215
- 'dropleft': this.dropleft,
216
- 'icon-only': !this.nav && !this.split && !!this.$slots.icon && !this.$slots.label,
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,
221
- };
222
- },
223
-
224
- actionClasses() {
225
- return [
226
- !this.nav && 'btn',
227
- !this.nav && prefix(this.size, 'btn'),
228
- !this.nav && prefix(this.variant, 'btn')
229
- ]
230
- .filter(value => !!value)
231
- .join(' ');
232
- },
233
-
234
- toggleStyle() {
235
- return {
236
- width: this.width,
237
- height: this.height,
238
- };
239
- },
240
-
241
- toggleClasses() {
242
- return [
243
- this.nav && 'nav-link',
244
- !this.nav && 'btn',
245
- !this.nav && this.variantClass,
246
- this.sizeableClass,
247
- this.active ? 'active' : '',
248
- this.block ? 'btn-block' : '',
249
- !this.split && this.circle ? 'rounded-circle' : '',
250
- !this.split && this.rotate && this.isDropdownShowing ? 'rotate-90' : '',
251
- !this.nav && this.split ? 'dropdown-toggle-split' : '',
252
- 'dropdown-toggle',
253
- ]
254
- .filter(value => !!value)
255
- .join(' ');
256
- }
257
- },
258
-
259
- beforeDestroy() {
260
- this.popper && this.popper.destroy();
261
- },
262
-
263
- mounted() {
264
- const toggle = this.$el.querySelector('.dropdown-toggle');
265
-
266
- toggle.addEventListener('click', () => {
267
- if(!this.isDropdownShowing) {
268
- toggle.blur();
269
- }
270
- });
271
-
272
- toggle.addEventListener('blur', this.onBlurItem);
273
-
274
- const menu = this.$el.querySelector('.dropdown-menu');
275
-
276
- menu.addEventListener('click', e => {
277
- if(e.target === menu) {
278
- toggle.focus();
279
- }
280
- });
281
- },
282
-
283
- methods: {
284
-
285
- /**
286
- * Focus on the the dropdown toggle button
287
- *
288
- * @return void
289
- */
290
- focus() {
291
- this.$el.querySelector('.dropdown-toggle').focus();
292
- },
293
-
294
- /**
295
- * Focus on the the dropdown toggle button
296
- *
297
- * @return void
298
- */
299
- queryFocusable() {
300
- return this.$el.querySelector('.dropdown-menu').querySelectorAll('label, input, select, textarea, [tabindex]:not([tabindex="-1"])');
301
- },
302
-
303
- /**
304
- * Method to check if the given element is focusable.
305
- *
306
- * @return void
307
- */
308
- isFocusable(element) {
309
- const nodes = this.queryFocusable();
310
-
311
- for(let i in nodes) {
312
- if(element === nodes[i]) {
313
- return true;
314
- }
315
- }
316
-
317
- return false;
318
- },
319
-
320
- /**
321
- * Toggle the dropdown menu
322
- *
323
- * @return void
324
- */
325
- toggle(e) {
326
- !this.isDropdownShowing ? this.show() : this.hide();
327
- },
328
-
329
- /**
330
- * Show the dropdown menu
331
- *
332
- * @return void
333
- */
334
- show() {
335
- this.isDropdownShowing = true;
336
-
337
- const target = this.$refs.split || this.$el;
338
-
339
- // Hack for popper for align="right"
340
- this.$refs.menu.$el.style.left = 'auto';
341
- this.$refs.menu.$el.style.right = 'auto';
342
-
343
- if(!this.nav && !this.popper) {
344
- this.popper = createPopper(target, this.$refs.menu.$el, {
345
- placement: `${this.placement}-${this.align === 'left' ? 'start' : 'end'}`,
346
- onFirstUpdate: () => {
347
- this.triggerAnimation = this.animated;
348
- },
349
- modifiers: [
350
- {
351
- name: 'offset',
352
- options: {
353
- offset: [0, !this.nav ? 4 : 1],
354
- },
355
- },
356
- ]
357
- });
358
- }
359
- else if(this.popper) {
360
- this.popper.update();
361
- }
362
- },
363
-
364
- /**
365
- * Hide the dropdown menu
366
- *
367
- * @return void
368
- */
369
- hide() {
370
- this.isDropdownShowing = false;
371
- },
372
-
373
- /**
374
- * A callback function for the `blur-item` event.
375
- *
376
- * @return void
377
- */
378
- onBlurItem(e) {
379
- if(!this.$el.contains(e.relatedTarget)) {
380
- this.hide();
381
- }
382
- },
383
-
384
- /**
385
- * A callback function for the `click-item` event.
386
- *
387
- * @return void
388
- */
389
- onClickItem(e) {
390
- if(!this.isFocusable(e.target)) {
391
- this.hide();
392
- }
393
- },
394
-
395
- /**
396
- * A callback function for the `click-toggle` event.
397
- *
398
- * @return void
399
- */
400
- onClickToggle(e) {
401
- this.$emit('click-toggle', e);
402
-
403
- if(!e.defaultPrevented) {
404
- this.toggle();
405
- }
406
- }
407
-
408
- },
409
-
410
- watch: {
411
- isDropdownShowing(value) {
412
- this.$nextTick(() => {
413
- this.$emit(value ? 'show' : 'hide');
414
- this.$emit('toggle', value);
415
- });
416
- }
417
- }
418
-
419
- };
@@ -1 +0,0 @@
1
- @tailwind components;
@@ -1,13 +0,0 @@
1
- const plugin = require('tailwindcss/plugin');
2
-
3
- module.exports = {
4
- purge: false,
5
- corePlugins: {
6
- container: false,
7
- },
8
- plugins: [
9
- require('@vue-interface/dropdown-menu/tailwindcss'),
10
- require('@vue-interface/btn/tailwindcss'),
11
- require('@vue-interface/btn-group/tailwindcss'),
12
- ]
13
- };
package/vue.config.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- css: {
3
- loaderOptions: {
4
- postcss: {
5
- plugins: [
6
- require('tailwindcss')
7
- ]
8
- }
9
- }
10
- }
11
- };