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