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