@vue-interface/btn-dropdown 2.0.0-beta.1 → 2.0.0-beta.11
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.js +600 -0
- package/dist/btn-dropdown.umd.cjs +1 -0
- package/{index.js → dist/index.d.ts} +1 -4
- package/dist/src/BtnDropdown.vue.d.ts +9 -0
- package/dist/src/BtnDropdownAction.vue.d.ts +43 -0
- package/dist/src/BtnDropdownSingle.vue.d.ts +236 -0
- package/dist/src/BtnDropdownSplit.vue.d.ts +238 -0
- package/dist/src/DropdownHandler.d.ts +463 -0
- package/package.json +22 -20
- package/dist/btn-dropdown.es.js +0 -1609
- package/dist/btn-dropdown.umd.js +0 -5
- package/src/BtnDropdown.vue +0 -121
- package/src/BtnDropdownAction.vue +0 -38
- package/src/BtnDropdownSingle.vue +0 -43
- package/src/BtnDropdownSplit.vue +0 -77
- package/src/DropdownHandler.js +0 -435
- /package/dist/{btn-dropdown.css → style.css} +0 -0
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import { defineComponent as m, openBlock as a, createBlock as d, resolveDynamicComponent as S, mergeProps as b, withCtx as n, renderSlot as s, resolveComponent as p, normalizeClass as l, normalizeProps as u, guardReactiveProps as c, createVNode as C, normalizeStyle as P, createTextVNode as w, toDisplayString as y, withKeys as D, withModifiers as T, createCommentVNode as g, createElementBlock as z, createSlots as F } from "vue";
|
|
2
|
+
import { createPopper as K } from "@popperjs/core";
|
|
3
|
+
import { Btn as M } from "@vue-interface/btn";
|
|
4
|
+
import { BtnGroup as j } from "@vue-interface/btn-group";
|
|
5
|
+
import { DropdownMenu as q } from "@vue-interface/dropdown-menu";
|
|
6
|
+
const E = m({
|
|
7
|
+
props: {
|
|
8
|
+
expanded: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: !1
|
|
11
|
+
},
|
|
12
|
+
id: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: void 0
|
|
15
|
+
},
|
|
16
|
+
href: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: void 0
|
|
19
|
+
},
|
|
20
|
+
to: {
|
|
21
|
+
type: [String, Object],
|
|
22
|
+
default: void 0
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
is() {
|
|
27
|
+
return this.to ? "router-link" : this.href ? "a" : "button";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}), k = (e, t) => {
|
|
31
|
+
const i = e.__vccOpts || e;
|
|
32
|
+
for (const [h, f] of t)
|
|
33
|
+
i[h] = f;
|
|
34
|
+
return i;
|
|
35
|
+
};
|
|
36
|
+
function O(e, t, i, h, f, B) {
|
|
37
|
+
return a(), d(S(e.is), b({ id: e.id }, e.to ? { to: e.to } : { href: e.href }, {
|
|
38
|
+
"aria-haspopup": "true",
|
|
39
|
+
"aria-expanded": e.expanded,
|
|
40
|
+
type: e.is === "button" ? "button" : void 0
|
|
41
|
+
}), {
|
|
42
|
+
default: n(() => [
|
|
43
|
+
s(e.$slots, "default")
|
|
44
|
+
]),
|
|
45
|
+
_: 3
|
|
46
|
+
}, 16, ["id", "aria-expanded", "type"]);
|
|
47
|
+
}
|
|
48
|
+
const G = /* @__PURE__ */ k(E, [["render", O]]), A = m({
|
|
49
|
+
components: {
|
|
50
|
+
BtnDropdownAction: G,
|
|
51
|
+
BtnGroup: j,
|
|
52
|
+
DropdownMenu: q
|
|
53
|
+
},
|
|
54
|
+
extends: M,
|
|
55
|
+
props: {
|
|
56
|
+
/**
|
|
57
|
+
* Display the dropdown menu aligned left or right
|
|
58
|
+
*
|
|
59
|
+
* @property String
|
|
60
|
+
*/
|
|
61
|
+
align: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: "left",
|
|
64
|
+
validate(e) {
|
|
65
|
+
return ["left", "right"].indexOf(e.toLowerCase()) !== -1;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* Should animate the dropdown opening.
|
|
70
|
+
*
|
|
71
|
+
* @property {Boolean}
|
|
72
|
+
*/
|
|
73
|
+
animated: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: !0
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* Additional button classes.
|
|
79
|
+
*
|
|
80
|
+
* @property {Object|String}
|
|
81
|
+
*/
|
|
82
|
+
buttonClass: [Object, String],
|
|
83
|
+
/**
|
|
84
|
+
* Show the caret.
|
|
85
|
+
*
|
|
86
|
+
* @property {Boolean}
|
|
87
|
+
*/
|
|
88
|
+
caret: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: !0
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Should display the toggle button as a circle.
|
|
94
|
+
*
|
|
95
|
+
* @property Boolean
|
|
96
|
+
*/
|
|
97
|
+
// circle: {
|
|
98
|
+
// type: Boolean,
|
|
99
|
+
// default: false
|
|
100
|
+
// },
|
|
101
|
+
/**
|
|
102
|
+
* Display as a dropup instead of a dropdown.
|
|
103
|
+
*
|
|
104
|
+
* @property Boolean
|
|
105
|
+
*/
|
|
106
|
+
dropup: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: !1
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Display as a dropright instead of a dropdown.
|
|
112
|
+
*
|
|
113
|
+
* @property Boolean
|
|
114
|
+
*/
|
|
115
|
+
dropright: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: !1
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* Display as a dropleft instead of a dropdown.
|
|
121
|
+
*
|
|
122
|
+
* @property Boolean
|
|
123
|
+
*/
|
|
124
|
+
dropleft: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: !1
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* The action height.
|
|
130
|
+
*
|
|
131
|
+
* @property {String}
|
|
132
|
+
*/
|
|
133
|
+
height: String,
|
|
134
|
+
/**
|
|
135
|
+
* The href action.
|
|
136
|
+
*
|
|
137
|
+
* @property {String}
|
|
138
|
+
*/
|
|
139
|
+
href: String,
|
|
140
|
+
/**
|
|
141
|
+
* Is the dropdown a nav item?
|
|
142
|
+
*
|
|
143
|
+
* @property {Boolean}
|
|
144
|
+
*/
|
|
145
|
+
nav: Boolean,
|
|
146
|
+
/**
|
|
147
|
+
* The toggle button's label. If not defined as an attribute,
|
|
148
|
+
* you can override with the component's slot (inner html).
|
|
149
|
+
*
|
|
150
|
+
* @property {String}
|
|
151
|
+
*/
|
|
152
|
+
label: String,
|
|
153
|
+
offset: {
|
|
154
|
+
type: Number,
|
|
155
|
+
default: 5
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* Should rotate the toggle button when opened.
|
|
159
|
+
*
|
|
160
|
+
* @property {Boolean}
|
|
161
|
+
*/
|
|
162
|
+
rotate: {
|
|
163
|
+
type: Boolean,
|
|
164
|
+
default: !1
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* Display the dropdown button with a split toggle button.
|
|
168
|
+
*
|
|
169
|
+
* @property {Boolean}
|
|
170
|
+
*/
|
|
171
|
+
split: {
|
|
172
|
+
type: Boolean,
|
|
173
|
+
default: !1
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* The "to" path, used for vue-router.
|
|
177
|
+
*
|
|
178
|
+
* @property {String|Object}
|
|
179
|
+
*/
|
|
180
|
+
to: [String, Object],
|
|
181
|
+
/**
|
|
182
|
+
* The button type attribute.
|
|
183
|
+
*
|
|
184
|
+
* @property {String}
|
|
185
|
+
*/
|
|
186
|
+
type: {
|
|
187
|
+
type: String,
|
|
188
|
+
default: "button"
|
|
189
|
+
},
|
|
190
|
+
/**
|
|
191
|
+
* The action width.
|
|
192
|
+
*
|
|
193
|
+
* @property {String}
|
|
194
|
+
*/
|
|
195
|
+
width: String
|
|
196
|
+
},
|
|
197
|
+
emits: [
|
|
198
|
+
"click-toggle",
|
|
199
|
+
"show",
|
|
200
|
+
"hide",
|
|
201
|
+
"toggle"
|
|
202
|
+
],
|
|
203
|
+
data() {
|
|
204
|
+
return {
|
|
205
|
+
popper: null,
|
|
206
|
+
triggerAnimation: !1,
|
|
207
|
+
expanded: !1
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
computed: {
|
|
211
|
+
scope() {
|
|
212
|
+
return {
|
|
213
|
+
// Pass the computed props.
|
|
214
|
+
placement: this.placement,
|
|
215
|
+
variantClassPrefix: this.variantClassPrefix,
|
|
216
|
+
sizeableClassPrefix: this.sizeableClassPrefix,
|
|
217
|
+
classes: this.classes,
|
|
218
|
+
actionClasses: this.actionClasses,
|
|
219
|
+
toggleStyle: this.toggleStyle,
|
|
220
|
+
toggleClasses: this.toggleClasses,
|
|
221
|
+
// Pass the methods
|
|
222
|
+
focus: this.focus,
|
|
223
|
+
queryFocusable: this.queryFocusable,
|
|
224
|
+
isFocusable: this.isFocusable,
|
|
225
|
+
toggle: this.toggle,
|
|
226
|
+
show: this.show,
|
|
227
|
+
hide: this.hide,
|
|
228
|
+
onBlur: this.onBlur,
|
|
229
|
+
onClickItem: this.onClickItem,
|
|
230
|
+
onClickToggle: this.onClickToggle,
|
|
231
|
+
expanded: this.expanded
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
placement() {
|
|
235
|
+
return this.dropup ? "top" : this.dropleft ? "left" : this.dropright ? "right" : "bottom";
|
|
236
|
+
},
|
|
237
|
+
variantClassPrefix() {
|
|
238
|
+
return "btn" + (this.outline ? "-outline" : "");
|
|
239
|
+
},
|
|
240
|
+
sizeableClassPrefix() {
|
|
241
|
+
return "btn";
|
|
242
|
+
},
|
|
243
|
+
classes() {
|
|
244
|
+
return {
|
|
245
|
+
dropdown: this.dropup && this.dropright && this.dropleft,
|
|
246
|
+
dropup: this.dropup,
|
|
247
|
+
dropright: this.dropright,
|
|
248
|
+
dropleft: this.dropleft,
|
|
249
|
+
"icon-only": !this.nav && !this.split && !!this.$slots.icon && !this.$slots.label,
|
|
250
|
+
"hide-caret": !this.caret,
|
|
251
|
+
expanded: this.expanded,
|
|
252
|
+
"rotate-90": !this.nav && this.split && this.rotate && this.expanded
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
actionClasses() {
|
|
256
|
+
return Object.assign({
|
|
257
|
+
btn: !this.nav,
|
|
258
|
+
[this.variantClass]: !this.nav && !!this.variant,
|
|
259
|
+
[this.sizeableClass]: !!this.size
|
|
260
|
+
}, typeof this.buttonClass == "object" ? this.buttonClass : {
|
|
261
|
+
[this.buttonClass]: !!this.buttonClass
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
toggleStyle() {
|
|
265
|
+
return {
|
|
266
|
+
width: this.width,
|
|
267
|
+
height: this.height
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
toggleClasses() {
|
|
271
|
+
return Object.assign({
|
|
272
|
+
active: this.active,
|
|
273
|
+
btn: !this.nav,
|
|
274
|
+
"btn-block": !!this.block,
|
|
275
|
+
"nav-link": !!this.nav,
|
|
276
|
+
"rotate-90": !this.split && this.rotate && this.expanded,
|
|
277
|
+
"dropdown-toggle": !0,
|
|
278
|
+
"dropdown-toggle-split": !this.nav && this.split,
|
|
279
|
+
[this.variantClass]: !this.nav && !!this.variant,
|
|
280
|
+
[this.sizeableClass]: !!this.size
|
|
281
|
+
}, typeof this.buttonClass == "object" ? this.buttonClass : {
|
|
282
|
+
[this.buttonClass]: !!this.buttonClass
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
watch: {
|
|
287
|
+
expanded(e) {
|
|
288
|
+
this.$nextTick(() => {
|
|
289
|
+
this.$emit(e ? "show" : "hide"), this.$emit("toggle", e);
|
|
290
|
+
}), setTimeout(() => {
|
|
291
|
+
e ? document.addEventListener("click", this.onClickDocument) : document.removeEventListener("click", this.onClickDocument);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
beforeUnmount() {
|
|
296
|
+
this.popper && this.popper.destroy();
|
|
297
|
+
},
|
|
298
|
+
methods: {
|
|
299
|
+
/**
|
|
300
|
+
* Focus on the the dropdown toggle button
|
|
301
|
+
*
|
|
302
|
+
* @return void
|
|
303
|
+
*/
|
|
304
|
+
focus() {
|
|
305
|
+
var e;
|
|
306
|
+
(e = this.$el) == null || e.querySelector(".dropdown-toggle").focus();
|
|
307
|
+
},
|
|
308
|
+
/**
|
|
309
|
+
* Focus on the the dropdown toggle button
|
|
310
|
+
*
|
|
311
|
+
* @return void
|
|
312
|
+
*/
|
|
313
|
+
queryFocusable() {
|
|
314
|
+
var e;
|
|
315
|
+
return (e = this.$el) == null ? void 0 : e.querySelector(".dropdown-menu").querySelectorAll('label, input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
316
|
+
},
|
|
317
|
+
/**
|
|
318
|
+
* Method to check if the given element is focusable.
|
|
319
|
+
*
|
|
320
|
+
* @return void
|
|
321
|
+
*/
|
|
322
|
+
isFocusable(e) {
|
|
323
|
+
const t = this.queryFocusable();
|
|
324
|
+
for (const i in t)
|
|
325
|
+
if (e === t[i])
|
|
326
|
+
return !0;
|
|
327
|
+
return !1;
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Toggle the dropdown menu
|
|
331
|
+
*
|
|
332
|
+
* @return void
|
|
333
|
+
*/
|
|
334
|
+
toggle() {
|
|
335
|
+
this.expanded ? this.hide() : this.show();
|
|
336
|
+
},
|
|
337
|
+
/**
|
|
338
|
+
* Show the dropdown menu
|
|
339
|
+
*
|
|
340
|
+
* @return void
|
|
341
|
+
*/
|
|
342
|
+
show() {
|
|
343
|
+
var t, i;
|
|
344
|
+
this.expanded = !0;
|
|
345
|
+
const e = this.$refs.split && ((t = this.$refs.split) == null ? void 0 : t.$el) || this.$el;
|
|
346
|
+
!this.nav && !this.popper ? this.popper = K(e, (i = this.$refs.menu) == null ? void 0 : i.$el, {
|
|
347
|
+
placement: `${this.placement}-${this.align === "left" ? "start" : "end"}`,
|
|
348
|
+
onFirstUpdate: () => {
|
|
349
|
+
this.triggerAnimation = this.animated;
|
|
350
|
+
},
|
|
351
|
+
modifiers: [
|
|
352
|
+
{
|
|
353
|
+
name: "offset",
|
|
354
|
+
options: {
|
|
355
|
+
offset: [0, this.nav ? 1 : this.offset]
|
|
356
|
+
// offset: ['.125rem', !this.nav ? 4 : 1],
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}) : this.popper && this.popper.update();
|
|
361
|
+
},
|
|
362
|
+
/**
|
|
363
|
+
* Hide the dropdown menu
|
|
364
|
+
*
|
|
365
|
+
* @return void
|
|
366
|
+
*/
|
|
367
|
+
hide() {
|
|
368
|
+
this.expanded = !1;
|
|
369
|
+
},
|
|
370
|
+
/**
|
|
371
|
+
* A callback function for the `blur-item` event.
|
|
372
|
+
*
|
|
373
|
+
* @return void
|
|
374
|
+
*/
|
|
375
|
+
onBlur(e) {
|
|
376
|
+
var t;
|
|
377
|
+
(this.$refs.menu && !((t = this.$refs.menu) != null && t.$el.contains(e.relatedTarget)) || !(this != null && this.$el.contains(e.relatedTarget))) && this.hide();
|
|
378
|
+
},
|
|
379
|
+
onClickDocument(e) {
|
|
380
|
+
this != null && this.$el.contains(e.target) || this.hide();
|
|
381
|
+
},
|
|
382
|
+
/**
|
|
383
|
+
* A callback function for the `click-item` event.
|
|
384
|
+
*
|
|
385
|
+
* @return void
|
|
386
|
+
*/
|
|
387
|
+
onClickItem(e) {
|
|
388
|
+
this.isFocusable(e.target) || this.hide();
|
|
389
|
+
},
|
|
390
|
+
/**
|
|
391
|
+
* A callback function for the `click-toggle` event.
|
|
392
|
+
*
|
|
393
|
+
* @return void
|
|
394
|
+
*/
|
|
395
|
+
onClickToggle(e) {
|
|
396
|
+
e.target.dispatchEvent(new Event("focus", e)), this.$emit("click-toggle", e), e.defaultPrevented || this.toggle();
|
|
397
|
+
},
|
|
398
|
+
onKeydown(e) {
|
|
399
|
+
e.target.parentElement.lastElementChild === e.target && this.hide();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}), I = m({
|
|
403
|
+
mixins: [
|
|
404
|
+
A
|
|
405
|
+
]
|
|
406
|
+
});
|
|
407
|
+
function N(e, t, i, h, f, B) {
|
|
408
|
+
const o = p("BtnDropdownAction"), v = p("DropdownMenu"), $ = p("BtnGroup");
|
|
409
|
+
return a(), d($, {
|
|
410
|
+
class: l(e.classes)
|
|
411
|
+
}, {
|
|
412
|
+
default: n(() => [
|
|
413
|
+
s(e.$slots, "button", u(c(e.scope)), () => [
|
|
414
|
+
C(o, {
|
|
415
|
+
id: e.$attrs.id,
|
|
416
|
+
ref: "button",
|
|
417
|
+
expanded: e.expanded,
|
|
418
|
+
href: e.href,
|
|
419
|
+
to: e.to,
|
|
420
|
+
style: P(e.toggleStyle),
|
|
421
|
+
class: l(e.toggleClasses),
|
|
422
|
+
onBlur: e.onBlur,
|
|
423
|
+
onClick: e.onClickToggle
|
|
424
|
+
}, {
|
|
425
|
+
default: n(() => [
|
|
426
|
+
s(e.$slots, "icon"),
|
|
427
|
+
s(e.$slots, "label", {}, () => [
|
|
428
|
+
w(y(e.label), 1)
|
|
429
|
+
])
|
|
430
|
+
]),
|
|
431
|
+
_: 3
|
|
432
|
+
}, 8, ["id", "expanded", "href", "to", "style", "class", "onBlur", "onClick"])
|
|
433
|
+
]),
|
|
434
|
+
C(v, {
|
|
435
|
+
id: e.$attrs.id,
|
|
436
|
+
ref: "menu",
|
|
437
|
+
align: e.align,
|
|
438
|
+
show: e.expanded,
|
|
439
|
+
class: l({ animated: e.triggerAnimation }),
|
|
440
|
+
onBlur: e.onBlur,
|
|
441
|
+
onClick: e.onClickItem,
|
|
442
|
+
onKeydown: D(e.onKeydown, ["tab"]),
|
|
443
|
+
onMousedown: t[0] || (t[0] = T(() => {
|
|
444
|
+
}, ["prevent"]))
|
|
445
|
+
}, {
|
|
446
|
+
default: n(() => [
|
|
447
|
+
s(e.$slots, "default")
|
|
448
|
+
]),
|
|
449
|
+
_: 3
|
|
450
|
+
}, 8, ["id", "align", "show", "class", "onBlur", "onClick", "onKeydown"])
|
|
451
|
+
]),
|
|
452
|
+
_: 3
|
|
453
|
+
}, 8, ["class"]);
|
|
454
|
+
}
|
|
455
|
+
const L = /* @__PURE__ */ k(I, [["render", N]]), V = m({
|
|
456
|
+
mixins: [
|
|
457
|
+
A
|
|
458
|
+
],
|
|
459
|
+
emits: [
|
|
460
|
+
"click"
|
|
461
|
+
]
|
|
462
|
+
}), H = ["id", "aria-expanded"];
|
|
463
|
+
function U(e, t, i, h, f, B) {
|
|
464
|
+
const o = p("BtnDropdownAction"), v = p("DropdownMenu"), $ = p("BtnGroup");
|
|
465
|
+
return a(), d($, {
|
|
466
|
+
class: l([e.classes, "btn-dropdown-split"])
|
|
467
|
+
}, {
|
|
468
|
+
default: n(() => [
|
|
469
|
+
e.dropleft ? g("", !0) : s(e.$slots, "button", u(b({ key: 0 }, e.scope)), () => [
|
|
470
|
+
e.dropleft ? g("", !0) : (a(), d(o, {
|
|
471
|
+
key: 0,
|
|
472
|
+
id: e.$attrs.id,
|
|
473
|
+
ref: "button",
|
|
474
|
+
expanded: e.expanded,
|
|
475
|
+
href: e.href,
|
|
476
|
+
to: e.to,
|
|
477
|
+
class: l(e.actionClasses),
|
|
478
|
+
onClick: t[0] || (t[0] = (r) => e.$emit("click", r))
|
|
479
|
+
}, {
|
|
480
|
+
default: n(() => [
|
|
481
|
+
s(e.$slots, "icon"),
|
|
482
|
+
s(e.$slots, "label", {}, () => [
|
|
483
|
+
w(y(e.label), 1)
|
|
484
|
+
])
|
|
485
|
+
]),
|
|
486
|
+
_: 3
|
|
487
|
+
}, 8, ["id", "expanded", "href", "to", "class"]))
|
|
488
|
+
]),
|
|
489
|
+
C($, { ref: "split" }, {
|
|
490
|
+
default: n(() => [
|
|
491
|
+
s(e.$slots, "split", u(c(e.scope)), () => [
|
|
492
|
+
e.split ? (a(), z("button", {
|
|
493
|
+
key: 0,
|
|
494
|
+
id: e.$attrs.id,
|
|
495
|
+
type: "button",
|
|
496
|
+
"aria-haspopup": "true",
|
|
497
|
+
"aria-expanded": e.expanded,
|
|
498
|
+
class: l(e.toggleClasses),
|
|
499
|
+
onBlur: t[1] || (t[1] = (...r) => e.onBlur && e.onBlur(...r)),
|
|
500
|
+
onClick: t[2] || (t[2] = (...r) => e.onClickToggle && e.onClickToggle(...r))
|
|
501
|
+
}, null, 42, H)) : g("", !0)
|
|
502
|
+
]),
|
|
503
|
+
C(v, {
|
|
504
|
+
id: e.$attrs.id,
|
|
505
|
+
ref: "menu",
|
|
506
|
+
align: e.align,
|
|
507
|
+
show: e.expanded,
|
|
508
|
+
class: l({ animated: e.triggerAnimation }),
|
|
509
|
+
onBlur: e.onBlur,
|
|
510
|
+
onClick: e.onClickItem,
|
|
511
|
+
onKeydown: D(e.onKeydown, ["tab"]),
|
|
512
|
+
onMousedown: t[3] || (t[3] = T(() => {
|
|
513
|
+
}, ["prevent"]))
|
|
514
|
+
}, {
|
|
515
|
+
default: n(() => [
|
|
516
|
+
s(e.$slots, "default")
|
|
517
|
+
]),
|
|
518
|
+
_: 3
|
|
519
|
+
}, 8, ["id", "align", "show", "class", "onBlur", "onClick", "onKeydown"])
|
|
520
|
+
]),
|
|
521
|
+
_: 3
|
|
522
|
+
}, 512),
|
|
523
|
+
e.dropleft ? s(e.$slots, "button", u(b({ key: 1 }, e.scope)), () => [
|
|
524
|
+
e.dropleft ? (a(), d(o, {
|
|
525
|
+
key: 0,
|
|
526
|
+
id: e.$attrs.id,
|
|
527
|
+
ref: "button",
|
|
528
|
+
expanded: e.expanded,
|
|
529
|
+
href: e.href,
|
|
530
|
+
to: e.to,
|
|
531
|
+
class: l(e.actionClasses),
|
|
532
|
+
onClick: t[4] || (t[4] = (r) => e.$emit("click", r))
|
|
533
|
+
}, {
|
|
534
|
+
default: n(() => [
|
|
535
|
+
s(e.$slots, "icon"),
|
|
536
|
+
s(e.$slots, "label", {}, () => [
|
|
537
|
+
w(y(e.label), 1)
|
|
538
|
+
])
|
|
539
|
+
]),
|
|
540
|
+
_: 3
|
|
541
|
+
}, 8, ["id", "expanded", "href", "to", "class"])) : g("", !0)
|
|
542
|
+
]) : g("", !0)
|
|
543
|
+
]),
|
|
544
|
+
_: 3
|
|
545
|
+
}, 8, ["class"]);
|
|
546
|
+
}
|
|
547
|
+
const R = /* @__PURE__ */ k(V, [["render", U]]), J = m({
|
|
548
|
+
name: "BtnDropdown",
|
|
549
|
+
components: {
|
|
550
|
+
BtnDropdownSplit: R,
|
|
551
|
+
BtnDropdownSingle: L
|
|
552
|
+
},
|
|
553
|
+
inheritAttrs: !1,
|
|
554
|
+
emits: [
|
|
555
|
+
"click",
|
|
556
|
+
"click-toggle",
|
|
557
|
+
"dropdown",
|
|
558
|
+
"show",
|
|
559
|
+
"hide",
|
|
560
|
+
"toggle"
|
|
561
|
+
]
|
|
562
|
+
});
|
|
563
|
+
function Q(e, t, i, h, f, B) {
|
|
564
|
+
return a(), d(S(e.$attrs.split === void 0 || e.$attrs.nav ? "btn-dropdown-single" : "btn-dropdown-split"), b({ class: "btn-dropdown" }, e.$attrs, {
|
|
565
|
+
onClick: t[0] || (t[0] = (...o) => e.$emit("click", ...o)),
|
|
566
|
+
onClickToggle: t[1] || (t[1] = (...o) => e.$emit("click-toggle", ...o)),
|
|
567
|
+
onDropdown: t[2] || (t[2] = (...o) => e.$emit("dropdown", ...o)),
|
|
568
|
+
onShow: t[3] || (t[3] = (...o) => e.$emit("show", ...o)),
|
|
569
|
+
onHide: t[4] || (t[4] = (...o) => e.$emit("hide", ...o)),
|
|
570
|
+
onToggle: t[5] || (t[5] = (...o) => e.$emit("toggle", ...o))
|
|
571
|
+
}), F({
|
|
572
|
+
icon: n(() => [
|
|
573
|
+
s(e.$slots, "icon")
|
|
574
|
+
]),
|
|
575
|
+
button: n((o) => [
|
|
576
|
+
s(e.$slots, "button", u(c(o)))
|
|
577
|
+
]),
|
|
578
|
+
split: n((o) => [
|
|
579
|
+
s(e.$slots, "split", u(c(o)))
|
|
580
|
+
]),
|
|
581
|
+
default: n(() => [
|
|
582
|
+
s(e.$slots, "default")
|
|
583
|
+
]),
|
|
584
|
+
_: 2
|
|
585
|
+
}, [
|
|
586
|
+
e.$attrs.label || e.$slots.label ? {
|
|
587
|
+
name: "label",
|
|
588
|
+
fn: n(() => [
|
|
589
|
+
s(e.$slots, "label", {}, () => [
|
|
590
|
+
w(y(e.$attrs.label), 1)
|
|
591
|
+
])
|
|
592
|
+
]),
|
|
593
|
+
key: "0"
|
|
594
|
+
} : void 0
|
|
595
|
+
]), 1040);
|
|
596
|
+
}
|
|
597
|
+
const _ = /* @__PURE__ */ k(J, [["render", Q]]);
|
|
598
|
+
export {
|
|
599
|
+
_ as BtnDropdown
|
|
600
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@popperjs/core"),require("@vue-interface/btn"),require("@vue-interface/btn-group"),require("@vue-interface/dropdown-menu")):typeof define=="function"&&define.amd?define(["exports","vue","@popperjs/core","@vue-interface/btn","@vue-interface/btn-group","@vue-interface/dropdown-menu"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s.BtnDropdown={},s.Vue,s.PopperjsCore,s.VueInterfaceBtn,s.VueInterfaceBtnGroup,s.VueInterfaceDropdownMenu))})(this,function(s,t,m,c,u,C){"use strict";const $=t.defineComponent({props:{expanded:{type:Boolean,default:!1},id:{type:String,default:void 0},href:{type:String,default:void 0},to:{type:[String,Object],default:void 0}},computed:{is(){return this.to?"router-link":this.href?"a":"button"}}}),d=(e,o)=>{const i=e.__vccOpts||e;for(const[l,a]of o)i[l]=a;return i};function w(e,o,i,l,a,h){return t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.is),t.mergeProps({id:e.id},e.to?{to:e.to}:{href:e.href},{"aria-haspopup":"true","aria-expanded":e.expanded,type:e.is==="button"?"button":void 0}),{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},16,["id","aria-expanded","type"])}const b=d($,[["render",w]]),g=t.defineComponent({components:{BtnDropdownAction:b,BtnGroup:u.BtnGroup,DropdownMenu:C.DropdownMenu},extends:c.Btn,props:{align:{type:String,default:"left",validate(e){return["left","right"].indexOf(e.toLowerCase())!==-1}},animated:{type:Boolean,default:!0},buttonClass:[Object,String],caret:{type:Boolean,default:!0},dropup:{type:Boolean,default:!1},dropright:{type:Boolean,default:!1},dropleft:{type:Boolean,default:!1},height:String,href:String,nav:Boolean,label:String,offset:{type:Number,default:5},rotate:{type:Boolean,default:!1},split:{type:Boolean,default:!1},to:[String,Object],type:{type:String,default:"button"},width:String},emits:["click-toggle","show","hide","toggle"],data(){return{popper:null,triggerAnimation:!1,expanded:!1}},computed:{scope(){return{placement:this.placement,variantClassPrefix:this.variantClassPrefix,sizeableClassPrefix:this.sizeableClassPrefix,classes:this.classes,actionClasses:this.actionClasses,toggleStyle:this.toggleStyle,toggleClasses:this.toggleClasses,focus:this.focus,queryFocusable:this.queryFocusable,isFocusable:this.isFocusable,toggle:this.toggle,show:this.show,hide:this.hide,onBlur:this.onBlur,onClickItem:this.onClickItem,onClickToggle:this.onClickToggle,expanded:this.expanded}},placement(){return this.dropup?"top":this.dropleft?"left":this.dropright?"right":"bottom"},variantClassPrefix(){return"btn"+(this.outline?"-outline":"")},sizeableClassPrefix(){return"btn"},classes(){return{dropdown:this.dropup&&this.dropright&&this.dropleft,dropup:this.dropup,dropright:this.dropright,dropleft:this.dropleft,"icon-only":!this.nav&&!this.split&&!!this.$slots.icon&&!this.$slots.label,"hide-caret":!this.caret,expanded:this.expanded,"rotate-90":!this.nav&&this.split&&this.rotate&&this.expanded}},actionClasses(){return Object.assign({btn:!this.nav,[this.variantClass]:!this.nav&&!!this.variant,[this.sizeableClass]:!!this.size},typeof this.buttonClass=="object"?this.buttonClass:{[this.buttonClass]:!!this.buttonClass})},toggleStyle(){return{width:this.width,height:this.height}},toggleClasses(){return Object.assign({active:this.active,btn:!this.nav,"btn-block":!!this.block,"nav-link":!!this.nav,"rotate-90":!this.split&&this.rotate&&this.expanded,"dropdown-toggle":!0,"dropdown-toggle-split":!this.nav&&this.split,[this.variantClass]:!this.nav&&!!this.variant,[this.sizeableClass]:!!this.size},typeof this.buttonClass=="object"?this.buttonClass:{[this.buttonClass]:!!this.buttonClass})}},watch:{expanded(e){this.$nextTick(()=>{this.$emit(e?"show":"hide"),this.$emit("toggle",e)}),setTimeout(()=>{e?document.addEventListener("click",this.onClickDocument):document.removeEventListener("click",this.onClickDocument)})}},beforeUnmount(){this.popper&&this.popper.destroy()},methods:{focus(){var e;(e=this.$el)==null||e.querySelector(".dropdown-toggle").focus()},queryFocusable(){var e;return(e=this.$el)==null?void 0:e.querySelector(".dropdown-menu").querySelectorAll('label, input, select, textarea, [tabindex]:not([tabindex="-1"])')},isFocusable(e){const o=this.queryFocusable();for(const i in o)if(e===o[i])return!0;return!1},toggle(){this.expanded?this.hide():this.show()},show(){var o,i;this.expanded=!0;const e=this.$refs.split&&((o=this.$refs.split)==null?void 0:o.$el)||this.$el;!this.nav&&!this.popper?this.popper=m.createPopper(e,(i=this.$refs.menu)==null?void 0:i.$el,{placement:`${this.placement}-${this.align==="left"?"start":"end"}`,onFirstUpdate:()=>{this.triggerAnimation=this.animated},modifiers:[{name:"offset",options:{offset:[0,this.nav?1:this.offset]}}]}):this.popper&&this.popper.update()},hide(){this.expanded=!1},onBlur(e){var o;(this.$refs.menu&&!((o=this.$refs.menu)!=null&&o.$el.contains(e.relatedTarget))||!(this!=null&&this.$el.contains(e.relatedTarget)))&&this.hide()},onClickDocument(e){this!=null&&this.$el.contains(e.target)||this.hide()},onClickItem(e){this.isFocusable(e.target)||this.hide()},onClickToggle(e){e.target.dispatchEvent(new Event("focus",e)),this.$emit("click-toggle",e),e.defaultPrevented||this.toggle()},onKeydown(e){e.target.parentElement.lastElementChild===e.target&&this.hide()}}}),y=t.defineComponent({mixins:[g]});function k(e,o,i,l,a,h){const n=t.resolveComponent("BtnDropdownAction"),f=t.resolveComponent("DropdownMenu"),p=t.resolveComponent("BtnGroup");return t.openBlock(),t.createBlock(p,{class:t.normalizeClass(e.classes)},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"button",t.normalizeProps(t.guardReactiveProps(e.scope)),()=>[t.createVNode(n,{id:e.$attrs.id,ref:"button",expanded:e.expanded,href:e.href,to:e.to,style:t.normalizeStyle(e.toggleStyle),class:t.normalizeClass(e.toggleClasses),onBlur:e.onBlur,onClick:e.onClickToggle},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"icon"),t.renderSlot(e.$slots,"label",{},()=>[t.createTextVNode(t.toDisplayString(e.label),1)])]),_:3},8,["id","expanded","href","to","style","class","onBlur","onClick"])]),t.createVNode(f,{id:e.$attrs.id,ref:"menu",align:e.align,show:e.expanded,class:t.normalizeClass({animated:e.triggerAnimation}),onBlur:e.onBlur,onClick:e.onClickItem,onKeydown:t.withKeys(e.onKeydown,["tab"]),onMousedown:o[0]||(o[0]=t.withModifiers(()=>{},["prevent"]))},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},8,["id","align","show","class","onBlur","onClick","onKeydown"])]),_:3},8,["class"])}const B=d(y,[["render",k]]),S=t.defineComponent({mixins:[g],emits:["click"]}),D=["id","aria-expanded"];function P(e,o,i,l,a,h){const n=t.resolveComponent("BtnDropdownAction"),f=t.resolveComponent("DropdownMenu"),p=t.resolveComponent("BtnGroup");return t.openBlock(),t.createBlock(p,{class:t.normalizeClass([e.classes,"btn-dropdown-split"])},{default:t.withCtx(()=>[e.dropleft?t.createCommentVNode("",!0):t.renderSlot(e.$slots,"button",t.normalizeProps(t.mergeProps({key:0},e.scope)),()=>[e.dropleft?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(n,{key:0,id:e.$attrs.id,ref:"button",expanded:e.expanded,href:e.href,to:e.to,class:t.normalizeClass(e.actionClasses),onClick:o[0]||(o[0]=r=>e.$emit("click",r))},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"icon"),t.renderSlot(e.$slots,"label",{},()=>[t.createTextVNode(t.toDisplayString(e.label),1)])]),_:3},8,["id","expanded","href","to","class"]))]),t.createVNode(p,{ref:"split"},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"split",t.normalizeProps(t.guardReactiveProps(e.scope)),()=>[e.split?(t.openBlock(),t.createElementBlock("button",{key:0,id:e.$attrs.id,type:"button","aria-haspopup":"true","aria-expanded":e.expanded,class:t.normalizeClass(e.toggleClasses),onBlur:o[1]||(o[1]=(...r)=>e.onBlur&&e.onBlur(...r)),onClick:o[2]||(o[2]=(...r)=>e.onClickToggle&&e.onClickToggle(...r))},null,42,D)):t.createCommentVNode("",!0)]),t.createVNode(f,{id:e.$attrs.id,ref:"menu",align:e.align,show:e.expanded,class:t.normalizeClass({animated:e.triggerAnimation}),onBlur:e.onBlur,onClick:e.onClickItem,onKeydown:t.withKeys(e.onKeydown,["tab"]),onMousedown:o[3]||(o[3]=t.withModifiers(()=>{},["prevent"]))},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},8,["id","align","show","class","onBlur","onClick","onKeydown"])]),_:3},512),e.dropleft?t.renderSlot(e.$slots,"button",t.normalizeProps(t.mergeProps({key:1},e.scope)),()=>[e.dropleft?(t.openBlock(),t.createBlock(n,{key:0,id:e.$attrs.id,ref:"button",expanded:e.expanded,href:e.href,to:e.to,class:t.normalizeClass(e.actionClasses),onClick:o[4]||(o[4]=r=>e.$emit("click",r))},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"icon"),t.renderSlot(e.$slots,"label",{},()=>[t.createTextVNode(t.toDisplayString(e.label),1)])]),_:3},8,["id","expanded","href","to","class"])):t.createCommentVNode("",!0)]):t.createCommentVNode("",!0)]),_:3},8,["class"])}const z=d(S,[["render",P]]),T=t.defineComponent({name:"BtnDropdown",components:{BtnDropdownSplit:z,BtnDropdownSingle:B},inheritAttrs:!1,emits:["click","click-toggle","dropdown","show","hide","toggle"]}),j="";function V(e,o,i,l,a,h){return t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.$attrs.split===void 0||e.$attrs.nav?"btn-dropdown-single":"btn-dropdown-split"),t.mergeProps({class:"btn-dropdown"},e.$attrs,{onClick:o[0]||(o[0]=(...n)=>e.$emit("click",...n)),onClickToggle:o[1]||(o[1]=(...n)=>e.$emit("click-toggle",...n)),onDropdown:o[2]||(o[2]=(...n)=>e.$emit("dropdown",...n)),onShow:o[3]||(o[3]=(...n)=>e.$emit("show",...n)),onHide:o[4]||(o[4]=(...n)=>e.$emit("hide",...n)),onToggle:o[5]||(o[5]=(...n)=>e.$emit("toggle",...n))}),t.createSlots({icon:t.withCtx(()=>[t.renderSlot(e.$slots,"icon")]),button:t.withCtx(n=>[t.renderSlot(e.$slots,"button",t.normalizeProps(t.guardReactiveProps(n)))]),split:t.withCtx(n=>[t.renderSlot(e.$slots,"split",t.normalizeProps(t.guardReactiveProps(n)))]),default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:2},[e.$attrs.label||e.$slots.label?{name:"label",fn:t.withCtx(()=>[t.renderSlot(e.$slots,"label",{},()=>[t.createTextVNode(t.toDisplayString(e.$attrs.label),1)])]),key:"0"}:void 0]),1040)}const N=d(T,[["render",V]]);s.BtnDropdown=N,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _sfc_main: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("toggle" | "show" | "click-toggle" | "hide" | "click" | "dropdown")[], "toggle" | "show" | "click-toggle" | "hide" | "click" | "dropdown", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
|
|
2
|
+
onToggle?: ((...args: any[]) => any) | undefined;
|
|
3
|
+
onShow?: ((...args: any[]) => any) | undefined;
|
|
4
|
+
"onClick-toggle"?: ((...args: any[]) => any) | undefined;
|
|
5
|
+
onHide?: ((...args: any[]) => any) | undefined;
|
|
6
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
7
|
+
onDropdown?: ((...args: any[]) => any) | undefined;
|
|
8
|
+
}, {}>;
|
|
9
|
+
export default _sfc_main;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
2
|
+
expanded: {
|
|
3
|
+
type: BooleanConstructor;
|
|
4
|
+
default: boolean;
|
|
5
|
+
};
|
|
6
|
+
id: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: undefined;
|
|
9
|
+
};
|
|
10
|
+
href: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
to: {
|
|
15
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
18
|
+
}, unknown, unknown, {
|
|
19
|
+
is(): "button" | "router-link" | "a";
|
|
20
|
+
}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
21
|
+
expanded: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
id: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
href: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
to: {
|
|
34
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
37
|
+
}>>, {
|
|
38
|
+
expanded: boolean;
|
|
39
|
+
id: string;
|
|
40
|
+
href: string;
|
|
41
|
+
to: string | Record<string, any>;
|
|
42
|
+
}>;
|
|
43
|
+
export default _sfc_main;
|