1 |
- System.register(["./index-legacy.eb062188.js","./index-legacy.ac7c51db.js"],(function(e){"use strict";var t,l,n,o,a,i,u,c,s,r,v,d,p,m,f,h,b,g,x,y,T,w,k,H,O,C,B,S,I,N,D,M;return{setters:[function(e){t=e.t,l=e.a1,n=e.N,o=e.aZ,a=e.d,i=e.z,u=e.aB,c=e.av,s=e.R,r=e.aq,v=e.y,d=e.C,p=e.W,m=e.aU,f=e.a0,h=e.c,b=e.a4,g=e.au,x=e.Z,y=e.w,T=e.x,w=e.am,k=e.v,H=e.u,O=e.aM,C=e.a_,B=e.L,S=e.E,I=e._,N=e.a$},function(e){D=e.T,M=e.a}],execute:function(){const[V,$,j]=t("picker"),P=e=>e.find((e=>!e.disabled))||e[0];function E(e,t){for(let l=t=o(t,0,e.length);l<e.length;l++)if(!e[l].disabled)return l;for(let l=t-1;l>=0;l--)if(!e[l].disabled)return l;return 0}const z=(e,t,l)=>void 0!==t&&!!e.find((e=>e[l.value]===t));function A(e,t,l){const n=e.findIndex((e=>e[l.value]===t));return e[E(e,n)]}const[F,L]=t("picker-column"),R=Symbol(F);var U=a({name:F,props:{value:i,fields:u(Object),options:c(),readonly:Boolean,allowHtml:Boolean,optionHeight:u(Number),swipeDuration:u(i),visibleOptionNum:u(i)},emits:["change","clickOption","scrollInto"],setup(e,{emit:t,slots:l}){let n,a,i,u,c;const g=s(),x=s(),y=s(0),T=s(0),w=r(),k=()=>e.options.length,H=()=>e.optionHeight*(+e.visibleOptionNum-1)/2,O=l=>{let o=E(e.options,l);const a=-o*e.optionHeight,i=()=>{o>k()-1&&(o=E(e.options,l));const n=e.options[o][e.fields.value];n!==e.value&&t("change",n)};n&&a!==y.value?c=i:i(),y.value=a},C=()=>e.readonly||!e.options.length,B=t=>o(Math.round(-t/e.optionHeight),0,k()-1),S=v((()=>B(y.value))),I=()=>{n=!1,T.value=0,c&&(c(),c=null)},N=e=>{if(!C()){if(w.start(e),n){const e=function(e){const{transform:t}=window.getComputedStyle(e),l=t.slice(7,t.length-1).split(", ")[5];return Number(l)}(x.value);y.value=Math.min(0,e-H())}T.value=0,a=y.value,i=Date.now(),u=a,c=null}},D=()=>{if(C())return;const t=y.value-u,l=Date.now()-i;if(l<300&&Math.abs(t)>15)return void((t,l)=>{const n=Math.abs(t/l);t=y.value+n/.003*(t<0?-1:1);const o=B(t);T.value=+e.swipeDuration,O(o)})(t,l);const o=B(y.value);T.value=200,O(o),setTimeout((()=>{n=!1}),0)},M=()=>{const o={height:`${e.optionHeight}px`};return e.options.map(((a,i)=>{const u=a[e.fields.text],{disabled:s}=a,r=a[e.fields.value],v={role:"button",style:o,tabindex:s?-1:0,class:[L("item",{disabled:s,selected:r===e.value}),a.className],onClick:()=>(l=>{n||C()||(c=null,T.value=200,O(l),t("clickOption",e.options[l]))})(i)},d={class:"van-ellipsis",[e.allowHtml?"innerHTML":"textContent"]:u};return h("li",v,[l.option?l.option(a,i):h("div",d,null)])}))};return d(R),p({stopMomentum:I}),m((()=>{const t=n?Math.floor(-y.value/e.optionHeight):e.options.findIndex((t=>t[e.fields.value]===e.value)),l=E(e.options,t),o=-l*e.optionHeight;n&&l<t&&I(),y.value=o})),f("touchmove",(l=>{if(C())return;w.move(l),w.isVertical()&&(n=!0,b(l,!0));const c=o(a+w.deltaY.value,-k()*e.optionHeight,e.optionHeight),s=B(c);s!==S.value&&t("scrollInto",e.options[s]),y.value=c;const r=Date.now();r-i>300&&(i=r,u=c)}),{target:g}),()=>h("div",{ref:g,class:L(),onTouchstartPassive:N,onTouchend:D,onTouchcancel:D},[h("ul",{ref:x,style:{transform:`translate3d(0, ${y.value+H()}px, 0)`,transitionDuration:`${T.value}ms`,transitionProperty:T.value?"all":"none"},class:L("wrapper"),onTransitionend:I},[M()])])}});const[Z]=t("picker-toolbar"),_={title:String,cancelButtonText:String,confirmButtonText:String},q=["cancel","confirm","title","toolbar"],W=Object.keys(_);var Y=a({name:Z,props:_,emits:["confirm","cancel"],setup(e,{emit:t,slots:l}){const n=()=>t("cancel"),o=()=>t("confirm"),a=()=>{const t=e.cancelButtonText||j("cancel");return h("button",{type:"button",class:[$("cancel"),g],onClick:n},[l.cancel?l.cancel():t])},i=()=>{const t=e.confirmButtonText||j("confirm");return h("button",{type:"button",class:[$("confirm"),g],onClick:o},[l.confirm?l.confirm():t])};return()=>h("div",{class:$("toolbar")},[l.toolbar?l.toolbar():[a(),l.title?l.title():e.title?h("div",{class:[$("title"),"van-ellipsis"]},[e.title]):void 0,i()]])}});const[G,J]=t("picker-group"),K=Symbol(G),Q=n({tabs:c(),activeTab:y(0),nextStepText:String},_);e("a",a({name:G,props:Q,emits:["confirm","cancel","update:activeTab"],setup(e,{emit:t,slots:l}){const n=((e,t)=>{const l=s(e());return x(e,(e=>{e!==l.value&&(l.value=e)})),x(l,(l=>{l!==e()&&t(l)})),l})((()=>e.activeTab),(e=>t("update:activeTab",e))),{children:o,linkChildren:a}=T(K);a();const i=()=>+n.value<e.tabs.length-1&&e.nextStepText,u=()=>{i()?n.value=+n.value+1:t("confirm",o.map((e=>e.confirm())))},c=()=>t("cancel");return()=>{var t;const o=null==(t=l.default)?void 0:t.call(l),a=i()?e.nextStepText:e.confirmButtonText;return h("div",{class:J()},[h(Y,{title:e.title,cancelButtonText:e.cancelButtonText,confirmButtonText:a,onConfirm:u,onCancel:c},w(l,q)),h(D,{active:n.value,"onUpdate:active":e=>n.value=e,class:J("tabs"),shrink:!0,animated:!0,lazyRender:!1},{default:()=>[e.tabs.map(((e,t)=>h(M,{title:e,titleClass:J("tab-title")},{default:()=>[null==o?void 0:o[t]]})))]})])}}}));const X=e("p",n({loading:Boolean,readonly:Boolean,allowHtml:Boolean,optionHeight:y(44),showToolbar:k,swipeDuration:y(1e3),visibleOptionNum:y(6)},_)),ee=n({},X,{columns:c(),modelValue:c(),toolbarPosition:H("top"),columnsFieldNames:Object});e("s",a({name:V,props:ee,emits:["confirm","cancel","change","scrollInto","clickOption","update:modelValue"],setup(e,{emit:t,slots:o}){const a=s(),i=s(e.modelValue.slice(0)),{parent:u}=d(K),{children:c,linkChildren:r}=T(R);r();const m=v((()=>function(e){return n({text:"text",value:"value",children:"children"},e)}(e.columnsFieldNames))),g=v((()=>O(e.optionHeight))),y=v((()=>function(e,t){const l=e[0];if(l){if(Array.isArray(l))return"multiple";if(t.children in l)return"cascade"}return"default"}(e.columns,m.value))),k=v((()=>{const{columns:t}=e;switch(y.value){case"multiple":return t;case"cascade":return function(e,t,n){const o=[];let a={[t.children]:e},i=0;for(;a&&a[t.children];){const e=a[t.children],u=n.value[i];a=l(u)?A(e,u,t):void 0,!a&&e.length&&(a=A(e,P(e)[t.value],t)),i++,o.push(e)}return o}(t,m.value,i);default:return[t]}})),H=v((()=>k.value.some((e=>e.length)))),D=v((()=>k.value.map(((e,t)=>A(e,i.value[t],m.value))))),M=v((()=>k.value.map(((e,t)=>e.findIndex((e=>e[m.value.value]===i.value[t])))))),V=(e,t)=>{if(i.value[e]!==t){const l=i.value.slice(0);l[e]=t,i.value=l}},j=()=>({selectedValues:i.value.slice(0),selectedOptions:D.value,selectedIndexes:M.value}),E=()=>{c.forEach((e=>e.stopMomentum()));const e=j();return I((()=>{t("confirm",e)})),e},F=()=>t("cancel",j()),L=()=>k.value.map(((l,a)=>h(U,{value:i.value[a],fields:m.value,options:l,readonly:e.readonly,allowHtml:e.allowHtml,optionHeight:g.value,swipeDuration:e.swipeDuration,visibleOptionNum:e.visibleOptionNum,onChange:e=>((e,l)=>{V(l,e),"cascade"===y.value&&i.value.forEach(((e,t)=>{const l=k.value[t];z(l,e,m.value)||V(t,l.length?l[0][m.value.value]:void 0)})),I((()=>{t("change",n({columnIndex:l},j()))}))})(e,a),onClickOption:e=>((e,l)=>{const o={columnIndex:l,currentOption:e};t("clickOption",n(j(),o)),t("scrollInto",o)})(e,a),onScrollInto:e=>{t("scrollInto",{currentOption:e,columnIndex:a})}},{option:o.option}))),Z=e=>{if(H.value){const t={height:`${g.value}px`},l={backgroundSize:`100% ${(e-g.value)/2}px`};return[h("div",{class:$("mask"),style:l},null),h("div",{class:[N,$("frame")],style:t},null)]}},_=()=>{const t=g.value*+e.visibleOptionNum,l={height:`${t}px`};return h("div",{ref:a,class:$("columns"),style:l},[L(),Z(t)])},G=()=>{if(e.showToolbar&&!u)return h(Y,S(w(e,W),{onConfirm:E,onCancel:F}),w(o,q))};let J;return x(k,(e=>{e.forEach(((e,t)=>{e.length&&!z(e,i.value[t],m.value)&&V(t,P(e)[m.value.value])}))}),{immediate:!0}),x((()=>e.modelValue),(e=>{C(e,i.value)||C(e,J)||(i.value=e.slice(0),J=e.slice(0))}),{deep:!0}),x(i,(l=>{C(l,e.modelValue)||(J=l.slice(0),t("update:modelValue",J))}),{immediate:!0}),f("touchmove",b,{target:a}),p({confirm:E,getSelectedOptions:()=>D.value}),()=>{var t,l;return h("div",{class:$()},["top"===e.toolbarPosition?G():null,e.loading?h(B,{class:$("loading")},null):null,null==(t=o["columns-top"])?void 0:t.call(o),_(),null==(l=o["columns-bottom"])?void 0:l.call(o),"bottom"===e.toolbarPosition?G():null])}}}))}}}));
|