@vue-interface/btn-activity 2.0.0-beta.0 → 2.0.0-beta.10
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-activity.js +445 -0
- package/dist/btn-activity.umd.cjs +1 -0
- package/{index.js → dist/index.d.ts} +1 -4
- package/dist/src/BtnActivity.vue.d.ts +169 -0
- package/dist/style.css +1 -0
- package/package.json +26 -19
- package/dist/btn-activity.css +0 -1
- package/dist/btn-activity.es.js +0 -280
- package/dist/btn-activity.umd.js +0 -14
- package/src/BtnActivity.vue +0 -355
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { defineComponent as b, inject as O, openBlock as a, createElementBlock as g, normalizeClass as j, normalizeStyle as N, createElementVNode as E, createBlock as y, resolveDynamicComponent as x, createCommentVNode as $, toDisplayString as f, mergeProps as w, withCtx as A, renderSlot as C, createTextVNode as k, resolveComponent as P, createVNode as _, normalizeProps as H, guardReactiveProps as R } from "vue";
|
|
2
|
+
function r(t, i = "px") {
|
|
3
|
+
return t != null && t !== !1 && isFinite(t) ? `${t}${i}` : t;
|
|
4
|
+
}
|
|
5
|
+
const V = b({
|
|
6
|
+
props: {
|
|
7
|
+
absolute: Boolean,
|
|
8
|
+
center: Boolean,
|
|
9
|
+
label: String,
|
|
10
|
+
size: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: "md"
|
|
13
|
+
},
|
|
14
|
+
registry: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "indicators"
|
|
17
|
+
},
|
|
18
|
+
type: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: !0
|
|
21
|
+
},
|
|
22
|
+
height: [String, Number],
|
|
23
|
+
maxHeight: [String, Number],
|
|
24
|
+
minHeight: [String, Number],
|
|
25
|
+
width: [String, Number],
|
|
26
|
+
maxWidth: [String, Number],
|
|
27
|
+
minWidth: [String, Number]
|
|
28
|
+
},
|
|
29
|
+
data: () => ({
|
|
30
|
+
is: null
|
|
31
|
+
}),
|
|
32
|
+
setup(t) {
|
|
33
|
+
return {
|
|
34
|
+
registryInstance: O(t.registry || "indicators")
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
computed: {
|
|
38
|
+
classes() {
|
|
39
|
+
return {
|
|
40
|
+
"activity-indicator-center": this.center,
|
|
41
|
+
"activity-indicator-absolute": this.absolute,
|
|
42
|
+
[this.size && `activity-indicator-${this.size}`]: !!this.size
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
style() {
|
|
46
|
+
return {
|
|
47
|
+
width: r(this.width),
|
|
48
|
+
maxWidth: r(this.maxWidth),
|
|
49
|
+
minWidth: r(this.minWidth),
|
|
50
|
+
height: r(this.height),
|
|
51
|
+
maxHeight: r(this.maxHeight),
|
|
52
|
+
minHeight: r(this.minHeight)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async mounted() {
|
|
57
|
+
const t = await this.component();
|
|
58
|
+
this.is = () => t;
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
async component() {
|
|
62
|
+
let t = this.registryInstance.get(this.type);
|
|
63
|
+
return t instanceof Promise ? t : (typeof t == "function" && (t = await t()), t.default ? t.default : t);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}), W = (t, i) => {
|
|
67
|
+
const e = t.__vccOpts || t;
|
|
68
|
+
for (const [n, s] of i)
|
|
69
|
+
e[n] = s;
|
|
70
|
+
return e;
|
|
71
|
+
}, D = { class: "activity-indicator-content" }, L = {
|
|
72
|
+
key: 1,
|
|
73
|
+
class: "activity-indicator-label"
|
|
74
|
+
};
|
|
75
|
+
function I(t, i, e, n, s, o) {
|
|
76
|
+
return a(), g("div", {
|
|
77
|
+
class: j(["activity-indicator", t.classes]),
|
|
78
|
+
style: N(t.style)
|
|
79
|
+
}, [
|
|
80
|
+
E("div", D, [
|
|
81
|
+
t.is ? (a(), y(x(t.is()), {
|
|
82
|
+
key: 0,
|
|
83
|
+
class: "mx-auto"
|
|
84
|
+
})) : $("", !0),
|
|
85
|
+
t.label ? (a(), g("div", L, f(t.label), 1)) : $("", !0)
|
|
86
|
+
])
|
|
87
|
+
], 6);
|
|
88
|
+
}
|
|
89
|
+
const Z = /* @__PURE__ */ W(V, [["render", I]]);
|
|
90
|
+
var F = Object.defineProperty, M = (t, i, e) => i in t ? F(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e, T = (t, i, e) => (M(t, typeof i != "symbol" ? i + "" : i, e), e), u = function() {
|
|
91
|
+
return u = Object.assign || function(t) {
|
|
92
|
+
for (var i, e = 1, n = arguments.length; e < n; e++) {
|
|
93
|
+
i = arguments[e];
|
|
94
|
+
for (var s in i)
|
|
95
|
+
Object.prototype.hasOwnProperty.call(i, s) && (t[s] = i[s]);
|
|
96
|
+
}
|
|
97
|
+
return t;
|
|
98
|
+
}, u.apply(this, arguments);
|
|
99
|
+
};
|
|
100
|
+
function q(t) {
|
|
101
|
+
return t.toLowerCase();
|
|
102
|
+
}
|
|
103
|
+
var G = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g], J = /[^A-Z0-9]+/gi;
|
|
104
|
+
function K(t, i) {
|
|
105
|
+
i === void 0 && (i = {});
|
|
106
|
+
for (var e = i.splitRegexp, n = e === void 0 ? G : e, s = i.stripRegexp, o = s === void 0 ? J : s, c = i.transform, v = c === void 0 ? q : c, l = i.delimiter, B = l === void 0 ? " " : l, h = S(S(t, n, "$1\0$2"), o, "\0"), p = 0, m = h.length; h.charAt(p) === "\0"; )
|
|
107
|
+
p++;
|
|
108
|
+
for (; h.charAt(m - 1) === "\0"; )
|
|
109
|
+
m--;
|
|
110
|
+
return h.slice(p, m).split("\0").map(v).join(B);
|
|
111
|
+
}
|
|
112
|
+
function S(t, i, e) {
|
|
113
|
+
return i instanceof RegExp ? t.replace(i, e) : i.reduce(function(n, s) {
|
|
114
|
+
return n.replace(s, e);
|
|
115
|
+
}, t);
|
|
116
|
+
}
|
|
117
|
+
function Q(t, i) {
|
|
118
|
+
return i === void 0 && (i = {}), K(t, u({ delimiter: "." }, i));
|
|
119
|
+
}
|
|
120
|
+
function d(t, i) {
|
|
121
|
+
return i === void 0 && (i = {}), Q(t, u({ delimiter: "-" }, i));
|
|
122
|
+
}
|
|
123
|
+
class U {
|
|
124
|
+
constructor(i = {}) {
|
|
125
|
+
T(this, "components"), this.components = /* @__PURE__ */ new Map(), Object.entries(i).forEach(([e, n]) => {
|
|
126
|
+
this.register(e, n);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
get(i) {
|
|
130
|
+
const e = this.components.get(
|
|
131
|
+
i = d(i)
|
|
132
|
+
);
|
|
133
|
+
if (e)
|
|
134
|
+
return e;
|
|
135
|
+
throw new Error(`"${i}" has not been registered yet!`);
|
|
136
|
+
}
|
|
137
|
+
register(i, e) {
|
|
138
|
+
return typeof i == "object" ? (Object.entries(i).forEach(([n, s]) => {
|
|
139
|
+
this.register(d(n), s);
|
|
140
|
+
}), this) : (this.components.set(d(i), e), this);
|
|
141
|
+
}
|
|
142
|
+
remove(i) {
|
|
143
|
+
return this.components.delete(d(i)), this;
|
|
144
|
+
}
|
|
145
|
+
reset() {
|
|
146
|
+
return this.components = /* @__PURE__ */ new Map(), this;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function X(t = {}) {
|
|
150
|
+
return new U(t);
|
|
151
|
+
}
|
|
152
|
+
X();
|
|
153
|
+
const Y = {
|
|
154
|
+
props: {
|
|
155
|
+
componentPrefix: String,
|
|
156
|
+
size: String,
|
|
157
|
+
sizePrefix: String
|
|
158
|
+
},
|
|
159
|
+
computed: {
|
|
160
|
+
sizeableClassPrefix() {
|
|
161
|
+
return this.sizePrefix || this.componentPrefix;
|
|
162
|
+
},
|
|
163
|
+
hasSizeablePrefix() {
|
|
164
|
+
return this.size === void 0 ? !1 : !!this.size.match(new RegExp(`^${this.sizeableClassPrefix}`));
|
|
165
|
+
},
|
|
166
|
+
sizeableClass() {
|
|
167
|
+
return this.size ? !this.sizeableClassPrefix || this.hasSizeablePrefix ? this.size : `${this.sizeableClassPrefix}-${this.size}` : "";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, tt = {
|
|
171
|
+
props: {
|
|
172
|
+
componentPrefix: String,
|
|
173
|
+
variant: String,
|
|
174
|
+
variantPrefix: String
|
|
175
|
+
},
|
|
176
|
+
computed: {
|
|
177
|
+
variantClassPrefix() {
|
|
178
|
+
return this.variantPrefix || this.componentPrefix;
|
|
179
|
+
},
|
|
180
|
+
hasVariantPrefix() {
|
|
181
|
+
return this.variant === void 0 ? !1 : !!this.variant.match(new RegExp(`^${this.variantClassPrefix}`));
|
|
182
|
+
},
|
|
183
|
+
variantClass() {
|
|
184
|
+
return this.variant ? !this.variantClassPrefix || this.hasVariantPrefix ? this.variant : `${this.variantClassPrefix}-${this.variant}` : "";
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, it = b({
|
|
188
|
+
mixins: [
|
|
189
|
+
Y,
|
|
190
|
+
tt
|
|
191
|
+
],
|
|
192
|
+
props: {
|
|
193
|
+
active: Boolean,
|
|
194
|
+
block: Boolean,
|
|
195
|
+
componentPrefix: {
|
|
196
|
+
type: String,
|
|
197
|
+
default: "btn"
|
|
198
|
+
},
|
|
199
|
+
disabled: Boolean,
|
|
200
|
+
label: String,
|
|
201
|
+
outline: Boolean,
|
|
202
|
+
tag: String,
|
|
203
|
+
variant: {
|
|
204
|
+
type: String,
|
|
205
|
+
default: "primary"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
computed: {
|
|
209
|
+
classes() {
|
|
210
|
+
return [
|
|
211
|
+
"btn",
|
|
212
|
+
this.variantClass,
|
|
213
|
+
this.sizeableClass,
|
|
214
|
+
this.active && "active",
|
|
215
|
+
this.block && "btn-block",
|
|
216
|
+
this.disabled && "disabled"
|
|
217
|
+
];
|
|
218
|
+
},
|
|
219
|
+
component() {
|
|
220
|
+
return this.tag ? this.tag : this.$attrs.href ? "a" : "button";
|
|
221
|
+
},
|
|
222
|
+
variantClassPrefix() {
|
|
223
|
+
return (this.variantPrefix || this.componentPrefix) + (this.outline ? "-outline" : "");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}), et = (t, i) => {
|
|
227
|
+
const e = t.__vccOpts || t;
|
|
228
|
+
for (const [n, s] of i)
|
|
229
|
+
e[n] = s;
|
|
230
|
+
return e;
|
|
231
|
+
};
|
|
232
|
+
function st(t, i, e, n, s, o) {
|
|
233
|
+
return a(), y(x(t.component), w(t.$attrs, {
|
|
234
|
+
disabled: t.disabled,
|
|
235
|
+
class: t.classes,
|
|
236
|
+
role: "button"
|
|
237
|
+
}), {
|
|
238
|
+
default: A(() => [
|
|
239
|
+
C(t.$slots, "default", {}, () => [
|
|
240
|
+
k(f(t.label), 1)
|
|
241
|
+
])
|
|
242
|
+
]),
|
|
243
|
+
_: 3
|
|
244
|
+
}, 16, ["disabled", "class"]);
|
|
245
|
+
}
|
|
246
|
+
const nt = /* @__PURE__ */ et(it, [["render", st]]), rt = function(t) {
|
|
247
|
+
const i = parseFloat(t || 0), e = t && t.match(/m?s/), n = e ? e[0] : !1;
|
|
248
|
+
let s;
|
|
249
|
+
switch (n) {
|
|
250
|
+
case "s":
|
|
251
|
+
s = i * 1e3;
|
|
252
|
+
break;
|
|
253
|
+
case "ms":
|
|
254
|
+
default:
|
|
255
|
+
s = i;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
return s || 0;
|
|
259
|
+
}, z = function(t, i) {
|
|
260
|
+
const e = (t.ownerDocument || document).defaultView;
|
|
261
|
+
setTimeout(
|
|
262
|
+
i,
|
|
263
|
+
rt(
|
|
264
|
+
e == null ? void 0 : e.getComputedStyle(t).animationDuration
|
|
265
|
+
)
|
|
266
|
+
);
|
|
267
|
+
}, at = b({
|
|
268
|
+
components: {
|
|
269
|
+
ActivityIndicator: Z,
|
|
270
|
+
Btn: nt
|
|
271
|
+
},
|
|
272
|
+
inheritAttrs: !1,
|
|
273
|
+
props: {
|
|
274
|
+
/**
|
|
275
|
+
* Make the button appear with the active state.
|
|
276
|
+
*/
|
|
277
|
+
active: Boolean,
|
|
278
|
+
/**
|
|
279
|
+
* Show the activity indicator inside the button.
|
|
280
|
+
*/
|
|
281
|
+
activity: Boolean,
|
|
282
|
+
/**
|
|
283
|
+
* Display the button as block width.
|
|
284
|
+
*/
|
|
285
|
+
block: Boolean,
|
|
286
|
+
/**
|
|
287
|
+
* Disable the button.
|
|
288
|
+
*/
|
|
289
|
+
disabled: Boolean,
|
|
290
|
+
/**
|
|
291
|
+
* The type of activity indicator inside the button.
|
|
292
|
+
*/
|
|
293
|
+
indicator: {
|
|
294
|
+
type: [Object, String],
|
|
295
|
+
default: "spinner"
|
|
296
|
+
},
|
|
297
|
+
/**
|
|
298
|
+
* The button label.
|
|
299
|
+
*/
|
|
300
|
+
label: {
|
|
301
|
+
type: String,
|
|
302
|
+
default: void 0
|
|
303
|
+
},
|
|
304
|
+
/**
|
|
305
|
+
* The orientation of the activity button inside the button.
|
|
306
|
+
*/
|
|
307
|
+
orientation: {
|
|
308
|
+
type: String,
|
|
309
|
+
default: "right"
|
|
310
|
+
},
|
|
311
|
+
/**
|
|
312
|
+
* The size of the button.
|
|
313
|
+
*/
|
|
314
|
+
size: {
|
|
315
|
+
type: String,
|
|
316
|
+
default: "md"
|
|
317
|
+
},
|
|
318
|
+
/**
|
|
319
|
+
* The HTML tag.
|
|
320
|
+
*/
|
|
321
|
+
tag: {
|
|
322
|
+
type: String,
|
|
323
|
+
default: void 0
|
|
324
|
+
},
|
|
325
|
+
/**
|
|
326
|
+
* The variant of the button.
|
|
327
|
+
*/
|
|
328
|
+
variant: {
|
|
329
|
+
type: String,
|
|
330
|
+
default: "primary"
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
emits: ["click", "hide-activity", "show-activity"],
|
|
334
|
+
data() {
|
|
335
|
+
return {
|
|
336
|
+
currentActivity: this.activity
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
computed: {
|
|
340
|
+
/**
|
|
341
|
+
* An object of classes to append to the button.
|
|
342
|
+
*/
|
|
343
|
+
classes() {
|
|
344
|
+
return {
|
|
345
|
+
disabled: this.disabled,
|
|
346
|
+
active: this.active,
|
|
347
|
+
"btn-activity": this.activity,
|
|
348
|
+
[`btn-activity-${this.orientation.replace("btn-activity-", "")}`]: !!this.orientation,
|
|
349
|
+
[`btn-activity-indicator-${this.indicatorProps.type.replace("btn-activity-indicator-", "")}`]: !!this.indicatorProps.type
|
|
350
|
+
};
|
|
351
|
+
},
|
|
352
|
+
indicatorProps() {
|
|
353
|
+
return Object.assign(
|
|
354
|
+
{
|
|
355
|
+
type: "spinner"
|
|
356
|
+
},
|
|
357
|
+
(typeof this.indicator == "string" ? {
|
|
358
|
+
type: this.indicator
|
|
359
|
+
} : this.indicator) || {}
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
watch: {
|
|
364
|
+
activity(t) {
|
|
365
|
+
t ? this.showActivity() : this.hideActivity();
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
mounted() {
|
|
369
|
+
this.activity && this.showActivity();
|
|
370
|
+
},
|
|
371
|
+
methods: {
|
|
372
|
+
/**
|
|
373
|
+
* Disable the button.
|
|
374
|
+
*/
|
|
375
|
+
disable() {
|
|
376
|
+
this.$el.disabled = !0, this.$el.classList.add("disabled");
|
|
377
|
+
},
|
|
378
|
+
/**
|
|
379
|
+
* Enable the button.
|
|
380
|
+
*/
|
|
381
|
+
enable() {
|
|
382
|
+
this.$el.disabled = !1, this.$el.classList.remove("disabled");
|
|
383
|
+
},
|
|
384
|
+
/**
|
|
385
|
+
* Hide the activity indicator inside the button.
|
|
386
|
+
*/
|
|
387
|
+
hideActivity() {
|
|
388
|
+
this.$el.classList.add("btn-hide-activity"), z(this.$el, () => {
|
|
389
|
+
this.disabled || this.enable(), this.currentActivity = !1, this.$el.classList.remove("btn-activity", "btn-hide-activity"), this.$emit("hide-activity");
|
|
390
|
+
});
|
|
391
|
+
},
|
|
392
|
+
/**
|
|
393
|
+
* Show the activity indicator inside the button.
|
|
394
|
+
*/
|
|
395
|
+
showActivity() {
|
|
396
|
+
this.currentActivity = !0, this.disable(), z(this.$el, () => {
|
|
397
|
+
this.$el.classList.add("btn-activity"), this.$emit("show-activity");
|
|
398
|
+
});
|
|
399
|
+
},
|
|
400
|
+
/**
|
|
401
|
+
* Show the activity indicator inside the button.
|
|
402
|
+
*/
|
|
403
|
+
toggle() {
|
|
404
|
+
this.currentActivity ? this.hideActivity() : this.showActivity();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
const ot = (t, i) => {
|
|
409
|
+
const e = t.__vccOpts || t;
|
|
410
|
+
for (const [n, s] of i)
|
|
411
|
+
e[n] = s;
|
|
412
|
+
return e;
|
|
413
|
+
};
|
|
414
|
+
function ct(t, i, e, n, s, o) {
|
|
415
|
+
const c = P("activity-indicator"), v = P("btn");
|
|
416
|
+
return a(), y(v, w({
|
|
417
|
+
active: t.active,
|
|
418
|
+
block: t.block,
|
|
419
|
+
disabled: t.disabled,
|
|
420
|
+
size: t.size,
|
|
421
|
+
tag: t.tag,
|
|
422
|
+
variant: t.variant,
|
|
423
|
+
class: t.classes
|
|
424
|
+
}, Object.assign({}, t.$attrs, { onClick: void 0 }), {
|
|
425
|
+
onClick: i[0] || (i[0] = (l) => !t.disabled && t.$emit("click", l, {
|
|
426
|
+
disable: t.disable,
|
|
427
|
+
enable: t.enable,
|
|
428
|
+
toggle: t.toggle,
|
|
429
|
+
showActivity: t.showActivity,
|
|
430
|
+
hideActivity: t.hideActivity
|
|
431
|
+
}))
|
|
432
|
+
}), {
|
|
433
|
+
default: A(() => [
|
|
434
|
+
C(t.$slots, "default", {}, () => [
|
|
435
|
+
k(f(t.label), 1)
|
|
436
|
+
]),
|
|
437
|
+
_(c, H(R(t.indicatorProps)), null, 16)
|
|
438
|
+
]),
|
|
439
|
+
_: 3
|
|
440
|
+
}, 16, ["active", "block", "disabled", "size", "tag", "variant", "class"]);
|
|
441
|
+
}
|
|
442
|
+
const ht = /* @__PURE__ */ ot(at, [["render", ct]]);
|
|
443
|
+
export {
|
|
444
|
+
ht as BtnActivity
|
|
445
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(a,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(a=typeof globalThis<"u"?globalThis:a||self,e(a.BtnActivity={},a.Vue))})(this,function(a,e){"use strict";function o(t,i="px"){return t!=null&&t!==!1&&isFinite(t)?`${t}${i}`:t}const v=e.defineComponent({props:{absolute:Boolean,center:Boolean,label:String,size:{type:String,default:"md"},registry:{type:String,default:"indicators"},type:{type:String,required:!0},height:[String,Number],maxHeight:[String,Number],minHeight:[String,Number],width:[String,Number],maxWidth:[String,Number],minWidth:[String,Number]},data:()=>({is:null}),setup(t){return{registryInstance:e.inject(t.registry||"indicators")}},computed:{classes(){return{"activity-indicator-center":this.center,"activity-indicator-absolute":this.absolute,[this.size&&`activity-indicator-${this.size}`]:!!this.size}},style(){return{width:o(this.width),maxWidth:o(this.maxWidth),minWidth:o(this.minWidth),height:o(this.height),maxHeight:o(this.maxHeight),minHeight:o(this.minHeight)}}},async mounted(){const t=await this.component();this.is=()=>t},methods:{async component(){let t=this.registryInstance.get(this.type);return t instanceof Promise?t:(typeof t=="function"&&(t=await t()),t.default?t.default:t)}}}),$=(t,i)=>{const n=t.__vccOpts||t;for(const[r,s]of i)n[r]=s;return n},P={class:"activity-indicator-content"},S={key:1,class:"activity-indicator-label"};function x(t,i,n,r,s,d){return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["activity-indicator",t.classes]),style:e.normalizeStyle(t.style)},[e.createElementVNode("div",P,[t.is?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.is()),{key:0,class:"mx-auto"})):e.createCommentVNode("",!0),t.label?(e.openBlock(),e.createElementBlock("div",S,e.toDisplayString(t.label),1)):e.createCommentVNode("",!0)])],6)}const z=$(v,[["render",x]]);var C=Object.defineProperty,w=(t,i,n)=>i in t?C(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n,A=(t,i,n)=>(w(t,typeof i!="symbol"?i+"":i,n),n),c=function(){return c=Object.assign||function(t){for(var i,n=1,r=arguments.length;n<r;n++){i=arguments[n];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},c.apply(this,arguments)};function k(t){return t.toLowerCase()}var B=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],j=/[^A-Z0-9]+/gi;function O(t,i){i===void 0&&(i={});for(var n=i.splitRegexp,r=n===void 0?B:n,s=i.stripRegexp,d=s===void 0?j:s,h=i.transform,f=h===void 0?k:h,p=i.delimiter,q=p===void 0?" ":p,m=b(b(t,r,"$1\0$2"),d,"\0"),u=0,y=m.length;m.charAt(u)==="\0";)u++;for(;m.charAt(y-1)==="\0";)y--;return m.slice(u,y).split("\0").map(f).join(q)}function b(t,i,n){return i instanceof RegExp?t.replace(i,n):i.reduce(function(r,s){return r.replace(s,n)},t)}function N(t,i){return i===void 0&&(i={}),O(t,c({delimiter:"."},i))}function l(t,i){return i===void 0&&(i={}),N(t,c({delimiter:"-"},i))}class E{constructor(i={}){A(this,"components"),this.components=new Map,Object.entries(i).forEach(([n,r])=>{this.register(n,r)})}get(i){const n=this.components.get(i=l(i));if(n)return n;throw new Error(`"${i}" has not been registered yet!`)}register(i,n){return typeof i=="object"?(Object.entries(i).forEach(([r,s])=>{this.register(l(r),s)}),this):(this.components.set(l(i),n),this)}remove(i){return this.components.delete(l(i)),this}reset(){return this.components=new Map,this}}function V(t={}){return new E(t)}V();const D={props:{componentPrefix:String,size:String,sizePrefix:String},computed:{sizeableClassPrefix(){return this.sizePrefix||this.componentPrefix},hasSizeablePrefix(){return this.size===void 0?!1:!!this.size.match(new RegExp(`^${this.sizeableClassPrefix}`))},sizeableClass(){return this.size?!this.sizeableClassPrefix||this.hasSizeablePrefix?this.size:`${this.sizeableClassPrefix}-${this.size}`:""}}},_={props:{componentPrefix:String,variant:String,variantPrefix:String},computed:{variantClassPrefix(){return this.variantPrefix||this.componentPrefix},hasVariantPrefix(){return this.variant===void 0?!1:!!this.variant.match(new RegExp(`^${this.variantClassPrefix}`))},variantClass(){return this.variant?!this.variantClassPrefix||this.hasVariantPrefix?this.variant:`${this.variantClassPrefix}-${this.variant}`:""}}},H=e.defineComponent({mixins:[D,_],props:{active:Boolean,block:Boolean,componentPrefix:{type:String,default:"btn"},disabled:Boolean,label:String,outline:Boolean,tag:String,variant:{type:String,default:"primary"}},computed:{classes(){return["btn",this.variantClass,this.sizeableClass,this.active&&"active",this.block&&"btn-block",this.disabled&&"disabled"]},component(){return this.tag?this.tag:this.$attrs.href?"a":"button"},variantClassPrefix(){return(this.variantPrefix||this.componentPrefix)+(this.outline?"-outline":"")}}}),R=(t,i)=>{const n=t.__vccOpts||t;for(const[r,s]of i)n[r]=s;return n};function T(t,i,n,r,s,d){return e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.component),e.mergeProps(t.$attrs,{disabled:t.disabled,class:t.classes,role:"button"}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.label),1)])]),_:3},16,["disabled","class"])}const W=R(H,[["render",T]]),L=function(t){const i=parseFloat(t||0),n=t&&t.match(/m?s/),r=n?n[0]:!1;let s;switch(r){case"s":s=i*1e3;break;case"ms":default:s=i;break}return s||0},g=function(t,i){const n=(t.ownerDocument||document).defaultView;setTimeout(i,L(n==null?void 0:n.getComputedStyle(t).animationDuration))},I=e.defineComponent({components:{ActivityIndicator:z,Btn:W},inheritAttrs:!1,props:{active:Boolean,activity:Boolean,block:Boolean,disabled:Boolean,indicator:{type:[Object,String],default:"spinner"},label:{type:String,default:void 0},orientation:{type:String,default:"right"},size:{type:String,default:"md"},tag:{type:String,default:void 0},variant:{type:String,default:"primary"}},emits:["click","hide-activity","show-activity"],data(){return{currentActivity:this.activity}},computed:{classes(){return{disabled:this.disabled,active:this.active,"btn-activity":this.activity,[`btn-activity-${this.orientation.replace("btn-activity-","")}`]:!!this.orientation,[`btn-activity-indicator-${this.indicatorProps.type.replace("btn-activity-indicator-","")}`]:!!this.indicatorProps.type}},indicatorProps(){return Object.assign({type:"spinner"},(typeof this.indicator=="string"?{type:this.indicator}:this.indicator)||{})}},watch:{activity(t){t?this.showActivity():this.hideActivity()}},mounted(){this.activity&&this.showActivity()},methods:{disable(){this.$el.disabled=!0,this.$el.classList.add("disabled")},enable(){this.$el.disabled=!1,this.$el.classList.remove("disabled")},hideActivity(){this.$el.classList.add("btn-hide-activity"),g(this.$el,()=>{this.disabled||this.enable(),this.currentActivity=!1,this.$el.classList.remove("btn-activity","btn-hide-activity"),this.$emit("hide-activity")})},showActivity(){this.currentActivity=!0,this.disable(),g(this.$el,()=>{this.$el.classList.add("btn-activity"),this.$emit("show-activity")})},toggle(){this.currentActivity?this.hideActivity():this.showActivity()}}}),G="",Z=(t,i)=>{const n=t.__vccOpts||t;for(const[r,s]of i)n[r]=s;return n};function M(t,i,n,r,s,d){const h=e.resolveComponent("activity-indicator"),f=e.resolveComponent("btn");return e.openBlock(),e.createBlock(f,e.mergeProps({active:t.active,block:t.block,disabled:t.disabled,size:t.size,tag:t.tag,variant:t.variant,class:t.classes},Object.assign({},t.$attrs,{onClick:void 0}),{onClick:i[0]||(i[0]=p=>!t.disabled&&t.$emit("click",p,{disable:t.disable,enable:t.enable,toggle:t.toggle,showActivity:t.showActivity,hideActivity:t.hideActivity}))}),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.label),1)]),e.createVNode(h,e.normalizeProps(e.guardReactiveProps(t.indicatorProps)),null,16)]),_:3},16,["active","block","disabled","size","tag","variant","class"])}const F=Z(I,[["render",M]]);a.BtnActivity=F,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
2
|
+
/**
|
|
3
|
+
* Make the button appear with the active state.
|
|
4
|
+
*/
|
|
5
|
+
active: BooleanConstructor;
|
|
6
|
+
/**
|
|
7
|
+
* Show the activity indicator inside the button.
|
|
8
|
+
*/
|
|
9
|
+
activity: BooleanConstructor;
|
|
10
|
+
/**
|
|
11
|
+
* Display the button as block width.
|
|
12
|
+
*/
|
|
13
|
+
block: BooleanConstructor;
|
|
14
|
+
/**
|
|
15
|
+
* Disable the button.
|
|
16
|
+
*/
|
|
17
|
+
disabled: BooleanConstructor;
|
|
18
|
+
/**
|
|
19
|
+
* The type of activity indicator inside the button.
|
|
20
|
+
*/
|
|
21
|
+
indicator: {
|
|
22
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The button label.
|
|
27
|
+
*/
|
|
28
|
+
label: {
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The orientation of the activity button inside the button.
|
|
34
|
+
*/
|
|
35
|
+
orientation: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The size of the button.
|
|
41
|
+
*/
|
|
42
|
+
size: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The HTML tag.
|
|
48
|
+
*/
|
|
49
|
+
tag: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The variant of the button.
|
|
55
|
+
*/
|
|
56
|
+
variant: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
default: string;
|
|
59
|
+
};
|
|
60
|
+
}, unknown, {
|
|
61
|
+
currentActivity: boolean;
|
|
62
|
+
}, {
|
|
63
|
+
/**
|
|
64
|
+
* An object of classes to append to the button.
|
|
65
|
+
*/
|
|
66
|
+
classes(): {
|
|
67
|
+
[x: string]: any;
|
|
68
|
+
disabled: any;
|
|
69
|
+
active: any;
|
|
70
|
+
'btn-activity': any;
|
|
71
|
+
};
|
|
72
|
+
indicatorProps(): any;
|
|
73
|
+
}, {
|
|
74
|
+
/**
|
|
75
|
+
* Disable the button.
|
|
76
|
+
*/
|
|
77
|
+
disable(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Enable the button.
|
|
80
|
+
*/
|
|
81
|
+
enable(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Hide the activity indicator inside the button.
|
|
84
|
+
*/
|
|
85
|
+
hideActivity(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Show the activity indicator inside the button.
|
|
88
|
+
*/
|
|
89
|
+
showActivity(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Show the activity indicator inside the button.
|
|
92
|
+
*/
|
|
93
|
+
toggle(): void;
|
|
94
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "hide-activity" | "show-activity")[], "click" | "hide-activity" | "show-activity", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
95
|
+
/**
|
|
96
|
+
* Make the button appear with the active state.
|
|
97
|
+
*/
|
|
98
|
+
active: BooleanConstructor;
|
|
99
|
+
/**
|
|
100
|
+
* Show the activity indicator inside the button.
|
|
101
|
+
*/
|
|
102
|
+
activity: BooleanConstructor;
|
|
103
|
+
/**
|
|
104
|
+
* Display the button as block width.
|
|
105
|
+
*/
|
|
106
|
+
block: BooleanConstructor;
|
|
107
|
+
/**
|
|
108
|
+
* Disable the button.
|
|
109
|
+
*/
|
|
110
|
+
disabled: BooleanConstructor;
|
|
111
|
+
/**
|
|
112
|
+
* The type of activity indicator inside the button.
|
|
113
|
+
*/
|
|
114
|
+
indicator: {
|
|
115
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
116
|
+
default: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The button label.
|
|
120
|
+
*/
|
|
121
|
+
label: {
|
|
122
|
+
type: StringConstructor;
|
|
123
|
+
default: undefined;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* The orientation of the activity button inside the button.
|
|
127
|
+
*/
|
|
128
|
+
orientation: {
|
|
129
|
+
type: StringConstructor;
|
|
130
|
+
default: string;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The size of the button.
|
|
134
|
+
*/
|
|
135
|
+
size: {
|
|
136
|
+
type: StringConstructor;
|
|
137
|
+
default: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The HTML tag.
|
|
141
|
+
*/
|
|
142
|
+
tag: {
|
|
143
|
+
type: StringConstructor;
|
|
144
|
+
default: undefined;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The variant of the button.
|
|
148
|
+
*/
|
|
149
|
+
variant: {
|
|
150
|
+
type: StringConstructor;
|
|
151
|
+
default: string;
|
|
152
|
+
};
|
|
153
|
+
}>> & {
|
|
154
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
155
|
+
"onHide-activity"?: ((...args: any[]) => any) | undefined;
|
|
156
|
+
"onShow-activity"?: ((...args: any[]) => any) | undefined;
|
|
157
|
+
}, {
|
|
158
|
+
label: string;
|
|
159
|
+
size: string;
|
|
160
|
+
active: boolean;
|
|
161
|
+
block: boolean;
|
|
162
|
+
disabled: boolean;
|
|
163
|
+
tag: string;
|
|
164
|
+
variant: string;
|
|
165
|
+
activity: boolean;
|
|
166
|
+
indicator: string | Record<string, any>;
|
|
167
|
+
orientation: string;
|
|
168
|
+
}>;
|
|
169
|
+
export default _sfc_main;
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@-webkit-keyframes btn-activity-in{0%,to{-webkit-transform:scale(1);transform:scale(1)}30%{-webkit-transform:scale(.98);transform:scale(.98)}}@keyframes btn-activity-in{0%,to{-webkit-transform:scale(1);transform:scale(1)}30%{-webkit-transform:scale(.98);transform:scale(.98)}}@-webkit-keyframes btn-activity-out{0%,to{-webkit-transform:scale(1);transform:scale(1)}70%{-webkit-transform:scale(.98);transform:scale(.98)}}@keyframes btn-activity-out{0%,to{-webkit-transform:scale(1);transform:scale(1)}70%{-webkit-transform:scale(.98);transform:scale(.98)}}.btn-activity-top,.btn.btn-activity-top,.btn-activity-bottom,.btn.btn-activity-bottom,.btn-activity-left,.btn.btn-activity-left,.btn-activity-right,.btn.btn-activity-right{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;position:relative;-webkit-transition:all 166.5ms ease-in;transition:all 166.5ms ease-in}.btn-activity-top .activity-indicator,.btn-activity-bottom .activity-indicator,.btn-activity-left .activity-indicator,.btn-activity-right .activity-indicator{opacity:0;position:absolute;visibility:hidden;-webkit-transition:opacity 333ms ease-in;transition:opacity 333ms ease-in}.btn-activity-top,.btn-activity-bottom{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.btn-activity-top .activity-indicator,.btn-activity-bottom .activity-indicator{margin-left:auto;margin-right:auto}.btn-activity-top{-webkit-box-orient:vertical;-webkit-box-direction:reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse}.btn-activity-top .activity-indicator{padding-bottom:1em}.btn-activity-bottom .activity-indicator{padding-top:1em}.btn-activity-left,.btn-activity-right{-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.btn-activity-left{-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse}.btn-activity-left .activity-indicator{padding-right:1em}.btn-activity-right .activity-indicator{padding-left:1em}.btn-activity:not(.btn-link){-webkit-animation:btn-activity-in 333ms;animation:btn-activity-in 333ms}.btn-hide-activity:not(.btn-link){-webkit-animation:btn-activity-out 333ms;animation:btn-activity-out 333ms}.btn-activity.btn-hide-activity .activity-indicator{opacity:0}.btn-activity .activity-indicator{opacity:1;visibility:visible;position:relative;font-size:.55em}
|