@vue-interface/btn-activity 2.0.0-beta.3 → 2.0.0-beta.4
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 +64 -37
- package/dist/btn-activity.umd.js +1 -1
- package/package.json +2 -3
- package/src/BtnActivity.vue +0 -354
package/dist/btn-activity.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
function
|
|
1
|
+
import { inject as P, openBlock as c, createElementBlock as h, normalizeClass as m, normalizeStyle as S, createElementVNode as z, createBlock as o, resolveDynamicComponent as y, createCommentVNode as d, toDisplayString as l, mergeProps as _, withCtx as b, renderSlot as f, createTextVNode as p, resolveComponent as u, createVNode as $, normalizeProps as C, guardReactiveProps as B } from "vue";
|
|
2
|
+
function r(t, e = "px") {
|
|
3
3
|
return t != null && t !== !1 && isFinite(t) ? `${t}${e}` : t;
|
|
4
4
|
}
|
|
5
|
-
const
|
|
5
|
+
const w = {
|
|
6
6
|
props: {
|
|
7
7
|
absolute: Boolean,
|
|
8
8
|
center: Boolean,
|
|
@@ -31,7 +31,7 @@ const P = {
|
|
|
31
31
|
}),
|
|
32
32
|
setup(t) {
|
|
33
33
|
return {
|
|
34
|
-
registryInstance:
|
|
34
|
+
registryInstance: P(t.registry || "indicators")
|
|
35
35
|
};
|
|
36
36
|
},
|
|
37
37
|
computed: {
|
|
@@ -44,12 +44,12 @@ const P = {
|
|
|
44
44
|
},
|
|
45
45
|
style() {
|
|
46
46
|
return {
|
|
47
|
-
width:
|
|
48
|
-
maxWidth:
|
|
49
|
-
minWidth:
|
|
50
|
-
height:
|
|
51
|
-
maxHeight:
|
|
52
|
-
minHeight:
|
|
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
53
|
};
|
|
54
54
|
}
|
|
55
55
|
},
|
|
@@ -63,27 +63,27 @@ const P = {
|
|
|
63
63
|
return t instanceof Promise ? t : (typeof t == "function" && (t = await t()), t.default ? t.default : t);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
},
|
|
66
|
+
}, A = (t, e) => {
|
|
67
67
|
const i = t.__vccOpts || t;
|
|
68
68
|
for (const [a, s] of e)
|
|
69
69
|
i[a] = s;
|
|
70
70
|
return i;
|
|
71
|
-
},
|
|
71
|
+
}, k = {
|
|
72
72
|
class: "activity-indicator-content"
|
|
73
|
-
},
|
|
73
|
+
}, N = {
|
|
74
74
|
key: 1,
|
|
75
75
|
class: "activity-indicator-label"
|
|
76
76
|
};
|
|
77
|
-
function
|
|
78
|
-
return
|
|
79
|
-
class:
|
|
80
|
-
style:
|
|
81
|
-
}, [
|
|
77
|
+
function H(t, e, i, a, s, n) {
|
|
78
|
+
return c(), h("div", {
|
|
79
|
+
class: m(["activity-indicator", n.classes]),
|
|
80
|
+
style: S(n.style)
|
|
81
|
+
}, [z("div", k, [t.is ? (c(), o(y(t.is()), {
|
|
82
82
|
key: 0,
|
|
83
83
|
class: "mx-auto"
|
|
84
|
-
})) :
|
|
84
|
+
})) : d("", !0), i.label ? (c(), h("div", N, l(i.label), 1)) : d("", !0)])], 6);
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const O = /* @__PURE__ */ A(w, [["render", H]]), V = {
|
|
87
87
|
props: {
|
|
88
88
|
componentPrefix: String,
|
|
89
89
|
size: String,
|
|
@@ -100,7 +100,7 @@ const w = /* @__PURE__ */ $(P, [["render", C]]), A = {
|
|
|
100
100
|
return this.size ? !this.sizeableClassPrefix || this.hasSizeablePrefix ? this.size : `${this.sizeableClassPrefix}-${this.size}` : "";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, W = {
|
|
104
104
|
props: {
|
|
105
105
|
componentPrefix: String,
|
|
106
106
|
variant: String,
|
|
@@ -117,9 +117,9 @@ const w = /* @__PURE__ */ $(P, [["render", C]]), A = {
|
|
|
117
117
|
return this.variant ? !this.variantClassPrefix || this.hasVariantPrefix ? this.variant : `${this.variantClassPrefix}-${this.variant}` : "";
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
},
|
|
120
|
+
}, D = {
|
|
121
121
|
name: "Btn",
|
|
122
|
-
mixins: [
|
|
122
|
+
mixins: [V, W],
|
|
123
123
|
props: {
|
|
124
124
|
active: Boolean,
|
|
125
125
|
block: Boolean,
|
|
@@ -147,23 +147,23 @@ const w = /* @__PURE__ */ $(P, [["render", C]]), A = {
|
|
|
147
147
|
return (this.variantPrefix || this.componentPrefix) + (this.outline ? "-outline" : "");
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
},
|
|
150
|
+
}, E = (t, e) => {
|
|
151
151
|
const i = t.__vccOpts || t;
|
|
152
152
|
for (const [a, s] of e)
|
|
153
153
|
i[a] = s;
|
|
154
154
|
return i;
|
|
155
155
|
};
|
|
156
|
-
function
|
|
157
|
-
return
|
|
156
|
+
function L(t, e, i, a, s, n) {
|
|
157
|
+
return c(), o(y(n.component), _(t.$attrs, {
|
|
158
158
|
disabled: i.disabled,
|
|
159
|
-
class:
|
|
159
|
+
class: n.classes,
|
|
160
160
|
role: "button"
|
|
161
161
|
}), {
|
|
162
|
-
default:
|
|
162
|
+
default: b(() => [f(t.$slots, "default", {}, () => [p(l(i.label), 1)])]),
|
|
163
163
|
_: 3
|
|
164
164
|
}, 16, ["disabled", "class"]);
|
|
165
165
|
}
|
|
166
|
-
const
|
|
166
|
+
const j = /* @__PURE__ */ E(D, [["render", L]]), I = function(t) {
|
|
167
167
|
const e = parseFloat(t || 0), i = t && t.match(/m?s/), a = i ? i[0] : !1;
|
|
168
168
|
let s;
|
|
169
169
|
switch (a) {
|
|
@@ -176,17 +176,17 @@ const W = /* @__PURE__ */ N(k, [["render", H]]), D = function(t) {
|
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
178
|
return s || 0;
|
|
179
|
-
},
|
|
179
|
+
}, v = function(t, e) {
|
|
180
180
|
const i = (t.ownerDocument || document).defaultView;
|
|
181
181
|
setTimeout(
|
|
182
182
|
e,
|
|
183
|
-
|
|
183
|
+
I(i == null ? void 0 : i.getComputedStyle(t).animationDuration)
|
|
184
184
|
);
|
|
185
|
-
},
|
|
185
|
+
}, R = {
|
|
186
186
|
name: "BtnActivity",
|
|
187
187
|
components: {
|
|
188
|
-
ActivityIndicator:
|
|
189
|
-
Btn:
|
|
188
|
+
ActivityIndicator: O,
|
|
189
|
+
Btn: j
|
|
190
190
|
},
|
|
191
191
|
props: {
|
|
192
192
|
active: Boolean,
|
|
@@ -257,12 +257,12 @@ const W = /* @__PURE__ */ N(k, [["render", H]]), D = function(t) {
|
|
|
257
257
|
this.$el.disabled = !1, this.$el.classList.remove("disabled");
|
|
258
258
|
},
|
|
259
259
|
hideActivity() {
|
|
260
|
-
this.$el.classList.add("btn-hide-activity"),
|
|
260
|
+
this.$el.classList.add("btn-hide-activity"), v(this.$el, () => {
|
|
261
261
|
this.enable(), this.currentActivity = !1, this.$el.classList.remove("btn-activity", "btn-hide-activity"), this.$emit("hide-activity");
|
|
262
262
|
});
|
|
263
263
|
},
|
|
264
264
|
showActivity() {
|
|
265
|
-
this.currentActivity = !0, this.disable(),
|
|
265
|
+
this.currentActivity = !0, this.disable(), v(this.$el, () => {
|
|
266
266
|
this.$el.classList.add("btn-activity"), this.$emit("show-activity");
|
|
267
267
|
});
|
|
268
268
|
},
|
|
@@ -271,6 +271,33 @@ const W = /* @__PURE__ */ N(k, [["render", H]]), D = function(t) {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
|
+
const T = (t, e) => {
|
|
275
|
+
const i = t.__vccOpts || t;
|
|
276
|
+
for (const [a, s] of e)
|
|
277
|
+
i[a] = s;
|
|
278
|
+
return i;
|
|
279
|
+
};
|
|
280
|
+
function F(t, e, i, a, s, n) {
|
|
281
|
+
const g = u("activity-indicator"), x = u("btn");
|
|
282
|
+
return c(), o(x, {
|
|
283
|
+
active: i.active,
|
|
284
|
+
block: i.block,
|
|
285
|
+
disabled: i.disabled,
|
|
286
|
+
size: i.size,
|
|
287
|
+
tag: i.tag,
|
|
288
|
+
variant: i.variant,
|
|
289
|
+
class: m(n.classes)
|
|
290
|
+
}, {
|
|
291
|
+
default: b(() => [
|
|
292
|
+
f(t.$slots, "default", {}, () => [
|
|
293
|
+
p(l(i.label), 1)
|
|
294
|
+
]),
|
|
295
|
+
$(g, C(B(n.indicatorProps)), null, 16)
|
|
296
|
+
]),
|
|
297
|
+
_: 3
|
|
298
|
+
}, 8, ["active", "block", "disabled", "size", "tag", "variant", "class"]);
|
|
299
|
+
}
|
|
300
|
+
const G = /* @__PURE__ */ T(R, [["render", F]]);
|
|
274
301
|
export {
|
|
275
|
-
|
|
302
|
+
G as BtnActivity
|
|
276
303
|
};
|
package/dist/btn-activity.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(o=typeof globalThis<"u"?globalThis:o||self,i(o.BtnActivity={},o.Vue))})(this,function(o,i){"use strict";function c(t,s="px"){return t!=null&&t!==!1&&isFinite(t)?`${t}${s}`:t}const d={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:i.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: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=this.registryInstance.get(this.type);return t instanceof Promise?t:(typeof t=="function"&&(t=await t()),t.default?t.default:t)}}},h=(t,s)=>{const e=t.__vccOpts||t;for(const[a,n]of s)e[a]=n;return e},m={class:"activity-indicator-content"},y={key:1,class:"activity-indicator-label"};function f(t,s,e,a,n,r){return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["activity-indicator",r.classes]),style:i.normalizeStyle(r.style)},[i.createElementVNode("div",m,[t.is?(i.openBlock(),i.createBlock(i.resolveDynamicComponent(t.is()),{key:0,class:"mx-auto"})):i.createCommentVNode("",!0),e.label?(i.openBlock(),i.createElementBlock("div",y,i.toDisplayString(e.label),1)):i.createCommentVNode("",!0)])],6)}const p=h(d,[["render",f]]),b={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}`:""}}},u={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}`:""}}},g={name:"Btn",mixins:[b,u],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":"")}}},v=(t,s)=>{const e=t.__vccOpts||t;for(const[a,n]of s)e[a]=n;return e};function x(t,s,e,a,n,r){return i.openBlock(),i.createBlock(i.resolveDynamicComponent(r.component),i.mergeProps(t.$attrs,{disabled:e.disabled,class:r.classes,role:"button"}),{default:i.withCtx(()=>[i.renderSlot(t.$slots,"default",{},()=>[i.createTextVNode(i.toDisplayString(e.label),1)])]),_:3},16,["disabled","class"])}const S=v(g,[["render",x]]),P=function(t){const s=parseFloat(t||0),e=t&&t.match(/m?s/),a=e?e[0]:!1;let n;switch(a){case"s":n=s*1e3;break;case"ms":default:n=s;break}return n||0},l=function(t,s){const e=(t.ownerDocument||document).defaultView;setTimeout(s,P(e==null?void 0:e.getComputedStyle(t).animationDuration))},z={name:"BtnActivity",components:{ActivityIndicator:p,Btn:S},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(){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"),l(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(),l(this.$el,()=>{this.$el.classList.add("btn-activity"),this.$emit("show-activity")})},toggle(){this.currentActivity?this.hideActivity():this.showActivity()}}},A="",_=(t,s)=>{const e=t.__vccOpts||t;for(const[a,n]of s)e[a]=n;return e};function B(t,s,e,a,n,r){const k=i.resolveComponent("activity-indicator"),$=i.resolveComponent("btn");return i.openBlock(),i.createBlock($,{active:e.active,block:e.block,disabled:e.disabled,size:e.size,tag:e.tag,variant:e.variant,class:i.normalizeClass(r.classes)},{default:i.withCtx(()=>[i.renderSlot(t.$slots,"default",{},()=>[i.createTextVNode(i.toDisplayString(e.label),1)]),i.createVNode(k,i.normalizeProps(i.guardReactiveProps(r.indicatorProps)),null,16)]),_:3},8,["active","block","disabled","size","tag","variant","class"])}const C=_(z,[["render",B]]);o.BtnActivity=C,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-interface/btn-activity",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "A Vue activity button component.",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.js",
|
|
7
|
-
"dist"
|
|
8
|
-
"src"
|
|
7
|
+
"dist"
|
|
9
8
|
],
|
|
10
9
|
"main": "./dist/btn-activity.umd.js",
|
|
11
10
|
"module": "./dist/btn-activity.es.js",
|
package/src/BtnActivity.vue
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { ActivityIndicator } from "@vue-interface/activity-indicator";
|
|
3
|
-
import { Btn } from "@vue-interface/btn";
|
|
4
|
-
|
|
5
|
-
const convertAnimationDelayToInt = function (delay: any) {
|
|
6
|
-
const num = parseFloat(delay || 0);
|
|
7
|
-
const matches = delay && delay.match(/m?s/);
|
|
8
|
-
const unit = matches ? matches[0] : false;
|
|
9
|
-
|
|
10
|
-
let milliseconds;
|
|
11
|
-
|
|
12
|
-
switch (unit) {
|
|
13
|
-
case "s": // seconds
|
|
14
|
-
milliseconds = num * 1000;
|
|
15
|
-
break;
|
|
16
|
-
case "ms":
|
|
17
|
-
default:
|
|
18
|
-
milliseconds = num;
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return milliseconds || 0;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const animated = function (el: HTMLElement, callback: Function) {
|
|
26
|
-
const defaultView = (el.ownerDocument || document).defaultView;
|
|
27
|
-
|
|
28
|
-
setTimeout(
|
|
29
|
-
callback,
|
|
30
|
-
convertAnimationDelayToInt(defaultView?.getComputedStyle(el).animationDuration)
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default {
|
|
35
|
-
name: "BtnActivity",
|
|
36
|
-
|
|
37
|
-
components: {
|
|
38
|
-
ActivityIndicator,
|
|
39
|
-
Btn,
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
props: {
|
|
43
|
-
/**
|
|
44
|
-
* Make the button appear with the active state.
|
|
45
|
-
*
|
|
46
|
-
* @property {Boolean}
|
|
47
|
-
*/
|
|
48
|
-
active: Boolean,
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Show the activity indicator inside the button.
|
|
52
|
-
*
|
|
53
|
-
* @property {Boolean}
|
|
54
|
-
*/
|
|
55
|
-
activity: Boolean,
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Display the button as block width.
|
|
59
|
-
*
|
|
60
|
-
* @property {Boolean}
|
|
61
|
-
*/
|
|
62
|
-
block: Boolean,
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Disable the button.
|
|
66
|
-
*
|
|
67
|
-
* @property {Boolean}
|
|
68
|
-
*/
|
|
69
|
-
disabled: Boolean,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The type of activity indicator inside the button.
|
|
73
|
-
*
|
|
74
|
-
* @property {String}
|
|
75
|
-
*/
|
|
76
|
-
indicator: {
|
|
77
|
-
type: [Object, String],
|
|
78
|
-
default: "spinner",
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The button label.
|
|
83
|
-
*
|
|
84
|
-
* @property {String}
|
|
85
|
-
*/
|
|
86
|
-
label: String,
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The orientation of the activity button inside the button.
|
|
90
|
-
*
|
|
91
|
-
* @property {String}
|
|
92
|
-
*/
|
|
93
|
-
orientation: {
|
|
94
|
-
type: String,
|
|
95
|
-
default: "right",
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* The size of the button.
|
|
100
|
-
*
|
|
101
|
-
* @property {String}
|
|
102
|
-
*/
|
|
103
|
-
size: {
|
|
104
|
-
type: String,
|
|
105
|
-
default: "md",
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* The HTML tag.
|
|
110
|
-
*
|
|
111
|
-
* @property {String}
|
|
112
|
-
*/
|
|
113
|
-
tag: String,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The variant of the button.
|
|
117
|
-
*
|
|
118
|
-
* @property {String}
|
|
119
|
-
*/
|
|
120
|
-
variant: {
|
|
121
|
-
type: String,
|
|
122
|
-
default: "primary",
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
data() {
|
|
127
|
-
return {
|
|
128
|
-
currentActivity: this.activity,
|
|
129
|
-
};
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
computed: {
|
|
133
|
-
/**
|
|
134
|
-
* An object of classes to append to the button.
|
|
135
|
-
*
|
|
136
|
-
* @return void
|
|
137
|
-
*/
|
|
138
|
-
classes() {
|
|
139
|
-
return {
|
|
140
|
-
disabled: this.disabled,
|
|
141
|
-
active: this.active,
|
|
142
|
-
"btn-activity": this.activity,
|
|
143
|
-
[`btn-activity-${this.orientation.replace("btn-activity-", "")}`]: !!this
|
|
144
|
-
.orientation,
|
|
145
|
-
[`'btn-activity-indicator-${this.indicatorProps.type.replace(
|
|
146
|
-
"btn-activity-indicator-",
|
|
147
|
-
""
|
|
148
|
-
)}`]: !!this.indicatorProps.type,
|
|
149
|
-
};
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
indicatorProps() {
|
|
153
|
-
return Object.assign(
|
|
154
|
-
{
|
|
155
|
-
type: "spinner",
|
|
156
|
-
},
|
|
157
|
-
(typeof this.indicator === "string"
|
|
158
|
-
? {
|
|
159
|
-
type: this.indicator,
|
|
160
|
-
}
|
|
161
|
-
: this.indicator) || {}
|
|
162
|
-
);
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
watch: {
|
|
167
|
-
activity(value: boolean) {
|
|
168
|
-
if (value) {
|
|
169
|
-
this.showActivity();
|
|
170
|
-
} else {
|
|
171
|
-
this.hideActivity();
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
mounted() {
|
|
177
|
-
if (this.activity) {
|
|
178
|
-
this.showActivity();
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
methods: {
|
|
183
|
-
/**
|
|
184
|
-
* Disable the button.
|
|
185
|
-
*
|
|
186
|
-
* @return void
|
|
187
|
-
*/
|
|
188
|
-
disable() {
|
|
189
|
-
this.$el.disabled = true;
|
|
190
|
-
this.$el.classList.add("disabled");
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Enable the button.
|
|
195
|
-
*
|
|
196
|
-
* @return void
|
|
197
|
-
*/
|
|
198
|
-
enable() {
|
|
199
|
-
this.$el.disabled = false;
|
|
200
|
-
this.$el.classList.remove("disabled");
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Hide the activity indicator inside the button.
|
|
205
|
-
*
|
|
206
|
-
* @return void
|
|
207
|
-
*/
|
|
208
|
-
hideActivity() {
|
|
209
|
-
this.$el.classList.add("btn-hide-activity");
|
|
210
|
-
|
|
211
|
-
animated(this.$el, () => {
|
|
212
|
-
this.enable();
|
|
213
|
-
this.currentActivity = false;
|
|
214
|
-
this.$el.classList.remove("btn-activity", "btn-hide-activity");
|
|
215
|
-
this.$emit("hide-activity");
|
|
216
|
-
});
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Show the activity indicator inside the button.
|
|
221
|
-
*
|
|
222
|
-
* @return void
|
|
223
|
-
*/
|
|
224
|
-
showActivity() {
|
|
225
|
-
this.currentActivity = true;
|
|
226
|
-
this.disable();
|
|
227
|
-
|
|
228
|
-
animated(this.$el, () => {
|
|
229
|
-
this.$el.classList.add("btn-activity");
|
|
230
|
-
this.$emit("show-activity");
|
|
231
|
-
});
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Show the activity indicator inside the button.
|
|
236
|
-
*
|
|
237
|
-
* @return void
|
|
238
|
-
*/
|
|
239
|
-
toggle() {
|
|
240
|
-
if (!this.currentActivity) {
|
|
241
|
-
this.showActivity();
|
|
242
|
-
} else {
|
|
243
|
-
this.hideActivity();
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
</script>
|
|
249
|
-
|
|
250
|
-
<style>
|
|
251
|
-
@keyframes btn-activity-in {
|
|
252
|
-
0%,
|
|
253
|
-
100% {
|
|
254
|
-
transform: scale(1);
|
|
255
|
-
}
|
|
256
|
-
30% {
|
|
257
|
-
transform: scale(0.98);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
@keyframes btn-activity-out {
|
|
262
|
-
0%,
|
|
263
|
-
100% {
|
|
264
|
-
transform: scale(1);
|
|
265
|
-
}
|
|
266
|
-
70% {
|
|
267
|
-
transform: scale(0.98);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.btn-activity-top,
|
|
272
|
-
.btn.btn-activity-top,
|
|
273
|
-
.btn-activity-bottom,
|
|
274
|
-
.btn.btn-activity-bottom,
|
|
275
|
-
.btn-activity-left,
|
|
276
|
-
.btn.btn-activity-left,
|
|
277
|
-
.btn-activity-right,
|
|
278
|
-
.btn.btn-activity-right {
|
|
279
|
-
display: inline-flex;
|
|
280
|
-
position: relative;
|
|
281
|
-
transition: all calc(333ms / 2) ease-in;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
.btn-activity-top .activity-indicator,
|
|
285
|
-
.btn-activity-bottom .activity-indicator,
|
|
286
|
-
.btn-activity-left .activity-indicator,
|
|
287
|
-
.btn-activity-right .activity-indicator {
|
|
288
|
-
opacity: 0;
|
|
289
|
-
position: absolute;
|
|
290
|
-
visibility: hidden;
|
|
291
|
-
transition: opacity 333ms ease-in;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.btn-activity-top,
|
|
295
|
-
.btn-activity-bottom {
|
|
296
|
-
flex-direction: column;
|
|
297
|
-
align-items: center;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
.btn-activity-top .activity-indicator,
|
|
301
|
-
.btn-activity-bottom .activity-indicator {
|
|
302
|
-
margin-left: auto;
|
|
303
|
-
margin-right: auto;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
.btn-activity-top {
|
|
307
|
-
flex-direction: column-reverse;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.btn-activity-top .activity-indicator {
|
|
311
|
-
padding-bottom: 1em;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.btn-activity-bottom .activity-indicator {
|
|
315
|
-
padding-top: 1em;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.btn-activity-left,
|
|
319
|
-
.btn-activity-right {
|
|
320
|
-
align-items: center;
|
|
321
|
-
justify-content: center;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.btn-activity-left {
|
|
325
|
-
flex-direction: row-reverse;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.btn-activity-left .activity-indicator {
|
|
329
|
-
padding-right: 1em;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
.btn-activity-right .activity-indicator {
|
|
333
|
-
padding-left: 1em;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
.btn-activity:not(.btn-link) {
|
|
337
|
-
animation: btn-activity-in 333ms;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
.btn-hide-activity:not(.btn-link) {
|
|
341
|
-
animation: btn-activity-out 333ms;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
.btn-activity.btn-hide-activity .activity-indicator {
|
|
345
|
-
opacity: 0;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
.btn-activity .activity-indicator {
|
|
349
|
-
opacity: 1;
|
|
350
|
-
visibility: visible;
|
|
351
|
-
position: relative;
|
|
352
|
-
font-size: 0.55em;
|
|
353
|
-
}
|
|
354
|
-
</style>
|