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.c1f63540.js","./index-legacy.aa9b4ef8.js"],(function(e){"use strict";var o,i,r,l,u,a,c,s,f,v,m,d,p,h,b,g,y,w,x,O,k,H,C,S,T,N,B,j,D,M,V,A;return{setters:[function(n){o=n.t,i=n.a1,r=n.N,l=n.aU,u=n.d,a=n.z,c=n.aB,s=n.av,f=n.R,v=n.aq,m=n.C,d=n.W,p=n.aV,h=n.a0,b=n.c,g=n.a4,y=n.at,w=n.x,x=n.E,O=n.w,k=n.v,H=n.u,C=n.y,S=n.aM,T=n.Z,N=n.aW,B=n.L,j=n.am,D=n._,M=n.aX},function(n){V=n.T,A=n.a}],execute:function(){var I=t(o("picker"),3),P=I[0],E=I[1],z=I[2],F=function(n){return n.find((function(n){return!n.disabled}))||n[0]};function L(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[L(n,o)]}var q=t(o("picker-column"),2),R=q[0],X=q[1],Y=Symbol(R),Z=u({name:R,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=L(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)},B=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}},D=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)}}},M=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:[X("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)}},m=n({class:"van-ellipsis"},t.allowHtml?"innerHTML":"textContent",l);return b("li",v,[s.option?s.option(i):b("div",m,null)])}))};return m(Y),d({stopMomentum:B}),p((function(){var n=t.options.findIndex((function(n){return n[t.fields.value]===t.value})),e=-L(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:X(),onTouchstartPassive:j,onTouchend:D,onTouchcancel:D},[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:X("wrapper"),onTransitionend:B},[M()])])}}}),$=t(o("picker-toolbar"),1)[0],_={title:String,cancelButtonText:String,confirmButtonText:String},G=["cancel","confirm","title","toolbar"],J=Object.keys(_),K=u({name:$,props:_,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||z("confirm");return b("button",{type:"button",class:[E("confirm"),y],onClick:r},[o.confirm?o.confirm():t])};return function(){return b("div",{class:E("toolbar")},[o.toolbar?o.toolbar():[(t=n.cancelButtonText||z("cancel"),b("button",{type:"button",class:[E("cancel"),y],onClick:i},[o.cancel?o.cancel():t])),o.title?o.title():n.title?b("div",{class:[E("title"),"van-ellipsis"]},[n.title]):void 0,l()]]);var t}}}),Q=t(o("picker-group"),2),nn=Q[0],tn=Q[1],en=Symbol(nn),on=r({tabs:s()},_),rn=(e("a",u({name:nn,props:on,emits:["confirm","cancel"],setup:function(n,t){var e=t.emit,o=t.slots,i=w(en),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:tn()},[b(K,x(n,{onConfirm:l,onCancel:u}),null),b(V,{shrink:!0,class:tn("tabs"),animated:!0},{default:function(){return[n.tabs.map((function(n,t){return b(A,{title:n,titleClass:tn("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)},_))),ln=r({},rn,{columns:s(),modelValue:s(),toolbarPosition:H("top"),columnsFieldNames:Object});e("s",u({name:P,props:ln,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=m(en).parent,s=w(Y),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,F(a)[e.value],e)),u++,r.push(a)}return r}(e,y.value,a);default:return[e]}})),V=C((function(){return H.value.some((function(n){return n.length}))})),A=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:A.value}},z=function(){v.forEach((function(n){return n.stopMomentum()}));var n=P();return D((function(){o("confirm",n)})),n},L=function(){return o("cancel",P())},q=function(){return H.value.map((function(n,e){return b(Z,{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})}))},R=function(n){if(V.value){var t={height:"".concat(O.value,"px")},e={backgroundSize:"100% ".concat((n-O.value)/2,"px")};return[b("div",{class:E("mask"),style:e},null),b("div",{class:[M,E("frame")],style:t},null)]}},X=function(){if(t.showToolbar&&!c)return b(K,x(j(t,J),{onConfirm:z,onCancel:L}),j(l,G))};T(H,(function(n){n.forEach((function(n,t){n.length&&!U(n,a.value[t],y.value)&&I(t,F(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 d({confirm:z,getSelectedOptions:function(){return A.value}}),function(){var n,e,o,i;return b("div",{class:E()},["top"===t.toolbarPosition?X():null,t.loading?b(B,{class:E("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:E("columns"),style:i},[q(),R(o)])),null==(e=l["columns-bottom"])?void 0:e.call(l),"bottom"===t.toolbarPosition?X():null])}}}))}}}))}();
|