index-legacy.384d768f.js 8.9 KB

1
  1. !function(){function n(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function t(n,t){return function(n){if(Array.isArray(n))return n}(n)||function(n,t){var e=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null==e)return;var o,i,r=[],l=!0,u=!1;try{for(e=e.call(n);!(l=(o=e.next()).done)&&(r.push(o.value),!t||r.length!==t);l=!0);}catch(a){u=!0,i=a}finally{try{l||null==e.return||e.return()}finally{if(u)throw i}}return r}(n,t)||function(n,t){if(!n)return;if("string"==typeof n)return e(n,t);var o=Object.prototype.toString.call(n).slice(8,-1);"Object"===o&&n.constructor&&(o=n.constructor.name);if("Map"===o||"Set"===o)return Array.from(n);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return e(n,t)}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,o=new Array(t);e<t;e++)o[e]=n[e];return o}System.register(["./index-legacy.48c8d62c.js","./index-legacy.ef66d7bb.js"],(function(e){"use strict";var o,i,r,l,u,a,c,s,f,v,d,m,p,h,b,g,y,w,x,O,k,H,C,S,T,N,D,j,A,B,M,V,I;return{setters:[function(n){o=n.t,i=n.a1,r=n.N,l=n.au,u=n.d,a=n.z,c=n.av,s=n.aw,f=n.R,v=n.ao,d=n.C,m=n.W,p=n.ax,h=n.a0,b=n.c,g=n.a4,y=n.ay,w=n.x,x=n.E,O=n.w,k=n.v,H=n.u,C=n.y,S=n.az,T=n.Z,N=n.ar,D=n.L,j=n.al,A=n._,B=n.aA,M=n.D},function(n){V=n.T,I=n.a}],execute:function(){var P=t(o("picker"),3),E=P[0],z=P[1],F=P[2],L=function(n){return n.find((function(n){return!n.disabled}))||n[0]};function R(n,t){for(var e=t=l(t,0,n.length);e<n.length;e++)if(!n[e].disabled)return e;for(var o=t-1;o>=0;o--)if(!n[o].disabled)return o;return 0}var U=function(n,t,e){return void 0!==t&&!!n.find((function(n){return n[e.value]===t}))};function W(n,t,e){var o=n.findIndex((function(n){return n[e.value]===t}));return n[R(n,o)]}var Y=t(o("picker-column"),2),Z=Y[0],$=Y[1],_=Symbol(Z),q=u({name:Z,props:{value:a,fields:c(Object),options:s(),readonly:Boolean,allowHtml:Boolean,optionHeight:c(Number),swipeDuration:c(a),visibleOptionNum:c(a)},emits:["change","clickOption"],setup:function(t,e){var o,i,r,u,a,c=e.emit,s=e.slots,y=f(),w=f(),x=f(0),O=f(0),k=v(),H=function(){return t.options.length},C=function(){return t.optionHeight*(+t.visibleOptionNum-1)/2},S=function(n){var e=R(t.options,n),i=-e*t.optionHeight,r=function(){var n=t.options[e][t.fields.value];n!==t.value&&c("change",n)};o&&i!==x.value?a=r:r(),x.value=i},T=function(){return t.readonly||!t.options.length},N=function(n){return l(Math.round(-n/t.optionHeight),0,H()-1)},D=function(){o=!1,O.value=0,a&&(a(),a=null)},j=function(n){if(!T()){if(k.start(n),o){var t=function(n){var t=window.getComputedStyle(n).transform,e=t.slice(7,t.length-1).split(", ")[5];return Number(e)}(w.value);x.value=Math.min(0,t-C())}O.value=0,i=x.value,r=Date.now(),u=i,a=null}},A=function(){if(!T()){var n=x.value-u,e=Date.now()-r;if(e<300&&Math.abs(n)>15)!function(n,e){var o=Math.abs(n/e);n=x.value+o/.003*(n<0?-1:1);var i=N(n);O.value=+t.swipeDuration,S(i)}(n,e);else{var i=N(x.value);O.value=200,S(i),setTimeout((function(){o=!1}),0)}}},B=function(){var e={height:"".concat(t.optionHeight,"px")};return t.options.map((function(i,r){var l=i[t.fields.text],u=i.disabled,f=i[t.fields.value],v={role:"button",style:e,tabindex:u?-1:0,class:[$("item",{disabled:u,selected:f===t.value}),i.className],onClick:function(){return function(n){o||T()||(a=null,O.value=200,S(n),c("clickOption",t.options[n]))}(r)}},d=n({class:"van-ellipsis"},t.allowHtml?"innerHTML":"textContent",l);return b("li",v,[s.option?s.option(i):b("div",d,null)])}))};return d(_),m({stopMomentum:D}),p((function(){var n=t.options.findIndex((function(n){return n[t.fields.value]===t.value})),e=-R(t.options,n)*t.optionHeight;x.value=e})),h("touchmove",(function(n){if(!T()){k.move(n),k.isVertical()&&(o=!0,g(n,!0)),x.value=l(i+k.deltaY.value,-H()*t.optionHeight,t.optionHeight);var e=Date.now();e-r>300&&(r=e,u=x.value)}}),{target:y}),function(){return b("div",{ref:y,class:$(),onTouchstartPassive:j,onTouchend:A,onTouchcancel:A},[b("ul",{ref:w,style:{transform:"translate3d(0, ".concat(x.value+C(),"px, 0)"),transitionDuration:"".concat(O.value,"ms"),transitionProperty:O.value?"all":"none"},class:$("wrapper"),onTransitionend:D},[B()])])}}}),G=t(o("picker-toolbar"),1)[0],J={title:String,cancelButtonText:String,confirmButtonText:String},K=["cancel","confirm","title","toolbar"],Q=Object.keys(J),X=u({name:G,props:J,emits:["confirm","cancel"],setup:function(n,t){var e=t.emit,o=t.slots,i=function(){return e("cancel")},r=function(){return e("confirm")},l=function(){var t=n.confirmButtonText||F("confirm");return b("button",{type:"button",class:[z("confirm"),y],onClick:r},[o.confirm?o.confirm():t])};return function(){return b("div",{class:z("toolbar")},[o.toolbar?o.toolbar():[(t=n.cancelButtonText||F("cancel"),b("button",{type:"button",class:[z("cancel"),y],onClick:i},[o.cancel?o.cancel():t])),o.title?o.title():n.title?b("div",{class:[z("title"),"van-ellipsis"]},[n.title]):void 0,l()]]);var t}}}),nn=t(o("picker-group"),2),tn=nn[0],en=nn[1],on=Symbol(tn),rn=r({tabs:s()},J),ln=(e("s",u({name:tn,props:rn,emits:["confirm","cancel"],setup:function(n,t){var e=t.emit,o=t.slots,i=w(on),r=i.children;(0,i.linkChildren)();var l=function(){e("confirm",r.map((function(n){return n.confirm()})))},u=function(){return e("cancel")};return function(){var t,e=null==(t=o.default)?void 0:t.call(o);return b("div",{class:en()},[b(X,x(n,{onConfirm:l,onCancel:u}),null),b(V,{shrink:!0,class:en("tabs"),animated:!0},{default:function(){return[n.tabs.map((function(n,t){return b(I,{title:n,titleClass:en("tab-title")},{default:function(){return[null==e?void 0:e[t]]}})}))]}})])}}})),e("p",r({loading:Boolean,readonly:Boolean,allowHtml:Boolean,optionHeight:O(44),showToolbar:k,swipeDuration:O(1e3),visibleOptionNum:O(6)},J))),un=r({},ln,{columns:s(),modelValue:s(),toolbarPosition:H("top"),columnsFieldNames:Object}),an=u({name:E,props:un,emits:["confirm","cancel","change","clickOption","update:modelValue"],setup:function(t,e){var o=e.emit,l=e.slots,u=f(),a=f(t.modelValue.slice(0)),c=d(on).parent,s=w(_),v=s.children;(0,s.linkChildren)();var p,y=C((function(){return function(n){return r({text:"text",value:"value",children:"children"},n)}(t.columnsFieldNames)})),O=C((function(){return S(t.optionHeight)})),k=C((function(){return function(n,t){var e=n[0];if(e){if(Array.isArray(e))return"multiple";if(t.children in e)return"cascade"}return"default"}(t.columns,y.value)})),H=C((function(){var e=t.columns;switch(k.value){case"multiple":return e;case"cascade":return function(t,e,o){for(var r=[],l=n({},e.children,t),u=0;l&&l[e.children];){var a=l[e.children],c=o.value[u];!(l=i(c)?W(a,c,e):void 0)&&a.length&&(l=W(a,L(a)[e.value],e)),u++,r.push(a)}return r}(e,y.value,a);default:return[e]}})),M=C((function(){return H.value.some((function(n){return n.length}))})),V=C((function(){return H.value.map((function(n,t){return W(n,a.value[t],y.value)}))})),I=function(n,t){if(a.value[n]!==t){var e=a.value.slice(0);e[n]=t,a.value=e}},P=function(){return{selectedValues:a.value.slice(0),selectedOptions:V.value}},E=function(){v.forEach((function(n){return n.stopMomentum()}));var n=P();return A((function(){o("confirm",n)})),n},F=function(){return o("cancel",P())},R=function(){return H.value.map((function(n,e){return b(q,{value:a.value[e],fields:y.value,options:n,readonly:t.readonly,allowHtml:t.allowHtml,optionHeight:O.value,swipeDuration:t.swipeDuration,visibleOptionNum:t.visibleOptionNum,onChange:function(n){return function(n,t){I(t,n),"cascade"===k.value&&a.value.forEach((function(n,t){var e=H.value[t];U(e,n,y.value)||I(t,e.length?e[0][y.value.value]:void 0)})),o("change",r({columnIndex:t},P()))}(n,e)},onClickOption:function(n){return function(n,t){return o("clickOption",r({columnIndex:t,currentOption:n},P()))}(n,e)}},{option:l.option})}))},Y=function(n){if(M.value){var t={height:"".concat(O.value,"px")},e={backgroundSize:"100% ".concat((n-O.value)/2,"px")};return[b("div",{class:z("mask"),style:e},null),b("div",{class:[B,z("frame")],style:t},null)]}},Z=function(){if(t.showToolbar&&!c)return b(X,x(j(t,Q),{onConfirm:E,onCancel:F}),j(l,K))};T(H,(function(n){n.forEach((function(n,t){n.length&&!U(n,a.value[t],y.value)&&I(t,L(n)[y.value.value])}))}),{immediate:!0}),T((function(){return t.modelValue}),(function(n){N(n,a.value)||N(n,p)||(a.value=n.slice(0))}),{deep:!0}),T(a,(function(n){N(n,t.modelValue)||(p=n.slice(0),o("update:modelValue",p))}),{immediate:!0}),h("touchmove",g,{target:u});return m({confirm:E,getSelectedOptions:function(){return V.value}}),function(){var n,e,o,i;return b("div",{class:z()},["top"===t.toolbarPosition?Z():null,t.loading?b(D,{class:z("loading")},null):null,null==(n=l["columns-top"])?void 0:n.call(l),(o=O.value*+t.visibleOptionNum,i={height:"".concat(o,"px")},b("div",{ref:u,class:z("columns"),style:i},[R(),Y(o)])),null==(e=l["columns-bottom"])?void 0:e.call(l),"bottom"===t.toolbarPosition?Z():null])}}});e("P",M(an))}}}))}();