12345 |
- <<<<<<<< HEAD:dist/assets/index-cbfe6e55.js
- import{j as V,aw as be,A as E,ak as G,d as $,t as K,ag as I,q as _,i as y,ah as Te,ae as oe,an as le,k as xe,ai as ce,g as d,aj as ie,aq as X,ac as se,p as J,am as Y,v as Oe,n as ke,E as C,aU as pe,w as j,aN as L,a9 as Ce,m as ye,y as Z,aV as Ee,D as Pe}from"./index-6ef77773.js";import{T as we,a as Se}from"./index-e5198b82.js";const[Ne,O,ee]=V("picker"),ue=e=>e.find(o=>!o.disabled)||e[0];function Be(e,o){const n=e[0];if(n){if(Array.isArray(n))return"multiple";if(o.children in n)return"cascade"}return"default"}function Q(e,o){o=G(o,0,e.length);for(let n=o;n<e.length;n++)if(!e[n].disabled)return n;for(let n=o-1;n>=0;n--)if(!e[n].disabled)return n;return 0}const te=(e,o,n)=>o!==void 0&&!!e.find(i=>i[n.value]===o);function W(e,o,n){const i=e.findIndex(h=>h[n.value]===o),l=Q(e,i);return e[l]}function De(e,o,n){const i=[];let l={[o.children]:e},h=0;for(;l&&l[o.children];){const f=l[o.children],g=n.value[h];if(l=be(g)?W(f,g,o):void 0,!l&&f.length){const u=ue(f)[o.value];l=W(f,u,o)}h++,i.push(f)}return i}function He(e){const{transform:o}=window.getComputedStyle(e),n=o.slice(7,o.length-1).split(", ")[5];return Number(n)}function Me(e){return E({text:"text",value:"value",children:"children"},e)}const ne=200,ae=300,Ie=15,[re,q]=V("picker-column"),de=Symbol(re);var _e=$({name:re,props:{value:K,fields:I(Object),options:_(),readonly:Boolean,allowHtml:Boolean,optionHeight:I(Number),swipeDuration:I(K),visibleOptionNum:I(K)},emits:["change","clickOption"],setup(e,{emit:o,slots:n}){let i,l,h,f,g;const u=y(),b=y(),m=y(0),v=y(0),T=Te(),k=()=>e.options.length,w=()=>e.optionHeight*(+e.visibleOptionNum-1)/2,p=c=>{const r=Q(e.options,c),t=-r*e.optionHeight,a=()=>{const s=e.options[r][e.fields.value];s!==e.value&&o("change",s)};i&&t!==m.value?g=a:a(),m.value=t},x=()=>e.readonly||!e.options.length,A=c=>{i||x()||(g=null,v.value=ne,p(c),o("clickOption",e.options[c]))},S=c=>G(Math.round(-c/e.optionHeight),0,k()-1),N=(c,r)=>{const t=Math.abs(c/r);c=m.value+t/.003*(c<0?-1:1);const a=S(c);v.value=+e.swipeDuration,p(a)},B=()=>{i=!1,v.value=0,g&&(g(),g=null)},U=c=>{if(!x()){if(T.start(c),i){const r=He(b.value);m.value=Math.min(0,r-w())}v.value=0,l=m.value,h=Date.now(),f=l,g=null}},F=c=>{if(x())return;T.move(c),T.isVertical()&&(i=!0,ie(c,!0)),m.value=G(l+T.deltaY.value,-(k()*e.optionHeight),e.optionHeight);const r=Date.now();r-h>ae&&(h=r,f=m.value)},D=()=>{if(x())return;const c=m.value-f,r=Date.now()-h;if(r<ae&&Math.abs(c)>Ie){N(c,r);return}const a=S(m.value);v.value=ne,p(a),setTimeout(()=>{i=!1},0)},H=()=>{const c={height:`${e.optionHeight}px`};return e.options.map((r,t)=>{const a=r[e.fields.text],{disabled:s}=r,M=r[e.fields.value],P={role:"button",style:c,tabindex:s?-1:0,class:[q("item",{disabled:s,selected:M===e.value}),r.className],onClick:()=>A(t)},ge={class:"van-ellipsis",[e.allowHtml?"innerHTML":"textContent"]:a};return d("li",P,[n.option?n.option(r,t):d("div",ge,null)])})};return oe(de),le({stopMomentum:B}),xe(()=>{const c=e.options.findIndex(a=>a[e.fields.value]===e.value),t=-Q(e.options,c)*e.optionHeight;m.value=t}),ce("touchmove",F,{target:u}),()=>d("div",{ref:u,class:q(),onTouchstartPassive:U,onTouchend:D,onTouchcancel:D},[d("ul",{ref:b,style:{transform:`translate3d(0, ${m.value+w()}px, 0)`,transitionDuration:`${v.value}ms`,transitionProperty:v.value?"all":"none"},class:q("wrapper"),onTransitionend:B},[H()])])}});const[Ve]=V("picker-toolbar"),R={title:String,cancelButtonText:String,confirmButtonText:String},me=["cancel","confirm","title","toolbar"],$e=Object.keys(R);var fe=$({name:Ve,props:R,emits:["confirm","cancel"],setup(e,{emit:o,slots:n}){const i=()=>{if(n.title)return n.title();if(e.title)return d("div",{class:[O("title"),"van-ellipsis"]},[e.title])},l=()=>o("cancel"),h=()=>o("confirm"),f=()=>{const u=e.cancelButtonText||ee("cancel");return d("button",{type:"button",class:[O("cancel"),X],onClick:l},[n.cancel?n.cancel():u])},g=()=>{const u=e.confirmButtonText||ee("confirm");return d("button",{type:"button",class:[O("confirm"),X],onClick:h},[n.confirm?n.confirm():u])};return()=>d("div",{class:O("toolbar")},[n.toolbar?n.toolbar():[f(),i(),g()]])}});const[ve,z]=V("picker-group"),he=Symbol(ve),Re=E({tabs:_(),nextStepText:String},R);$({name:ve,props:Re,emits:["confirm","cancel"],setup(e,{emit:o,slots:n}){const i=y(0),{children:l,linkChildren:h}=se(he);h();const f=()=>i.value<e.tabs.length-1&&e.nextStepText,g=()=>{f()?i.value++:o("confirm",l.map(b=>b.confirm()))},u=()=>o("cancel");return()=>{var b;const m=(b=n.default)==null?void 0:b.call(n),v=f()?e.nextStepText:e.confirmButtonText;return d("div",{class:z()},[d(fe,{title:e.title,cancelButtonText:e.cancelButtonText,confirmButtonText:v,onConfirm:g,onCancel:u},J(n,me)),d(we,{active:i.value,"onUpdate:active":T=>i.value=T,class:z("tabs"),shrink:!0,animated:!0,lazyRender:!1},{default:()=>[e.tabs.map((T,k)=>d(Se,{title:T,titleClass:z("tab-title")},{default:()=>[m==null?void 0:m[k]]}))]})])}}});const Ae=E({loading:Boolean,readonly:Boolean,allowHtml:Boolean,optionHeight:Y(44),showToolbar:Oe,swipeDuration:Y(1e3),visibleOptionNum:Y(6)},R),Ue=E({},Ae,{columns:_(),modelValue:_(),toolbarPosition:ke("top"),columnsFieldNames:Object});var Fe=$({name:Ne,props:Ue,emits:["confirm","cancel","change","clickOption","update:modelValue"],setup(e,{emit:o,slots:n}){const i=y(),l=y(e.modelValue.slice(0)),{parent:h}=oe(he),{children:f,linkChildren:g}=se(de);g();const u=C(()=>Me(e.columnsFieldNames)),b=C(()=>pe(e.optionHeight)),m=C(()=>Be(e.columns,u.value)),v=C(()=>{const{columns:t}=e;switch(m.value){case"multiple":return t;case"cascade":return De(t,u.value,l);default:return[t]}}),T=C(()=>v.value.some(t=>t.length)),k=C(()=>v.value.map((t,a)=>W(t,l.value[a],u.value))),w=C(()=>v.value.map((t,a)=>t.findIndex(s=>s[u.value.value]===l.value[a]))),p=(t,a)=>{if(l.value[t]!==a){const s=l.value.slice(0);s[t]=a,l.value=s}},x=()=>({selectedValues:l.value.slice(0),selectedOptions:k.value,selectedIndexes:w.value}),A=(t,a)=>{p(a,t),m.value==="cascade"&&l.value.forEach((s,M)=>{const P=v.value[M];te(P,s,u.value)||p(M,P.length?P[0][u.value.value]:void 0)}),Z(()=>{o("change",E({columnIndex:a},x()))})},S=(t,a)=>o("clickOption",E({columnIndex:a,currentOption:t},x())),N=()=>{f.forEach(a=>a.stopMomentum());const t=x();return Z(()=>{o("confirm",t)}),t},B=()=>o("cancel",x()),U=()=>v.value.map((t,a)=>d(_e,{value:l.value[a],fields:u.value,options:t,readonly:e.readonly,allowHtml:e.allowHtml,optionHeight:b.value,swipeDuration:e.swipeDuration,visibleOptionNum:e.visibleOptionNum,onChange:s=>A(s,a),onClickOption:s=>S(s,a)},{option:n.option})),F=t=>{if(T.value){const a={height:`${b.value}px`},s={backgroundSize:`100% ${(t-b.value)/2}px`};return[d("div",{class:O("mask"),style:s},null),d("div",{class:[Ee,O("frame")],style:a},null)]}},D=()=>{const t=b.value*+e.visibleOptionNum,a={height:`${t}px`};return d("div",{ref:i,class:O("columns"),style:a},[U(),F(t)])},H=()=>{if(e.showToolbar&&!h)return d(fe,ye(J(e,$e),{onConfirm:N,onCancel:B}),J(n,me))};j(v,t=>{t.forEach((a,s)=>{a.length&&!te(a,l.value[s],u.value)&&p(s,ue(a)[u.value.value])})},{immediate:!0});let c;return j(()=>e.modelValue,t=>{!L(t,l.value)&&!L(t,c)&&(l.value=t.slice(0),c=t.slice(0))},{deep:!0}),j(l,t=>{L(t,e.modelValue)||(c=t.slice(0),o("update:modelValue",c))},{immediate:!0}),ce("touchmove",ie,{target:i}),le({confirm:N,getSelectedOptions:()=>k.value}),()=>{var t,a;return d("div",{class:O()},[e.toolbarPosition==="top"?H():null,e.loading?d(Ce,{class:O("loading")},null):null,(t=n["columns-top"])==null?void 0:t.call(n),D(),(a=n["columns-bottom"])==null?void 0:a.call(n),e.toolbarPosition==="bottom"?H():null])}}});const je=Pe(Fe);export{je as P,Ae as p};
- ========
- import{j as V,aw as be,A as E,ak as G,d as $,t as K,ag as I,q as _,i as y,ah as Te,ae as oe,an as le,k as xe,ai as ce,g as d,aj as ie,aq as X,ac as se,p as J,am as Y,v as Oe,n as ke,E as C,aU as pe,w as j,aN as L,a9 as Ce,m as ye,y as Z,aV as Ee,D as Pe}from"./index-dbd58bee.js";import{T as we,a as Se}from"./index-96c8c221.js";const[Ne,O,ee]=V("picker"),ue=e=>e.find(o=>!o.disabled)||e[0];function Be(e,o){const n=e[0];if(n){if(Array.isArray(n))return"multiple";if(o.children in n)return"cascade"}return"default"}function Q(e,o){o=G(o,0,e.length);for(let n=o;n<e.length;n++)if(!e[n].disabled)return n;for(let n=o-1;n>=0;n--)if(!e[n].disabled)return n;return 0}const te=(e,o,n)=>o!==void 0&&!!e.find(i=>i[n.value]===o);function W(e,o,n){const i=e.findIndex(h=>h[n.value]===o),l=Q(e,i);return e[l]}function De(e,o,n){const i=[];let l={[o.children]:e},h=0;for(;l&&l[o.children];){const f=l[o.children],g=n.value[h];if(l=be(g)?W(f,g,o):void 0,!l&&f.length){const u=ue(f)[o.value];l=W(f,u,o)}h++,i.push(f)}return i}function He(e){const{transform:o}=window.getComputedStyle(e),n=o.slice(7,o.length-1).split(", ")[5];return Number(n)}function Me(e){return E({text:"text",value:"value",children:"children"},e)}const ne=200,ae=300,Ie=15,[re,q]=V("picker-column"),de=Symbol(re);var _e=$({name:re,props:{value:K,fields:I(Object),options:_(),readonly:Boolean,allowHtml:Boolean,optionHeight:I(Number),swipeDuration:I(K),visibleOptionNum:I(K)},emits:["change","clickOption"],setup(e,{emit:o,slots:n}){let i,l,h,f,g;const u=y(),b=y(),m=y(0),v=y(0),T=Te(),k=()=>e.options.length,w=()=>e.optionHeight*(+e.visibleOptionNum-1)/2,p=c=>{const r=Q(e.options,c),t=-r*e.optionHeight,a=()=>{const s=e.options[r][e.fields.value];s!==e.value&&o("change",s)};i&&t!==m.value?g=a:a(),m.value=t},x=()=>e.readonly||!e.options.length,A=c=>{i||x()||(g=null,v.value=ne,p(c),o("clickOption",e.options[c]))},S=c=>G(Math.round(-c/e.optionHeight),0,k()-1),N=(c,r)=>{const t=Math.abs(c/r);c=m.value+t/.003*(c<0?-1:1);const a=S(c);v.value=+e.swipeDuration,p(a)},B=()=>{i=!1,v.value=0,g&&(g(),g=null)},U=c=>{if(!x()){if(T.start(c),i){const r=He(b.value);m.value=Math.min(0,r-w())}v.value=0,l=m.value,h=Date.now(),f=l,g=null}},F=c=>{if(x())return;T.move(c),T.isVertical()&&(i=!0,ie(c,!0)),m.value=G(l+T.deltaY.value,-(k()*e.optionHeight),e.optionHeight);const r=Date.now();r-h>ae&&(h=r,f=m.value)},D=()=>{if(x())return;const c=m.value-f,r=Date.now()-h;if(r<ae&&Math.abs(c)>Ie){N(c,r);return}const a=S(m.value);v.value=ne,p(a),setTimeout(()=>{i=!1},0)},H=()=>{const c={height:`${e.optionHeight}px`};return e.options.map((r,t)=>{const a=r[e.fields.text],{disabled:s}=r,M=r[e.fields.value],P={role:"button",style:c,tabindex:s?-1:0,class:[q("item",{disabled:s,selected:M===e.value}),r.className],onClick:()=>A(t)},ge={class:"van-ellipsis",[e.allowHtml?"innerHTML":"textContent"]:a};return d("li",P,[n.option?n.option(r,t):d("div",ge,null)])})};return oe(de),le({stopMomentum:B}),xe(()=>{const c=e.options.findIndex(a=>a[e.fields.value]===e.value),t=-Q(e.options,c)*e.optionHeight;m.value=t}),ce("touchmove",F,{target:u}),()=>d("div",{ref:u,class:q(),onTouchstartPassive:U,onTouchend:D,onTouchcancel:D},[d("ul",{ref:b,style:{transform:`translate3d(0, ${m.value+w()}px, 0)`,transitionDuration:`${v.value}ms`,transitionProperty:v.value?"all":"none"},class:q("wrapper"),onTransitionend:B},[H()])])}});const[Ve]=V("picker-toolbar"),R={title:String,cancelButtonText:String,confirmButtonText:String},me=["cancel","confirm","title","toolbar"],$e=Object.keys(R);var fe=$({name:Ve,props:R,emits:["confirm","cancel"],setup(e,{emit:o,slots:n}){const i=()=>{if(n.title)return n.title();if(e.title)return d("div",{class:[O("title"),"van-ellipsis"]},[e.title])},l=()=>o("cancel"),h=()=>o("confirm"),f=()=>{const u=e.cancelButtonText||ee("cancel");return d("button",{type:"button",class:[O("cancel"),X],onClick:l},[n.cancel?n.cancel():u])},g=()=>{const u=e.confirmButtonText||ee("confirm");return d("button",{type:"button",class:[O("confirm"),X],onClick:h},[n.confirm?n.confirm():u])};return()=>d("div",{class:O("toolbar")},[n.toolbar?n.toolbar():[f(),i(),g()]])}});const[ve,z]=V("picker-group"),he=Symbol(ve),Re=E({tabs:_(),nextStepText:String},R);$({name:ve,props:Re,emits:["confirm","cancel"],setup(e,{emit:o,slots:n}){const i=y(0),{children:l,linkChildren:h}=se(he);h();const f=()=>i.value<e.tabs.length-1&&e.nextStepText,g=()=>{f()?i.value++:o("confirm",l.map(b=>b.confirm()))},u=()=>o("cancel");return()=>{var b;const m=(b=n.default)==null?void 0:b.call(n),v=f()?e.nextStepText:e.confirmButtonText;return d("div",{class:z()},[d(fe,{title:e.title,cancelButtonText:e.cancelButtonText,confirmButtonText:v,onConfirm:g,onCancel:u},J(n,me)),d(we,{active:i.value,"onUpdate:active":T=>i.value=T,class:z("tabs"),shrink:!0,animated:!0,lazyRender:!1},{default:()=>[e.tabs.map((T,k)=>d(Se,{title:T,titleClass:z("tab-title")},{default:()=>[m==null?void 0:m[k]]}))]})])}}});const Ae=E({loading:Boolean,readonly:Boolean,allowHtml:Boolean,optionHeight:Y(44),showToolbar:Oe,swipeDuration:Y(1e3),visibleOptionNum:Y(6)},R),Ue=E({},Ae,{columns:_(),modelValue:_(),toolbarPosition:ke("top"),columnsFieldNames:Object});var Fe=$({name:Ne,props:Ue,emits:["confirm","cancel","change","clickOption","update:modelValue"],setup(e,{emit:o,slots:n}){const i=y(),l=y(e.modelValue.slice(0)),{parent:h}=oe(he),{children:f,linkChildren:g}=se(de);g();const u=C(()=>Me(e.columnsFieldNames)),b=C(()=>pe(e.optionHeight)),m=C(()=>Be(e.columns,u.value)),v=C(()=>{const{columns:t}=e;switch(m.value){case"multiple":return t;case"cascade":return De(t,u.value,l);default:return[t]}}),T=C(()=>v.value.some(t=>t.length)),k=C(()=>v.value.map((t,a)=>W(t,l.value[a],u.value))),w=C(()=>v.value.map((t,a)=>t.findIndex(s=>s[u.value.value]===l.value[a]))),p=(t,a)=>{if(l.value[t]!==a){const s=l.value.slice(0);s[t]=a,l.value=s}},x=()=>({selectedValues:l.value.slice(0),selectedOptions:k.value,selectedIndexes:w.value}),A=(t,a)=>{p(a,t),m.value==="cascade"&&l.value.forEach((s,M)=>{const P=v.value[M];te(P,s,u.value)||p(M,P.length?P[0][u.value.value]:void 0)}),Z(()=>{o("change",E({columnIndex:a},x()))})},S=(t,a)=>o("clickOption",E({columnIndex:a,currentOption:t},x())),N=()=>{f.forEach(a=>a.stopMomentum());const t=x();return Z(()=>{o("confirm",t)}),t},B=()=>o("cancel",x()),U=()=>v.value.map((t,a)=>d(_e,{value:l.value[a],fields:u.value,options:t,readonly:e.readonly,allowHtml:e.allowHtml,optionHeight:b.value,swipeDuration:e.swipeDuration,visibleOptionNum:e.visibleOptionNum,onChange:s=>A(s,a),onClickOption:s=>S(s,a)},{option:n.option})),F=t=>{if(T.value){const a={height:`${b.value}px`},s={backgroundSize:`100% ${(t-b.value)/2}px`};return[d("div",{class:O("mask"),style:s},null),d("div",{class:[Ee,O("frame")],style:a},null)]}},D=()=>{const t=b.value*+e.visibleOptionNum,a={height:`${t}px`};return d("div",{ref:i,class:O("columns"),style:a},[U(),F(t)])},H=()=>{if(e.showToolbar&&!h)return d(fe,ye(J(e,$e),{onConfirm:N,onCancel:B}),J(n,me))};j(v,t=>{t.forEach((a,s)=>{a.length&&!te(a,l.value[s],u.value)&&p(s,ue(a)[u.value.value])})},{immediate:!0});let c;return j(()=>e.modelValue,t=>{!L(t,l.value)&&!L(t,c)&&(l.value=t.slice(0),c=t.slice(0))},{deep:!0}),j(l,t=>{L(t,e.modelValue)||(c=t.slice(0),o("update:modelValue",c))},{immediate:!0}),ce("touchmove",ie,{target:i}),le({confirm:N,getSelectedOptions:()=>k.value}),()=>{var t,a;return d("div",{class:O()},[e.toolbarPosition==="top"?H():null,e.loading?d(Ce,{class:O("loading")},null):null,(t=n["columns-top"])==null?void 0:t.call(n),D(),(a=n["columns-bottom"])==null?void 0:a.call(n),e.toolbarPosition==="bottom"?H():null])}}});const je=Pe(Fe);export{je as P,Ae as p};
- >>>>>>>> 87d4d1b1 (更新):dist/assets/index-96fefea8.js
|