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