UNPKG

@vue-nextui/button

Version:

```bash npm add @vue-nextui/button @nextui-org/theme ```

1 lines 5.32 kB
import*as e from"vue";import{createElementBlock as t,defineComponent as n,mergeProps as r,openBlock as i,ref as a,renderSlot as o,useAttrs as s,watch as c}from"vue";import{button as l}from"@heroui/theme";import{useRipple as u}from"@vue-nextui/shared";var d=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,m=Object.prototype.hasOwnProperty,h=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=p(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&d(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=f(t,s))||r.enumerable});return e},_=(e,t,n)=>(g(e,t,`default`),n&&g(n,t,`default`)),v={};h(v,{Vue:()=>e,Vue2:()=>S,del:()=>T,install:()=>C,isVue2:()=>b,isVue3:()=>x,set:()=>w});import*as y from"vue";_(v,y);var b=!1,x=!0,S=void 0;function C(){}function w(e,t,n){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,n),n):(e[t]=n,n)}function T(e,t){if(Array.isArray(e)){e.splice(t,1);return}delete e[t]}function E(e){return(0,v.getCurrentScope)()?((0,v.onScopeDispose)(e),!0):!1}function D(e){return typeof e==`function`?e():(0,v.unref)(e)}const O=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;const k=Object.prototype.toString,A=e=>k.call(e)===`[object Object]`,j=()=>{};function M(e){let t=Object.create(null);return n=>{let r=t[n];return r||(t[n]=e(n))}}const N=/\B([A-Z])/g;M(e=>e.replace(N,`-$1`).toLowerCase());const P=/-(\w)/g;M(e=>e.replace(P,(e,t)=>t?t.toUpperCase():``));const F=O?window:void 0;O&&window.document,O&&window.navigator,O&&window.location;function I(e){var t;let n=D(e);return(t=n?.$el)??n}function L(...e){let t,n,r,i;if(typeof e[0]==`string`||Array.isArray(e[0])?([n,r,i]=e,t=F):[t,n,r,i]=e,!t)return j;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);let a=[],o=()=>{a.forEach(e=>e()),a.length=0},s=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),c=(0,v.watch)(()=>[I(t),D(i)],([e,t])=>{if(o(),!e)return;let i=A(t)?{...t}:t;a.push(...n.flatMap(t=>r.map(n=>s(e,t,n,i))))},{immediate:!0,flush:`post`}),l=()=>{c(),o()};return E(l),l}function R(e,t={}){let{delayEnter:n=0,delayLeave:r=0,window:i=F}=t,a=(0,v.ref)(!1),o,s=e=>{let t=e?n:r;o&&(clearTimeout(o),o=void 0),t?o=setTimeout(()=>a.value=e,t):a.value=e};return i?(L(e,`mouseenter`,()=>s(!0),{passive:!0}),L(e,`mouseleave`,()=>s(!1),{passive:!0}),a):a}function z(e,t={}){let{initialValue:n=!1,focusVisible:r=!1,preventScroll:i=!1}=t,a=(0,v.ref)(!1),o=(0,v.computed)(()=>I(e));L(o,`focus`,e=>{var t,n;(!r||(n=(t=e.target).matches)?.call(t,`:focus-visible`))&&(a.value=!0)}),L(o,`blur`,()=>a.value=!1);let s=(0,v.computed)({get:()=>a.value,set(e){var t,n;!e&&a.value?(t=o.value)==null||t.blur():e&&!a.value&&((n=o.value)==null||n.focus({preventScroll:i}))}});return(0,v.watch)(o,()=>{s.value=n},{immediate:!0,flush:`post`}),{focused:s}}function B(e={}){let{touch:t=!0,drag:n=!0,capture:r=!1,initialValue:i=!1,window:a=F}=e,o=(0,v.ref)(i),s=(0,v.ref)(null);if(!a)return{pressed:o,sourceType:s};let c=e=>()=>{o.value=!0,s.value=e},l=()=>{o.value=!1,s.value=null},u=(0,v.computed)(()=>I(e.target)||a);return L(u,`mousedown`,c(`mouse`),{passive:!0,capture:r}),L(a,`mouseleave`,l,{passive:!0,capture:r}),L(a,`mouseup`,l,{passive:!0,capture:r}),n&&(L(u,`dragstart`,c(`mouse`),{passive:!0,capture:r}),L(a,`drop`,l,{passive:!0,capture:r}),L(a,`dragend`,l,{passive:!0,capture:r})),t&&(L(u,`touchstart`,c(`touch`),{passive:!0,capture:r}),L(a,`touchend`,l,{passive:!0,capture:r}),L(a,`touchcancel`,l,{passive:!0,capture:r})),{pressed:o,sourceType:s}}process.env.NODE_ENV,process.env.NODE_ENV;var V=e=>e?`true`:void 0;function H(e,t){let n=s(),r=a(),{focused:i}=z(t),{pressed:o}=B({target:t}),d=R(t);return u(t),c([e,i,o,d],([e={},t,i,a])=>{let{class:o,isLoading:s=!1,disableRipple:c=!1,fullWidth:u=!1,radius:d,size:f=`md`,color:p=`default`,variant:m=`solid`,disableAnimation:h=!1,isDisabled:g=!1,isIconOnly:_=!1,spinnerPlacement:v=`start`}={...e,...n},y=g||s,b=l({size:f,color:p,variant:m,radius:d,fullWidth:u,isDisabled:y,isInGroup:!1,disableAnimation:h,isIconOnly:_,className:o});r.value={"data-disabled":V(!!y),"data-focus":V(!!t),"data-pressed":V(!!i),"data-focus-visible":V(!1),"data-hover":V(!!a),"data-loading":V(!!s),class:b}},{immediate:!0}),r}var U=n({__name:`Button`,props:{isLoading:{type:Boolean,required:!1},disableRipple:{type:Boolean,required:!1},spinnerPlacement:{type:String,required:!1},as:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},color:{type:null,required:!1},radius:{type:null,required:!1},fullWidth:{type:null,required:!1},isDisabled:{type:null,required:!1},isIconOnly:{type:null,required:!1},disableAnimation:{type:null,required:!1}},setup(e,{expose:t}){t();let n=e,r=a(),i=H(n,r),o={props:n,buttonRef:r,bind:i};return Object.defineProperty(o,`__isScriptSetup`,{enumerable:!1,value:!0}),o}}),W=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n};function G(e,n,a,s,c,l){return i(),t(`button`,r({ref:`buttonRef`},s.bind),[o(e.$slots,`startContent`),o(e.$slots,`spinner`),o(e.$slots,`default`),o(e.$slots,`endContent`)],16)}var K=W(U,[[`render`,G],[`__file`,`/home/runner/work/nextui-vue/nextui-vue/packages/components/button/src/Button.vue`]]);export{K as Button};