vant/v3/assets/index.d6ef702b.js
2024-04-20 08:49:23 +00:00

2 lines
4.5 KiB
JavaScript

import{c as U,i as W,r as z,Y as I,n as M,l as O,F as j,a as X}from"./use-translate.d2900b8c.js";import{c as Y,n as P,w as $}from"./with-install.19a35764.js";import{c as G}from"./interceptor.f0c85874.js";import{u as J}from"./use-touch.04ca7093.js";import{u as K}from"./use-expose.c942d5f8.js";import{z as q,C as _,H as Q,D as V,e as l,r as Z,o as ee,a as te,w as r,B as t,F as oe}from"./vue-libs.b44bc779.js";import{V as p}from"./index.8e37fe56.js";import{V as R}from"./index.bbd81525.js";import{V as le}from"./index.628e86fc.js";import{c as ne}from"./index.d8fe3225.js";import{D as ae}from"./function-call.88939e57.js";import"./constant.80c6de18.js";import"./use-route.82f2be69.js";import"./index.b70c9b40.js";import"./index.4e4daaac.js";import"./index.4d1fb3f9.js";import"./index.45d743b7.js";import"./mount-component.f3744995.js";import"./index.e6e790ed.js";import"./use-lazy-render.f712e85e.js";import"./on-popup-reopen.138c77eb.js";import"./index.d46e53a8.js";import"./index.1e164870.js";import"./use-placeholder.7306f9cf.js";import"./use-height.f6deaa0a.js";const[se,b]=U("swipe-cell"),re={name:Y(""),disabled:Boolean,leftWidth:P,rightWidth:P,beforeClose:Function,stopPropagation:Boolean},ie=q({name:se,props:re,emits:["open","close","click"],setup(n,{emit:o,slots:m}){let i,u,d;const f=_(),w=_(),y=_(),a=Q({offset:0,dragging:!1}),g=J(),k=e=>e.value?z(e).width:0,h=V(()=>W(n.leftWidth)?+n.leftWidth:k(w)),C=V(()=>W(n.rightWidth)?+n.rightWidth:k(y)),T=e=>{a.offset=e==="left"?h.value:-C.value,i||(i=!0,o("open",{name:n.name,position:e}))},v=e=>{a.offset=0,i&&(i=!1,o("close",{name:n.name,position:e}))},A=e=>{const s=Math.abs(a.offset),c=.15,L=i?1-c:c,F=e==="left"?h.value:C.value;F&&s>F*L?T(e):v(e)},H=e=>{n.disabled||(d=a.offset,g.start(e))},N=e=>{if(n.disabled)return;const{deltaX:s}=g;g.move(e),g.isHorizontal()&&(u=!0,a.dragging=!0,(!i||s.value*d<0)&&O(e,n.stopPropagation),a.offset=j(s.value+d,-C.value,h.value))},B=()=>{a.dragging&&(a.dragging=!1,A(a.offset>0?"left":"right"),setTimeout(()=>{u=!1},0))},E=(e="outside")=>{o("click",e),i&&!u&&G(n.beforeClose,{args:[{name:n.name,position:e}],done:()=>v(e)})},S=(e,s)=>c=>{s&&c.stopPropagation(),E(e)},D=(e,s)=>{const c=m[e];if(c)return l("div",{ref:s,class:b(e),onClick:S(e,!0)},[c()])};return K({open:T,close:v}),I(f,()=>E("outside"),{eventName:"touchstart"}),M("touchmove",N,{target:f}),()=>{var s;const e={transform:`translate3d(${a.offset}px, 0, 0)`,transitionDuration:a.dragging?"0s":".6s"};return l("div",{ref:f,class:b(),onClick:S("cell",u),onTouchstartPassive:H,onTouchend:B,onTouchcancel:B},[l("div",{class:b("wrapper"),style:e},[D("left",w),(s=m.default)==null?void 0:s.call(m),D("right",y)])])}}}),ce=$(ie),x=ce,qe=q({__name:"index",setup(n){const o=X({"zh-CN":{select:"\u9009\u62E9",delete:"\u5220\u9664",collect:"\u6536\u85CF",title:"\u5355\u5143\u683C",confirm:"\u786E\u5B9A\u5220\u9664\u5417\uFF1F",cardTitle:"\u5546\u54C1\u6807\u9898",beforeClose:"\u5F02\u6B65\u5173\u95ED",customContent:"\u81EA\u5B9A\u4E49\u5185\u5BB9"},"en-US":{select:"Select",delete:"Delete",collect:"Collect",title:"Cell",confirm:"Are you sure to delete?",cardTitle:"Title",beforeClose:"Before Close",customContent:"Custom Content"}}),m=ne("ipad.jpeg"),i=({position:u})=>{switch(u){case"left":case"cell":case"outside":return!0;case"right":return new Promise(d=>{ae.confirm({title:o("confirm")}).then(()=>{d(!0)})})}};return(u,d)=>{const f=Z("demo-block");return ee(),te(oe,null,[l(f,{title:t(o)("basicUsage")},{default:r(()=>[l(t(x),null,{left:r(()=>[l(t(p),{square:"",type:"primary",text:t(o)("select")},null,8,["text"])]),right:r(()=>[l(t(p),{square:"",type:"danger",text:t(o)("delete")},null,8,["text"]),l(t(p),{square:"",type:"primary",text:t(o)("collect")},null,8,["text"])]),default:r(()=>[l(t(R),{border:!1,title:t(o)("title"),value:t(o)("content")},null,8,["title","value"])]),_:1})]),_:1},8,["title"]),l(f,{title:t(o)("customContent")},{default:r(()=>[l(t(x),null,{right:r(()=>[l(t(p),{square:"",type:"danger",class:"delete-button",text:t(o)("delete")},null,8,["text"])]),default:r(()=>[l(t(le),{num:"2",price:"2.00",desc:t(o)("desc"),title:t(o)("cardTitle"),thumb:t(m)},null,8,["desc","title","thumb"])]),_:1})]),_:1},8,["title"]),l(f,{title:t(o)("beforeClose")},{default:r(()=>[l(t(x),{"before-close":i},{left:r(()=>[l(t(p),{square:"",type:"primary",text:t(o)("select")},null,8,["text"])]),right:r(()=>[l(t(p),{square:"",type:"danger",text:t(o)("delete")},null,8,["text"])]),default:r(()=>[l(t(R),{border:!1,title:t(o)("title"),value:t(o)("content")},null,8,["title","value"])]),_:1})]),_:1},8,["title"])],64)}}});export{qe as default};