index-legacy-154aa02e.js 10 KB

1
  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-46c61774.js","./index-legacy-ece741fa.js"],(function(n,o){"use strict";var r,i,u,l,a,c,f,s,v,m,p,d,b,h,g,y,x,w,S,O,T,k,H,C,j,B,N,D,A,I,P,V,M;return{setters:[function(n){r=n.j,i=n.aw,u=n.A,l=n.ak,a=n.d,c=n.t,f=n.ag,s=n.q,v=n.i,m=n.ah,p=n.ae,d=n.an,b=n.k,h=n.ai,g=n.g,y=n.aj,x=n.aq,w=n.ac,S=n.p,O=n.am,T=n.v,k=n.n,H=n.E,C=n.aU,j=n.w,B=n.aN,N=n.a9,D=n.m,A=n.y,I=n.aV,P=n.D},function(n){V=n.T,M=n.a}],execute:function(){var o=e(r("picker"),3),E=o[0],U=o[1],q=o[2],z=function(n){return n.find((function(n){return!n.disabled}))||n[0]};function F(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[F(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=F(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},C=function(){return n.readonly||!n.options.length},j=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(!C()){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(!C()){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=j(t);S.value=+n.swipeDuration,H(r)}(t,e);else{var r=j(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||C()||(a=null,S.value=200,H(t),c("clickOption",n.options[t]))}(i)}},m=t({class:"van-ellipsis"},n.allowHtml?"innerHTML":"textContent",u);return g("li",v,[f.option?f.option(r,i):g("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=-F(n.options,t)*n.optionHeight;w.value=e})),h("touchmove",(function(t){if(!C()){O.move(t),O.isVertical()&&(o=!0,y(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 g("div",{ref:s,class:G(),onTouchstartPassive:N,onTouchend:D,onTouchcancel:D},[g("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||q("confirm");return g("button",{type:"button",class:[U("confirm"),x],onClick:i},[o.confirm?o.confirm():t])};return function(){return g("div",{class:U("toolbar")},[o.toolbar?o.toolbar():[(t=n.cancelButtonText||q("cancel"),g("button",{type:"button",class:[U("cancel"),x],onClick:r},[o.cancel?o.cancel():t])),o.title?o.title():n.title?g("div",{class:[U("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 g("div",{class:en()},[g(_,{title:n.title,cancelButtonText:n.cancelButtonText,confirmButtonText:i,onConfirm:a,onCancel:c},S(o,X)),g(V,{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 g(M,{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 C(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,z(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)}))})),V=H((function(){return T.value.map((function(n,t){return n.findIndex((function(n){return n[b.value.value]===a.value[t]}))}))})),M=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:V.value}},q=function(){s.forEach((function(n){return n.stopMomentum()}));var n=E();return A((function(){o("confirm",n)})),n},F=function(){return o("cancel",E())},Y=function(){return T.value.map((function(t,e){return g(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){M(t,n),"cascade"===O.value&&a.value.forEach((function(n,t){var e=T.value[t];L(e,n,b.value)||M(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[g("div",{class:U("mask"),style:e},null),g("div",{class:[I,U("frame")],style:t},null)]}},G=function(){if(n.showToolbar&&!c)return g(_,D(S(n,Z),{onConfirm:q,onCancel:F}),S(r,X))};j(T,(function(n){n.forEach((function(n,t){n.length&&!L(n,a.value[t],b.value)&&M(t,z(n)[b.value.value])}))}),{immediate:!0}),j((function(){return n.modelValue}),(function(n){B(n,a.value)||B(n,m)||(a.value=n.slice(0),m=n.slice(0))}),{deep:!0}),j(a,(function(t){B(t,n.modelValue)||(m=t.slice(0),o("update:modelValue",m))}),{immediate:!0}),h("touchmove",y,{target:l});return d({confirm:q,getSelectedOptions:function(){return P.value}}),function(){var t,e,o,i;return g("div",{class:U()},["top"===n.toolbarPosition?G():null,n.loading?g(N,{class:U("loading")},null):null,null==(t=r["columns-top"])?void 0:t.call(r),(o=x.value*+n.visibleOptionNum,i={height:"".concat(o,"px")},g("div",{ref:l,class:U("columns"),style:i},[Y(),$(o)])),null==(e=r["columns-bottom"])?void 0:e.call(r),"bottom"===n.toolbarPosition?G():null])}}});n("P",P(an))}}}))}();