| 123456 |
- var q=Object.defineProperty,F=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var P=(r,l,o)=>l in r?q(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)=>F(r,j(l));import{b as H,c as I,m as R,d as A,b0 as E,r as _,ad as G,w as K,as as L,ai as N,b1 as U,aj as Q,f as X,o as J,g as k,h as y,j as Y,n as B,k as V,a7 as Z,a4 as W,q as ee}from"./index-C2C--_0G.js";import{q as ae,r as se,p as le,c as te}from"./clickoutside.BhsqYzww.js";import{u as oe}from"./useTouch.THbm70v3.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,p=o,c=E(ae,null),T=_(""),u=_(0),t=_(0),v=_(!1),m=oe(),{proxy:d}=G();K(()=>i.modelValue,(e,a)=>{S(e,a)},{deep:!0}),L(()=>{c&&c.pushToQueue?c.pushToQueue(d):le(d),u.value=0,t.value=0,v.value=!1}),N(()=>{v.value=!0,S(i.modelValue),v.value=!1}),U(()=>{c&&c.removeFromQueue?c.removeFromQueue(d):se(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=v.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),p("click",{value:e}))}function w(e){i.disabled||(u.value=t.value,m.touchStart(e),c&&c.closeOther?c.closeOther(d):te(d))}function D(e){if(i.disabled||(m.touchMove(e),m.direction.value==="vertical"))return;e.preventDefault(),e.stopPropagation(),v.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;v.value=!1,h().then(([a,s])=>{u.value<0&&t.value<0&&t.value-u.value<s*e?(n(-s),p("update:modelValue","right")):u.value>0&&t.value>0&&u.value-t.value<a*e?(n(a),p("update:modelValue","left")):s>0&&u.value>=0&&t.value<0&&Math.abs(t.value)>s*e?(n(-s),p("update:modelValue","right")):a>0&&u.value<=0&&t.value>0&&Math.abs(t.value)>a*e?(n(a),p("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"&&p("update:modelValue","close")}return l({close:b}),(e,a)=>{const s=Y;return J(),X(s,{class:W(`wd-swipe-action ${e.customClass}`),style:B(e.customStyle),onClick:a[2]||(a[2]=Z(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"])}}})),pe=ee(re,[["__scopeId","data-v-ec0f42c7"]]);export{pe as _};
|