| 123456 |
- var F=Object.defineProperty,j=Object.defineProperties;var q=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var P=(r,l,o)=>l in r?F(r,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[l]=o,C=(r,l)=>{for(var o in l||(l={}))x.call(l,o)&&P(r,o,l[o]);if(O)for(var o of O(l))z.call(l,o)&&P(r,o,l[o]);return r},$=(r,l)=>j(r,q(l));import{b as H,c as I,m as R,d as A,b2 as E,b3 as G,r as _,ad as K,w as L,as as N,b4 as U,ai as X,b5 as J,b6 as Y,aj as Q,f as Z,o as W,g as k,h as y,j as ee,n as B,k as V,a7 as ae,a4 as se,b7 as le,q as te}from"./index-q8TQmcfk.js";import{u as oe}from"./useTouch.BnlusLLU.js";const ue=$(C({},H),{modelValue:R("close"),disabled:I(!1),beforeClose:Function}),ne={name:"wd-swipe-action",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"}},re=A($(C({},ne),{props:ue,emits:["click","update:modelValue"],setup(r,{expose:l,emit:o}){const i=r,v=o,c=E(G,null),T=_(""),u=_(0),t=_(0),p=_(!1),m=oe(),{proxy:d}=K();L(()=>i.modelValue,(e,a)=>{S(e,a)},{deep:!0}),N(()=>{c&&c.pushToQueue?c.pushToQueue(d):U(d),u.value=0,t.value=0,p.value=!1}),X(()=>{p.value=!0,S(i.modelValue),p.value=!1}),J(()=>{c&&c.removeFromQueue?c.removeFromQueue(d):Y(d)});function S(e,a){i.disabled||h().then(([s,f])=>{switch(e){case"close":if(t.value===0)return;b("value",a);break;case"left":n(s);break;case"right":n(-f);break}})}function h(){return Promise.all([Q(".wd-swipe-action__left",!1,d).then(e=>e.width?e.width:0),Q(".wd-swipe-action__right",!1,d).then(e=>e.width?e.width:0)])}function n(e=0){const a=`translate3d(${e}px, 0, 0)`,s=p.value?"none":".6s cubic-bezier(0.18, 0.89, 0.32, 1)";T.value=`
- -webkit-transform: ${a};
- -webkit-transition: ${s};
- transform: ${a};
- transition: ${s};
- `,t.value=e}function g(e){i.disabled||t.value===0||(e=e||"inside",b("click",e),v("click",{value:e}))}function w(e){i.disabled||(u.value=t.value,m.touchStart(e),c&&c.closeOther?c.closeOther(d):le(d))}function D(e){if(i.disabled||(m.touchMove(e),m.direction.value==="vertical"))return;e.preventDefault(),e.stopPropagation(),p.value=!0;const a=u.value+m.deltaX.value;h().then(([s,f])=>{if(s===0&&a>0||f===0&&a<0)return n(0),w(e);if(s!==0&&a>=s)return n(s),w(e);if(f!==0&&-a>=f)return n(-f),w(e);n(a)})}function M(){if(i.disabled)return;const e=.3;p.value=!1,h().then(([a,s])=>{u.value<0&&t.value<0&&t.value-u.value<s*e?(n(-s),v("update:modelValue","right")):u.value>0&&t.value>0&&u.value-t.value<a*e?(n(a),v("update:modelValue","left")):s>0&&u.value>=0&&t.value<0&&Math.abs(t.value)>s*e?(n(-s),v("update:modelValue","right")):a>0&&u.value<=0&&t.value>0&&Math.abs(t.value)>a*e?(n(a),v("update:modelValue","left")):b("swipe")})}function b(e,a){if(e==="swipe"&&u.value===0)return n(0);e==="swipe"&&u.value>0?a="left":e==="swipe"&&u.value<0&&(a="right"),e&&a&&i.beforeClose&&i.beforeClose(e,a),n(0),i.modelValue!=="close"&&v("update:modelValue","close")}return l({close:b}),(e,a)=>{const s=ee;return W(),Z(s,{class:se(`wd-swipe-action ${e.customClass}`),style:B(e.customStyle),onClick:a[2]||(a[2]=ae(f=>g(),["stop"])),onTouchstart:w,onTouchmove:D,onTouchend:M,onTouchcancel:M},{default:k(()=>[y(s,{class:"wd-swipe-action__wrapper",style:B(T.value)},{default:k(()=>[y(s,{class:"wd-swipe-action__left",onClick:a[0]||(a[0]=f=>g("left"))},{default:k(()=>[V(e.$slots,"left",{},void 0,!0)]),_:3}),V(e.$slots,"default",{},void 0,!0),y(s,{class:"wd-swipe-action__right",onClick:a[1]||(a[1]=f=>g("right"))},{default:k(()=>[V(e.$slots,"right",{},void 0,!0)]),_:3})]),_:3},8,["style"])]),_:3},8,["class","style"])}}})),de=te(re,[["__scopeId","data-v-ec0f42c7"]]);export{de as _};
|