@vue-interface/btn-activity 2.0.0-beta.0 → 2.0.0-beta.1
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.es.js +200 -94
- package/dist/btn-activity.umd.js +2 -2
- package/package.json +1 -1
- package/src/BtnActivity.vue +65 -51
package/dist/btn-activity.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { openBlock as c, createElementBlock as
|
|
1
|
+
import { openBlock as c, createElementBlock as p, normalizeClass as z, normalizeStyle as R, createElementVNode as N, createBlock as m, resolveDynamicComponent as w, createCommentVNode as b, toDisplayString as f, mergeProps as O, withCtx as $, renderSlot as A, createTextVNode as B, resolveComponent as x, createVNode as D, normalizeProps as L, guardReactiveProps as j } from "vue";
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,81 +13,81 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
var
|
|
17
|
-
return
|
|
16
|
+
var h = function() {
|
|
17
|
+
return h = Object.assign || function(e) {
|
|
18
18
|
for (var i, n = 1, s = arguments.length; n < s; n++) {
|
|
19
19
|
i = arguments[n];
|
|
20
|
-
for (var
|
|
21
|
-
Object.prototype.hasOwnProperty.call(i,
|
|
20
|
+
for (var a in i)
|
|
21
|
+
Object.prototype.hasOwnProperty.call(i, a) && (e[a] = i[a]);
|
|
22
22
|
}
|
|
23
23
|
return e;
|
|
24
|
-
},
|
|
24
|
+
}, h.apply(this, arguments);
|
|
25
25
|
};
|
|
26
|
-
function
|
|
26
|
+
function T(t) {
|
|
27
27
|
return t.toLowerCase();
|
|
28
28
|
}
|
|
29
|
-
var
|
|
30
|
-
function
|
|
29
|
+
var V = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g], F = /[^A-Z0-9]+/gi;
|
|
30
|
+
function H(t, e) {
|
|
31
31
|
e === void 0 && (e = {});
|
|
32
|
-
for (var i = e.splitRegexp, n = i === void 0 ?
|
|
33
|
-
|
|
34
|
-
for (;
|
|
35
|
-
|
|
36
|
-
return
|
|
32
|
+
for (var i = e.splitRegexp, n = i === void 0 ? V : i, s = e.stripRegexp, a = s === void 0 ? F : s, o = e.transform, _ = o === void 0 ? T : o, l = e.delimiter, E = l === void 0 ? " " : l, d = P(P(t, n, "$1\0$2"), a, "\0"), v = 0, y = d.length; d.charAt(v) === "\0"; )
|
|
33
|
+
v++;
|
|
34
|
+
for (; d.charAt(y - 1) === "\0"; )
|
|
35
|
+
y--;
|
|
36
|
+
return d.slice(v, y).split("\0").map(_).join(E);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function P(t, e, i) {
|
|
39
39
|
return e instanceof RegExp ? t.replace(e, i) : e.reduce(function(n, s) {
|
|
40
40
|
return n.replace(s, i);
|
|
41
41
|
}, t);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
return e === void 0 && (e = {}),
|
|
43
|
+
function I(t, e) {
|
|
44
|
+
return e === void 0 && (e = {}), H(t, h({
|
|
45
45
|
delimiter: "."
|
|
46
46
|
}, e));
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return e === void 0 && (e = {}),
|
|
48
|
+
function u(t, e) {
|
|
49
|
+
return e === void 0 && (e = {}), I(t, h({
|
|
50
50
|
delimiter: "-"
|
|
51
51
|
}, e));
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class k {
|
|
54
54
|
constructor(e = {}) {
|
|
55
55
|
this.components = /* @__PURE__ */ new Map(), Object.entries(e).forEach(([i, n]) => {
|
|
56
56
|
this.register(i, n);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
get(e) {
|
|
60
|
-
const i = this.components.get(e =
|
|
60
|
+
const i = this.components.get(e = u(e));
|
|
61
61
|
if (i)
|
|
62
62
|
return i;
|
|
63
63
|
throw new Error(`"${e}" has not been registered yet!`);
|
|
64
64
|
}
|
|
65
65
|
register(e, i) {
|
|
66
66
|
return typeof e == "object" ? (Object.entries(e).forEach(([n, s]) => {
|
|
67
|
-
this.register(
|
|
68
|
-
}), this) : (this.components.set(
|
|
67
|
+
this.register(u(n), s);
|
|
68
|
+
}), this) : (this.components.set(u(e), i), this);
|
|
69
69
|
}
|
|
70
70
|
remove(e) {
|
|
71
|
-
return this.components.delete(
|
|
71
|
+
return this.components.delete(u(e)), this;
|
|
72
72
|
}
|
|
73
73
|
reset() {
|
|
74
74
|
return this.components = /* @__PURE__ */ new Map(), this;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
return new
|
|
77
|
+
function W(...t) {
|
|
78
|
+
return new k(...t);
|
|
79
79
|
}
|
|
80
|
-
const
|
|
81
|
-
const
|
|
80
|
+
const S = W();
|
|
81
|
+
const g = (t, e) => {
|
|
82
82
|
const i = t.__vccOpts || t;
|
|
83
83
|
for (const [n, s] of e)
|
|
84
84
|
i[n] = s;
|
|
85
85
|
return i;
|
|
86
86
|
};
|
|
87
|
-
function
|
|
87
|
+
function r(t, e = "px") {
|
|
88
88
|
return t != null && t !== !1 && isFinite(t) ? `${t}${e}` : t;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const q = {
|
|
91
91
|
name: "ActivityIndicator",
|
|
92
92
|
props: {
|
|
93
93
|
absolute: Boolean,
|
|
@@ -98,9 +98,9 @@ const V = {
|
|
|
98
98
|
default: "md"
|
|
99
99
|
},
|
|
100
100
|
registry: {
|
|
101
|
-
type:
|
|
101
|
+
type: k,
|
|
102
102
|
default() {
|
|
103
|
-
return
|
|
103
|
+
return S;
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
type: {
|
|
@@ -127,12 +127,12 @@ const V = {
|
|
|
127
127
|
},
|
|
128
128
|
style() {
|
|
129
129
|
return {
|
|
130
|
-
width:
|
|
131
|
-
maxWidth:
|
|
132
|
-
minWidth:
|
|
133
|
-
height:
|
|
134
|
-
maxHeight:
|
|
135
|
-
minHeight:
|
|
130
|
+
width: r(this.width),
|
|
131
|
+
maxWidth: r(this.maxWidth),
|
|
132
|
+
minWidth: r(this.minWidth),
|
|
133
|
+
height: r(this.height),
|
|
134
|
+
maxHeight: r(this.maxHeight),
|
|
135
|
+
minHeight: r(this.minHeight)
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
},
|
|
@@ -142,30 +142,124 @@ const V = {
|
|
|
142
142
|
},
|
|
143
143
|
methods: {
|
|
144
144
|
async component() {
|
|
145
|
-
let t =
|
|
145
|
+
let t = S.get(this.type);
|
|
146
146
|
return t instanceof Promise ? t : (typeof t == "function" && (t = await t()), t.default ? t.default : t);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
},
|
|
149
|
+
}, Z = { class: "activity-indicator-content" }, G = {
|
|
150
150
|
key: 1,
|
|
151
151
|
class: "activity-indicator-label"
|
|
152
152
|
};
|
|
153
|
-
function
|
|
154
|
-
return c(),
|
|
155
|
-
class:
|
|
156
|
-
style:
|
|
153
|
+
function M(t, e, i, n, s, a) {
|
|
154
|
+
return c(), p("div", {
|
|
155
|
+
class: z(["activity-indicator", a.classes]),
|
|
156
|
+
style: R(a.style)
|
|
157
157
|
}, [
|
|
158
|
-
|
|
159
|
-
t.is ? (c(),
|
|
158
|
+
N("div", Z, [
|
|
159
|
+
t.is ? (c(), m(w(t.is()), {
|
|
160
160
|
key: 0,
|
|
161
161
|
class: "mx-auto"
|
|
162
|
-
})) :
|
|
163
|
-
i.label ? (c(),
|
|
162
|
+
})) : b("", !0),
|
|
163
|
+
i.label ? (c(), p("div", G, f(i.label), 1)) : b("", !0)
|
|
164
164
|
])
|
|
165
165
|
], 6);
|
|
166
166
|
}
|
|
167
|
-
const
|
|
168
|
-
const
|
|
167
|
+
const U = /* @__PURE__ */ g(q, [["render", M]]);
|
|
168
|
+
const X = {
|
|
169
|
+
props: {
|
|
170
|
+
componentPrefix: String,
|
|
171
|
+
size: String,
|
|
172
|
+
sizePrefix: String
|
|
173
|
+
},
|
|
174
|
+
computed: {
|
|
175
|
+
sizeableClassPrefix() {
|
|
176
|
+
return this.sizePrefix || this.componentPrefix;
|
|
177
|
+
},
|
|
178
|
+
hasSizeablePrefix() {
|
|
179
|
+
return this.size && !!this.size.match(
|
|
180
|
+
new RegExp(`^${this.sizeableClassPrefix}`)
|
|
181
|
+
);
|
|
182
|
+
},
|
|
183
|
+
sizeableClass() {
|
|
184
|
+
return this.size ? !this.sizeableClassPrefix || this.hasSizeablePrefix ? this.size : `${this.sizeableClassPrefix}-${this.size}` : "";
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, J = {
|
|
188
|
+
props: {
|
|
189
|
+
componentPrefix: String,
|
|
190
|
+
variant: String,
|
|
191
|
+
variantPrefix: String
|
|
192
|
+
},
|
|
193
|
+
computed: {
|
|
194
|
+
variantClassPrefix() {
|
|
195
|
+
return this.variantPrefix || this.componentPrefix;
|
|
196
|
+
},
|
|
197
|
+
hasVariantPrefix() {
|
|
198
|
+
return this.variant && !!this.variant.match(
|
|
199
|
+
new RegExp(`^${this.variantClassPrefix}`)
|
|
200
|
+
);
|
|
201
|
+
},
|
|
202
|
+
variantClass() {
|
|
203
|
+
return this.variant ? !this.variantClassPrefix || this.hasVariantPrefix ? this.variant : `${this.variantClassPrefix}-${this.variant}` : "";
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}, K = {
|
|
207
|
+
name: "Btn",
|
|
208
|
+
mixins: [
|
|
209
|
+
X,
|
|
210
|
+
J
|
|
211
|
+
],
|
|
212
|
+
props: {
|
|
213
|
+
active: Boolean,
|
|
214
|
+
block: Boolean,
|
|
215
|
+
componentPrefix: {
|
|
216
|
+
type: String,
|
|
217
|
+
default: "btn"
|
|
218
|
+
},
|
|
219
|
+
disabled: Boolean,
|
|
220
|
+
label: String,
|
|
221
|
+
outline: Boolean,
|
|
222
|
+
tag: String,
|
|
223
|
+
variant: {
|
|
224
|
+
type: String,
|
|
225
|
+
default: "primary"
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
computed: {
|
|
229
|
+
classes() {
|
|
230
|
+
return [
|
|
231
|
+
"btn",
|
|
232
|
+
this.variantClass,
|
|
233
|
+
this.sizeableClass,
|
|
234
|
+
this.active && "active",
|
|
235
|
+
this.block && "btn-block",
|
|
236
|
+
this.disabled && "disabled"
|
|
237
|
+
];
|
|
238
|
+
},
|
|
239
|
+
component() {
|
|
240
|
+
return this.tag ? this.tag : this.$attrs.href ? "a" : "button";
|
|
241
|
+
},
|
|
242
|
+
variantClassPrefix() {
|
|
243
|
+
return (this.variantPrefix || this.componentPrefix) + (this.outline ? "-outline" : "");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
function Q(t, e, i, n, s, a) {
|
|
248
|
+
return c(), m(w(a.component), O(t.$attrs, {
|
|
249
|
+
disabled: i.disabled,
|
|
250
|
+
class: a.classes,
|
|
251
|
+
role: "button"
|
|
252
|
+
}), {
|
|
253
|
+
default: $(() => [
|
|
254
|
+
A(t.$slots, "default", {}, () => [
|
|
255
|
+
B(f(i.label), 1)
|
|
256
|
+
])
|
|
257
|
+
]),
|
|
258
|
+
_: 3
|
|
259
|
+
}, 16, ["disabled", "class"]);
|
|
260
|
+
}
|
|
261
|
+
const Y = /* @__PURE__ */ g(K, [["render", Q]]);
|
|
262
|
+
const tt = function(t) {
|
|
169
263
|
const e = parseFloat(t || 0, 10), i = t && t.match(/m?s/), n = i ? i[0] : !1;
|
|
170
264
|
let s;
|
|
171
265
|
switch (n) {
|
|
@@ -178,50 +272,54 @@ const M = function(t) {
|
|
|
178
272
|
break;
|
|
179
273
|
}
|
|
180
274
|
return s || 0;
|
|
181
|
-
},
|
|
275
|
+
}, C = function(t, e) {
|
|
182
276
|
const i = (t.ownerDocument || document).defaultView;
|
|
183
277
|
setTimeout(() => {
|
|
184
278
|
e.apply();
|
|
185
|
-
},
|
|
186
|
-
},
|
|
279
|
+
}, tt(i.getComputedStyle(t).animationDuration));
|
|
280
|
+
}, et = {
|
|
187
281
|
name: "BtnActivity",
|
|
188
282
|
components: {
|
|
189
|
-
ActivityIndicator:
|
|
283
|
+
ActivityIndicator: U,
|
|
284
|
+
Btn: Y
|
|
190
285
|
},
|
|
191
286
|
props: {
|
|
192
287
|
active: Boolean,
|
|
193
288
|
activity: Boolean,
|
|
194
289
|
block: Boolean,
|
|
195
290
|
disabled: Boolean,
|
|
291
|
+
indicator: {
|
|
292
|
+
type: [Object, String],
|
|
293
|
+
default: "spinner"
|
|
294
|
+
},
|
|
196
295
|
label: String,
|
|
197
|
-
|
|
198
|
-
|
|
296
|
+
orientation: {
|
|
297
|
+
type: String,
|
|
298
|
+
default: "right"
|
|
299
|
+
},
|
|
199
300
|
size: {
|
|
200
301
|
type: String,
|
|
201
302
|
default: "md"
|
|
202
303
|
},
|
|
304
|
+
tag: String,
|
|
203
305
|
variant: {
|
|
204
306
|
type: String,
|
|
205
307
|
default: "primary"
|
|
206
|
-
},
|
|
207
|
-
indicator: {
|
|
208
|
-
type: [Object, String],
|
|
209
|
-
default: "spinner"
|
|
210
|
-
},
|
|
211
|
-
orientation: {
|
|
212
|
-
type: String,
|
|
213
|
-
default: "right"
|
|
214
308
|
}
|
|
215
309
|
},
|
|
310
|
+
data() {
|
|
311
|
+
return {
|
|
312
|
+
currentActivity: this.activity
|
|
313
|
+
};
|
|
314
|
+
},
|
|
216
315
|
computed: {
|
|
217
316
|
classes() {
|
|
218
317
|
const t = {
|
|
219
318
|
disabled: this.disabled,
|
|
220
319
|
active: this.active,
|
|
221
|
-
"btn-block": this.block,
|
|
222
320
|
"btn-activity": this.activity
|
|
223
321
|
};
|
|
224
|
-
return t["btn-
|
|
322
|
+
return t["btn-activity-" + this.orientation.replace("btn-activity-", "")] = !!this.orientation, t["btn-activity-indicator-" + this.indicatorProps.type.replace("btn-activity-indicator-", "")] = !!this.indicatorProps.type, t;
|
|
225
323
|
},
|
|
226
324
|
indicatorProps() {
|
|
227
325
|
return Object.assign({
|
|
@@ -236,45 +334,53 @@ const M = function(t) {
|
|
|
236
334
|
t ? this.showActivity() : this.hideActivity();
|
|
237
335
|
}
|
|
238
336
|
},
|
|
337
|
+
mounted() {
|
|
338
|
+
this.activity && this.showActivity();
|
|
339
|
+
},
|
|
239
340
|
methods: {
|
|
240
341
|
disable() {
|
|
241
|
-
this.$el.disabled = !0;
|
|
342
|
+
this.$el.disabled = !0, this.$el.classList.add("disabled");
|
|
242
343
|
},
|
|
243
344
|
enable() {
|
|
244
|
-
this.$el.disabled = !1;
|
|
345
|
+
this.$el.disabled = !1, this.$el.classList.remove("disabled");
|
|
245
346
|
},
|
|
246
|
-
|
|
247
|
-
this.
|
|
248
|
-
this.$el.classList.
|
|
347
|
+
hideActivity() {
|
|
348
|
+
this.$el.classList.add("btn-hide-activity"), C(this.$el, () => {
|
|
349
|
+
this.enable(), this.currentActivity = !1, this.$el.classList.remove("btn-activity", "btn-hide-activity"), this.$emit("hide-activity");
|
|
249
350
|
});
|
|
250
351
|
},
|
|
251
|
-
|
|
252
|
-
this
|
|
253
|
-
this
|
|
352
|
+
showActivity() {
|
|
353
|
+
this.currentActivity = !0, this.disable(), C(this.$el, () => {
|
|
354
|
+
this.$el.classList.add("btn-activity"), this.$emit("show-activity");
|
|
254
355
|
});
|
|
255
356
|
},
|
|
256
|
-
|
|
257
|
-
this.
|
|
357
|
+
toggle() {
|
|
358
|
+
this.currentActivity ? this.hideActivity() : this.showActivity();
|
|
258
359
|
}
|
|
259
360
|
}
|
|
260
|
-
}
|
|
261
|
-
function
|
|
262
|
-
const o =
|
|
263
|
-
return c(),
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
i.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
361
|
+
};
|
|
362
|
+
function it(t, e, i, n, s, a) {
|
|
363
|
+
const o = x("activity-indicator"), _ = x("btn");
|
|
364
|
+
return c(), m(_, {
|
|
365
|
+
active: i.active,
|
|
366
|
+
block: i.block,
|
|
367
|
+
disabled: i.disabled,
|
|
368
|
+
size: i.size,
|
|
369
|
+
tag: i.tag,
|
|
370
|
+
variant: i.variant,
|
|
371
|
+
class: z(a.classes),
|
|
372
|
+
onClick: e[0] || (e[0] = (l) => !i.disabled && t.$emit("click", l, this))
|
|
373
|
+
}, {
|
|
374
|
+
default: $(() => [
|
|
375
|
+
A(t.$slots, "default", {}, () => [
|
|
376
|
+
B(f(i.label), 1)
|
|
377
|
+
]),
|
|
378
|
+
D(o, L(j(a.indicatorProps)), null, 16)
|
|
379
|
+
]),
|
|
380
|
+
_: 3
|
|
381
|
+
}, 8, ["active", "block", "disabled", "size", "tag", "variant", "class"]);
|
|
276
382
|
}
|
|
277
|
-
const
|
|
383
|
+
const st = /* @__PURE__ */ g(et, [["render", it]]);
|
|
278
384
|
export {
|
|
279
|
-
|
|
385
|
+
st as BtnActivity
|
|
280
386
|
};
|
package/dist/btn-activity.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(o=typeof globalThis<"u"?globalThis:o||self,n(o.BtnActivity={},o.Vue))})(this,function(o,n){"use strict";/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */var l=function(){return l=Object.assign||function(e){for(var i,s=1,
|
|
14
|
+
***************************************************************************** */var l=function(){return l=Object.assign||function(e){for(var i,s=1,a=arguments.length;s<a;s++){i=arguments[s];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},l.apply(this,arguments)};function S(t){return t.toLowerCase()}var P=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],C=/[^A-Z0-9]+/gi;function z(t,e){e===void 0&&(e={});for(var i=e.splitRegexp,s=i===void 0?P:i,a=e.stripRegexp,r=a===void 0?C:a,h=e.transform,m=h===void 0?S:h,_=e.delimiter,F=_===void 0?" ":_,u=v(v(t,s,"$1\0$2"),r,"\0"),y=0,p=u.length;u.charAt(y)==="\0";)y++;for(;u.charAt(p-1)==="\0";)p--;return u.slice(y,p).split("\0").map(m).join(F)}function v(t,e,i){return e instanceof RegExp?t.replace(e,i):e.reduce(function(s,a){return s.replace(a,i)},t)}function $(t,e){return e===void 0&&(e={}),z(t,l({delimiter:"."},e))}function d(t,e){return e===void 0&&(e={}),$(t,l({delimiter:"-"},e))}class g{constructor(e={}){this.components=new Map,Object.entries(e).forEach(([i,s])=>{this.register(i,s)})}get(e){const i=this.components.get(e=d(e));if(i)return i;throw new Error(`"${e}" has not been registered yet!`)}register(e,i){return typeof e=="object"?(Object.entries(e).forEach(([s,a])=>{this.register(d(s),a)}),this):(this.components.set(d(e),i),this)}remove(e){return this.components.delete(d(e)),this}reset(){return this.components=new Map,this}}function w(...t){return new g(...t)}const b=w(),H="",f=(t,e)=>{const i=t.__vccOpts||t;for(const[s,a]of e)i[s]=a;return i};function c(t,e="px"){return t!=null&&t!==!1&&isFinite(t)?`${t}${e}`:t}const A={name:"ActivityIndicator",props:{absolute:Boolean,center:Boolean,label:String,size:{type:String,default:"md"},registry:{type:g,default(){return b}},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}),computed:{classes(){return{"activity-indicator-center":this.center,"activity-indicator-absolute":this.absolute,[this.size&&`activity-indicator-${this.size}`]:!!this.size}},style(){return{width:c(this.width),maxWidth:c(this.maxWidth),minWidth:c(this.minWidth),height:c(this.height),maxHeight:c(this.maxHeight),minHeight:c(this.minHeight)}}},async mounted(){const t=await this.component();this.is=()=>t},methods:{async component(){let t=b.get(this.type);return t instanceof Promise?t:(typeof t=="function"&&(t=await t()),t.default?t.default:t)}}},B={class:"activity-indicator-content"},k={key:1,class:"activity-indicator-label"};function E(t,e,i,s,a,r){return n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["activity-indicator",r.classes]),style:n.normalizeStyle(r.style)},[n.createElementVNode("div",B,[t.is?(n.openBlock(),n.createBlock(n.resolveDynamicComponent(t.is()),{key:0,class:"mx-auto"})):n.createCommentVNode("",!0),i.label?(n.openBlock(),n.createElementBlock("div",k,n.toDisplayString(i.label),1)):n.createCommentVNode("",!0)])],6)}const D=f(A,[["render",E]]),I="",W="",q="",M="",Z="",G="",U="",X="",J="",K="",Q="",Y="",tt="",et="",N={name:"Btn",mixins:[{props:{componentPrefix:String,size:String,sizePrefix:String},computed:{sizeableClassPrefix(){return this.sizePrefix||this.componentPrefix},hasSizeablePrefix(){return this.size&&!!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&&!!this.variant.match(new RegExp(`^${this.variantClassPrefix}`))},variantClass(){return this.variant?!this.variantClassPrefix||this.hasVariantPrefix?this.variant:`${this.variantClassPrefix}-${this.variant}`:""}}}],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":"")}}};function R(t,e,i,s,a,r){return n.openBlock(),n.createBlock(n.resolveDynamicComponent(r.component),n.mergeProps(t.$attrs,{disabled:i.disabled,class:r.classes,role:"button"}),{default:n.withCtx(()=>[n.renderSlot(t.$slots,"default",{},()=>[n.createTextVNode(n.toDisplayString(i.label),1)])]),_:3},16,["disabled","class"])}const T=f(N,[["render",R]]),st="",O=function(t){const e=parseFloat(t||0,10),i=t&&t.match(/m?s/),s=i?i[0]:!1;let a;switch(s){case"s":a=e*1e3;break;case"ms":default:a=e;break}return a||0},x=function(t,e){const i=(t.ownerDocument||document).defaultView;setTimeout(()=>{e.apply()},O(i.getComputedStyle(t).animationDuration))},V={name:"BtnActivity",components:{ActivityIndicator:D,Btn:T},props:{active:Boolean,activity:Boolean,block:Boolean,disabled:Boolean,indicator:{type:[Object,String],default:"spinner"},label:String,orientation:{type:String,default:"right"},size:{type:String,default:"md"},tag:String,variant:{type:String,default:"primary"}},data(){return{currentActivity:this.activity}},computed:{classes(){const t={disabled:this.disabled,active:this.active,"btn-activity":this.activity};return t["btn-activity-"+this.orientation.replace("btn-activity-","")]=!!this.orientation,t["btn-activity-indicator-"+this.indicatorProps.type.replace("btn-activity-indicator-","")]=!!this.indicatorProps.type,t},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"),x(this.$el,()=>{this.enable(),this.currentActivity=!1,this.$el.classList.remove("btn-activity","btn-hide-activity"),this.$emit("hide-activity")})},showActivity(){this.currentActivity=!0,this.disable(),x(this.$el,()=>{this.$el.classList.add("btn-activity"),this.$emit("show-activity")})},toggle(){this.currentActivity?this.hideActivity():this.showActivity()}}};function j(t,e,i,s,a,r){const h=n.resolveComponent("activity-indicator"),m=n.resolveComponent("btn");return n.openBlock(),n.createBlock(m,{active:i.active,block:i.block,disabled:i.disabled,size:i.size,tag:i.tag,variant:i.variant,class:n.normalizeClass(r.classes),onClick:e[0]||(e[0]=_=>!i.disabled&&t.$emit("click",_,this))},{default:n.withCtx(()=>[n.renderSlot(t.$slots,"default",{},()=>[n.createTextVNode(n.toDisplayString(i.label),1)]),n.createVNode(h,n.normalizeProps(n.guardReactiveProps(r.indicatorProps)),null,16)]),_:3},8,["active","block","disabled","size","tag","variant","class"])}const L=f(V,[["render",j]]);o.BtnActivity=L,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
package/src/BtnActivity.vue
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<btn
|
|
3
|
+
:active="active"
|
|
4
|
+
:block="block"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
:size="size"
|
|
7
|
+
:tag="tag"
|
|
8
|
+
:variant="variant"
|
|
9
|
+
:class="classes"
|
|
10
|
+
@click="(e) => !disabled && $emit('click', e, this)">
|
|
11
|
+
<slot>{{ label }}</slot>
|
|
5
12
|
<activity-indicator v-bind="indicatorProps" />
|
|
6
|
-
</
|
|
13
|
+
</btn>
|
|
7
14
|
</template>
|
|
8
15
|
|
|
9
16
|
<script>
|
|
10
17
|
import { ActivityIndicator } from '@vue-interface/activity-indicator';
|
|
18
|
+
import { Btn } from '@vue-interface/btn';
|
|
11
19
|
|
|
12
20
|
const convertAnimationDelayToInt = function(delay) {
|
|
13
21
|
const num = parseFloat(delay || 0, 10);
|
|
@@ -40,9 +48,10 @@ const animated = function(el, callback) {
|
|
|
40
48
|
export default {
|
|
41
49
|
|
|
42
50
|
name: 'BtnActivity',
|
|
43
|
-
|
|
51
|
+
|
|
44
52
|
components: {
|
|
45
|
-
ActivityIndicator
|
|
53
|
+
ActivityIndicator,
|
|
54
|
+
Btn
|
|
46
55
|
},
|
|
47
56
|
|
|
48
57
|
props: {
|
|
@@ -69,33 +78,38 @@ export default {
|
|
|
69
78
|
block: Boolean,
|
|
70
79
|
|
|
71
80
|
/**
|
|
72
|
-
*
|
|
81
|
+
* Disable the button.
|
|
73
82
|
*
|
|
74
83
|
* @property {Boolean}
|
|
75
84
|
*/
|
|
76
85
|
disabled: Boolean,
|
|
77
86
|
|
|
78
87
|
/**
|
|
79
|
-
* The
|
|
80
|
-
* inside the element's html.
|
|
88
|
+
* The type of activity indicator inside the button.
|
|
81
89
|
*
|
|
82
90
|
* @property {String}
|
|
83
91
|
*/
|
|
84
|
-
|
|
92
|
+
indicator: {
|
|
93
|
+
type: [Object, String],
|
|
94
|
+
default: 'spinner'
|
|
95
|
+
},
|
|
85
96
|
|
|
86
97
|
/**
|
|
87
|
-
* The button
|
|
98
|
+
* The button label.
|
|
88
99
|
*
|
|
89
100
|
* @property {String}
|
|
90
101
|
*/
|
|
91
|
-
|
|
102
|
+
label: String,
|
|
92
103
|
|
|
93
104
|
/**
|
|
94
|
-
* The
|
|
105
|
+
* The orientation of the activity button inside the button.
|
|
95
106
|
*
|
|
96
107
|
* @property {String}
|
|
97
108
|
*/
|
|
98
|
-
|
|
109
|
+
orientation: {
|
|
110
|
+
type: String,
|
|
111
|
+
default: 'right'
|
|
112
|
+
},
|
|
99
113
|
|
|
100
114
|
/**
|
|
101
115
|
* The size of the button.
|
|
@@ -108,35 +122,28 @@ export default {
|
|
|
108
122
|
},
|
|
109
123
|
|
|
110
124
|
/**
|
|
111
|
-
* The
|
|
112
|
-
*
|
|
113
|
-
* @property {String}
|
|
114
|
-
*/
|
|
115
|
-
variant: {
|
|
116
|
-
type: String,
|
|
117
|
-
default: 'primary'
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The type of activity indicator inside the button.
|
|
125
|
+
* The HTML tag.
|
|
122
126
|
*
|
|
123
127
|
* @property {String}
|
|
124
128
|
*/
|
|
125
|
-
|
|
126
|
-
type: [Object, String],
|
|
127
|
-
default: 'spinner'
|
|
128
|
-
},
|
|
129
|
+
tag: String,
|
|
129
130
|
|
|
130
131
|
/**
|
|
131
|
-
* The
|
|
132
|
+
* The variant of the button.
|
|
132
133
|
*
|
|
133
134
|
* @property {String}
|
|
134
135
|
*/
|
|
135
|
-
|
|
136
|
+
variant: {
|
|
136
137
|
type: String,
|
|
137
|
-
default: '
|
|
138
|
+
default: 'primary'
|
|
138
139
|
}
|
|
139
140
|
},
|
|
141
|
+
|
|
142
|
+
data() {
|
|
143
|
+
return {
|
|
144
|
+
currentActivity: this.activity
|
|
145
|
+
};
|
|
146
|
+
},
|
|
140
147
|
|
|
141
148
|
computed: {
|
|
142
149
|
|
|
@@ -149,12 +156,9 @@ export default {
|
|
|
149
156
|
const classes = {
|
|
150
157
|
'disabled': this.disabled,
|
|
151
158
|
'active': this.active,
|
|
152
|
-
'btn-block': this.block,
|
|
153
159
|
'btn-activity': this.activity
|
|
154
160
|
};
|
|
155
161
|
|
|
156
|
-
classes['btn-' + this.size.replace('btn-', '')] = !!this.size;
|
|
157
|
-
classes['btn-' + this.variant.replace('btn-', '')] = !!this.variant;
|
|
158
162
|
classes['btn-activity-' + this.orientation.replace('btn-activity-', '')] = !!this.orientation;
|
|
159
163
|
classes['btn-activity-indicator-' + this.indicatorProps.type.replace('btn-activity-indicator-', '')] = !!this.indicatorProps.type;
|
|
160
164
|
|
|
@@ -184,6 +188,12 @@ export default {
|
|
|
184
188
|
|
|
185
189
|
},
|
|
186
190
|
|
|
191
|
+
mounted() {
|
|
192
|
+
if(this.activity) {
|
|
193
|
+
this.showActivity();
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
187
197
|
methods: {
|
|
188
198
|
|
|
189
199
|
/**
|
|
@@ -193,6 +203,7 @@ export default {
|
|
|
193
203
|
*/
|
|
194
204
|
disable() {
|
|
195
205
|
this.$el.disabled = true;
|
|
206
|
+
this.$el.classList.add('disabled');
|
|
196
207
|
},
|
|
197
208
|
|
|
198
209
|
/**
|
|
@@ -202,48 +213,51 @@ export default {
|
|
|
202
213
|
*/
|
|
203
214
|
enable() {
|
|
204
215
|
this.$el.disabled = false;
|
|
216
|
+
this.$el.classList.remove('disabled');
|
|
205
217
|
},
|
|
206
218
|
|
|
207
219
|
/**
|
|
208
|
-
*
|
|
220
|
+
* Hide the activity indicator inside the button.
|
|
209
221
|
*
|
|
210
222
|
* @return void
|
|
211
223
|
*/
|
|
212
|
-
|
|
213
|
-
this.
|
|
224
|
+
hideActivity() {
|
|
225
|
+
this.$el.classList.add('btn-hide-activity');
|
|
214
226
|
|
|
215
227
|
animated(this.$el, () => {
|
|
216
|
-
this
|
|
217
|
-
this
|
|
228
|
+
this.enable();
|
|
229
|
+
this.currentActivity = false;
|
|
230
|
+
this.$el.classList.remove('btn-activity', 'btn-hide-activity');
|
|
231
|
+
this.$emit('hide-activity');
|
|
218
232
|
});
|
|
219
233
|
},
|
|
220
234
|
|
|
221
235
|
/**
|
|
222
|
-
*
|
|
236
|
+
* Show the activity indicator inside the button.
|
|
223
237
|
*
|
|
224
238
|
* @return void
|
|
225
239
|
*/
|
|
226
|
-
|
|
227
|
-
this
|
|
240
|
+
showActivity() {
|
|
241
|
+
this.currentActivity = true;
|
|
242
|
+
this.disable();
|
|
228
243
|
|
|
229
244
|
animated(this.$el, () => {
|
|
230
|
-
this.
|
|
231
|
-
this.$
|
|
232
|
-
this.$emit('hide-activity');
|
|
245
|
+
this.$el.classList.add('btn-activity');
|
|
246
|
+
this.$emit('show-activity');
|
|
233
247
|
});
|
|
234
248
|
},
|
|
235
249
|
|
|
236
250
|
/**
|
|
237
|
-
*
|
|
251
|
+
* Show the activity indicator inside the button.
|
|
238
252
|
*
|
|
239
253
|
* @return void
|
|
240
254
|
*/
|
|
241
|
-
|
|
242
|
-
if(!this.
|
|
243
|
-
this
|
|
255
|
+
toggle() {
|
|
256
|
+
if(!this.currentActivity) {
|
|
257
|
+
this.showActivity();
|
|
244
258
|
}
|
|
245
259
|
else {
|
|
246
|
-
|
|
260
|
+
this.hideActivity();
|
|
247
261
|
}
|
|
248
262
|
}
|
|
249
263
|
|