@vue-interface/btn-activity 2.0.0-beta.16 → 2.0.0-beta.17

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,186 +1,80 @@
1
- import { ActivityIndicator as d } from "@vue-interface/activity-indicator";
2
- import { Btn as h } from "@vue-interface/btn";
3
- import { defineComponent as v, resolveComponent as a, openBlock as y, createBlock as p, mergeProps as b, withCtx as u, renderSlot as m, createTextVNode as f, toDisplayString as g, createVNode as A, normalizeProps as $, guardReactiveProps as k } from "vue";
4
- const w = function(t) {
5
- const e = parseFloat(t || 0), i = t && t.match(/m?s/), o = i ? i[0] : !1;
6
- let s;
7
- switch (o) {
8
- case "s":
9
- s = e * 1e3;
10
- break;
11
- case "ms":
12
- default:
13
- s = e;
14
- break;
15
- }
16
- return s || 0;
17
- }, n = function(t, e) {
18
- const i = (t.ownerDocument || document).defaultView;
19
- setTimeout(
20
- e,
21
- w(
22
- i == null ? void 0 : i.getComputedStyle(t).animationDuration
23
- )
24
- );
25
- }, B = v({
26
- components: {
27
- ActivityIndicator: d,
28
- Btn: h
29
- },
30
- inheritAttrs: !1,
1
+ import { defineComponent as m, ref as u, watchEffect as v, watch as g, openBlock as n, createBlock as l, unref as r, mergeProps as B, withCtx as s, renderSlot as z, createTextVNode as b, toDisplayString as h, createVNode as k, Transition as S, normalizeClass as w, createCommentVNode as C } from "vue";
2
+ import { ActivityIndicator as A } from "@vue-interface/activity-indicator";
3
+ import { Btn as N } from "@vue-interface/btn";
4
+ const E = /* @__PURE__ */ m({
5
+ __name: "BtnActivity",
31
6
  props: {
32
- /**
33
- * Make the button appear with the active state.
34
- */
35
- active: Boolean,
36
- /**
37
- * Show the activity indicator inside the button.
38
- */
39
- activity: Boolean,
40
- /**
41
- * Display the button as block width.
42
- */
43
- block: Boolean,
44
- /**
45
- * Disable the button.
46
- */
47
- disabled: Boolean,
48
- /**
49
- * The type of activity indicator inside the button.
50
- */
51
- indicator: {
52
- type: Object,
53
- required: !0
54
- },
55
- /**
56
- * The button label.
57
- */
58
- label: {
59
- type: String,
60
- default: void 0
61
- },
62
- /**
63
- * The orientation of the activity button inside the button.
64
- */
65
- orientation: {
66
- type: String,
67
- default: "right"
68
- },
69
- /**
70
- * The HTML tag.
71
- */
72
- tag: {
73
- type: String,
74
- default: void 0
75
- }
7
+ activity: { type: Boolean },
8
+ indicator: {},
9
+ indicatorSize: {},
10
+ label: {},
11
+ orientation: { default: "right" },
12
+ active: { type: Boolean },
13
+ block: { type: Boolean },
14
+ disabled: { type: Boolean },
15
+ outline: { type: Boolean },
16
+ size: {},
17
+ tag: {},
18
+ variant: { default: "btn-primary" }
76
19
  },
77
20
  emits: ["click", "hide-activity", "show-activity"],
78
- data() {
79
- return {
80
- currentActivity: this.activity
81
- };
82
- },
83
- computed: {
84
- /**
85
- * An object of classes to append to the button.
86
- */
87
- classes() {
88
- return {
89
- "btn-activity": this.activity,
90
- [`btn-activity-${this.orientation.replace("btn-activity-", "")}`]: !!this.orientation,
91
- [`btn-activity-indicator-${this.indicatorProps.type.replace("btn-activity-indicator-", "")}`]: !!this.indicatorProps.type
92
- };
93
- },
94
- indicatorProps() {
95
- return Object.assign(
96
- {
97
- type: "spinner"
98
- },
99
- (typeof this.indicator == "string" ? {
100
- type: this.indicator
101
- } : this.indicator) || {}
102
- );
103
- }
104
- },
105
- watch: {
106
- activity(t) {
107
- t ? this.showActivity() : this.hideActivity();
108
- }
109
- },
110
- mounted() {
111
- this.activity && this.showActivity();
112
- },
113
- methods: {
114
- /**
115
- * Disable the button.
116
- */
117
- disable() {
118
- this.$el.disabled = !0, this.$el.classList.add("disabled");
119
- },
120
- /**
121
- * Enable the button.
122
- */
123
- enable() {
124
- this.$el.disabled = !1, this.$el.classList.remove("disabled");
125
- },
126
- /**
127
- * Hide the activity indicator inside the button.
128
- */
129
- hideActivity() {
130
- this.$el.classList.add("btn-hide-activity"), n(this.$el, () => {
131
- this.disabled || this.enable(), this.currentActivity = !1, this.$el.classList.remove("btn-activity", "btn-hide-activity"), this.$emit("hide-activity");
132
- });
133
- },
134
- /**
135
- * Show the activity indicator inside the button.
136
- */
137
- showActivity() {
138
- this.currentActivity = !0, this.disable(), n(this.$el, () => {
139
- this.$el.classList.add("btn-activity"), this.$emit("show-activity");
140
- });
141
- },
142
- /**
143
- * Show the activity indicator inside the button.
144
- */
145
- toggle() {
146
- this.currentActivity ? this.hideActivity() : this.showActivity();
21
+ setup(c, { emit: p }) {
22
+ const i = c, o = p, e = u(i.activity);
23
+ v(() => {
24
+ e.value = i.activity;
25
+ }), g(e, (t) => {
26
+ o(t ? "show-activity" : "hide-activity");
27
+ });
28
+ function d() {
29
+ e.value = !e.value;
147
30
  }
31
+ const f = {
32
+ status: e,
33
+ toggle: d
34
+ };
35
+ return (t, a) => (n(), l(r(N), B(i, {
36
+ class: {
37
+ "gap-1": !t.indicatorSize || ["xs", "sm"].includes(t.indicatorSize),
38
+ "gap-2": ["md", "lg", "xl"].includes(t.indicatorSize),
39
+ "flex-col flex-col-reverse": t.orientation === "top",
40
+ "flex-col": t.orientation === "bottom",
41
+ "flex-row-reverse": t.orientation === "left"
42
+ },
43
+ onClick: a[0] || (a[0] = (y) => o("click", y, f))
44
+ }), {
45
+ default: s(() => [
46
+ z(t.$slots, "default", {}, () => [
47
+ b(h(t.label), 1)
48
+ ]),
49
+ k(S, {
50
+ "enter-active-class": "transition-all ease-out duration-250",
51
+ "enter-from-class": "opacity-0",
52
+ "enter-to-class": "opacity-100",
53
+ "leave-active-class": "transition-all ease-in duration-250",
54
+ "leave-from-class": "opacity-100",
55
+ "leave-to-class": "opacity-0"
56
+ }, {
57
+ default: s(() => [
58
+ e.value ? (n(), l(r(A), {
59
+ key: 0,
60
+ type: t.indicator,
61
+ size: t.indicatorSize ?? "xs",
62
+ class: w({
63
+ "pt-1": t.orientation === "top",
64
+ "pb-1": t.orientation === "bottom",
65
+ "pr-1": t.orientation === "left",
66
+ "pl-1": t.orientation === "right"
67
+ })
68
+ }, null, 8, ["type", "size", "class"])) : C("", !0)
69
+ ]),
70
+ _: 1
71
+ })
72
+ ]),
73
+ _: 3
74
+ }, 16, ["class"]));
148
75
  }
149
76
  });
150
- const P = (t, e) => {
151
- const i = t.__vccOpts || t;
152
- for (const [o, s] of e)
153
- i[o] = s;
154
- return i;
155
- };
156
- function C(t, e, i, o, s, S) {
157
- const c = a("ActivityIndicator"), r = a("Btn");
158
- return y(), p(r, b({
159
- active: t.active,
160
- block: t.block,
161
- disabled: t.disabled,
162
- tag: t.tag,
163
- class: t.classes
164
- }, Object.assign({}, t.$attrs, { onClick: void 0 }), {
165
- onClick: e[0] || (e[0] = (l) => !t.disabled && t.$emit("click", l, {
166
- disable: t.disable,
167
- enable: t.enable,
168
- toggle: t.toggle,
169
- showActivity: t.showActivity,
170
- hideActivity: t.hideActivity
171
- }))
172
- }), {
173
- default: u(() => [
174
- m(t.$slots, "default", {}, () => [
175
- f(g(t.label), 1)
176
- ]),
177
- A(c, $(k(t.indicatorProps)), null, 16)
178
- ]),
179
- _: 3
180
- }, 16, ["active", "block", "disabled", "tag", "class"]);
181
- }
182
- const O = /* @__PURE__ */ P(B, [["render", C]]);
183
77
  export {
184
- O as BtnActivity
78
+ E as BtnActivity
185
79
  };
186
80
  //# sourceMappingURL=btn-activity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"btn-activity.js","sources":["../src/BtnActivity.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport { Btn } from '@vue-interface/btn';\nimport { defineComponent } from 'vue';\n\nconst convertAnimationDelayToInt = function (delay: any) {\n const num = parseFloat(delay || 0);\n const matches = delay && delay.match(/m?s/);\n const unit = matches ? matches[0] : false;\n\n let milliseconds;\n\n switch (unit) {\n case 's': // seconds\n milliseconds = num * 1000;\n break;\n case 'ms':\n default:\n milliseconds = num;\n break;\n }\n\n return milliseconds || 0;\n};\n\nconst animated = function (el: HTMLElement, callback: Function) {\n const defaultView = (el.ownerDocument || document).defaultView;\n\n setTimeout(\n callback,\n convertAnimationDelayToInt(\n defaultView?.getComputedStyle(el).animationDuration\n )\n );\n};\n\nexport default defineComponent({\n\n components: {\n ActivityIndicator,\n Btn,\n },\n\n inheritAttrs: false,\n\n props: {\n /**\n\t\t * Make the button appear with the active state.\n\t\t */\n active: Boolean,\n\n /**\n\t\t * Show the activity indicator inside the button.\n\t\t */\n activity: Boolean,\n\n /**\n\t\t * Display the button as block width.\n\t\t */\n block: Boolean,\n\n /**\n\t\t * Disable the button.\n\t\t */\n disabled: Boolean,\n\n /**\n\t\t * The type of activity indicator inside the button.\n\t\t */\n indicator: {\n type: Object,\n required: true\n },\n\n /**\n\t\t * The button label.\n\t\t */\n label: {\n type: String,\n default: undefined\n },\n\n /**\n\t\t * The orientation of the activity button inside the button.\n\t\t */\n orientation: {\n type: String,\n default: 'right',\n },\n\n /**\n\t\t * The HTML tag.\n\t\t */\n tag: {\n type: String,\n default: undefined\n },\n },\n\n emits: ['click', 'hide-activity', 'show-activity'],\n\n data() {\n return {\n currentActivity: this.activity,\n };\n },\n\n computed: {\n /**\n\t\t * An object of classes to append to the button.\n\t\t */\n classes() {\n return {\n 'btn-activity': this.activity,\n [`btn-activity-${this.orientation.replace('btn-activity-', '')}`]: !!this.orientation,\n [`btn-activity-indicator-${this.indicatorProps.type.replace('btn-activity-indicator-', '')}`]: !!this.indicatorProps.type,\n };\n },\n\n indicatorProps() {\n return Object.assign(\n {\n type: 'spinner',\n },\n (typeof this.indicator === 'string'\n ? {\n type: this.indicator,\n }\n : this.indicator) || {}\n );\n },\n },\n\n watch: {\n activity(value: boolean) {\n if(value) {\n this.showActivity();\n } else {\n this.hideActivity();\n }\n },\n },\n\n mounted() {\n if(this.activity) {\n this.showActivity();\n }\n },\n\n methods: {\n /**\n\t\t * Disable the button.\n\t\t */\n disable(): void {\n this.$el.disabled = true;\n this.$el.classList.add('disabled');\n },\n\n /**\n\t\t * Enable the button.\n\t\t */\n enable(): void {\n this.$el.disabled = false;\n this.$el.classList.remove('disabled');\n },\n\n /**\n\t\t * Hide the activity indicator inside the button.\n\t\t */\n hideActivity(): void {\n this.$el.classList.add('btn-hide-activity');\n\n animated(this.$el, () => {\n if(!this.disabled) {\n \tthis.enable();\n }\n\t\t\t\t\n this.currentActivity = false;\n this.$el.classList.remove('btn-activity', 'btn-hide-activity');\n this.$emit('hide-activity');\n });\n },\n\n /**\n\t\t * Show the activity indicator inside the button.\n\t\t */\n showActivity(): void {\n this.currentActivity = true;\n this.disable();\n\n animated(this.$el, () => {\n this.$el.classList.add('btn-activity');\n this.$emit('show-activity');\n });\n },\n\n /**\n\t\t * Show the activity indicator inside the button.\n\t\t */\n toggle(): void {\n if(!this.currentActivity) {\n this.showActivity();\n } else {\n this.hideActivity();\n }\n },\n },\n});\n</script>\n\n<template>\n <Btn\n :active=\"active\"\n :block=\"block\"\n :disabled=\"disabled\"\n :tag=\"tag\"\n :class=\"classes\"\n v-bind=\"Object.assign({}, $attrs, { onClick: undefined })\"\n @click=\"!disabled && $emit('click', $event, {\n disable,\n enable,\n toggle,\n showActivity,\n hideActivity,\n })\">\n <slot>{{ label }}</slot>\n <ActivityIndicator v-bind=\"indicatorProps\" />\n </Btn>\n</template>\n\n<style>\n@keyframes btn-activity-in {\n\n\t0%,\n\t100% {\n\t\ttransform: scale(1);\n\t}\n\n\t30% {\n\t\ttransform: scale(0.98);\n\t}\n}\n\n@keyframes btn-activity-out {\n\n\t0%,\n\t100% {\n\t\ttransform: scale(1);\n\t}\n\n\t70% {\n\t\ttransform: scale(0.98);\n\t}\n}\n\n.btn-activity-top,\n.btn.btn-activity-top,\n.btn-activity-bottom,\n.btn.btn-activity-bottom,\n.btn-activity-left,\n.btn.btn-activity-left,\n.btn-activity-right,\n.btn.btn-activity-right {\n\tdisplay: inline-flex;\n\tposition: relative;\n\ttransition: all calc(333ms / 2) ease-in;\n}\n\n.btn-activity-top .activity-indicator,\n.btn-activity-bottom .activity-indicator,\n.btn-activity-left .activity-indicator,\n.btn-activity-right .activity-indicator {\n\topacity: 0;\n\tposition: absolute;\n\tvisibility: hidden;\n\ttransition: opacity 333ms ease-in;\n}\n\n.btn-activity-top,\n.btn-activity-bottom {\n\tflex-direction: column;\n\talign-items: center;\n}\n\n.btn-activity-top .activity-indicator,\n.btn-activity-bottom .activity-indicator {\n\tmargin-left: auto;\n\tmargin-right: auto;\n}\n\n.btn-activity-top {\n\tflex-direction: column-reverse;\n}\n\n.btn-activity-top .activity-indicator {\n\tpadding-bottom: 1em;\n}\n\n.btn-activity-bottom .activity-indicator {\n\tpadding-top: 1em;\n}\n\n.btn-activity-left,\n.btn-activity-right {\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.btn-activity-left {\n\tflex-direction: row-reverse;\n}\n\n.btn-activity-left .activity-indicator {\n\tpadding-right: 1em;\n}\n\n.btn-activity-right .activity-indicator {\n\tpadding-left: 1em;\n}\n\n.btn-activity:not(.btn-link) {\n\tanimation: btn-activity-in 333ms;\n}\n\n.btn-hide-activity:not(.btn-link) {\n\tanimation: btn-activity-out 333ms;\n}\n\n.btn-activity.btn-hide-activity .activity-indicator {\n\topacity: 0;\n}\n\n.btn-activity .activity-indicator {\n\topacity: 1;\n\tvisibility: visible;\n\tposition: relative;\n\tfont-size: 0.55em;\n}\n</style>\n"],"names":["convertAnimationDelayToInt","delay","num","matches","unit","milliseconds","animated","el","callback","defaultView","_sfc_main","defineComponent","ActivityIndicator","Btn","value","_resolveComponent","_openBlock","_createBlock","_component_Btn","_mergeProps","_ctx","_cache","$event","_withCtx","_createTextVNode","_toDisplayString"],"mappings":";;;AAKA,MAAMA,IAA6B,SAAUC,GAAY;AAC/C,QAAAC,IAAM,WAAWD,KAAS,CAAC,GAC3BE,IAAUF,KAASA,EAAM,MAAM,KAAK,GACpCG,IAAOD,IAAUA,EAAQ,CAAC,IAAI;AAEhC,MAAAE;AAEJ,UAAQD,GAAM;AAAA,IACd,KAAK;AACD,MAAAC,IAAeH,IAAM;AACrB;AAA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,kBAGL,KAAK,aAAa,IAFlB,KAAK,aAAa;AAAA,IAI1B;AAAA,EACJ;AACJ,CAAC;;;;;;;;wCAIGS,EAgBM,KAAA;SAdIC,EAAO,GAAAC,EAAAC,GAAAC,EAAA;AAAA,IACZ,QAAQC,EAAE;AAAA,IACV,OAAKA,EAAA;AAAA,IACL,UAAOA,EAAA;AAAA,IAAA,KACAA,EAAO;AAAA,IACd,OAAKA,EAAA;AAAA,EAAA,GAAA,OAAA,OAAA,CAAA,GAAoDA,EAAO,QAAA,EAAA,SAAA,OAAA,CAAA,GAAA;AAAA,IAAA,SAAAC,EAAc,CAAM,MAAAA,EAAA,CAAA,IAAA,CAAAC,MAAA,CAAAF,EAAA,YAAAA,EAAA,MAAA,SAAAE,GAAA;AAAA,MAAc,SAAAF,EAAA;AAAA,MAAA,QAAAA,EAAA;AAAA;;;;EAOnG,CAAA,GAAA;AAAA,IAAA,SAAAG,EAAA,MAAA;AAAA;QACAC,EAA6CC,EAAAL,EAAA,KAAA,GAAA,CAAA;AAAA,MAAA,CAAA;AAAA;;;;;;"}
1
+ {"version":3,"file":"btn-activity.js","sources":["../src/BtnActivity.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport { Btn, type BtnProps } from '@vue-interface/btn';\nimport { ref, watch, watchEffect, type Component, type Ref } from 'vue';\n\nexport type BtnActivityProps = {\n activity?: boolean;\n indicator: Component;\n indicatorSize?: string;\n label?: string;\n orientation?: 'top' | 'bottom' | 'left' | 'right';\n};\n\nconst props = withDefaults(defineProps<BtnActivityProps & BtnProps>(), {\n orientation: 'right',\n variant: 'btn-primary'\n});\n\nexport type BtnActivityContext = {\n status: Ref<boolean>;\n toggle: Function;\n}\n\nconst emit = defineEmits<{\n click: [event: MouseEvent, context: BtnActivityContext];\n 'hide-activity': [];\n 'show-activity': [];\n}>();\n\nconst status = ref(props.activity);\n\nwatchEffect(() => {\n status.value = props.activity;\n});\n\nwatch(status, (value) => {\n if(value) {\n emit('show-activity');\n }\n else {\n emit('hide-activity');\n }\n});\n\nfunction toggle() {\n status.value = !status.value;\n}\n\nconst context = {\n status,\n toggle,\n};\n</script>\n\n<template>\n <Btn\n v-bind=\"props\"\n :class=\"{\n 'gap-1': !indicatorSize || ['xs', 'sm'].includes(indicatorSize),\n 'gap-2': ['md', 'lg', 'xl'].includes(indicatorSize),\n 'flex-col flex-col-reverse': orientation === 'top',\n 'flex-col': orientation === 'bottom',\n 'flex-row-reverse': orientation === 'left',\n }\"\n @click=\"emit('click', $event, context)\">\n <slot>{{ label }}</slot>\n <Transition\n enter-active-class=\"transition-all ease-out duration-250\"\n enter-from-class=\"opacity-0\"\n enter-to-class=\"opacity-100\"\n leave-active-class=\"transition-all ease-in duration-250\"\n leave-from-class=\"opacity-100\"\n leave-to-class=\"opacity-0\">\n <ActivityIndicator\n v-if=\"status\"\n :type=\"indicator\"\n :size=\"indicatorSize ?? 'xs'\"\n :class=\"{\n 'pt-1': orientation === 'top',\n 'pb-1': orientation === 'bottom',\n 'pr-1': orientation === 'left',\n 'pl-1': orientation === 'right',\n }\" />\n </Transition>\n </Btn>\n</template>\n"],"names":["props","__props","emit","__emit","status","ref","watchEffect","watch","value","toggle","context"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAaA,UAAMA,IAAQC,GAURC,IAAOC,GAMPC,IAASC,EAAIL,EAAM,QAAQ;AAEjC,IAAAM,EAAY,MAAM;AACd,MAAAF,EAAO,QAAQJ,EAAM;AAAA,IAAA,CACxB,GAEKO,EAAAH,GAAQ,CAACI,MAAU;AACrB,MACIN,EADDM,IACM,kBAGA,eAHe;AAAA,IAIxB,CACH;AAED,aAASC,IAAS;AACP,MAAAL,EAAA,QAAQ,CAACA,EAAO;AAAA,IAC3B;AAEA,UAAMM,IAAU;AAAA,MACZ,QAAAN;AAAA,MACA,QAAAK;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- (function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@vue-interface/activity-indicator"),require("@vue-interface/btn"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@vue-interface/activity-indicator","@vue-interface/btn","vue"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.BtnActivity={},n.VueInterfaceActivityIndicator,n.VueInterfaceBtn,n.Vue))})(this,function(n,a,d,i){"use strict";const l=function(t){const s=parseFloat(t||0),e=t&&t.match(/m?s/),c=e?e[0]:!1;let o;switch(c){case"s":o=s*1e3;break;case"ms":default:o=s;break}return o||0},r=function(t,s){const e=(t.ownerDocument||document).defaultView;setTimeout(s,l(e==null?void 0:e.getComputedStyle(t).animationDuration))},y=i.defineComponent({components:{ActivityIndicator:a.ActivityIndicator,Btn:d.Btn},inheritAttrs:!1,props:{active:Boolean,activity:Boolean,block:Boolean,disabled:Boolean,indicator:{type:Object,required:!0},label:{type:String,default:void 0},orientation:{type:String,default:"right"},tag:{type:String,default:void 0}},emits:["click","hide-activity","show-activity"],data(){return{currentActivity:this.activity}},computed:{classes(){return{"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"),r(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(),r(this.$el,()=>{this.$el.classList.add("btn-activity"),this.$emit("show-activity")})},toggle(){this.currentActivity?this.hideActivity():this.showActivity()}}}),m="",h=(t,s)=>{const e=t.__vccOpts||t;for(const[c,o]of s)e[c]=o;return e};function v(t,s,e,c,o,A){const u=i.resolveComponent("ActivityIndicator"),f=i.resolveComponent("Btn");return i.openBlock(),i.createBlock(f,i.mergeProps({active:t.active,block:t.block,disabled:t.disabled,tag:t.tag,class:t.classes},Object.assign({},t.$attrs,{onClick:void 0}),{onClick:s[0]||(s[0]=b=>!t.disabled&&t.$emit("click",b,{disable:t.disable,enable:t.enable,toggle:t.toggle,showActivity:t.showActivity,hideActivity:t.hideActivity}))}),{default:i.withCtx(()=>[i.renderSlot(t.$slots,"default",{},()=>[i.createTextVNode(i.toDisplayString(t.label),1)]),i.createVNode(u,i.normalizeProps(i.guardReactiveProps(t.indicatorProps)),null,16)]),_:3},16,["active","block","disabled","tag","class"])}const p=h(y,[["render",v]]);n.BtnActivity=p,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vue-interface/activity-indicator"),require("@vue-interface/btn")):typeof define=="function"&&define.amd?define(["exports","vue","@vue-interface/activity-indicator","@vue-interface/btn"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.BtnActivity={},i.Vue,i.VueInterfaceActivityIndicator,i.VueInterfaceBtn))})(this,function(i,t,c,l){"use strict";const s=t.defineComponent({__name:"BtnActivity",props:{activity:{type:Boolean},indicator:{},indicatorSize:{},label:{},orientation:{default:"right"},active:{type:Boolean},block:{type:Boolean},disabled:{type:Boolean},outline:{type:Boolean},size:{},tag:{},variant:{default:"btn-primary"}},emits:["click","hide-activity","show-activity"],setup(d,{emit:f}){const n=d,a=f,o=t.ref(n.activity);t.watchEffect(()=>{o.value=n.activity}),t.watch(o,e=>{a(e?"show-activity":"hide-activity")});function p(){o.value=!o.value}const y={status:o,toggle:p};return(e,r)=>(t.openBlock(),t.createBlock(t.unref(l.Btn),t.mergeProps(n,{class:{"gap-1":!e.indicatorSize||["xs","sm"].includes(e.indicatorSize),"gap-2":["md","lg","xl"].includes(e.indicatorSize),"flex-col flex-col-reverse":e.orientation==="top","flex-col":e.orientation==="bottom","flex-row-reverse":e.orientation==="left"},onClick:r[0]||(r[0]=u=>a("click",u,y))}),{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default",{},()=>[t.createTextVNode(t.toDisplayString(e.label),1)]),t.createVNode(t.Transition,{"enter-active-class":"transition-all ease-out duration-250","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition-all ease-in duration-250","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:t.withCtx(()=>[o.value?(t.openBlock(),t.createBlock(t.unref(c.ActivityIndicator),{key:0,type:e.indicator,size:e.indicatorSize??"xs",class:t.normalizeClass({"pt-1":e.orientation==="top","pb-1":e.orientation==="bottom","pr-1":e.orientation==="left","pl-1":e.orientation==="right"})},null,8,["type","size","class"])):t.createCommentVNode("",!0)]),_:1})]),_:3},16,["class"]))}});i.BtnActivity=s,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=btn-activity.umd.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"btn-activity.umd.cjs","sources":["../src/BtnActivity.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport { Btn } from '@vue-interface/btn';\nimport { defineComponent } from 'vue';\n\nconst convertAnimationDelayToInt = function (delay: any) {\n const num = parseFloat(delay || 0);\n const matches = delay && delay.match(/m?s/);\n const unit = matches ? matches[0] : false;\n\n let milliseconds;\n\n switch (unit) {\n case 's': // seconds\n milliseconds = num * 1000;\n break;\n case 'ms':\n default:\n milliseconds = num;\n break;\n }\n\n return milliseconds || 0;\n};\n\nconst animated = function (el: HTMLElement, callback: Function) {\n const defaultView = (el.ownerDocument || document).defaultView;\n\n setTimeout(\n callback,\n convertAnimationDelayToInt(\n defaultView?.getComputedStyle(el).animationDuration\n )\n );\n};\n\nexport default defineComponent({\n\n components: {\n ActivityIndicator,\n Btn,\n },\n\n inheritAttrs: false,\n\n props: {\n /**\n\t\t * Make the button appear with the active state.\n\t\t */\n active: Boolean,\n\n /**\n\t\t * Show the activity indicator inside the button.\n\t\t */\n activity: Boolean,\n\n /**\n\t\t * Display the button as block width.\n\t\t */\n block: Boolean,\n\n /**\n\t\t * Disable the button.\n\t\t */\n disabled: Boolean,\n\n /**\n\t\t * The type of activity indicator inside the button.\n\t\t */\n indicator: {\n type: Object,\n required: true\n },\n\n /**\n\t\t * The button label.\n\t\t */\n label: {\n type: String,\n default: undefined\n },\n\n /**\n\t\t * The orientation of the activity button inside the button.\n\t\t */\n orientation: {\n type: String,\n default: 'right',\n },\n\n /**\n\t\t * The HTML tag.\n\t\t */\n tag: {\n type: String,\n default: undefined\n },\n },\n\n emits: ['click', 'hide-activity', 'show-activity'],\n\n data() {\n return {\n currentActivity: this.activity,\n };\n },\n\n computed: {\n /**\n\t\t * An object of classes to append to the button.\n\t\t */\n classes() {\n return {\n 'btn-activity': this.activity,\n [`btn-activity-${this.orientation.replace('btn-activity-', '')}`]: !!this.orientation,\n [`btn-activity-indicator-${this.indicatorProps.type.replace('btn-activity-indicator-', '')}`]: !!this.indicatorProps.type,\n };\n },\n\n indicatorProps() {\n return Object.assign(\n {\n type: 'spinner',\n },\n (typeof this.indicator === 'string'\n ? {\n type: this.indicator,\n }\n : this.indicator) || {}\n );\n },\n },\n\n watch: {\n activity(value: boolean) {\n if(value) {\n this.showActivity();\n } else {\n this.hideActivity();\n }\n },\n },\n\n mounted() {\n if(this.activity) {\n this.showActivity();\n }\n },\n\n methods: {\n /**\n\t\t * Disable the button.\n\t\t */\n disable(): void {\n this.$el.disabled = true;\n this.$el.classList.add('disabled');\n },\n\n /**\n\t\t * Enable the button.\n\t\t */\n enable(): void {\n this.$el.disabled = false;\n this.$el.classList.remove('disabled');\n },\n\n /**\n\t\t * Hide the activity indicator inside the button.\n\t\t */\n hideActivity(): void {\n this.$el.classList.add('btn-hide-activity');\n\n animated(this.$el, () => {\n if(!this.disabled) {\n \tthis.enable();\n }\n\t\t\t\t\n this.currentActivity = false;\n this.$el.classList.remove('btn-activity', 'btn-hide-activity');\n this.$emit('hide-activity');\n });\n },\n\n /**\n\t\t * Show the activity indicator inside the button.\n\t\t */\n showActivity(): void {\n this.currentActivity = true;\n this.disable();\n\n animated(this.$el, () => {\n this.$el.classList.add('btn-activity');\n this.$emit('show-activity');\n });\n },\n\n /**\n\t\t * Show the activity indicator inside the button.\n\t\t */\n toggle(): void {\n if(!this.currentActivity) {\n this.showActivity();\n } else {\n this.hideActivity();\n }\n },\n },\n});\n</script>\n\n<template>\n <Btn\n :active=\"active\"\n :block=\"block\"\n :disabled=\"disabled\"\n :tag=\"tag\"\n :class=\"classes\"\n v-bind=\"Object.assign({}, $attrs, { onClick: undefined })\"\n @click=\"!disabled && $emit('click', $event, {\n disable,\n enable,\n toggle,\n showActivity,\n hideActivity,\n })\">\n <slot>{{ label }}</slot>\n <ActivityIndicator v-bind=\"indicatorProps\" />\n </Btn>\n</template>\n\n<style>\n@keyframes btn-activity-in {\n\n\t0%,\n\t100% {\n\t\ttransform: scale(1);\n\t}\n\n\t30% {\n\t\ttransform: scale(0.98);\n\t}\n}\n\n@keyframes btn-activity-out {\n\n\t0%,\n\t100% {\n\t\ttransform: scale(1);\n\t}\n\n\t70% {\n\t\ttransform: scale(0.98);\n\t}\n}\n\n.btn-activity-top,\n.btn.btn-activity-top,\n.btn-activity-bottom,\n.btn.btn-activity-bottom,\n.btn-activity-left,\n.btn.btn-activity-left,\n.btn-activity-right,\n.btn.btn-activity-right {\n\tdisplay: inline-flex;\n\tposition: relative;\n\ttransition: all calc(333ms / 2) ease-in;\n}\n\n.btn-activity-top .activity-indicator,\n.btn-activity-bottom .activity-indicator,\n.btn-activity-left .activity-indicator,\n.btn-activity-right .activity-indicator {\n\topacity: 0;\n\tposition: absolute;\n\tvisibility: hidden;\n\ttransition: opacity 333ms ease-in;\n}\n\n.btn-activity-top,\n.btn-activity-bottom {\n\tflex-direction: column;\n\talign-items: center;\n}\n\n.btn-activity-top .activity-indicator,\n.btn-activity-bottom .activity-indicator {\n\tmargin-left: auto;\n\tmargin-right: auto;\n}\n\n.btn-activity-top {\n\tflex-direction: column-reverse;\n}\n\n.btn-activity-top .activity-indicator {\n\tpadding-bottom: 1em;\n}\n\n.btn-activity-bottom .activity-indicator {\n\tpadding-top: 1em;\n}\n\n.btn-activity-left,\n.btn-activity-right {\n\talign-items: center;\n\tjustify-content: center;\n}\n\n.btn-activity-left {\n\tflex-direction: row-reverse;\n}\n\n.btn-activity-left .activity-indicator {\n\tpadding-right: 1em;\n}\n\n.btn-activity-right .activity-indicator {\n\tpadding-left: 1em;\n}\n\n.btn-activity:not(.btn-link) {\n\tanimation: btn-activity-in 333ms;\n}\n\n.btn-hide-activity:not(.btn-link) {\n\tanimation: btn-activity-out 333ms;\n}\n\n.btn-activity.btn-hide-activity .activity-indicator {\n\topacity: 0;\n}\n\n.btn-activity .activity-indicator {\n\topacity: 1;\n\tvisibility: visible;\n\tposition: relative;\n\tfont-size: 0.55em;\n}\n</style>\n"],"names":["convertAnimationDelayToInt","delay","num","matches","unit","milliseconds","animated","el","callback","defaultView","_sfc_main","defineComponent","ActivityIndicator","Btn","value","_resolveComponent","_openBlock","_createBlock","_component_Btn","_mergeProps","_ctx","_cache","$event","_withCtx","_createTextVNode","_toDisplayString"],"mappings":"0bAKA,MAAMA,EAA6B,SAAUC,EAAY,CAC/C,MAAAC,EAAM,WAAWD,GAAS,CAAC,EAC3BE,EAAUF,GAASA,EAAM,MAAM,KAAK,EACpCG,EAAOD,EAAUA,EAAQ,CAAC,EAAI,GAEhC,IAAAE,EAEJ,OAAQD,EAAM,CACd,IAAK,IACDC,EAAeH,EAAM,IACrB,MACJ,IAAK,KACL,QACmBG,EAAAH,EACf,KACJ,CAEA,OAAOG,GAAgB,CAC3B,EAEMC,EAAW,SAAUC,EAAiBC,EAAoB,CACtD,MAAA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B,CACZ,KAAA,IAAI,UAAU,IAAI,mBAAmB,EAEjCR,EAAA,KAAK,IAAK,IAAM,CACjB,KAAK,UACR,KAAK,OAAO,EAGb,KAAK,gBAAkB,GACvB,KAAK,IAAI,UAAU,OAAO,eAAgB,mBAAmB,EAC7D,KAAK,MAAM,eAAe,CAAA,CAC7B,CACL,EAKA,cAAqB,CACjB,KAAK,gBAAkB,GACvB,KAAK,QAAQ,EAEJA,EAAA,KAAK,IAAK,IAAM,CAChB,KAAA,IAAI,UAAU,IAAI,cAAc,EACrC,KAAK,MAAM,eAAe,CAAA,CAC7B,CACL,EAKA,QAAe,CACP,KAAK,gBAGL,KAAK,aAAa,EAFlB,KAAK,aAAa,CAI1B,CACJ,CACJ,CAAC,sJAIGS,mBAgBM,KAAA,SAdIC,YAAO,EAAAC,cAAAC,EAAAC,EAAAA,WAAA,CACZ,OAAQC,EAAE,OACV,MAAKA,EAAA,MACL,SAAOA,EAAA,SAAA,IACAA,EAAO,IACd,MAAKA,EAAA,OAAA,EAAA,OAAA,OAAA,CAAA,EAAoDA,EAAO,OAAA,CAAA,QAAA,MAAA,CAAA,EAAA,CAAA,QAAAC,EAAc,CAAM,IAAAA,EAAA,CAAA,EAAAC,GAAA,CAAAF,EAAA,UAAAA,EAAA,MAAA,QAAAE,EAAA,CAAc,QAAAF,EAAA,QAAA,OAAAA,EAAA,iFAOnG,CAAA,EAAA,CAAA,QAAAG,EAAA,QAAA,IAAA,yCACAC,EAAAA,gBAA6CC,EAAAA,gBAAAL,EAAA,KAAA,EAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"btn-activity.umd.cjs","sources":["../src/BtnActivity.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport { Btn, type BtnProps } from '@vue-interface/btn';\nimport { ref, watch, watchEffect, type Component, type Ref } from 'vue';\n\nexport type BtnActivityProps = {\n activity?: boolean;\n indicator: Component;\n indicatorSize?: string;\n label?: string;\n orientation?: 'top' | 'bottom' | 'left' | 'right';\n};\n\nconst props = withDefaults(defineProps<BtnActivityProps & BtnProps>(), {\n orientation: 'right',\n variant: 'btn-primary'\n});\n\nexport type BtnActivityContext = {\n status: Ref<boolean>;\n toggle: Function;\n}\n\nconst emit = defineEmits<{\n click: [event: MouseEvent, context: BtnActivityContext];\n 'hide-activity': [];\n 'show-activity': [];\n}>();\n\nconst status = ref(props.activity);\n\nwatchEffect(() => {\n status.value = props.activity;\n});\n\nwatch(status, (value) => {\n if(value) {\n emit('show-activity');\n }\n else {\n emit('hide-activity');\n }\n});\n\nfunction toggle() {\n status.value = !status.value;\n}\n\nconst context = {\n status,\n toggle,\n};\n</script>\n\n<template>\n <Btn\n v-bind=\"props\"\n :class=\"{\n 'gap-1': !indicatorSize || ['xs', 'sm'].includes(indicatorSize),\n 'gap-2': ['md', 'lg', 'xl'].includes(indicatorSize),\n 'flex-col flex-col-reverse': orientation === 'top',\n 'flex-col': orientation === 'bottom',\n 'flex-row-reverse': orientation === 'left',\n }\"\n @click=\"emit('click', $event, context)\">\n <slot>{{ label }}</slot>\n <Transition\n enter-active-class=\"transition-all ease-out duration-250\"\n enter-from-class=\"opacity-0\"\n enter-to-class=\"opacity-100\"\n leave-active-class=\"transition-all ease-in duration-250\"\n leave-from-class=\"opacity-100\"\n leave-to-class=\"opacity-0\">\n <ActivityIndicator\n v-if=\"status\"\n :type=\"indicator\"\n :size=\"indicatorSize ?? 'xs'\"\n :class=\"{\n 'pt-1': orientation === 'top',\n 'pb-1': orientation === 'bottom',\n 'pr-1': orientation === 'left',\n 'pl-1': orientation === 'right',\n }\" />\n </Transition>\n </Btn>\n</template>\n"],"names":["props","__props","emit","__emit","status","ref","watchEffect","watch","value","toggle","context"],"mappings":"0xBAaA,MAAMA,EAAQC,EAURC,EAAOC,EAMPC,EAASC,EAAAA,IAAIL,EAAM,QAAQ,EAEjCM,EAAAA,YAAY,IAAM,CACdF,EAAO,MAAQJ,EAAM,QAAA,CACxB,EAEKO,QAAAH,EAASI,GAAU,CAEjBN,EADDM,EACM,gBAGA,eAHe,CAIxB,CACH,EAED,SAASC,GAAS,CACPL,EAAA,MAAQ,CAACA,EAAO,KAC3B,CAEA,MAAMM,EAAU,CACZ,OAAAN,EACA,OAAAK,CAAA"}
@@ -1,136 +1,56 @@
1
- declare const _default: 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: ObjectConstructor;
23
- required: true;
24
- };
25
- /**
26
- * The button label.
27
- */
28
- label: {
29
- type: StringConstructor;
30
- default: any;
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 HTML tag.
41
- */
42
- tag: {
43
- type: StringConstructor;
44
- default: any;
45
- };
46
- }, unknown, {
47
- currentActivity: boolean;
48
- }, {
49
- /**
50
- * An object of classes to append to the button.
51
- */
52
- classes(): {
53
- [x: string]: any;
54
- 'btn-activity': any;
55
- };
56
- indicatorProps(): any;
1
+ import { type BtnProps } from '@vue-interface/btn';
2
+ import { type Component, type Ref } from 'vue';
3
+ export type BtnActivityProps = {
4
+ activity?: boolean;
5
+ indicator: Component;
6
+ indicatorSize?: string;
7
+ label?: string;
8
+ orientation?: 'top' | 'bottom' | 'left' | 'right';
9
+ };
10
+ export type BtnActivityContext = {
11
+ status: Ref<boolean>;
12
+ toggle: Function;
13
+ };
14
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<BtnActivityProps & BtnProps>, {
15
+ orientation: string;
16
+ variant: string;
17
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ click: (event: MouseEvent, context: BtnActivityContext) => void;
19
+ "hide-activity": () => void;
20
+ "show-activity": () => void;
21
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<BtnActivityProps & BtnProps>, {
22
+ orientation: string;
23
+ variant: string;
24
+ }>>> & {
25
+ onClick?: (event: MouseEvent, context: BtnActivityContext) => any;
26
+ "onHide-activity"?: () => any;
27
+ "onShow-activity"?: () => any;
57
28
  }, {
58
- /**
59
- * Disable the button.
60
- */
61
- disable(): void;
62
- /**
63
- * Enable the button.
64
- */
65
- enable(): void;
66
- /**
67
- * Hide the activity indicator inside the button.
68
- */
69
- hideActivity(): void;
70
- /**
71
- * Show the activity indicator inside the button.
72
- */
73
- showActivity(): void;
74
- /**
75
- * Show the activity indicator inside the button.
76
- */
77
- toggle(): void;
78
- }, 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<{
79
- /**
80
- * Make the button appear with the active state.
81
- */
82
- active: BooleanConstructor;
83
- /**
84
- * Show the activity indicator inside the button.
85
- */
86
- activity: BooleanConstructor;
87
- /**
88
- * Display the button as block width.
89
- */
90
- block: BooleanConstructor;
91
- /**
92
- * Disable the button.
93
- */
94
- disabled: BooleanConstructor;
95
- /**
96
- * The type of activity indicator inside the button.
97
- */
98
- indicator: {
99
- type: ObjectConstructor;
29
+ orientation: "top" | "bottom" | "left" | "right";
30
+ variant: string;
31
+ }, {}>, {
32
+ default?(_: {}): any;
33
+ }>;
34
+ export default _default;
35
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
36
+ type __VLS_TypePropsToRuntimeProps<T> = {
37
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
38
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
39
+ } : {
40
+ type: import('vue').PropType<T[K]>;
100
41
  required: true;
101
42
  };
102
- /**
103
- * The button label.
104
- */
105
- label: {
106
- type: StringConstructor;
107
- default: any;
108
- };
109
- /**
110
- * The orientation of the activity button inside the button.
111
- */
112
- orientation: {
113
- type: StringConstructor;
114
- default: string;
115
- };
116
- /**
117
- * The HTML tag.
118
- */
119
- tag: {
120
- type: StringConstructor;
121
- default: any;
122
- };
123
- }>> & {
124
- onClick?: (...args: any[]) => any;
125
- "onHide-activity"?: (...args: any[]) => any;
126
- "onShow-activity"?: (...args: any[]) => any;
127
- }, {
128
- label: string;
129
- active: boolean;
130
- block: boolean;
131
- disabled: boolean;
132
- tag: string;
133
- activity: boolean;
134
- orientation: string;
135
- }, {}>;
136
- export default _default;
43
+ };
44
+ type __VLS_WithDefaults<P, D> = {
45
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
46
+ default: D[K];
47
+ }> : P[K];
48
+ };
49
+ type __VLS_Prettify<T> = {
50
+ [K in keyof T]: T[K];
51
+ } & {};
52
+ type __VLS_WithTemplateSlots<T, S> = T & {
53
+ new (): {
54
+ $slots: S;
55
+ };
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/btn-activity",
3
- "version": "2.0.0-beta.16",
3
+ "version": "2.0.0-beta.17",
4
4
  "description": "A Vue activity button component.",
5
5
  "type": "module",
6
6
  "files": [
@@ -8,15 +8,13 @@
8
8
  ],
9
9
  "main": "./dist/btn-activity.umd.cjs",
10
10
  "module": "./dist/btn-activity.js",
11
- "style": "./dist/style.css",
12
11
  "types": "./dist/index.d.ts",
13
12
  "exports": {
14
13
  ".": {
15
14
  "import": "./dist/btn-activity.js",
16
15
  "require": "./dist/btn-activity.umd.cjs",
17
16
  "types": "./dist/index.d.ts"
18
- },
19
- "./dist/style.css": "./dist/style.css"
17
+ }
20
18
  },
21
19
  "browserslist": "last 2 versions, > 0.5%, ie >= 11",
22
20
  "scripts": {
@@ -43,8 +41,8 @@
43
41
  },
44
42
  "homepage": "https://github.com/vue-interface/btn-activity",
45
43
  "dependencies": {
46
- "@vue-interface/activity-indicator": "^2.0.0-beta.7",
47
- "@vue-interface/btn": "^3.0.0-beta.21"
44
+ "@vue-interface/activity-indicator": "^2.0.0-beta.20",
45
+ "@vue-interface/btn": "^3.0.0-beta.24"
48
46
  },
49
47
  "peerDependencies": {
50
48
  "vue": "^3.3.4"
package/dist/style.css DELETED
@@ -1 +0,0 @@
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}