@vue-interface/btn-activity 3.0.0 → 4.0.0
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/LICENSE +22 -0
- package/README.md +30 -0
- package/dist/btn-activity.js +83 -0
- package/dist/btn-activity.js.map +1 -0
- package/dist/btn-activity.umd.cjs +2 -0
- package/dist/btn-activity.umd.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/src/BtnActivity.vue.d.ts +48 -0
- package/package.json +13 -6
- package/CHANGELOG.md +0 -7
- package/demo.css +0 -4
- package/docs/btn-activity.md +0 -222
- package/index.html +0 -143
- package/index.ts +0 -5
- package/src/BtnActivity.vue +0 -102
- package/tsconfig.json +0 -27
- package/vite.config.js +0 -47
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Justin Kimbrell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Button Activity
|
|
2
|
+
|
|
3
|
+
The `btn-activity` component provides an interactive button with built-in activity indicators for async operations. It extends the standard button and combines activity indicators.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm i @vue-interface/btn-activity
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn add @vue-interface/btn-activity
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm i @vue-interface/btn-activity
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun i @vue-interface/btn-activity
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Basic Usage
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<BtnActivity :indicator="Dots" @click="onClick">Dots</BtnActivity>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For more comprehensive documentation and examples, please visit the [online documentation](https://vue-interface.github.io/packages/btn-activity/).
|
|
30
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { defineComponent as f, ref as y, watchEffect as v, watch as m, createElementBlock as b, openBlock as l, normalizeClass as c, renderSlot as x, createVNode as h, createTextVNode as k, toDisplayString as z, Transition as g, withCtx as w, createBlock as B, createCommentVNode as S, unref as C } from "vue";
|
|
2
|
+
import { ActivityIndicator as A } from "@vue-interface/activity-indicator";
|
|
3
|
+
const N = ["disabled"], T = /* @__PURE__ */ f({
|
|
4
|
+
__name: "BtnActivity",
|
|
5
|
+
props: {
|
|
6
|
+
activity: { type: Boolean },
|
|
7
|
+
indicator: {},
|
|
8
|
+
indicatorSize: { default: "xs" },
|
|
9
|
+
label: { default: void 0 },
|
|
10
|
+
orientation: { default: "right" },
|
|
11
|
+
variant: { default: "btn-primary" },
|
|
12
|
+
size: { default: "btn-md" },
|
|
13
|
+
block: { type: Boolean },
|
|
14
|
+
disabled: { type: Boolean }
|
|
15
|
+
},
|
|
16
|
+
emits: ["click", "hide-activity", "show-activity"],
|
|
17
|
+
setup(t, { emit: r }) {
|
|
18
|
+
const n = t, i = r, e = y(n.activity);
|
|
19
|
+
v(() => {
|
|
20
|
+
e.value = n.activity;
|
|
21
|
+
}), m(e, (a) => {
|
|
22
|
+
i(a ? "show-activity" : "hide-activity");
|
|
23
|
+
});
|
|
24
|
+
function s() {
|
|
25
|
+
e.value = !e.value;
|
|
26
|
+
}
|
|
27
|
+
const d = {
|
|
28
|
+
status: e,
|
|
29
|
+
toggle: s
|
|
30
|
+
};
|
|
31
|
+
return (a, o) => (l(), b("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
disabled: t.disabled,
|
|
34
|
+
class: c([
|
|
35
|
+
"btn",
|
|
36
|
+
t.variant,
|
|
37
|
+
t.size,
|
|
38
|
+
{
|
|
39
|
+
"w-full": t.block,
|
|
40
|
+
"gap-1": ["xs", "sm"].includes(t.indicatorSize),
|
|
41
|
+
"gap-2": ["md", "lg", "xl"].includes(t.indicatorSize),
|
|
42
|
+
"flex-col-reverse": t.orientation === "top",
|
|
43
|
+
"flex-col": t.orientation === "bottom",
|
|
44
|
+
"flex-row-reverse": t.orientation === "left",
|
|
45
|
+
"inline-flex items-center justify-center": !0,
|
|
46
|
+
"opacity-50 cursor-not-allowed": t.disabled
|
|
47
|
+
}
|
|
48
|
+
]),
|
|
49
|
+
onClick: o[0] || (o[0] = (u) => i("click", u, d))
|
|
50
|
+
}, [
|
|
51
|
+
x(a.$slots, "default", {}, () => [
|
|
52
|
+
k(z(t.label), 1)
|
|
53
|
+
]),
|
|
54
|
+
h(g, {
|
|
55
|
+
"enter-active-class": "transition-all ease-out duration-250",
|
|
56
|
+
"enter-from-class": "opacity-0",
|
|
57
|
+
"enter-to-class": "opacity-100",
|
|
58
|
+
"leave-active-class": "transition-all ease-in duration-250",
|
|
59
|
+
"leave-from-class": "opacity-100",
|
|
60
|
+
"leave-to-class": "opacity-0"
|
|
61
|
+
}, {
|
|
62
|
+
default: w(() => [
|
|
63
|
+
e.value ? (l(), B(C(A), {
|
|
64
|
+
key: 0,
|
|
65
|
+
type: t.indicator,
|
|
66
|
+
size: t.indicatorSize,
|
|
67
|
+
class: c({
|
|
68
|
+
"pt-1": t.orientation === "top",
|
|
69
|
+
"pb-1": t.orientation === "bottom",
|
|
70
|
+
"pr-1": t.orientation === "left",
|
|
71
|
+
"pl-1": t.orientation === "right"
|
|
72
|
+
})
|
|
73
|
+
}, null, 8, ["type", "size", "class"])) : S("", !0)
|
|
74
|
+
]),
|
|
75
|
+
_: 1
|
|
76
|
+
})
|
|
77
|
+
], 10, N));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
export {
|
|
81
|
+
T as BtnActivity
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=btn-activity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"btn-activity.js","sources":["../src/BtnActivity.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ActivityIndicator } from '@vue-interface/activity-indicator';\nimport { ref, watch, watchEffect, type Component, type Ref } from 'vue';\nimport { ActivityIndicatorSize } from '../../activity-indicator/src/ActivityIndicator.vue';\n\nexport type BtnActivityProps = {\n activity?: boolean;\n indicator: Component;\n indicatorSize?: ActivityIndicatorSize;\n label?: string;\n orientation?: 'top' | 'bottom' | 'left' | 'right';\n variant?: string;\n size?: string;\n block?: boolean; \n disabled?: boolean;\n};\n\nconst props = withDefaults(defineProps<BtnActivityProps>(), {\n indicatorSize: 'xs',\n label: undefined,\n orientation: 'right',\n variant: 'btn-primary',\n size: 'btn-md'\n});\n\nexport type BtnActivityContext = {\n status: Ref<boolean>;\n toggle: () => void;\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 <button\n type=\"button\"\n :disabled=\"disabled\"\n :class=\"[\n 'btn',\n variant,\n size,\n {\n 'w-full': block,\n 'gap-1': ['xs', 'sm'].includes(indicatorSize),\n 'gap-2': ['md', 'lg', 'xl'].includes(indicatorSize),\n 'flex-col-reverse': orientation === 'top',\n 'flex-col': orientation === 'bottom',\n 'flex-row-reverse': orientation === 'left',\n 'inline-flex items-center justify-center': true,\n 'opacity-50 cursor-not-allowed': disabled,\n }\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\"\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 </button>\n</template>"],"names":["props","__props","emit","__emit","status","ref","watchEffect","watch","value","toggle","context","_createElementBlock","_normalizeClass","_cache","$event","_renderSlot","_ctx","_createVNode","_Transition","_createBlock","_unref","ActivityIndicator"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,UAAMA,IAAQC,GAaRC,IAAOC,GAMPC,IAASC,EAAIL,EAAM,QAAQ;AAEjC,IAAAM,EAAY,MAAM;AACd,MAAAF,EAAO,QAAQJ,EAAM;AAAA,IACzB,CAAC,GAEDO,EAAMH,GAAQ,CAACI,MAAU;AACrB,MACIN,EADDM,IACM,kBAGA,eAHe;AAAA,IAK5B,CAAC;AAED,aAASC,IAAS;AACd,MAAAL,EAAO,QAAQ,CAACA,EAAO;AAAA,IAC3B;AAEA,UAAMM,IAAU;AAAA,MACZ,QAAAN;AAAA,MACA,QAAAK;AAAA,IAAA;2BAKAE,EAsCS,UAAA;AAAA,MArCL,MAAK;AAAA,MACJ,UAAUV,EAAA;AAAA,MACV,OAAKW,EAAA;AAAA;QAAmCX,EAAA;AAAA,QAAqBA,EAAA;AAAA;oBAA8CA,EAAA;AAAA,UAA6C,SAAA,CAAA,MAAA,IAAA,EAAA,SAASA,EAAA,aAAa;AAAA,UAA+C,SAAA,CAAA,MAAA,MAAA,IAAA,EAAA,SAASA,EAAA,aAAa;AAAA,8BAAuCA,EAAA,gBAAW;AAAA,sBAAwCA,EAAA,gBAAW;AAAA,8BAAmDA,EAAA,gBAAW;AAAA;2CAA+HA,EAAA;AAAA,QAAA;AAAA;MAerhB,SAAKY,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,CAAAC,MAAEZ,EAAI,SAAUY,GAAQJ,CAAO;AAAA,IAAA;MACrCK,EAAwBC,yBAAxB,MAAwB;AAAA,YAAff,EAAA,KAAK,GAAA,CAAA;AAAA,MAAA;MACdgB,EAiBaC,GAAA;AAAA,QAhBT,sBAAmB;AAAA,QACnB,oBAAiB;AAAA,QACjB,kBAAe;AAAA,QACf,sBAAmB;AAAA,QACnB,oBAAiB;AAAA,QACjB,kBAAe;AAAA,MAAA;;UAELd,EAAA,cADVe,EASSC,EAAAC,CAAA,GAAA;AAAA;YAPJ,MAAMpB,EAAA;AAAA,YACN,MAAMA,EAAA;AAAA,YACN,OAAKW,EAAA;AAAA,sBAAgCX,EAAA,gBAAW;AAAA,sBAAwCA,EAAA,gBAAW;AAAA,sBAA2CA,EAAA,gBAAW;AAAA,sBAAyCA,EAAA,gBAAW;AAAA,YAAA;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(i,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vue-interface/activity-indicator")):typeof define=="function"&&define.amd?define(["exports","vue","@vue-interface/activity-indicator"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.BtnActivity={},i.Vue,i.VueInterfaceActivityIndicator))})(this,(function(i,t,r){"use strict";const s=["disabled"],d=t.defineComponent({__name:"BtnActivity",props:{activity:{type:Boolean},indicator:{},indicatorSize:{default:"xs"},label:{default:void 0},orientation:{default:"right"},variant:{default:"btn-primary"},size:{default:"btn-md"},block:{type:Boolean},disabled:{type:Boolean}},emits:["click","hide-activity","show-activity"],setup(e,{emit:f}){const c=e,a=f,n=t.ref(c.activity);t.watchEffect(()=>{n.value=c.activity}),t.watch(n,o=>{a(o?"show-activity":"hide-activity")});function y(){n.value=!n.value}const u={status:n,toggle:y};return(o,l)=>(t.openBlock(),t.createElementBlock("button",{type:"button",disabled:e.disabled,class:t.normalizeClass(["btn",e.variant,e.size,{"w-full":e.block,"gap-1":["xs","sm"].includes(e.indicatorSize),"gap-2":["md","lg","xl"].includes(e.indicatorSize),"flex-col-reverse":e.orientation==="top","flex-col":e.orientation==="bottom","flex-row-reverse":e.orientation==="left","inline-flex items-center justify-center":!0,"opacity-50 cursor-not-allowed":e.disabled}]),onClick:l[0]||(l[0]=m=>a("click",m,u))},[t.renderSlot(o.$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(()=>[n.value?(t.openBlock(),t.createBlock(t.unref(r.ActivityIndicator),{key:0,type:e.indicator,size:e.indicatorSize,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})],10,s))}});i.BtnActivity=d,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
+
//# sourceMappingURL=btn-activity.umd.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 { ref, watch, watchEffect, type Component, type Ref } from 'vue';\nimport { ActivityIndicatorSize } from '../../activity-indicator/src/ActivityIndicator.vue';\n\nexport type BtnActivityProps = {\n activity?: boolean;\n indicator: Component;\n indicatorSize?: ActivityIndicatorSize;\n label?: string;\n orientation?: 'top' | 'bottom' | 'left' | 'right';\n variant?: string;\n size?: string;\n block?: boolean; \n disabled?: boolean;\n};\n\nconst props = withDefaults(defineProps<BtnActivityProps>(), {\n indicatorSize: 'xs',\n label: undefined,\n orientation: 'right',\n variant: 'btn-primary',\n size: 'btn-md'\n});\n\nexport type BtnActivityContext = {\n status: Ref<boolean>;\n toggle: () => void;\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 <button\n type=\"button\"\n :disabled=\"disabled\"\n :class=\"[\n 'btn',\n variant,\n size,\n {\n 'w-full': block,\n 'gap-1': ['xs', 'sm'].includes(indicatorSize),\n 'gap-2': ['md', 'lg', 'xl'].includes(indicatorSize),\n 'flex-col-reverse': orientation === 'top',\n 'flex-col': orientation === 'bottom',\n 'flex-row-reverse': orientation === 'left',\n 'inline-flex items-center justify-center': true,\n 'opacity-50 cursor-not-allowed': disabled,\n }\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\"\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 </button>\n</template>"],"names":["props","__props","emit","__emit","status","ref","watchEffect","watch","value","toggle","context","_createElementBlock","_normalizeClass","_cache","$event","_renderSlot","_ctx","_createVNode","_Transition","_createBlock","_unref","ActivityIndicator"],"mappings":"ytBAiBA,MAAMA,EAAQC,EAaRC,EAAOC,EAMPC,EAASC,EAAAA,IAAIL,EAAM,QAAQ,EAEjCM,EAAAA,YAAY,IAAM,CACdF,EAAO,MAAQJ,EAAM,QACzB,CAAC,EAEDO,QAAMH,EAASI,GAAU,CAEjBN,EADDM,EACM,gBAGA,eAHe,CAK5B,CAAC,EAED,SAASC,GAAS,CACdL,EAAO,MAAQ,CAACA,EAAO,KAC3B,CAEA,MAAMM,EAAU,CACZ,OAAAN,EACA,OAAAK,CAAA,8BAKAE,EAAAA,mBAsCS,SAAA,CArCL,KAAK,SACJ,SAAUV,EAAA,SACV,MAAKW,EAAAA,eAAA,OAAmCX,EAAA,QAAqBA,EAAA,eAA8CA,EAAA,MAA6C,QAAA,CAAA,KAAA,IAAA,EAAA,SAASA,EAAA,aAAa,EAA+C,QAAA,CAAA,KAAA,KAAA,IAAA,EAAA,SAASA,EAAA,aAAa,qBAAuCA,EAAA,cAAW,iBAAwCA,EAAA,cAAW,4BAAmDA,EAAA,cAAW,oFAA+HA,EAAA,QAAA,IAerhB,QAAKY,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAAC,GAAEZ,EAAI,QAAUY,EAAQJ,CAAO,EAAA,GACrCK,EAAAA,WAAwBC,sBAAxB,IAAwB,qCAAff,EAAA,KAAK,EAAA,CAAA,CAAA,GACdgB,EAAAA,YAiBaC,EAAAA,WAAA,CAhBT,qBAAmB,uCACnB,mBAAiB,YACjB,iBAAe,cACf,qBAAmB,sCACnB,mBAAiB,cACjB,iBAAe,WAAA,0BAELd,EAAA,qBADVe,EAAAA,YASSC,EAAAA,MAAAC,EAAAA,iBAAA,EAAA,OAPJ,KAAMpB,EAAA,UACN,KAAMA,EAAA,cACN,MAAKW,EAAAA,eAAA,QAAgCX,EAAA,cAAW,aAAwCA,EAAA,cAAW,gBAA2CA,EAAA,cAAW,cAAyCA,EAAA,cAAW,OAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component, Ref } from 'vue';
|
|
2
|
+
import { ActivityIndicatorSize } from '../../activity-indicator/src/ActivityIndicator.vue';
|
|
3
|
+
export type BtnActivityProps = {
|
|
4
|
+
activity?: boolean;
|
|
5
|
+
indicator: Component;
|
|
6
|
+
indicatorSize?: ActivityIndicatorSize;
|
|
7
|
+
label?: string;
|
|
8
|
+
orientation?: 'top' | 'bottom' | 'left' | 'right';
|
|
9
|
+
variant?: string;
|
|
10
|
+
size?: string;
|
|
11
|
+
block?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type BtnActivityContext = {
|
|
15
|
+
status: Ref<boolean>;
|
|
16
|
+
toggle: () => void;
|
|
17
|
+
};
|
|
18
|
+
declare function __VLS_template(): {
|
|
19
|
+
attrs: Partial<{}>;
|
|
20
|
+
slots: {
|
|
21
|
+
default?(_: {}): any;
|
|
22
|
+
};
|
|
23
|
+
refs: {};
|
|
24
|
+
rootEl: HTMLButtonElement;
|
|
25
|
+
};
|
|
26
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
27
|
+
declare const __VLS_component: import('vue').DefineComponent<BtnActivityProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
28
|
+
click: (event: MouseEvent, context: BtnActivityContext) => any;
|
|
29
|
+
"hide-activity": () => any;
|
|
30
|
+
"show-activity": () => any;
|
|
31
|
+
}, string, import('vue').PublicProps, Readonly<BtnActivityProps> & Readonly<{
|
|
32
|
+
onClick?: ((event: MouseEvent, context: BtnActivityContext) => any) | undefined;
|
|
33
|
+
"onHide-activity"?: (() => any) | undefined;
|
|
34
|
+
"onShow-activity"?: (() => any) | undefined;
|
|
35
|
+
}>, {
|
|
36
|
+
size: string;
|
|
37
|
+
label: string;
|
|
38
|
+
indicatorSize: ActivityIndicatorSize;
|
|
39
|
+
orientation: "top" | "bottom" | "left" | "right";
|
|
40
|
+
variant: string;
|
|
41
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLButtonElement>;
|
|
42
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
43
|
+
export default _default;
|
|
44
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
45
|
+
new (): {
|
|
46
|
+
$slots: S;
|
|
47
|
+
};
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-interface/btn-activity",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A Vue activity button component.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/btn-activity.umd.cjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"browserslist": "last 2 versions, > 0.5%, ie >= 11",
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/vue-interface/
|
|
20
|
+
"url": "git+https://github.com/vue-interface/vue-interface.github.io"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"Form",
|
|
@@ -28,15 +28,22 @@
|
|
|
28
28
|
"Bootstrap"
|
|
29
29
|
],
|
|
30
30
|
"author": "Justin Kimbrell",
|
|
31
|
-
"license": "
|
|
31
|
+
"license": "MIT",
|
|
32
32
|
"bugs": {
|
|
33
|
-
"url": "https://github.com/vue-interface/
|
|
33
|
+
"url": "https://github.com/vue-interface/vue-interface.github.io"
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/vue-interface/vue-interface",
|
|
36
|
+
"readme": "README.md",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"index.css",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
36
43
|
"peerDependencies": {
|
|
37
44
|
"vue": "^3.3.4",
|
|
38
|
-
"@vue-interface/activity-indicator": "3.0.
|
|
39
|
-
"@vue-interface/btn": "
|
|
45
|
+
"@vue-interface/activity-indicator": "3.0.1",
|
|
46
|
+
"@vue-interface/btn": "5.0.0"
|
|
40
47
|
},
|
|
41
48
|
"scripts": {
|
|
42
49
|
"dev": "vite",
|
package/CHANGELOG.md
DELETED
package/demo.css
DELETED
package/docs/btn-activity.md
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Button Activity
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
<script setup>
|
|
6
|
-
import '../demo.css'
|
|
7
|
-
import { ref, onMounted } from 'vue'
|
|
8
|
-
import BtnActivity from '../src/BtnActivity.vue';
|
|
9
|
-
import { Dots, Spinner, Pulse } from '@vue-interface/activity-indicator'
|
|
10
|
-
|
|
11
|
-
const activity = ref(false)
|
|
12
|
-
|
|
13
|
-
/* #region setup */
|
|
14
|
-
const onClick = (event, { toggle }) => {
|
|
15
|
-
toggle()
|
|
16
|
-
|
|
17
|
-
setTimeout(() => {
|
|
18
|
-
toggle()
|
|
19
|
-
}, 2000)
|
|
20
|
-
}
|
|
21
|
-
/* #endregion setup */
|
|
22
|
-
|
|
23
|
-
/* #region activity */
|
|
24
|
-
onMounted(() => {
|
|
25
|
-
const toggle = () => setTimeout(() => {
|
|
26
|
-
activity.value = !activity.value
|
|
27
|
-
toggle()
|
|
28
|
-
}, 1000)
|
|
29
|
-
|
|
30
|
-
toggle()
|
|
31
|
-
})
|
|
32
|
-
/* #endregion activity */
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
# Button Activity
|
|
36
|
-
|
|
37
|
-
The `btn-activity` component provides an interactive button with built-in activity indicators for async operations. It extends the standard [button](/packages/btn/docs/btn) and [activity-indicator](/packages/activity-indicator/docs/activity-indicator) components to create these buttons.
|
|
38
|
-
|
|
39
|
-
## Basic Usage
|
|
40
|
-
|
|
41
|
-
<div class="mb-5 flex gap-2">
|
|
42
|
-
<!-- #region basicUsage -->
|
|
43
|
-
<div><btn-activity :indicator="Dots" @click="onClick">Dots</btn-activity></div>
|
|
44
|
-
<div><btn-activity :indicator="Spinner" @click="onClick">Spinner</btn-activity></div>
|
|
45
|
-
<div><btn-activity :indicator="Pulse" @click="onClick">Pulse</btn-activity></div>
|
|
46
|
-
<!-- #endregion basicUsage -->
|
|
47
|
-
</div>
|
|
48
|
-
|
|
49
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#basicUsage{html}
|
|
50
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#setup{js}
|
|
51
|
-
|
|
52
|
-
## Dots
|
|
53
|
-
|
|
54
|
-
<div class="mb-5 flex gap-2">
|
|
55
|
-
<!-- #region dots -->
|
|
56
|
-
<div><btn-activity :indicator="Dots" size="btn-sm" @click="onClick">Click Me!</btn-activity></div>
|
|
57
|
-
<div><btn-activity :indicator="Dots" size="btn-md" @click="onClick">Click Me!</btn-activity></div>
|
|
58
|
-
<div><btn-activity :indicator="Dots" size="btn-lg" @click="onClick">Click Me!</btn-activity></div>
|
|
59
|
-
<!-- #endregion dots -->
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
::: details Show Code
|
|
63
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#dots{html}
|
|
64
|
-
:::
|
|
65
|
-
|
|
66
|
-
## Spinner
|
|
67
|
-
|
|
68
|
-
<div class="flex gap-2 mb-5">
|
|
69
|
-
<!-- #region spinner -->
|
|
70
|
-
<div><btn-activity :indicator="Spinner" size="btn-sm" @click="onClick">Click Me!</btn-activity></div>
|
|
71
|
-
<div><btn-activity :indicator="Spinner" size="btn-md" @click="onClick">Click Me!</btn-activity></div>
|
|
72
|
-
<div><btn-activity :indicator="Spinner" size="btn-lg" @click="onClick">Click Me!</btn-activity></div>
|
|
73
|
-
<!-- #endregion spinner -->
|
|
74
|
-
</div>
|
|
75
|
-
|
|
76
|
-
::: details Show Code
|
|
77
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#spinner{html}
|
|
78
|
-
:::
|
|
79
|
-
|
|
80
|
-
## Pulse
|
|
81
|
-
|
|
82
|
-
<div class="flex gap-2 mb-5">
|
|
83
|
-
<!-- #region pulse -->
|
|
84
|
-
<div><btn-activity :indicator="Pulse" size="btn-sm" @click="onClick">Click Me!</btn-activity></div>
|
|
85
|
-
<div><btn-activity :indicator="Pulse" size="btn-md" @click="onClick">Click Me!</btn-activity></div>
|
|
86
|
-
<div><btn-activity :indicator="Pulse" size="btn-lg" @click="onClick">Click Me!</btn-activity></div>
|
|
87
|
-
<!-- #endregion pulse -->
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
::: details Show Code
|
|
91
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#pulse{html}
|
|
92
|
-
:::
|
|
93
|
-
|
|
94
|
-
## Orientation
|
|
95
|
-
|
|
96
|
-
Control the position of the activity indicator relative to the button label using the `orientation` prop.
|
|
97
|
-
|
|
98
|
-
<div class="flex gap-2 mb-5">
|
|
99
|
-
<!-- #region orientation -->
|
|
100
|
-
<div><btn-activity :indicator="Spinner" orientation="top" @click="onClick">Orientate Top</btn-activity></div>
|
|
101
|
-
<div><btn-activity :indicator="Spinner" orientation="bottom" @click="onClick">Orientate Bottom</btn-activity></div>
|
|
102
|
-
<div><btn-activity :indicator="Spinner" orientation="left" @click="onClick">Orientate Left</btn-activity></div>
|
|
103
|
-
<div><btn-activity :indicator="Spinner" orientation="right" @click="onClick">Orientate Right</btn-activity></div>
|
|
104
|
-
<!-- #endregion orientation -->
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
::: details Show Code
|
|
108
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#orientation{html}
|
|
109
|
-
:::
|
|
110
|
-
|
|
111
|
-
## Block Activity Buttons
|
|
112
|
-
|
|
113
|
-
Full-width buttons with different indicator orientations using the `block` prop.
|
|
114
|
-
|
|
115
|
-
<div class="flex flex-col gap-4">
|
|
116
|
-
<!-- #region block -->
|
|
117
|
-
<btn-activity :indicator="Spinner" block orientation="top" @click="onClick">Spinner Top</btn-activity>
|
|
118
|
-
<btn-activity :indicator="Spinner" block orientation="bottom" @click="onClick">Spinner Bottom</btn-activity>
|
|
119
|
-
<btn-activity :indicator="Spinner" block orientation="left" @click="onClick">Spinner Left</btn-activity>
|
|
120
|
-
<btn-activity :indicator="Spinner" block orientation="right" @click="onClick">Spinner Right</btn-activity>
|
|
121
|
-
<!-- #endregion block -->
|
|
122
|
-
</div>
|
|
123
|
-
|
|
124
|
-
::: details Show Code
|
|
125
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#block{html}
|
|
126
|
-
:::
|
|
127
|
-
|
|
128
|
-
## Variants
|
|
129
|
-
|
|
130
|
-
Button activity supports all standard button color variants.
|
|
131
|
-
|
|
132
|
-
<div class="flex flex-wrap gap-2 mb-5">
|
|
133
|
-
<!-- #region variants -->
|
|
134
|
-
<btn-activity :indicator="Spinner" variant="btn-secondary" @click="onClick">btn-secondary</btn-activity>
|
|
135
|
-
<btn-activity :indicator="Spinner" variant="btn-warning" @click="onClick">btn-warning</btn-activity>
|
|
136
|
-
<btn-activity :indicator="Spinner" variant="btn-danger" @click="onClick">btn-danger</btn-activity>
|
|
137
|
-
<btn-activity :indicator="Spinner" variant="btn-success" @click="onClick">btn-success</btn-activity>
|
|
138
|
-
<!-- #endregion variants -->
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
::: details Show Code
|
|
142
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#variants{html}
|
|
143
|
-
:::
|
|
144
|
-
|
|
145
|
-
## Activity Attribute
|
|
146
|
-
|
|
147
|
-
Control the activity state programmatically using the `activity` prop.
|
|
148
|
-
|
|
149
|
-
<div class="flex gap-2 mb-5">
|
|
150
|
-
<!-- #region activityAttribute -->
|
|
151
|
-
<btn-activity :indicator="Spinner" :activity="activity">
|
|
152
|
-
{{ activity ? 'On' : 'Off' }}
|
|
153
|
-
</btn-activity>
|
|
154
|
-
<btn-activity :indicator="Spinner" :activity="activity" :disabled="true">
|
|
155
|
-
{{ activity ? 'On' : 'Off' }}
|
|
156
|
-
</btn-activity>
|
|
157
|
-
<!-- #endregion activityAttribute -->
|
|
158
|
-
</div>
|
|
159
|
-
|
|
160
|
-
::: details Show Code
|
|
161
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#activityAttribute{html}
|
|
162
|
-
:::
|
|
163
|
-
|
|
164
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#activity{js}
|
|
165
|
-
|
|
166
|
-
## Disabled State
|
|
167
|
-
|
|
168
|
-
Buttons can be disabled to prevent user interaction.
|
|
169
|
-
|
|
170
|
-
<div class="mb-5">
|
|
171
|
-
<!-- #region disabled -->
|
|
172
|
-
<btn-activity :indicator="Spinner" disabled @click="onClick">Spinner</btn-activity>
|
|
173
|
-
<!-- #endregion disabled -->
|
|
174
|
-
</div>
|
|
175
|
-
|
|
176
|
-
::: details Show Code
|
|
177
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#disabled{html}
|
|
178
|
-
:::
|
|
179
|
-
|
|
180
|
-
## Label Attribute
|
|
181
|
-
|
|
182
|
-
Use the `label` prop to set button text without using the default slot.
|
|
183
|
-
|
|
184
|
-
<div class="mb-5">
|
|
185
|
-
<!-- #region labelAttribute -->
|
|
186
|
-
<btn-activity :indicator="Spinner" label="Some Text Here" @click="onClick"></btn-activity>
|
|
187
|
-
<!-- #endregion labelAttribute -->
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
::: details Show Code
|
|
191
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#labelAttribute{html}
|
|
192
|
-
:::
|
|
193
|
-
|
|
194
|
-
## Custom Element
|
|
195
|
-
|
|
196
|
-
Combine slot content with the label attribute and disabled states.
|
|
197
|
-
|
|
198
|
-
<div class="flex gap-2 mb-5">
|
|
199
|
-
<!-- #region customElement -->
|
|
200
|
-
<btn-activity :indicator="Spinner" @click="onClick">Label</btn-activity>
|
|
201
|
-
<btn-activity :indicator="Spinner" label="Some Text Here" disabled @click="onClick"></btn-activity>
|
|
202
|
-
<!-- #endregion customElement -->
|
|
203
|
-
</div>
|
|
204
|
-
|
|
205
|
-
::: details Show Code
|
|
206
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#customElement{html}
|
|
207
|
-
:::
|
|
208
|
-
|
|
209
|
-
## Click Event
|
|
210
|
-
|
|
211
|
-
The click event handler receives a toggle function to control the activity state.
|
|
212
|
-
|
|
213
|
-
<div class="flex gap-2 mb-5">
|
|
214
|
-
<!-- #region clickEvent -->
|
|
215
|
-
<btn-activity :indicator="Spinner" class="btn-primary" @click="onClick">Enabled</btn-activity>
|
|
216
|
-
<btn-activity :indicator="Spinner" disabled @click="onClick">Disabled</btn-activity>
|
|
217
|
-
<!-- #endregion clickEvent -->
|
|
218
|
-
</div>
|
|
219
|
-
|
|
220
|
-
::: details Show Code
|
|
221
|
-
<<< @/packages/btn-activity/docs/btn-activity.md#clickEvent{html}
|
|
222
|
-
:::
|
package/index.html
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
6
|
-
<title>BtnActivity</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app" class="container mx-auto">
|
|
10
|
-
<h1 class="text-5xl mb-5">btn-activity</h1>
|
|
11
|
-
|
|
12
|
-
<div class="mb-5 flex gap-2">
|
|
13
|
-
<div><btn-activity :indicator="Dots()" @click="onClick">Dots</btn-activity></div>
|
|
14
|
-
<div><btn-activity :indicator="Spinner()" @click="onClick">Spinner</btn-activity></div>
|
|
15
|
-
<div><btn-activity :indicator="Pulse()" @click="onClick">Pulse</btn-activity></div>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<h3 class="text-2xl mt-6 mb-3">Dots</h3>
|
|
19
|
-
|
|
20
|
-
<div class="mb-5 flex gap-2">
|
|
21
|
-
<div><btn-activity :indicator="Dots()" size="btn-sm" @click="onClick">Click Me!</btn-activity></div>
|
|
22
|
-
<div><btn-activity :indicator="Dots()" size="btn-md" @click="onClick">Click Me!</btn-activity></div>
|
|
23
|
-
<div><btn-activity :indicator="Dots()" size="btn-lg" @click="onClick">Click Me!</btn-activity></div>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<h3 class="text-2xl mt-6 mb-3">Spinner</h3>
|
|
27
|
-
|
|
28
|
-
<div class="mb-5 flex gap-2">
|
|
29
|
-
<div><btn-activity :indicator="Spinner()" size="btn-sm" @click="onClick">Click Me!</btn-activity></div>
|
|
30
|
-
<div><btn-activity :indicator="Spinner()" size="btn-md" @click="onClick">Click Me!</btn-activity></div>
|
|
31
|
-
<div><btn-activity :indicator="Spinner()" size="btn-lg" @click="onClick">Click Me!</btn-activity></div>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
<h3 class="text-2xl mt-6 mb-3">Pulse</h3>
|
|
35
|
-
|
|
36
|
-
<div class="mb-5 flex gap-2">
|
|
37
|
-
<div><btn-activity :indicator="Pulse()" size="btn-sm" @click="onClick">Click Me!</btn-activity></div>
|
|
38
|
-
<div><btn-activity :indicator="Pulse()" size="btn-md" @click="onClick">Click Me!</btn-activity></div>
|
|
39
|
-
<div><btn-activity :indicator="Pulse()" size="btn-lg" @click="onClick">Click Me!</btn-activity></div>
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
<h2 class="text-2xl mt-6 mb-3">Orientation</h2>
|
|
43
|
-
|
|
44
|
-
<div class="mb-5 flex gap-2">
|
|
45
|
-
<div><btn-activity :indicator="Spinner()" orientation="top" @click="onClick">Orientate Top</btn-activity></div>
|
|
46
|
-
<div><btn-activity :indicator="Spinner()" orientation="bottom" @click="onClick">Orientate Bottom</btn-activity></div>
|
|
47
|
-
<div><btn-activity :indicator="Spinner()" orientation="left" @click="onClick">Orientate Left</btn-activity></div>
|
|
48
|
-
<div><btn-activity :indicator="Spinner()" orientation="right" @click="onClick">Orientate Right</btn-activity></div>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<h2 class="text-2xl mt-6 mb-3">Block</h2>
|
|
52
|
-
|
|
53
|
-
<div class="mb-5 flex-col gap-4">
|
|
54
|
-
<btn-activity :indicator="Spinner()" block orientation="top" @click="onClick">Spinner Top</btn-activity>
|
|
55
|
-
<btn-activity :indicator="Spinner()" block orientation="bottom" @click="onClick">Spinner Bottom</btn-activity>
|
|
56
|
-
<btn-activity :indicator="Spinner()" block orientation="left" @click="onClick">Spinner Left</btn-activity>
|
|
57
|
-
<btn-activity :indicator="Spinner()" block orientation="right" @click="onClick">Spinner Right</btn-activity>
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
<h2 class="text-2xl mt-6 mb-3">Variants</h2>
|
|
61
|
-
|
|
62
|
-
<div class="mb-5 flex gap-2">
|
|
63
|
-
<btn-activity :indicator="Spinner()" variant="btn-secondary" @click="onClick">btn-success</btn-activity>
|
|
64
|
-
<btn-activity :indicator="Spinner()" variant="btn-warning" @click="onClick">btn-warning</btn-activity>
|
|
65
|
-
<btn-activity :indicator="Spinner()" variant="btn-danger" @click="onClick">btn-danger</btn-activity>
|
|
66
|
-
<btn-activity :indicator="Spinner()" variant="btn-success" @click="onClick">btn-success</btn-activity>
|
|
67
|
-
</div>
|
|
68
|
-
|
|
69
|
-
<h2 class="text-2xl mt-6 mb-3">Activity Attribute</h2>
|
|
70
|
-
|
|
71
|
-
<div class="flex gap-2">
|
|
72
|
-
<btn-activity :indicator="Spinner()" :activity="activity">
|
|
73
|
-
{{ activity ? 'On' : 'Off' }}
|
|
74
|
-
</btn-activity>
|
|
75
|
-
|
|
76
|
-
<btn-activity :indicator="Spinner()" :activity="activity" :disabled="true">
|
|
77
|
-
{{ activity ? 'On' : 'Off' }}
|
|
78
|
-
</btn-activity>
|
|
79
|
-
</div>
|
|
80
|
-
|
|
81
|
-
<h2 class="text-2xl mt-6 mb-3">Disabled</h2>
|
|
82
|
-
|
|
83
|
-
<btn-activity :indicator="Spinner()" disabled @click="onClick">Spinner Top</btn-activity>
|
|
84
|
-
|
|
85
|
-
<h2 class="text-2xl mt-6 mb-3">Label Attribute</h2>
|
|
86
|
-
|
|
87
|
-
<btn-activity :indicator="Spinner()" label="Some Text Here" @click="onClick"></btn-activity>
|
|
88
|
-
|
|
89
|
-
<h3 class="text-2xl mt-6 mb-3">Custom Element</h3>
|
|
90
|
-
|
|
91
|
-
<div class="flex gap-2">
|
|
92
|
-
<btn-activity :indicator="Spinner()" @click="onClick">Label</btn-activity>
|
|
93
|
-
<btn-activity :indicator="Spinner()" label="Some Text Here" disabled @click="onClick"></btn-activity>
|
|
94
|
-
</div>
|
|
95
|
-
|
|
96
|
-
<h3 class="text-2xl mt-6 mb-3">Click Event</h3>
|
|
97
|
-
|
|
98
|
-
<btn-activity :indicator="Spinner()" class="btn-primary mr-1" @click="onClick">Enabled</btn-activity>
|
|
99
|
-
<btn-activity :indicator="Spinner()" disabled @click="onClick">Disabled</btn-activity>
|
|
100
|
-
|
|
101
|
-
</div>
|
|
102
|
-
|
|
103
|
-
<script type="module">
|
|
104
|
-
import './demo.css';
|
|
105
|
-
import { createApp } from 'vue/dist/vue.esm-bundler';
|
|
106
|
-
import { BtnActivity } from './index.ts';
|
|
107
|
-
import { Dots, Spinner, Pulse } from '@vue-interface/activity-indicator';
|
|
108
|
-
|
|
109
|
-
const vue = createApp({
|
|
110
|
-
components: {
|
|
111
|
-
BtnActivity
|
|
112
|
-
},
|
|
113
|
-
methods: {
|
|
114
|
-
onClick(event, { toggle }) {
|
|
115
|
-
toggle();
|
|
116
|
-
|
|
117
|
-
setTimeout(() => {
|
|
118
|
-
toggle();
|
|
119
|
-
}, 2000);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
data() {
|
|
123
|
-
return {
|
|
124
|
-
Dots: () => Dots,
|
|
125
|
-
Spinner: () => Spinner,
|
|
126
|
-
Pulse: () => Pulse,
|
|
127
|
-
activity: false
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
mounted() {
|
|
131
|
-
const toggle = () => setTimeout(() => {
|
|
132
|
-
this.activity = !this.activity;
|
|
133
|
-
|
|
134
|
-
toggle();
|
|
135
|
-
}, 1000);
|
|
136
|
-
|
|
137
|
-
toggle()
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
.mount('#app');
|
|
141
|
-
</script>
|
|
142
|
-
</body>
|
|
143
|
-
</html>
|
package/index.ts
DELETED
package/src/BtnActivity.vue
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { ActivityIndicator } from '@vue-interface/activity-indicator';
|
|
3
|
-
import { ref, watch, watchEffect, type Component, type Ref } from 'vue';
|
|
4
|
-
import { ActivityIndicatorSize } from '../../activity-indicator/src/ActivityIndicator.vue';
|
|
5
|
-
|
|
6
|
-
export type BtnActivityProps = {
|
|
7
|
-
activity?: boolean;
|
|
8
|
-
indicator: Component;
|
|
9
|
-
indicatorSize?: ActivityIndicatorSize;
|
|
10
|
-
label?: string;
|
|
11
|
-
orientation?: 'top' | 'bottom' | 'left' | 'right';
|
|
12
|
-
variant?: string;
|
|
13
|
-
size?: string;
|
|
14
|
-
block?: boolean;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const props = withDefaults(defineProps<BtnActivityProps>(), {
|
|
19
|
-
indicatorSize: 'xs',
|
|
20
|
-
label: undefined,
|
|
21
|
-
orientation: 'right',
|
|
22
|
-
variant: 'btn-primary',
|
|
23
|
-
size: 'btn-md'
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export type BtnActivityContext = {
|
|
27
|
-
status: Ref<boolean>;
|
|
28
|
-
toggle: () => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const emit = defineEmits<{
|
|
32
|
-
click: [event: MouseEvent, context: BtnActivityContext];
|
|
33
|
-
'hide-activity': [];
|
|
34
|
-
'show-activity': [];
|
|
35
|
-
}>();
|
|
36
|
-
|
|
37
|
-
const status = ref(props.activity);
|
|
38
|
-
|
|
39
|
-
watchEffect(() => {
|
|
40
|
-
status.value = props.activity;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
watch(status, (value) => {
|
|
44
|
-
if(value) {
|
|
45
|
-
emit('show-activity');
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
emit('hide-activity');
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
function toggle() {
|
|
53
|
-
status.value = !status.value;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const context = {
|
|
57
|
-
status,
|
|
58
|
-
toggle,
|
|
59
|
-
};
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<template>
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
:disabled="disabled"
|
|
66
|
-
:class="[
|
|
67
|
-
'btn',
|
|
68
|
-
variant,
|
|
69
|
-
size,
|
|
70
|
-
{
|
|
71
|
-
'w-full': block,
|
|
72
|
-
'gap-1': ['xs', 'sm'].includes(indicatorSize),
|
|
73
|
-
'gap-2': ['md', 'lg', 'xl'].includes(indicatorSize),
|
|
74
|
-
'flex-col-reverse': orientation === 'top',
|
|
75
|
-
'flex-col': orientation === 'bottom',
|
|
76
|
-
'flex-row-reverse': orientation === 'left',
|
|
77
|
-
'inline-flex items-center justify-center': true,
|
|
78
|
-
'opacity-50 cursor-not-allowed': disabled,
|
|
79
|
-
}
|
|
80
|
-
]"
|
|
81
|
-
@click="emit('click', $event, context)">
|
|
82
|
-
<slot>{{ label }}</slot>
|
|
83
|
-
<Transition
|
|
84
|
-
enter-active-class="transition-all ease-out duration-250"
|
|
85
|
-
enter-from-class="opacity-0"
|
|
86
|
-
enter-to-class="opacity-100"
|
|
87
|
-
leave-active-class="transition-all ease-in duration-250"
|
|
88
|
-
leave-from-class="opacity-100"
|
|
89
|
-
leave-to-class="opacity-0">
|
|
90
|
-
<ActivityIndicator
|
|
91
|
-
v-if="status"
|
|
92
|
-
:type="indicator"
|
|
93
|
-
:size="indicatorSize"
|
|
94
|
-
:class="{
|
|
95
|
-
'pt-1': orientation === 'top',
|
|
96
|
-
'pb-1': orientation === 'bottom',
|
|
97
|
-
'pr-1': orientation === 'left',
|
|
98
|
-
'pl-1': orientation === 'right',
|
|
99
|
-
}" />
|
|
100
|
-
</Transition>
|
|
101
|
-
</button>
|
|
102
|
-
</template>
|
package/tsconfig.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"moduleResolution": "bundler",
|
|
9
|
-
"customConditions": ["source"],
|
|
10
|
-
"allowImportingTsExtensions": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"noEmit": true,
|
|
14
|
-
"strict": true,
|
|
15
|
-
"noUnusedLocals": true,
|
|
16
|
-
"noUnusedParameters": true,
|
|
17
|
-
"noFallthroughCasesInSwitch": true,
|
|
18
|
-
"jsx": "preserve",
|
|
19
|
-
"jsxImportSource": "vue"
|
|
20
|
-
},
|
|
21
|
-
"include": [
|
|
22
|
-
"index.ts",
|
|
23
|
-
"src/*.ts",
|
|
24
|
-
"src/*.vue",
|
|
25
|
-
],
|
|
26
|
-
"exclude": ["node_modules"]
|
|
27
|
-
}
|
package/vite.config.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import tailwindcss from '@tailwindcss/vite';
|
|
2
|
-
import vue from '@vitejs/plugin-vue';
|
|
3
|
-
import { pascalCase } from 'change-case';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { defineConfig } from 'vite';
|
|
6
|
-
import dts from 'vite-plugin-dts';
|
|
7
|
-
import pkg from './package.json';
|
|
8
|
-
|
|
9
|
-
const fileName = pkg.name.split('/')[1];
|
|
10
|
-
|
|
11
|
-
const external = [
|
|
12
|
-
...(pkg.dependencies ? Object.keys(pkg.dependencies) : []),
|
|
13
|
-
...(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [])
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export default ({ command }) => defineConfig({
|
|
17
|
-
build: {
|
|
18
|
-
sourcemap: command === 'build',
|
|
19
|
-
lib: {
|
|
20
|
-
entry: path.resolve(__dirname, 'index.ts'),
|
|
21
|
-
name: pascalCase(fileName),
|
|
22
|
-
fileName,
|
|
23
|
-
},
|
|
24
|
-
rollupOptions: {
|
|
25
|
-
external,
|
|
26
|
-
output: {
|
|
27
|
-
globals: external.reduce((carry, dep) => {
|
|
28
|
-
return Object.assign(carry, {
|
|
29
|
-
[dep]: pascalCase(dep)
|
|
30
|
-
});
|
|
31
|
-
}, {}),
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
watch: !process.env.NODE_ENV && {
|
|
35
|
-
include: [
|
|
36
|
-
'./tailwindcss/**/*.js'
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
plugins: [
|
|
41
|
-
vue(),
|
|
42
|
-
dts({
|
|
43
|
-
entryRoot: path.resolve(__dirname, './'),
|
|
44
|
-
}),
|
|
45
|
-
tailwindcss()
|
|
46
|
-
],
|
|
47
|
-
});
|