@vue-interface/btn-dropdown 0.9.10 → 0.9.14
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/dist/btn-dropdown.es.js +2179 -0
- package/dist/btn-dropdown.umd.js +1 -0
- package/dist/style.css +1 -0
- package/package.json +26 -29
- package/.eslintrc.js +0 -53
- package/babel.config.js +0 -7
- package/dist/BtnDropdown.common.js +0 -6903
- package/dist/BtnDropdown.common.js.map +0 -1
- package/dist/BtnDropdown.css +0 -1
- package/dist/BtnDropdown.umd.js +0 -6913
- package/dist/BtnDropdown.umd.js.map +0 -1
- package/dist/BtnDropdown.umd.min.js +0 -2
- package/dist/BtnDropdown.umd.min.js.map +0 -1
- package/dist/demo.html +0 -19
- package/docs/.vuepress/config.js +0 -44
- package/docs/.vuepress/dist/404.html +0 -19
- package/docs/.vuepress/dist/assets/css/0.styles.275ee968.css +0 -1
- package/docs/.vuepress/dist/assets/img/search.83621669.svg +0 -1
- package/docs/.vuepress/dist/assets/js/10.5d93d289.js +0 -1
- package/docs/.vuepress/dist/assets/js/11.97ab3884.js +0 -1
- package/docs/.vuepress/dist/assets/js/2.f3d148c3.js +0 -1
- package/docs/.vuepress/dist/assets/js/3.81681fff.js +0 -1
- package/docs/.vuepress/dist/assets/js/4.82fa7382.js +0 -1
- package/docs/.vuepress/dist/assets/js/5.3dae6ad4.js +0 -1
- package/docs/.vuepress/dist/assets/js/6.6a04f815.js +0 -1
- package/docs/.vuepress/dist/assets/js/7.c033cb49.js +0 -1
- package/docs/.vuepress/dist/assets/js/8.6d6eb599.js +0 -1
- package/docs/.vuepress/dist/assets/js/9.eaefe866.js +0 -1
- package/docs/.vuepress/dist/assets/js/app.7ed065d3.js +0 -13
- package/docs/.vuepress/dist/examples/index.html +0 -21
- package/docs/.vuepress/dist/examples/test.html +0 -17
- package/docs/.vuepress/dist/index.html +0 -53
- package/docs/.vuepress/dist/options.html +0 -41
- package/docs/.vuepress/dist/tailwindcss.html +0 -85
- package/docs/README.md +0 -17
- package/docs/examples/README.md +0 -3
- package/docs/options.md +0 -44
- package/index.html +0 -339
- package/index.js +0 -3
- package/main.vue +0 -5
- package/postcss.config.js +0 -1
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -17
- package/src/BtnDropdown.vue +0 -108
- package/src/BtnDropdownAction.vue +0 -38
- package/src/BtnDropdownSingle.vue +0 -40
- package/src/BtnDropdownSplit.vue +0 -66
- package/src/DropdownHandler.js +0 -420
- package/src/css/BtnDropdown.css +0 -1
- package/tailwind.config.js +0 -13
- package/vue.config.js +0 -11
package/src/DropdownHandler.js
DELETED
|
@@ -1,420 +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
|
-
'nav-link': this.nav && this.split,
|
|
213
|
-
'dropdown': this.dropup && this.dropright && this.dropleft,
|
|
214
|
-
'dropup': this.dropup,
|
|
215
|
-
'dropright': this.dropright,
|
|
216
|
-
'dropleft': this.dropleft,
|
|
217
|
-
'icon-only': !this.split && !!this.$slots.icon && !this.$slots.label,
|
|
218
|
-
'hide-caret': !this.caret,
|
|
219
|
-
'expanded': this.isDropdownShowing,
|
|
220
|
-
'rounded-circle': this.split && this.circle,
|
|
221
|
-
'rotate-90': this.split && this.rotate && this.isDropdownShowing,
|
|
222
|
-
};
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
actionClasses() {
|
|
226
|
-
return [
|
|
227
|
-
!this.nav && 'btn',
|
|
228
|
-
!this.nav && prefix(this.size, 'btn'),
|
|
229
|
-
!this.nav && prefix(this.variant, 'btn')
|
|
230
|
-
]
|
|
231
|
-
.filter(value => !!value)
|
|
232
|
-
.join(' ');
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
toggleStyle() {
|
|
236
|
-
return {
|
|
237
|
-
width: this.width,
|
|
238
|
-
height: this.height,
|
|
239
|
-
};
|
|
240
|
-
},
|
|
241
|
-
|
|
242
|
-
toggleClasses() {
|
|
243
|
-
return [
|
|
244
|
-
this.nav && !this.split && 'nav-link',
|
|
245
|
-
!this.nav && 'btn',
|
|
246
|
-
!this.nav && this.variantClass,
|
|
247
|
-
this.sizeableClass,
|
|
248
|
-
this.active ? 'active' : '',
|
|
249
|
-
this.block ? 'btn-block' : '',
|
|
250
|
-
!this.split && this.circle ? 'rounded-circle' : '',
|
|
251
|
-
!this.split && this.rotate && this.isDropdownShowing ? 'rotate-90' : '',
|
|
252
|
-
(this.split ? 'dropdown-toggle-split' : ''),
|
|
253
|
-
'dropdown-toggle',
|
|
254
|
-
]
|
|
255
|
-
.filter(value => !!value)
|
|
256
|
-
.join(' ');
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
beforeDestroy() {
|
|
261
|
-
this.popper && this.popper.destroy();
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
mounted() {
|
|
265
|
-
const toggle = this.$el.querySelector('.dropdown-toggle');
|
|
266
|
-
|
|
267
|
-
toggle.addEventListener('click', () => {
|
|
268
|
-
if(!this.isDropdownShowing) {
|
|
269
|
-
toggle.blur();
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
toggle.addEventListener('blur', this.onBlurItem);
|
|
274
|
-
|
|
275
|
-
const menu = this.$el.querySelector('.dropdown-menu');
|
|
276
|
-
|
|
277
|
-
menu.addEventListener('click', e => {
|
|
278
|
-
if(e.target === menu) {
|
|
279
|
-
toggle.focus();
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
methods: {
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Focus on the the dropdown toggle button
|
|
288
|
-
*
|
|
289
|
-
* @return void
|
|
290
|
-
*/
|
|
291
|
-
focus() {
|
|
292
|
-
this.$el.querySelector('.dropdown-toggle').focus();
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Focus on the the dropdown toggle button
|
|
297
|
-
*
|
|
298
|
-
* @return void
|
|
299
|
-
*/
|
|
300
|
-
queryFocusable() {
|
|
301
|
-
return this.$el.querySelector('.dropdown-menu').querySelectorAll('label, input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Method to check if the given element is focusable.
|
|
306
|
-
*
|
|
307
|
-
* @return void
|
|
308
|
-
*/
|
|
309
|
-
isFocusable(element) {
|
|
310
|
-
const nodes = this.queryFocusable();
|
|
311
|
-
|
|
312
|
-
for(let i in nodes) {
|
|
313
|
-
if(element === nodes[i]) {
|
|
314
|
-
return true;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return false;
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Toggle the dropdown menu
|
|
323
|
-
*
|
|
324
|
-
* @return void
|
|
325
|
-
*/
|
|
326
|
-
toggle(e) {
|
|
327
|
-
!this.isDropdownShowing ? this.show() : this.hide();
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Show the dropdown menu
|
|
332
|
-
*
|
|
333
|
-
* @return void
|
|
334
|
-
*/
|
|
335
|
-
show() {
|
|
336
|
-
this.isDropdownShowing = true;
|
|
337
|
-
|
|
338
|
-
const target = this.$refs.split || this.$el;
|
|
339
|
-
|
|
340
|
-
// Hack for popper for align="right"
|
|
341
|
-
this.$refs.menu.$el.style.left = 'auto';
|
|
342
|
-
this.$refs.menu.$el.style.right = 'auto';
|
|
343
|
-
|
|
344
|
-
if(!this.popper) {
|
|
345
|
-
this.popper = createPopper(target, this.$refs.menu.$el, {
|
|
346
|
-
placement: `${this.placement}-${this.align === 'left' ? 'start' : 'end'}`,
|
|
347
|
-
onFirstUpdate: () => {
|
|
348
|
-
this.triggerAnimation = this.animated;
|
|
349
|
-
},
|
|
350
|
-
modifiers: [
|
|
351
|
-
{
|
|
352
|
-
name: 'offset',
|
|
353
|
-
options: {
|
|
354
|
-
offset: [0, !this.nav ? 4 : 1],
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
]
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
this.popper.update();
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Hide the dropdown menu
|
|
367
|
-
*
|
|
368
|
-
* @return void
|
|
369
|
-
*/
|
|
370
|
-
hide() {
|
|
371
|
-
this.isDropdownShowing = false;
|
|
372
|
-
},
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* A callback function for the `blur-item` event.
|
|
376
|
-
*
|
|
377
|
-
* @return void
|
|
378
|
-
*/
|
|
379
|
-
onBlurItem(e) {
|
|
380
|
-
if(!this.$el.contains(e.relatedTarget)) {
|
|
381
|
-
this.hide();
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* A callback function for the `click-item` event.
|
|
387
|
-
*
|
|
388
|
-
* @return void
|
|
389
|
-
*/
|
|
390
|
-
onClickItem(e) {
|
|
391
|
-
if(!this.isFocusable(e.target)) {
|
|
392
|
-
this.hide();
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* A callback function for the `click-toggle` event.
|
|
398
|
-
*
|
|
399
|
-
* @return void
|
|
400
|
-
*/
|
|
401
|
-
onClickToggle(e) {
|
|
402
|
-
this.$emit('click-toggle', e);
|
|
403
|
-
|
|
404
|
-
if(!e.defaultPrevented) {
|
|
405
|
-
this.toggle();
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
watch: {
|
|
412
|
-
isDropdownShowing(value) {
|
|
413
|
-
this.$nextTick(() => {
|
|
414
|
-
this.$emit(value ? 'show' : 'hide');
|
|
415
|
-
this.$emit('toggle', value);
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
};
|
package/src/css/BtnDropdown.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@tailwind components;
|
package/tailwind.config.js
DELETED
|
@@ -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
|
-
};
|