@component-hook/picker 0.2.5 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -163
- package/dist/react/index.css +1 -1
- package/dist/react/picker.es.d.ts +78 -40
- package/dist/react/picker.es.js +1601 -2948
- package/dist/react/picker.umd.js +15 -36
- package/dist/vue/index.css +1 -1
- package/dist/vue/picker.es.d.ts +188 -55
- package/dist/vue/picker.es.js +499 -1811
- package/dist/vue/picker.umd.js +2 -23
- package/package.json +5 -6
package/dist/vue/picker.umd.js
CHANGED
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(M);/*!
|
|
3
|
-
* better-scroll / core
|
|
4
|
-
* (c) 2016-2023 ustbhuangyi
|
|
5
|
-
* Released under the MIT License.
|
|
6
|
-
*//*! *****************************************************************************
|
|
7
|
-
Copyright (c) Microsoft Corporation.
|
|
8
|
-
|
|
9
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
purpose with or without fee is hereby granted.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
-
***************************************************************************** */var tt=function(o,t){return tt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])},tt(o,t)};function W(o,t){tt(o,t);function e(){this.constructor=o}o.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var z=function(){return z=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},z.apply(this,arguments)};function vt(){for(var o=0,t=0,e=arguments.length;t<e;t++)o+=arguments[t].length;for(var r=Array(o),n=0,t=0;t<e;t++)for(var i=arguments[t],s=0,l=i.length;s<l;s++,n++)r[n]=i[s];return r}var zt=[{sourceKey:"scroller.scrollBehaviorX.currentPos",key:"x"},{sourceKey:"scroller.scrollBehaviorY.currentPos",key:"y"},{sourceKey:"scroller.scrollBehaviorX.hasScroll",key:"hasHorizontalScroll"},{sourceKey:"scroller.scrollBehaviorY.hasScroll",key:"hasVerticalScroll"},{sourceKey:"scroller.scrollBehaviorX.contentSize",key:"scrollerWidth"},{sourceKey:"scroller.scrollBehaviorY.contentSize",key:"scrollerHeight"},{sourceKey:"scroller.scrollBehaviorX.maxScrollPos",key:"maxScrollX"},{sourceKey:"scroller.scrollBehaviorY.maxScrollPos",key:"maxScrollY"},{sourceKey:"scroller.scrollBehaviorX.minScrollPos",key:"minScrollX"},{sourceKey:"scroller.scrollBehaviorY.minScrollPos",key:"minScrollY"},{sourceKey:"scroller.scrollBehaviorX.movingDirection",key:"movingDirectionX"},{sourceKey:"scroller.scrollBehaviorY.movingDirection",key:"movingDirectionY"},{sourceKey:"scroller.scrollBehaviorX.direction",key:"directionX"},{sourceKey:"scroller.scrollBehaviorY.direction",key:"directionY"},{sourceKey:"scroller.actions.enabled",key:"enabled"},{sourceKey:"scroller.animater.pending",key:"pending"},{sourceKey:"scroller.animater.stop",key:"stop"},{sourceKey:"scroller.scrollTo",key:"scrollTo"},{sourceKey:"scroller.scrollBy",key:"scrollBy"},{sourceKey:"scroller.scrollToElement",key:"scrollToElement"},{sourceKey:"scroller.resetPosition",key:"resetPosition"}];function K(o){console.error("[BScroll warn]: "+o)}var S=typeof window<"u",X=S&&navigator.userAgent.toLowerCase(),Ht=!!(X&&/wechatdevtools/.test(X)),Nt=X&&X.indexOf("android")>0,Ft=function(){if(typeof X=="string"){var o=/os (\d\d?_\d(_\d)?)/,t=o.exec(X);if(!t)return!1;var e=t[1].split("_").map(function(r){return parseInt(r,10)});return e[0]===13&&e[1]>=4}return!1}(),mt=!1;if(S){var Wt="test-passive";try{var yt={};Object.defineProperty(yt,"passive",{get:function(){mt=!0}}),window.addEventListener(Wt,function(){},yt)}catch{}}function D(){return window.performance&&window.performance.now&&window.performance.timing?window.performance.now()+window.performance.timing.navigationStart:+new Date}var et=function(o,t){for(var e in t)o[e]=t[e];return o};function ot(o){return o==null}function gt(o,t,e){return o<t?t:o>e?e:o}var rt=S&&document.createElement("div").style,O=function(){if(!S)return!1;for(var o=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}],t=0,e=o;t<e.length;t++){var r=e[t];if(rt[r.value]!==void 0)return r.key}return!1}();function w(o){return O===!1?o:O==="standard"?o==="transitionEnd"?"transitionend":o:O+o.charAt(0).toUpperCase()+o.substr(1)}function kt(o){return typeof o=="string"?document.querySelector(o):o}function Kt(o,t,e,r){var n=mt?{passive:!1,capture:!!r}:!!r;o.addEventListener(t,e,n)}function Rt(o,t,e,r){o.removeEventListener(t,e,{capture:!!r})}function Tt(o){o.cancelable&&o.preventDefault()}function bt(o){for(var t=0,e=0;o;)t-=o.offsetLeft,e-=o.offsetTop,o=o.offsetParent;return{left:t,top:e}}O&&O!=="standard"&&""+O.toLowerCase();var Vt=w("transform"),St=w("transition"),$t=S&&w("perspective")in rt,wt=S&&("ontouchstart"in window||Ht),jt=S&&St in rt,B={transform:Vt,transition:St,transitionTimingFunction:w("transitionTimingFunction"),transitionDuration:w("transitionDuration"),transitionDelay:w("transitionDelay"),transformOrigin:w("transformOrigin"),transitionEnd:w("transitionEnd"),transitionProperty:w("transitionProperty")},nt={touchstart:1,touchmove:1,touchend:1,touchcancel:1,mousedown:2,mousemove:2,mouseup:2};function Pt(o){if(o instanceof window.SVGElement){var t=o.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}else return{top:o.offsetTop,left:o.offsetLeft,width:o.offsetWidth,height:o.offsetHeight}}function H(o,t){for(var e in t)if(t[e].test(o[e]))return!0;return!1}var Ut=H;function qt(o,t){var e=document.createEvent("Event");e.initEvent(t,!0,!0),e.pageX=o.pageX,e.pageY=o.pageY,o.target.dispatchEvent(e)}function Et(o,t){t===void 0&&(t="click");var e;o.type==="mouseup"?e=o:(o.type==="touchend"||o.type==="touchcancel")&&(e=o.changedTouches[0]);var r={};e&&(r.screenX=e.screenX||0,r.screenY=e.screenY||0,r.clientX=e.clientX||0,r.clientY=e.clientY||0);var n,i=!0,s=!0,l=o.ctrlKey,h=o.shiftKey,a=o.altKey,u=o.metaKey,p={ctrlKey:l,shiftKey:h,altKey:a,metaKey:u};if(typeof MouseEvent<"u")try{n=new MouseEvent(t,et(z({bubbles:i,cancelable:s},p),r))}catch{v()}else v();function v(){n=document.createEvent("Event"),n.initEvent(t,i,s),et(n,r)}n.forwardedTouchEvent=!0,n._constructed=!0,o.target.dispatchEvent(n)}function Gt(o){Et(o,"dblclick")}var _={swipe:{style:"cubic-bezier(0.23, 1, 0.32, 1)",fn:function(o){return 1+--o*o*o*o*o}},swipeBounce:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(o){return o*(2-o)}},bounce:{style:"cubic-bezier(0.165, 0.84, 0.44, 1)",fn:function(o){return 1- --o*o*o*o}}},Zt=1e3/60,x=S&&window;function xt(){}var Ct=function(){return S?x.requestAnimationFrame||x.webkitRequestAnimationFrame||x.mozRequestAnimationFrame||x.oRequestAnimationFrame||function(o){return window.setTimeout(o,o.interval||Zt)}:xt}(),A=function(){return S?x.cancelAnimationFrame||x.webkitCancelAnimationFrame||x.mozCancelAnimationFrame||x.oCancelAnimationFrame||function(o){window.clearTimeout(o)}:xt}(),Dt=function(o){},it={enumerable:!0,configurable:!0,get:Dt,set:Dt},Jt=function(o,t){for(var e=t.split("."),r=0;r<e.length-1;r++)if(o=o[e[r]],typeof o!="object"||!o)return;var n=e.pop();return typeof o[n]=="function"?function(){return o[n].apply(o,arguments)}:o[n]},Qt=function(o,t,e){for(var r=t.split("."),n,i=0;i<r.length-1;i++)n=r[i],o[n]||(o[n]={}),o=o[n];o[r.pop()]=e};function te(o,t,e){it.get=function(){return Jt(this,t)},it.set=function(n){Qt(this,t,n)},Object.defineProperty(o,e,it)}var C=function(){function o(t){this.events={},this.eventTypes={},this.registerType(t)}return o.prototype.on=function(t,e,r){return r===void 0&&(r=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,r]),this},o.prototype.once=function(t,e,r){var n=this;r===void 0&&(r=this),this.hasType(t);var i=function(){for(var s=[],l=0;l<arguments.length;l++)s[l]=arguments[l];n.off(t,i);var h=e.apply(r,s);if(h===!0)return h};return i.fn=e,this.on(t,i),this},o.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),!e)return this.events[t]=[],this;var r=this.events[t];if(!r)return this;for(var n=r.length;n--;)(r[n][0]===e||r[n][0]&&r[n][0].fn===e)&&r.splice(n,1);return this}},o.prototype.trigger=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];this.hasType(t);var n=this.events[t];if(n)for(var i=n.length,s=vt(n),l,h=0;h<i;h++){var a=s[h],u=a[0],p=a[1];if(u&&(l=u.apply(p,e),l===!0))return l}},o.prototype.registerType=function(t){var e=this;t.forEach(function(r){e.eventTypes[r]=r})},o.prototype.destroy=function(){this.events={},this.eventTypes={}},o.prototype.hasType=function(t){var e=this.eventTypes,r=e[t]===t;r||K('EventEmitter has used unknown event type: "'+t+'", should be oneof ['+(""+Object.keys(e).map(function(n){return JSON.stringify(n)}))+"]")},o}(),R=function(){function o(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}return o.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},o.prototype.addDOMEvents=function(){this.handleDOMEvents(Kt)},o.prototype.removeDOMEvents=function(){this.handleDOMEvents(Rt)},o.prototype.handleDOMEvents=function(t){var e=this,r=this.wrapper;this.events.forEach(function(n){t(r,n.name,e,!!n.capture)})},o.prototype.handleEvent=function(t){var e=t.type;this.events.some(function(r){return r.name===e?(r.handler(t),!0):!1})},o}(),ee=function(){function o(){}return o}(),oe=function(o){W(t,o);function t(){var e=o.call(this)||this;return e.startX=0,e.startY=0,e.scrollX=!1,e.scrollY=!0,e.freeScroll=!1,e.directionLockThreshold=0,e.eventPassthrough="",e.click=!1,e.dblclick=!1,e.tap="",e.bounce={top:!0,bottom:!0,left:!0,right:!0},e.bounceTime=800,e.momentum=!0,e.momentumLimitTime=300,e.momentumLimitDistance=15,e.swipeTime=2500,e.swipeBounceTime=500,e.deceleration=.0015,e.flickLimitTime=200,e.flickLimitDistance=100,e.resizePolling=60,e.probeType=0,e.stopPropagation=!1,e.preventDefault=!0,e.preventDefaultException={tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT|AUDIO)$/},e.tagException={tagName:/^TEXTAREA$/},e.HWCompositing=!0,e.useTransition=!0,e.bindToWrapper=!1,e.bindToTarget=!1,e.disableMouse=wt,e.disableTouch=!wt,e.autoBlur=!0,e.autoEndDistance=5,e.outOfBoundaryDampingFactor=1/3,e.specifiedIndexAsContent=0,e.quadrant=1,e}return t.prototype.merge=function(e){if(!e)return this;for(var r in e){if(r==="bounce"){this.bounce=this.resolveBounce(e[r]);continue}this[r]=e[r]}return this},t.prototype.process=function(){return this.translateZ=this.HWCompositing&&$t?" translateZ(1px)":"",this.useTransition=this.useTransition&&jt,this.preventDefault=!this.eventPassthrough&&this.preventDefault,this.scrollX=this.eventPassthrough==="horizontal"?!1:this.scrollX,this.scrollY=this.eventPassthrough==="vertical"?!1:this.scrollY,this.freeScroll=this.freeScroll&&!this.eventPassthrough,this.scrollX=this.freeScroll?!0:this.scrollX,this.scrollY=this.freeScroll?!0:this.scrollY,this.directionLockThreshold=this.eventPassthrough?0:this.directionLockThreshold,this},t.prototype.resolveBounce=function(e){var r={top:!0,right:!0,bottom:!0,left:!0},n={top:!1,right:!1,bottom:!1,left:!1},i;return typeof e=="object"?i=et(r,e):i=e?r:n,i},t}(ee),re=function(){function o(t,e){this.wrapper=t,this.options=e,this.hooks=new C(["beforeStart","start","move","end","click"]),this.handleDOMEvents()}return o.prototype.handleDOMEvents=function(){var t=this.options,e=t.bindToWrapper,r=t.disableMouse,n=t.disableTouch,i=t.click,s=this.wrapper,l=e?s:window,h=[],a=[],u=!n,p=!r;i&&h.push({name:"click",handler:this.click.bind(this),capture:!0}),u&&(h.push({name:"touchstart",handler:this.start.bind(this)}),a.push({name:"touchmove",handler:this.move.bind(this)},{name:"touchend",handler:this.end.bind(this)},{name:"touchcancel",handler:this.end.bind(this)})),p&&(h.push({name:"mousedown",handler:this.start.bind(this)}),a.push({name:"mousemove",handler:this.move.bind(this)},{name:"mouseup",handler:this.end.bind(this)})),this.wrapperEventRegister=new R(s,h),this.targetEventRegister=new R(l,a)},o.prototype.beforeHandler=function(t,e){var r=this.options,n=r.preventDefault,i=r.stopPropagation,s=r.preventDefaultException,l={start:function(){return n&&!H(t.target,s)},end:function(){return n&&!H(t.target,s)},move:function(){return n}};l[e]()&&t.preventDefault(),i&&t.stopPropagation()},o.prototype.setInitiated=function(t){t===void 0&&(t=0),this.initiated=t},o.prototype.start=function(t){var e=nt[t.type];if(!(this.initiated&&this.initiated!==e)){if(this.setInitiated(e),Ut(t.target,this.options.tagException)){this.setInitiated();return}if(!(e===2&&t.button!==0)&&!this.hooks.trigger(this.hooks.eventTypes.beforeStart,t)){this.beforeHandler(t,"start");var r=t.touches?t.touches[0]:t;this.pointX=r.pageX,this.pointY=r.pageY,this.hooks.trigger(this.hooks.eventTypes.start,t)}}},o.prototype.move=function(t){if(nt[t.type]===this.initiated){this.beforeHandler(t,"move");var e=t.touches?t.touches[0]:t,r=e.pageX-this.pointX,n=e.pageY-this.pointY;if(this.pointX=e.pageX,this.pointY=e.pageY,!this.hooks.trigger(this.hooks.eventTypes.move,{deltaX:r,deltaY:n,e:t})){var i=document.documentElement.scrollLeft||window.pageXOffset||document.body.scrollLeft,s=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop,l=this.pointX-i,h=this.pointY-s,a=this.options.autoEndDistance;(l>document.documentElement.clientWidth-a||h>document.documentElement.clientHeight-a||l<a||h<a)&&this.end(t)}}},o.prototype.end=function(t){nt[t.type]===this.initiated&&(this.setInitiated(),this.beforeHandler(t,"end"),this.hooks.trigger(this.hooks.eventTypes.end,t))},o.prototype.click=function(t){this.hooks.trigger(this.hooks.eventTypes.click,t)},o.prototype.setContent=function(t){t!==this.wrapper&&(this.wrapper=t,this.rebindDOMEvents())},o.prototype.rebindDOMEvents=function(){this.wrapperEventRegister.destroy(),this.targetEventRegister.destroy(),this.handleDOMEvents()},o.prototype.destroy=function(){this.wrapperEventRegister.destroy(),this.targetEventRegister.destroy(),this.hooks.destroy()},o}(),st={x:["translateX","px"],y:["translateY","px"]},ne=function(){function o(t){this.setContent(t),this.hooks=new C(["beforeTranslate","translate"])}return o.prototype.getComputedPosition=function(){var t=window.getComputedStyle(this.content,null),e=t[B.transform].split(")")[0].split(", "),r=+(e[12]||e[4])||0,n=+(e[13]||e[5])||0;return{x:r,y:n}},o.prototype.translate=function(t){var e=[];Object.keys(t).forEach(function(r){if(st[r]){var n=st[r][0];if(n){var i=st[r][1],s=t[r];e.push(n+"("+s+i+")")}}}),this.hooks.trigger(this.hooks.eventTypes.beforeTranslate,e,t),this.style[B.transform]=e.join(" "),this.hooks.trigger(this.hooks.eventTypes.translate,t)},o.prototype.setContent=function(t){this.content!==t&&(this.content=t,this.style=t.style)},o.prototype.destroy=function(){this.hooks.destroy()},o}(),Bt=function(){function o(t,e,r){this.translater=e,this.options=r,this.timer=0,this.hooks=new C(["move","end","beforeForceStop","forceStop","callStop","time","timeFunction"]),this.setContent(t)}return o.prototype.translate=function(t){this.translater.translate(t)},o.prototype.setPending=function(t){this.pending=t},o.prototype.setForceStopped=function(t){this.forceStopped=t},o.prototype.setCallStop=function(t){this.callStopWhenPending=t},o.prototype.setContent=function(t){this.content!==t&&(this.content=t,this.style=t.style,this.stop())},o.prototype.clearTimer=function(){this.timer&&(A(this.timer),this.timer=0)},o.prototype.destroy=function(){this.hooks.destroy(),A(this.timer)},o}(),ie=function(o,t,e,r){var n=function(a,u){var p=a-u,v=p>0?-1:p<0?1:0;return v},i=n(t.x,o.x),s=n(t.y,o.y),l=e.x-r.x,h=e.y-r.y;return i*l<=0&&s*h<=0},se=function(o){W(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}return t.prototype.startProbe=function(e,r){var n=this,i=e,s=function(){var l=n.translater.getComputedPosition();ie(e,r,l,i)&&n.hooks.trigger(n.hooks.eventTypes.move,l),n.pending||(n.callStopWhenPending?n.callStopWhenPending=!1:n.hooks.trigger(n.hooks.eventTypes.end,l)),i=l,n.pending&&(n.timer=Ct(s))};this.callStopWhenPending&&this.setCallStop(!1),A(this.timer),s()},t.prototype.transitionTime=function(e){e===void 0&&(e=0),this.style[B.transitionDuration]=e+"ms",this.hooks.trigger(this.hooks.eventTypes.time,e)},t.prototype.transitionTimingFunction=function(e){this.style[B.transitionTimingFunction]=e,this.hooks.trigger(this.hooks.eventTypes.timeFunction,e)},t.prototype.transitionProperty=function(){this.style[B.transitionProperty]=B.transform},t.prototype.move=function(e,r,n,i){this.setPending(n>0),this.transitionTimingFunction(i),this.transitionProperty(),this.transitionTime(n),this.translate(r);var s=this.options.probeType===3;n&&s&&this.startProbe(e,r),n||(this._reflow=this.content.offsetHeight,s&&this.hooks.trigger(this.hooks.eventTypes.move,r),this.hooks.trigger(this.hooks.eventTypes.end,r))},t.prototype.doStop=function(){var e=this.pending;if(this.setForceStopped(!1),this.setCallStop(!1),e){this.setPending(!1),A(this.timer);var r=this.translater.getComputedPosition(),n=r.x,i=r.y;this.transitionTime(),this.translate({x:n,y:i}),this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,{x:n,y:i})}return e},t.prototype.stop=function(){var e=this.doStop();e&&this.hooks.trigger(this.hooks.eventTypes.callStop)},t}(Bt),ae=function(o){W(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}return t.prototype.move=function(e,r,n,i){if(!n){this.translate(r),this.options.probeType===3&&this.hooks.trigger(this.hooks.eventTypes.move,r),this.hooks.trigger(this.hooks.eventTypes.end,r);return}this.animate(e,r,n,i)},t.prototype.animate=function(e,r,n,i){var s=this,l=D(),h=l+n,a=this.options.probeType===3,u=function(){var p=D();if(p>=h){s.translate(r),a&&s.hooks.trigger(s.hooks.eventTypes.move,r),s.hooks.trigger(s.hooks.eventTypes.end,r);return}p=(p-l)/n;var v=i(p),k={};Object.keys(r).forEach(function(d){var m=e[d],g=r[d];k[d]=(g-m)*v+m}),s.translate(k),a&&s.hooks.trigger(s.hooks.eventTypes.move,k),s.pending&&(s.timer=Ct(u)),s.pending||(s.callStopWhenPending?s.callStopWhenPending=!1:s.hooks.trigger(s.hooks.eventTypes.end,r))};this.setPending(!0),this.callStopWhenPending&&this.setCallStop(!1),A(this.timer),u()},t.prototype.doStop=function(){var e=this.pending;if(this.setForceStopped(!1),this.setCallStop(!1),e){this.setPending(!1),A(this.timer);var r=this.translater.getComputedPosition();this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,r)}return e},t.prototype.stop=function(){var e=this.doStop();e&&this.hooks.trigger(this.hooks.eventTypes.callStop)},t}(Bt);function le(o,t,e){var r=e.useTransition,n={};return Object.defineProperty(n,"probeType",{enumerable:!0,configurable:!1,get:function(){return e.probeType}}),r?new se(o,t,n):new ae(o,t,n)}var _t=function(){function o(t,e,r){this.wrapper=t,this.options=r,this.hooks=new C(["beforeComputeBoundary","computeBoundary","momentum","end","ignoreHasScroll"]),this.refresh(e)}return o.prototype.start=function(){this.dist=0,this.setMovingDirection(0),this.setDirection(0)},o.prototype.move=function(t){return t=this.hasScroll?t:0,this.setMovingDirection(t),this.performDampingAlgorithm(t,this.options.outOfBoundaryDampingFactor)},o.prototype.setMovingDirection=function(t){this.movingDirection=t>0?-1:t<0?1:0},o.prototype.setDirection=function(t){this.direction=t>0?-1:t<0?1:0},o.prototype.performDampingAlgorithm=function(t,e){var r=this.currentPos+t;return(r>this.minScrollPos||r<this.maxScrollPos)&&(r>this.minScrollPos&&this.options.bounces[0]||r<this.maxScrollPos&&this.options.bounces[1]?r=this.currentPos+t*e:r=r>this.minScrollPos?this.minScrollPos:this.maxScrollPos),r},o.prototype.end=function(t){var e={duration:0},r=Math.abs(this.currentPos-this.startPos);if(this.options.momentum&&t<this.options.momentumLimitTime&&r>this.options.momentumLimitDistance){var n=this.direction===-1&&this.options.bounces[0]||this.direction===1&&this.options.bounces[1]?this.wrapperSize:0;e=this.hasScroll?this.momentum(this.currentPos,this.startPos,t,this.maxScrollPos,this.minScrollPos,n,this.options):{destination:this.currentPos,duration:0}}else this.hooks.trigger(this.hooks.eventTypes.end,e);return e},o.prototype.momentum=function(t,e,r,n,i,s,l){l===void 0&&(l=this.options);var h=t-e,a=Math.abs(h)/r,u=l.deceleration,p=l.swipeBounceTime,v=l.swipeTime,k=Math.min(v,a*2/u),d={destination:t+a*a/u*(h<0?-1:1),duration:k,rate:15};return this.hooks.trigger(this.hooks.eventTypes.momentum,d,h),d.destination<n?(d.destination=s?Math.max(n-s/4,n-s/d.rate*a):n,d.duration=p):d.destination>i&&(d.destination=s?Math.min(i+s/4,i+s/d.rate*a):i,d.duration=p),d.destination=Math.round(d.destination),d},o.prototype.updateDirection=function(){var t=this.currentPos-this.absStartPos;this.setDirection(t)},o.prototype.refresh=function(t){var e=this.options.rect,r=e.size,n=e.position,i=window.getComputedStyle(this.wrapper,null).position==="static",s=Pt(this.wrapper);this.wrapperSize=this.wrapper[r==="width"?"clientWidth":"clientHeight"],this.setContent(t);var l=Pt(this.content);this.contentSize=l[r],this.relativeOffset=l[n],i&&(this.relativeOffset-=s[n]),this.computeBoundary(),this.setDirection(0)},o.prototype.setContent=function(t){t!==this.content&&(this.content=t,this.resetState())},o.prototype.resetState=function(){this.currentPos=0,this.startPos=0,this.dist=0,this.setDirection(0),this.setMovingDirection(0),this.resetStartPos()},o.prototype.computeBoundary=function(){this.hooks.trigger(this.hooks.eventTypes.beforeComputeBoundary);var t={minScrollPos:0,maxScrollPos:this.wrapperSize-this.contentSize};t.maxScrollPos<0&&(t.maxScrollPos-=this.relativeOffset,this.options.specifiedIndexAsContent===0&&(t.minScrollPos=-this.relativeOffset)),this.hooks.trigger(this.hooks.eventTypes.computeBoundary,t),this.minScrollPos=t.minScrollPos,this.maxScrollPos=t.maxScrollPos,this.hasScroll=this.options.scrollable&&this.maxScrollPos<this.minScrollPos,!this.hasScroll&&this.minScrollPos<this.maxScrollPos&&(this.maxScrollPos=this.minScrollPos,this.contentSize=this.wrapperSize)},o.prototype.updatePosition=function(t){this.currentPos=t},o.prototype.getCurrentPos=function(){return this.currentPos},o.prototype.checkInBoundary=function(){var t=this.adjustPosition(this.currentPos),e=t===this.getCurrentPos();return{position:t,inBoundary:e}},o.prototype.adjustPosition=function(t){return!this.hasScroll&&!this.hooks.trigger(this.hooks.eventTypes.ignoreHasScroll)?t=this.minScrollPos:t>this.minScrollPos?t=this.minScrollPos:t<this.maxScrollPos&&(t=this.maxScrollPos),t},o.prototype.updateStartPos=function(){this.startPos=this.currentPos},o.prototype.updateAbsStartPos=function(){this.absStartPos=this.currentPos},o.prototype.resetStartPos=function(){this.updateStartPos(),this.updateAbsStartPos()},o.prototype.getAbsDist=function(t){return this.dist+=t,Math.abs(this.dist)},o.prototype.destroy=function(){this.hooks.destroy()},o}(),V,$,j,U,At=(V={},V.yes=function(o){return!0},V.no=function(o){return Tt(o),!1},V),ce=($={},$.horizontal=(j={},j.yes="horizontal",j.no="vertical",j),$.vertical=(U={},U.yes="vertical",U.no="horizontal",U),$),he=function(){function o(t,e,r){this.directionLockThreshold=t,this.freeScroll=e,this.eventPassthrough=r,this.reset()}return o.prototype.reset=function(){this.directionLocked=""},o.prototype.checkMovingDirection=function(t,e,r){return this.computeDirectionLock(t,e),this.handleEventPassthrough(r)},o.prototype.adjustDelta=function(t,e){return this.directionLocked==="horizontal"?e=0:this.directionLocked==="vertical"&&(t=0),{deltaX:t,deltaY:e}},o.prototype.computeDirectionLock=function(t,e){this.directionLocked===""&&!this.freeScroll&&(t>e+this.directionLockThreshold?this.directionLocked="horizontal":e>=t+this.directionLockThreshold?this.directionLocked="vertical":this.directionLocked="none")},o.prototype.handleEventPassthrough=function(t){var e=ce[this.directionLocked];if(e){if(this.eventPassthrough===e.yes)return At.yes(t);if(this.eventPassthrough===e.no)return At.no(t)}return!1},o}(),ue=function(o,t,e){return e===2?[t,-o]:e===3?[-o,-t]:e===4?[-t,o]:[o,t]},pe=function(){function o(t,e,r,n,i){this.hooks=new C(["start","beforeMove","scrollStart","scroll","beforeEnd","end","scrollEnd","contentNotMoved","detectMovingDirection","coordinateTransformation"]),this.scrollBehaviorX=t,this.scrollBehaviorY=e,this.actionsHandler=r,this.animater=n,this.options=i,this.directionLockAction=new he(i.directionLockThreshold,i.freeScroll,i.eventPassthrough),this.enabled=!0,this.bindActionsHandler()}return o.prototype.bindActionsHandler=function(){var t=this;this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start,function(e){return t.enabled?t.handleStart(e):!0}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move,function(e){var r=e.deltaX,n=e.deltaY,i=e.e;if(!t.enabled)return!0;var s=ue(r,n,t.options.quadrant),l=s[0],h=s[1],a={deltaX:l,deltaY:h};return t.hooks.trigger(t.hooks.eventTypes.coordinateTransformation,a),t.handleMove(a.deltaX,a.deltaY,i)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end,function(e){return t.enabled?t.handleEnd(e):!0}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click,function(e){t.enabled&&!e._constructed&&t.handleClick(e)})},o.prototype.handleStart=function(t){var e=D();this.fingerMoved=!1,this.contentMoved=!1,this.startTime=e,this.directionLockAction.reset(),this.scrollBehaviorX.start(),this.scrollBehaviorY.start(),this.animater.doStop(),this.scrollBehaviorX.resetStartPos(),this.scrollBehaviorY.resetStartPos(),this.hooks.trigger(this.hooks.eventTypes.start,t)},o.prototype.handleMove=function(t,e,r){if(!this.hooks.trigger(this.hooks.eventTypes.beforeMove,r)){var n=this.scrollBehaviorX.getAbsDist(t),i=this.scrollBehaviorY.getAbsDist(e),s=D();if(this.checkMomentum(n,i,s))return!0;if(this.directionLockAction.checkMovingDirection(n,i,r))return this.actionsHandler.setInitiated(),!0;var l=this.directionLockAction.adjustDelta(t,e),h=this.scrollBehaviorX.getCurrentPos(),a=this.scrollBehaviorX.move(l.deltaX),u=this.scrollBehaviorY.getCurrentPos(),p=this.scrollBehaviorY.move(l.deltaY);if(!this.hooks.trigger(this.hooks.eventTypes.detectMovingDirection)){this.fingerMoved||(this.fingerMoved=!0);var v=a!==h||p!==u;!this.contentMoved&&!v&&this.hooks.trigger(this.hooks.eventTypes.contentNotMoved),!this.contentMoved&&v&&(this.contentMoved=!0,this.hooks.trigger(this.hooks.eventTypes.scrollStart)),this.contentMoved&&v&&(this.animater.translate({x:a,y:p}),this.dispatchScroll(s))}}},o.prototype.dispatchScroll=function(t){t-this.startTime>this.options.momentumLimitTime&&(this.startTime=t,this.scrollBehaviorX.updateStartPos(),this.scrollBehaviorY.updateStartPos(),this.options.probeType===1&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())),this.options.probeType>1&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())},o.prototype.checkMomentum=function(t,e,r){return r-this.endTime>this.options.momentumLimitTime&&e<this.options.momentumLimitDistance&&t<this.options.momentumLimitDistance},o.prototype.handleEnd=function(t){if(!this.hooks.trigger(this.hooks.eventTypes.beforeEnd,t)){var e=this.getCurrentPos();if(this.scrollBehaviorX.updateDirection(),this.scrollBehaviorY.updateDirection(),this.hooks.trigger(this.hooks.eventTypes.end,t,e))return!0;e=this.ensureIntegerPos(e),this.animater.translate(e),this.endTime=D();var r=this.endTime-this.startTime;this.hooks.trigger(this.hooks.eventTypes.scrollEnd,e,r)}},o.prototype.ensureIntegerPos=function(t){this.ensuringInteger=!0;var e=t.x,r=t.y,n=this.scrollBehaviorX,i=n.minScrollPos,s=n.maxScrollPos,l=this.scrollBehaviorY,h=l.minScrollPos,a=l.maxScrollPos;return e=e>0?Math.ceil(e):Math.floor(e),r=r>0?Math.ceil(r):Math.floor(r),e=gt(e,s,i),r=gt(r,a,h),{x:e,y:r}},o.prototype.handleClick=function(t){H(t.target,this.options.preventDefaultException)||(Tt(t),t.stopPropagation())},o.prototype.getCurrentPos=function(){return{x:this.scrollBehaviorX.getCurrentPos(),y:this.scrollBehaviorY.getCurrentPos()}},o.prototype.refresh=function(){this.endTime=0},o.prototype.destroy=function(){this.hooks.destroy()},o}();function fe(o){var t=["click","bindToWrapper","disableMouse","disableTouch","preventDefault","stopPropagation","tagException","preventDefaultException","autoEndDistance"].reduce(function(e,r){return e[r]=o[r],e},{});return t}function Yt(o,t,e,r){var n=["momentum","momentumLimitTime","momentumLimitDistance","deceleration","swipeBounceTime","swipeTime","outOfBoundaryDampingFactor","specifiedIndexAsContent"].reduce(function(i,s){return i[s]=o[s],i},{});return n.scrollable=!!o[t],n.bounces=e,n.rect=r,n}function at(o,t,e){e.forEach(function(r){var n,i;typeof r=="string"?n=i=r:(n=r.source,i=r.target),o.on(n,function(){for(var s=[],l=0;l<arguments.length;l++)s[l]=arguments[l];return t.trigger.apply(t,vt([i],s))})})}function de(o,t){for(var e=Object.keys(o),r=0,n=e;r<n.length;r++){var i=n[r];if(o[i]!==t[i])return!1}return!0}var Mt=1,ve=function(){function o(t,e,r){this.wrapper=t,this.content=e,this.resizeTimeout=0,this.hooks=new C(["beforeStart","beforeMove","beforeScrollStart","scrollStart","scroll","beforeEnd","scrollEnd","resize","touchEnd","end","flick","scrollCancel","momentum","scrollTo","minDistanceScroll","scrollToElement","beforeRefresh"]),this.options=r;var n=this.options.bounce,i=n.left,s=n.right,l=n.top,h=n.bottom;this.scrollBehaviorX=new _t(t,e,Yt(r,"scrollX",[i,s],{size:"width",position:"left"})),this.scrollBehaviorY=new _t(t,e,Yt(r,"scrollY",[l,h],{size:"height",position:"top"})),this.translater=new ne(this.content),this.animater=le(this.content,this.translater,this.options),this.actionsHandler=new re(this.options.bindToTarget?this.content:t,fe(this.options)),this.actions=new pe(this.scrollBehaviorX,this.scrollBehaviorY,this.actionsHandler,this.animater,this.options);var a=this.resize.bind(this);this.resizeRegister=new R(window,[{name:"orientationchange",handler:a},{name:"resize",handler:a}]),this.registerTransitionEnd(),this.init()}return o.prototype.init=function(){var t=this;this.bindTranslater(),this.bindAnimater(),this.bindActions(),this.hooks.on(this.hooks.eventTypes.scrollEnd,function(){t.togglePointerEvents(!0)})},o.prototype.registerTransitionEnd=function(){this.transitionEndRegister=new R(this.content,[{name:B.transitionEnd,handler:this.transitionEnd.bind(this)}])},o.prototype.bindTranslater=function(){var t=this,e=this.translater.hooks;e.on(e.eventTypes.beforeTranslate,function(r){t.options.translateZ&&r.push(t.options.translateZ)}),e.on(e.eventTypes.translate,function(r){var n=t.getCurrentPos();if(t.updatePositions(r),t.actions.ensuringInteger===!0){t.actions.ensuringInteger=!1;return}(r.x!==n.x||r.y!==n.y)&&t.togglePointerEvents(!1)})},o.prototype.bindAnimater=function(){var t=this;this.animater.hooks.on(this.animater.hooks.eventTypes.end,function(e){t.resetPosition(t.options.bounceTime)||(t.animater.setPending(!1),t.hooks.trigger(t.hooks.eventTypes.scrollEnd,e))}),at(this.animater.hooks,this.hooks,[{source:this.animater.hooks.eventTypes.move,target:this.hooks.eventTypes.scroll},{source:this.animater.hooks.eventTypes.forceStop,target:this.hooks.eventTypes.scrollEnd}])},o.prototype.bindActions=function(){var t=this,e=this.actions;at(e.hooks,this.hooks,[{source:e.hooks.eventTypes.start,target:this.hooks.eventTypes.beforeStart},{source:e.hooks.eventTypes.start,target:this.hooks.eventTypes.beforeScrollStart},{source:e.hooks.eventTypes.beforeMove,target:this.hooks.eventTypes.beforeMove},{source:e.hooks.eventTypes.scrollStart,target:this.hooks.eventTypes.scrollStart},{source:e.hooks.eventTypes.scroll,target:this.hooks.eventTypes.scroll},{source:e.hooks.eventTypes.beforeEnd,target:this.hooks.eventTypes.beforeEnd}]),e.hooks.on(e.hooks.eventTypes.end,function(r,n){if(t.hooks.trigger(t.hooks.eventTypes.touchEnd,n),t.hooks.trigger(t.hooks.eventTypes.end,n)||!e.fingerMoved&&(t.hooks.trigger(t.hooks.eventTypes.scrollCancel),t.checkClick(r)))return!0;if(t.resetPosition(t.options.bounceTime,_.bounce))return t.animater.setForceStopped(!1),!0}),e.hooks.on(e.hooks.eventTypes.scrollEnd,function(r,n){var i=Math.abs(r.x-t.scrollBehaviorX.startPos),s=Math.abs(r.y-t.scrollBehaviorY.startPos);if(t.checkFlick(n,i,s)){t.animater.setForceStopped(!1),t.hooks.trigger(t.hooks.eventTypes.flick);return}if(t.momentum(r,n)){t.animater.setForceStopped(!1);return}e.contentMoved&&t.hooks.trigger(t.hooks.eventTypes.scrollEnd,r),t.animater.forceStopped&&t.animater.setForceStopped(!1)})},o.prototype.checkFlick=function(t,e,r){var n=1;if(this.hooks.events.flick.length>1&&t<this.options.flickLimitTime&&e<this.options.flickLimitDistance&&r<this.options.flickLimitDistance&&(r>n||e>n))return!0},o.prototype.momentum=function(t,e){var r={time:0,easing:_.swiper,newX:t.x,newY:t.y},n=this.scrollBehaviorX.end(e),i=this.scrollBehaviorY.end(e);if(r.newX=ot(n.destination)?r.newX:n.destination,r.newY=ot(i.destination)?r.newY:i.destination,r.time=Math.max(n.duration,i.duration),this.hooks.trigger(this.hooks.eventTypes.momentum,r,this),r.newX!==t.x||r.newY!==t.y)return(r.newX>this.scrollBehaviorX.minScrollPos||r.newX<this.scrollBehaviorX.maxScrollPos||r.newY>this.scrollBehaviorY.minScrollPos||r.newY<this.scrollBehaviorY.maxScrollPos)&&(r.easing=_.swipeBounce),this.scrollTo(r.newX,r.newY,r.time,r.easing),!0},o.prototype.checkClick=function(t){var e={preventClick:this.animater.forceStopped};if(this.hooks.trigger(this.hooks.eventTypes.checkClick))return this.animater.setForceStopped(!1),!0;if(!e.preventClick){var r=this.options.dblclick,n=!1;if(r&&this.lastClickTime){var i=r.delay,s=i===void 0?300:i;D()-this.lastClickTime<s&&(n=!0,Gt(t))}return this.options.tap&&qt(t,this.options.tap),this.options.click&&!H(t.target,this.options.preventDefaultException)&&Et(t),this.lastClickTime=n?null:D(),!0}return!1},o.prototype.resize=function(){var t=this;this.actions.enabled&&(Nt&&(this.wrapper.scrollTop=0),clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(function(){t.hooks.trigger(t.hooks.eventTypes.resize)},this.options.resizePolling))},o.prototype.transitionEnd=function(t){if(!(t.target!==this.content||!this.animater.pending)){var e=this.animater;e.transitionTime(),this.resetPosition(this.options.bounceTime,_.bounce)||(this.animater.setPending(!1),this.options.probeType!==3&&this.hooks.trigger(this.hooks.eventTypes.scrollEnd,this.getCurrentPos()))}},o.prototype.togglePointerEvents=function(t){t===void 0&&(t=!0);for(var e=this.content.children.length?this.content.children:[this.content],r=t?"auto":"none",n=0;n<e.length;n++){var i=e[n];i.isBScrollContainer||(i.style.pointerEvents=r)}},o.prototype.refresh=function(t){var e=this.setContent(t);this.hooks.trigger(this.hooks.eventTypes.beforeRefresh),this.scrollBehaviorX.refresh(t),this.scrollBehaviorY.refresh(t),e&&(this.translater.setContent(t),this.animater.setContent(t),this.transitionEndRegister.destroy(),this.registerTransitionEnd(),this.options.bindToTarget&&this.actionsHandler.setContent(t)),this.actions.refresh(),this.wrapperOffset=bt(this.wrapper)},o.prototype.setContent=function(t){var e=t!==this.content;return e&&(this.content=t),e},o.prototype.scrollBy=function(t,e,r,n){r===void 0&&(r=0);var i=this.getCurrentPos(),s=i.x,l=i.y;n=n||_.bounce,t+=s,e+=l,this.scrollTo(t,e,r,n)},o.prototype.scrollTo=function(t,e,r,n,i){r===void 0&&(r=0),n===void 0&&(n=_.bounce),i===void 0&&(i={start:{},end:{}});var s=this.options.useTransition?n.style:n.fn,l=this.getCurrentPos(),h=z({x:l.x,y:l.y},i.start),a=z({x:t,y:e},i.end);if(this.hooks.trigger(this.hooks.eventTypes.scrollTo,a),!de(h,a)){var u=Math.abs(a.x-h.x),p=Math.abs(a.y-h.y);u<Mt&&p<Mt&&(r=0,this.hooks.trigger(this.hooks.eventTypes.minDistanceScroll)),this.animater.move(h,a,r,s)}},o.prototype.scrollToElement=function(t,e,r,n,i){var s=kt(t),l=bt(s),h=function(u,p,v){return typeof u=="number"?u:u?Math.round(p/2-v/2):0};r=h(r,s.offsetWidth,this.wrapper.offsetWidth),n=h(n,s.offsetHeight,this.wrapper.offsetHeight);var a=function(u,p,v,k){return u-=p,u=k.adjustPosition(u-v),u};l.left=a(l.left,this.wrapperOffset.left,r,this.scrollBehaviorX),l.top=a(l.top,this.wrapperOffset.top,n,this.scrollBehaviorY),!this.hooks.trigger(this.hooks.eventTypes.scrollToElement,s,l)&&this.scrollTo(l.left,l.top,e,i)},o.prototype.resetPosition=function(t,e){t===void 0&&(t=0),e===void 0&&(e=_.bounce);var r=this.scrollBehaviorX.checkInBoundary(),n=r.position,i=r.inBoundary,s=this.scrollBehaviorY.checkInBoundary(),l=s.position,h=s.inBoundary;return i&&h?!1:(Ft&&this.reflow(),this.scrollTo(n,l,t,e),!0)},o.prototype.reflow=function(){this._reflow=this.content.offsetHeight},o.prototype.updatePositions=function(t){this.scrollBehaviorX.updatePosition(t.x),this.scrollBehaviorY.updatePosition(t.y)},o.prototype.getCurrentPos=function(){return this.actions.getCurrentPos()},o.prototype.enable=function(){this.actions.enabled=!0},o.prototype.disable=function(){A(this.animater.timer),this.actions.enabled=!1},o.prototype.destroy=function(){var t=this,e=["resizeRegister","transitionEndRegister","actionsHandler","actions","hooks","animater","translater","scrollBehaviorX","scrollBehaviorY"];e.forEach(function(r){return t[r].destroy()})},o}(),q=function(o){W(t,o);function t(e,r){var n=o.call(this,["refresh","contentChanged","enable","disable","beforeScrollStart","scrollStart","scroll","scrollEnd","scrollCancel","touchEnd","flick","destroy"])||this,i=kt(e);return i?(n.plugins={},n.options=new oe().merge(r).process(),n.setContent(i).valid&&(n.hooks=new C(["refresh","enable","disable","destroy","beforeInitialScrollTo","contentChanged"]),n.init(i)),n):(K("Can not resolve the wrapper DOM."),n)}return t.use=function(e){var r=e.pluginName,n=t.plugins.some(function(i){return e===i.ctor});return n?t:ot(r)?(K("Plugin Class must specify plugin's name in static property by 'pluginName' field."),t):(t.pluginsMap[r]=!0,t.plugins.push({name:r,applyOrder:e.applyOrder,ctor:e}),t)},t.prototype.setContent=function(e){var r=!1,n=!0,i=e.children[this.options.specifiedIndexAsContent];return i?(r=this.content!==i,r&&(this.content=i)):(K("The wrapper need at least one child element to be content element to scroll."),n=!1),{valid:n,contentChanged:r}},t.prototype.init=function(e){var r=this;this.wrapper=e,e.isBScrollContainer=!0,this.scroller=new ve(e,this.content,this.options),this.scroller.hooks.on(this.scroller.hooks.eventTypes.resize,function(){r.refresh()}),this.eventBubbling(),this.handleAutoBlur(),this.enable(),this.proxy(zt),this.applyPlugins(),this.refreshWithoutReset(this.content);var n=this.options,i=n.startX,s=n.startY,l={x:i,y:s};this.hooks.trigger(this.hooks.eventTypes.beforeInitialScrollTo,l)||this.scroller.scrollTo(l.x,l.y)},t.prototype.applyPlugins=function(){var e=this,r=this.options;t.plugins.sort(function(n,i){var s,l=(s={},s.pre=-1,s.post=1,s),h=n.applyOrder?l[n.applyOrder]:0,a=i.applyOrder?l[i.applyOrder]:0;return h-a}).forEach(function(n){var i=n.ctor;r[n.name]&&typeof i=="function"&&(e.plugins[n.name]=new i(e))})},t.prototype.handleAutoBlur=function(){this.options.autoBlur&&this.on(this.eventTypes.beforeScrollStart,function(){var e=document.activeElement;e&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")&&e.blur()})},t.prototype.eventBubbling=function(){at(this.scroller.hooks,this,[this.eventTypes.beforeScrollStart,this.eventTypes.scrollStart,this.eventTypes.scroll,this.eventTypes.scrollEnd,this.eventTypes.scrollCancel,this.eventTypes.touchEnd,this.eventTypes.flick])},t.prototype.refreshWithoutReset=function(e){this.scroller.refresh(e),this.hooks.trigger(this.hooks.eventTypes.refresh,e),this.trigger(this.eventTypes.refresh,e)},t.prototype.proxy=function(e){var r=this;e.forEach(function(n){var i=n.key,s=n.sourceKey;te(r,s,i)})},t.prototype.refresh=function(){var e=this.setContent(this.wrapper),r=e.contentChanged,n=e.valid;if(n){var i=this.content;this.refreshWithoutReset(i),r&&(this.hooks.trigger(this.hooks.eventTypes.contentChanged,i),this.trigger(this.eventTypes.contentChanged,i)),this.scroller.resetPosition()}},t.prototype.enable=function(){this.scroller.enable(),this.hooks.trigger(this.hooks.eventTypes.enable),this.trigger(this.eventTypes.enable)},t.prototype.disable=function(){this.scroller.disable(),this.hooks.trigger(this.hooks.eventTypes.disable),this.trigger(this.eventTypes.disable)},t.prototype.destroy=function(){this.hooks.trigger(this.hooks.eventTypes.destroy),this.trigger(this.eventTypes.destroy),this.scroller.destroy()},t.prototype.eventRegister=function(e){this.registerType(e)},t.plugins=[],t.pluginsMap={},t}(C);function N(o,t){var e=new q(o,t);return e}N.use=q.use,N.plugins=q.plugins,N.pluginsMap=q.pluginsMap;var me=N;/*!
|
|
20
|
-
* better-scroll / wheel
|
|
21
|
-
* (c) 2016-2023 ustbhuangyi
|
|
22
|
-
* Released under the MIT License.
|
|
23
|
-
*/var F=typeof window<"u",G=F&&navigator.userAgent.toLowerCase();G&&G.indexOf("android")>0,function(){if(typeof G=="string"){var o=/os (\d\d?_\d(_\d)?)/,t=o.exec(G);if(!t)return!1;var e=t[1].split("_").map(function(r){return parseInt(r,10)});return e[0]===13&&e[1]>=4}return!1}();var ye=!1;if(F){var ge="test-passive";try{var Xt={};Object.defineProperty(Xt,"passive",{get:function(){ye=!0}}),window.addEventListener(ge,function(){},Xt)}catch{}}var ke=function(o,t){for(var e in t)o[e]=t[e];return o},Ot=F&&document.createElement("div").style,L=function(){if(!F)return!1;for(var o=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}],t=0,e=o;t<e.length;t++){var r=e[t];if(Ot[r.value]!==void 0)return r.key}return!1}();function P(o){return L===!1?o:L==="standard"?o==="transitionEnd"?"transitionend":o:L+o.charAt(0).toUpperCase()+o.substr(1)}L&&L!=="standard"&&""+L.toLowerCase();var Te=P("transform"),be=P("transition");F&&P("perspective")in Ot;var lt={transform:Te,transition:be,transitionTimingFunction:P("transitionTimingFunction"),transitionDuration:P("transitionDuration"),transitionDelay:P("transitionDelay"),transformOrigin:P("transformOrigin"),transitionEnd:P("transitionEnd"),transitionProperty:P("transitionProperty")};function Z(o,t){var e=new RegExp("(^|\\s)"+t+"(\\s|$)");return e.test(o.className)}function Se(o){return Array.prototype.slice.call(o,0)}var we={swipe:{style:"cubic-bezier(0.23, 1, 0.32, 1)",fn:function(o){return 1+--o*o*o*o*o}},swipeBounce:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(o){return o*(2-o)}},bounce:{style:"cubic-bezier(0.165, 0.84, 0.44, 1)",fn:function(o){return 1- --o*o*o*o}}},Pe="plugins.wheel",Ee=[{key:"wheelTo",name:"wheelTo"},{key:"getSelectedIndex",name:"getSelectedIndex"},{key:"restorePosition",name:"restorePosition"}],xe=Ee.map(function(o){return{key:o.key,sourceKey:Pe+"."+o.name}}),Lt="wheelIndexChanged",Ce={rate:4},De=function(){function o(t){this.scroll=t,this.init()}return o.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.refreshBoundary(),this.setSelectedIndex(this.options.selectedIndex)},o.prototype.handleBScroll=function(){this.scroll.proxy(xe),this.scroll.registerType([Lt])},o.prototype.handleOptions=function(){var t=this.scroll.options.wheel===!0?{}:this.scroll.options.wheel,e={wheelWrapperClass:"wheel-scroll",wheelItemClass:"wheel-item",rotate:25,adjustTime:400,selectedIndex:0,wheelDisabledItemClass:"wheel-disabled-item"};this.options=ke(e,t)},o.prototype.handleHooks=function(){var t=this,e=this.scroll,r=this.scroll.scroller,n=r.actionsHandler,i=r.scrollBehaviorX,s=r.scrollBehaviorY,l=r.animater,h=r.content;e.on(e.eventTypes.scrollEnd,function(a){var u=t.findNearestValidWheel(a.y).index;if(r.animater.forceStopped&&!t.isAdjustingPosition)return t.target=t.items[u],!0;t.setSelectedIndex(u),t.isAdjustingPosition&&(t.isAdjustingPosition=!1)}),this.scroll.hooks.on(this.scroll.hooks.eventTypes.refresh,function(a){a!==h&&(h=a,t.setSelectedIndex(t.options.selectedIndex,!0)),t.rotateX(t.scroll.y),t.wheelTo(t.selectedIndex,0)}),this.scroll.hooks.on(this.scroll.hooks.eventTypes.beforeInitialScrollTo,function(a){a.x=0,a.y=-(t.selectedIndex*t.itemHeight)}),r.hooks.on(r.hooks.eventTypes.checkClick,function(){var a=Se(t.items).indexOf(t.target);return a===-1||t.wheelTo(a,t.options.adjustTime,we.swipe),!0}),r.hooks.on(r.hooks.eventTypes.scrollTo,function(a){a.y=t.findNearestValidWheel(a.y).y}),r.hooks.on(r.hooks.eventTypes.minDistanceScroll,function(){var a=r.animater;a.forceStopped===!0&&(a.forceStopped=!1)}),r.hooks.on(r.hooks.eventTypes.scrollToElement,function(a,u){if(Z(a,t.options.wheelItemClass))u.top=t.findNearestValidWheel(u.top).y;else return!0}),n.hooks.on(n.hooks.eventTypes.beforeStart,function(a){t.target=a.target}),i.hooks.on(i.hooks.eventTypes.computeBoundary,function(a){a.maxScrollPos=0,a.minScrollPos=0}),s.hooks.on(s.hooks.eventTypes.computeBoundary,function(a){t.items=t.scroll.scroller.content.children,t.checkWheelAllDisabled(),t.itemHeight=t.items.length>0?s.contentSize/t.items.length:0,a.maxScrollPos=-t.itemHeight*(t.items.length-1),a.minScrollPos=0}),s.hooks.on(s.hooks.eventTypes.momentum,function(a){a.rate=Ce.rate,a.destination=t.findNearestValidWheel(a.destination).y}),s.hooks.on(s.hooks.eventTypes.end,function(a){var u=t.findNearestValidWheel(s.currentPos);a.destination=u.y,a.duration=t.options.adjustTime}),l.hooks.on(l.hooks.eventTypes.time,function(a){t.transitionDuration(a)}),l.hooks.on(l.hooks.eventTypes.timeFunction,function(a){t.timeFunction(a)}),l.hooks.on(l.hooks.eventTypes.callStop,function(){var a=t.findNearestValidWheel(t.scroll.y).index;t.isAdjustingPosition=!0,t.wheelTo(a,0)}),l.translater.hooks.on(l.translater.hooks.eventTypes.translate,function(a){t.rotateX(a.y)})},o.prototype.refreshBoundary=function(){var t=this.scroll.scroller,e=t.scrollBehaviorX,r=t.scrollBehaviorY,n=t.content;e.refresh(n),r.refresh(n)},o.prototype.setSelectedIndex=function(t,e){e===void 0&&(e=!1);var r=this.selectedIndex;this.selectedIndex=t,r!==t&&!e&&this.scroll.trigger(Lt,t)},o.prototype.getSelectedIndex=function(){return this.selectedIndex},o.prototype.wheelTo=function(t,e,r){t===void 0&&(t=0),e===void 0&&(e=0);var n=-t*this.itemHeight;this.scroll.scrollTo(0,n,e,r)},o.prototype.restorePosition=function(){var t=this.scroll.pending;if(t){var e=this.getSelectedIndex();this.scroll.scroller.animater.clearTimer(),this.wheelTo(e,0)}},o.prototype.transitionDuration=function(t){for(var e=0;e<this.items.length;e++)this.items[e].style[lt.transitionDuration]=t+"ms"},o.prototype.timeFunction=function(t){for(var e=0;e<this.items.length;e++)this.items[e].style[lt.transitionTimingFunction]=t},o.prototype.rotateX=function(t){for(var e=this.options.rotate,r=e===void 0?25:e,n=0;n<this.items.length;n++){var i=r*(t/this.itemHeight+n),s=i.toFixed(3);this.items[n].style[lt.transform]="rotateX("+s+"deg)"}},o.prototype.findNearestValidWheel=function(t){t=t>0?0:t<this.scroll.maxScrollY?this.scroll.maxScrollY:t;for(var e=Math.abs(Math.round(-t/this.itemHeight)),r=e,n=this.items,i=this.options.wheelDisabledItemClass;e>=0&&Z(n[e],i);)e--;if(e<0)for(e=r;e<=n.length-1&&Z(n[e],i);)e++;return e===n.length&&(e=r),{index:this.wheelItemsAllDisabled?-1:e,y:-e*this.itemHeight}},o.prototype.checkWheelAllDisabled=function(){var t=this.options.wheelDisabledItemClass,e=this.items;this.wheelItemsAllDisabled=!0;for(var r=0;r<e.length;r++)if(!Z(e[r],t)){this.wheelItemsAllDisabled=!1;break}},o.pluginName="wheel",o}();me.use(De);const J=Array.isArray,Be=o=>typeof o=="object"&&o!==null;function ct(o){return J(o)&&o.length===3}function _e(o){return o%4===0&&(o%100!==0||o%400===0)}function I(o,t){const e=[];for(let r=o;r<=t;r++)e.push(r);return e}function ht(o,t){const e=[];for(let r=o;r<=t;r++)e.push(`${r}`.padStart(2,"0"));return e}function Ae(){const o=ht(0,23),t=ht(0,59),e=ht(0,59),r=c.ref([]);n();function n(){const s=new Date,l=s.getHours(),h=s.getMinutes(),a=s.getSeconds();r.value=[l,h,a]}function i(s){return(ct(s)?s:r.value).map(h=>+h)}return{timeList:[o,t,e],updateDefaultTime:n,getTimeAnchors:i}}function Ye(){const e=new Date,r=e.getFullYear(),n=e.getMonth()+1,i=e.getDate(),s=c.ref(r),l=c.ref(n),h=I(1900,2100),a=I(1,12),u=c.computed(()=>{const d=[4,6,9,11],m=[1,3,5,7,8,10,12];return d.includes(l.value)?I(1,30):m.includes(l.value)?I(1,31):_e(s.value)?I(1,29):I(1,28)}),p=c.computed(()=>[h,a,u.value]);function v(d){return(ct(d)?d:[r,n,i]).map((g,Y)=>{const E=p.value[Y].indexOf(g);return E!==-1?E:0})}function k(d){const[m,g]=d;s.value=p.value[0][m],l.value=p.value[1][g]}return{selectYear:s,selectMonth:l,dateList:p,updateDateSelect:k,getDateAnchors:v}}function Me(o,t){const e=c.ref([]),r=c.ref(),n=c.ref([]),i=c.computed(()=>o.type==="date"),s=c.computed(()=>o.type==="time"),{selectYear:l,selectMonth:h,dateList:a,updateDateSelect:u,getDateAnchors:p}=Ye(),{timeList:v,updateDefaultTime:k,getTimeAnchors:d}=Ae(),m=c.computed(()=>i.value?p(o.anchor):s.value?d(o.anchor):J(o.anchor)?o.anchor:[o.anchor]);async function g(f=!1){f?Y():E(),await c.nextTick(),e.value.forEach((T,y)=>ut(y)),f||He(),Ne()}function Y(){const f={date:a==null?void 0:a.value,time:v},T=o.type,b=J(o.data[0])?[...o.data]:[o.data];e.value=f[T]??b}function E(){!i.value&&!s.value||(i.value&&u(m.value),s.value&&!ct(o.anchor)&&k())}function ut(f){var b;const T=(b=r.value)==null?void 0:b.children[f];if(!T)return;let y=n.value[f];if(y)y.refresh();else{const ft=N(T,{wheel:{selectedIndex:0,rotate:25},swipeTime:o.swipeTime??500});y=n.value[f]=ft,y.on("scrollEnd",()=>Q(f))}return y}function Q(f){if(!i.value||f===2)return;const T=n.value[f].getSelectedIndex(),y=a.value[f][T];f===0&&(l.value=y),f===1&&(h.value=y),g(!0)}function He(){n.value.forEach((f,T)=>{var b;const y=(b=m.value)==null?void 0:b[T];f.wheelTo(y??0)})}function Ne(){const f=e.value.length;if(n.value.length<=f)return;n.value.splice(f).forEach(y=>y.destroy())}function Fe(){t("cancel"),pt()}function We(){n.value.some(b=>b.isInTransition)&&Ke();const{item:T,anchor:y}=Re();t("confirm",T),t("update:anchor",y),pt()}function pt(){t("update:isShowPicker",!1)}function Ke(){n.value.forEach(f=>f.stop())}function Re(){const{item:f,anchor:T}=n.value.reduce((y,b,ft)=>{const It=b.getSelectedIndex(),dt=e.value[ft][It];return y.item.push(s.value?+dt:dt),y.anchor.push(i.value?dt:It),y},{item:[],anchor:[]});return f.length>1?{item:f,anchor:T}:{item:f[0],anchor:T[0]}}return c.watch(()=>o.data,()=>g(!0),{immediate:!0}),c.watch(()=>o.isShowPicker,f=>f&&g()),c.watch(()=>o.type,()=>{E(),g(!0)}),{pickerData:e,wheelWrapper:r,cancel:Fe,confirm:We,closePicker:pt}}const Xe={cancelClass:"",confirmClass:"",titleClass:"",cancelColor:"#999",confirmColor:"#42b983",titleColor:"",cancelText:"Cancel",confirmText:"Confirm",titleText:""},Oe={class:"component-hook-picker"},Le={class:"component-hook-picker_title"},Ie={class:"component-hook-picker_panel"},ze={class:"component-hook-picker_wheel_scroll"};return c.defineComponent({__name:"Picker",props:{data:{default:()=>[]},isShowPicker:{type:Boolean},options:{default:()=>({})},anchor:{},showKey:{default:""},swipeTime:{default:500},type:{default:""}},emits:["update:isShowPicker","update:anchor","cancel","confirm"],setup(o,{emit:t}){const e=o,r=t,n=c.computed(()=>({...Xe,...e.options})),i=c.computed(()=>n.value.cancelColor),s=c.computed(()=>n.value.confirmColor),l=c.computed(()=>n.value.titleColor),h=c.computed(()=>J(e.showKey)?e.showKey:[e.showKey]),{pickerData:a,wheelWrapper:u,cancel:p,confirm:v,closePicker:k}=Me(e,r);return(d,m)=>(c.openBlock(),c.createElementBlock("div",null,[c.createVNode(c.Transition,{name:"component-hook-picker-fade"},{default:c.withCtx(()=>[c.withDirectives(c.createElementVNode("div",{class:"component-hook-picker-mask",onClick:m[0]||(m[0]=(...g)=>c.unref(k)&&c.unref(k)(...g))},null,512),[[c.vShow,d.isShowPicker]])]),_:1}),c.createVNode(c.Transition,{name:"component-hook-picker-slide"},{default:c.withCtx(()=>[c.withDirectives(c.createElementVNode("div",Oe,[c.createElementVNode("div",Le,[c.createElementVNode("button",{class:c.normalizeClass(["component-hook-picker_cancel",n.value.cancelClass]),style:c.normalizeStyle({color:i.value}),onClick:m[1]||(m[1]=(...g)=>c.unref(p)&&c.unref(p)(...g))},c.toDisplayString(n.value.cancelText),7),c.createElementVNode("button",{class:c.normalizeClass(["component-hook-picker_confirm",n.value.confirmClass]),style:c.normalizeStyle({color:s.value}),onClick:m[2]||(m[2]=(...g)=>c.unref(v)&&c.unref(v)(...g))},c.toDisplayString(n.value.confirmText),7),c.createElementVNode("h4",{class:c.normalizeClass([n.value.titleClass]),style:c.normalizeStyle({color:l.value})},c.toDisplayString(n.value.titleText),7)]),c.createElementVNode("div",Ie,[m[3]||(m[3]=c.createElementVNode("div",{class:"component-hook-picker_mask_top"},null,-1)),m[4]||(m[4]=c.createElementVNode("div",{class:"component-hook-picker_mask_bottom"},null,-1)),c.createElementVNode("div",{ref_key:"wheelWrapper",ref:u,class:"component-hook-picker_wheel_wrapper"},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(c.unref(a),(g,Y)=>(c.openBlock(),c.createElementBlock("div",{key:Y,class:"component-hook-picker_wheel"},[c.createElementVNode("ul",ze,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(g,(E,ut)=>{var Q;return c.openBlock(),c.createElementBlock("li",{key:ut,class:"component-hook-picker_wheel_item"},c.toDisplayString((Q=h.value)!=null&&Q[Y]&&c.unref(Be)(E)?E[h.value[Y]]:E),1)}),128))])]))),128))],512)])],512),[[c.vShow,d.isShowPicker]])]),_:1})]))}})});
|
|
1
|
+
(function(B,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(B=typeof globalThis<"u"?globalThis:B||self,e(B.picker={},B.Vue))})(this,function(B,e){"use strict";var L=document.createElement("style");L.textContent=`:root{--chook-picker-background: #fff;--chook-picker-border-radius: .5rem;--chook-picker-padding-bottom: 1.25rem;--chook-picker-z-index: 2147483646;--chook-picker-mask-background: rgba(0, 0, 0, .2);--chook-picker-header-padding: .75rem 0;--chook-picker-header-margin-bottom: 1.25rem;--chook-picker-title-font-size: 1rem;--chook-picker-title-font-weight: 500;--chook-picker-title-color: #323233;--chook-picker-confirm-color: #1989fa;--chook-picker-confirm-font-size: .875rem;--chook-picker-confirm-padding: 0 1rem;--chook-picker-cancel-color: #969799;--chook-picker-cancel-font-size: .875rem;--chook-picker-cancel-padding: 0 1rem;--chook-picker-active-opacity: .6;--chook-picker-columns-margin: 0 1rem;--chook-picker-columns-backdrop: linear-gradient( to bottom, #f2f2f2 0px, #f2f2f2 .0625rem, transparent .0625rem, transparent calc(100% - .0625rem) , #f2f2f2 calc(100% - .0625rem) , #f2f2f2 100% );--chook-picker-mask-backdrop: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .4)), linear-gradient(0deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .4));--chook-picker-column-label-color: #323233;--chook-picker-column-label-padding: 0 .25rem;--chook-picker-column-font-size: 1rem;--chook-picker-column-font-weight: 500}.chook-picker-mask{position:fixed;top:0;right:0;bottom:0;left:0;background:var(--chook-picker-mask-background);z-index:calc(var(--chook-picker-z-index) - 1)}.chook-picker-container{position:fixed;left:0;bottom:0;width:100vw;z-index:var(--chook-picker-z-index);-webkit-user-select:none;user-select:none;padding-bottom:var(--chook-picker-padding-bottom);background:var(--chook-picker-background);border-top-left-radius:var(--chook-picker-border-radius);border-top-right-radius:var(--chook-picker-border-radius)}.chook-picker-header{display:flex;align-items:center;justify-content:space-between;padding:var(--chook-picker-header-padding);margin-bottom:var(--chook-picker-header-margin-bottom)}.chook-picker-title{font-size:var(--chook-picker-title-font-size);font-weight:var(--chook-picker-title-font-weight);color:var(--chook-picker-title-color);margin:0}.chook-picker-columns{width:calc(100% - var(--chook-picker-columns-margin) * 2);height:13.5rem;overflow:hidden;position:relative;display:flex;margin:var(--chook-picker-columns-margin)}.chook-picker-columns-backdrop{background-image:var(--chook-picker-columns-backdrop);background-repeat:no-repeat;background-position:center;background-size:100% 3rem}.chook-picker-mask-backdrop{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;background-image:var(--chook-picker-mask-backdrop);background-repeat:no-repeat;background-position:top,bottom;background-size:100% 5.25rem}.chook-picker-loading{height:100%;width:100%;position:absolute;top:0;left:0}.chook-picker-column{flex:1 1 0%;overflow:hidden;padding:5.375rem 0;cursor:grab}.chook-picker-column ul{margin:0;padding:0;list-style:none}.chook-picker-column-item{height:3rem;display:flex;justify-content:center;align-items:center;cursor:grab}.chook-picker-column-label{color:var(--chook-picker-column-label-color);font-size:var(--chook-picker-column-font-size);font-weight:var(--chook-picker-column-font-weight);padding:var(--chook-picker-column-label-padding);text-overflow:ellipsis;overflow:hidden;white-space:nowrap}button.chook-picker-confirm{color:var(--chook-picker-confirm-color);font-size:var(--chook-picker-confirm-font-size);background-color:transparent;padding:var(--chook-picker-confirm-padding);border:none}button.chook-picker-confirm:active{opacity:var(--chook-picker-active-opacity)}button.chook-picker-confirm:hover{color:var(--chook-picker-confirm-color);background-color:transparent}button.chook-picker-cancel{color:var(--chook-picker-cancel-color);font-size:var(--chook-picker-cancel-font-size);background-color:transparent;padding:var(--chook-picker-cancel-padding);border:none}button.chook-picker-cancel:active{opacity:var(--chook-picker-active-opacity)}button.chook-picker-cancel:hover{color:var(--chook-picker-cancel-color);background-color:transparent}.chook-picker-fade-enter-active,.chook-picker-fade-leave-active,.chook-picker-slide-enter-active,.chook-picker-slide-leave-active{transition:all .3s ease}.chook-picker-fade-enter-from,.chook-picker-fade-leave-to{opacity:0}.chook-picker-slide-enter-from,.chook-picker-slide-leave-to{opacity:.5;transform:translate3d(0,100%,0)}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(L);const q=Array.isArray;function G(o,a){if(A(o))return"multiple";const[n]=o;return n[a.children]?"cascade":"single"}function K(o){return{children:(o==null?void 0:o.children)||"children",label:(o==null?void 0:o.label)||"label",value:(o==null?void 0:o.value)||"value"}}function Z(o,a,n){var k;if(A(o))return[];const s=[];let r=o,i=0;for(;r;){const b=a[i];let h=z(r,b,n);h===-1&&(h=0),s.push(r),i+=1,r=(k=r[h])==null?void 0:k[n.children]}return s}function J(o,a,n,s){const r=[...n];let i=o,k=a+1;for(;i!=null&&i[s.children];){const b=i[s.children][0];r[k]=b.value,i=b,k+=1}return r}function z(o,a,n){return o.findIndex(s=>s[n.value]===a)}function A(o){const[a]=o;return q(a)}function Q(o,a){return o>a?"horizontal":a>o?"vertical":""}function C(o,a,n){const s=[];for(let r=o;r<=a;r++){const i=n(`${r}`);s.push({label:i,value:r})}return s}function $(o,a){return o===a.getFullYear()}function U(o,a){return o===a.getFullYear()}function W(o,a){return o===a.getMonth()+1}function ee(o,a){return o===a.getMonth()+1}function oe(o,a){return new Date(o,a,0).getDate()}function I(o){return o}function te(o){return/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$/.test(o)}function X(o){if(!te(o))return null;const[a,n,s]=o.split(":");return{hour:Number(a),minute:Number(n),second:Number(s)}}function Y(o){return o.padStart(2,"0")}const ne={class:"chook-picker-container"},re=e.defineComponent({__name:"Popup",props:{teleport:{default:"body"},modelValue:{type:Boolean}},emits:["update:modelValue","open","close","closed"],setup(o,{emit:a}){const n=o,s=a;return e.watch(()=>n.modelValue,r=>{r?(document.body.style.overflow="hidden",s("open")):(document.body.style.overflow="",s("close"))},{immediate:!0}),(r,i)=>(e.openBlock(),e.createBlock(e.Teleport,{to:r.teleport},[e.createVNode(e.Transition,{name:"chook-picker-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:"chook-picker-mask",onClick:i[0]||(i[0]=k=>r.$emit("update:modelValue",!1))},null,512),[[e.vShow,r.modelValue]])]),_:1}),e.createVNode(e.Transition,{name:"chook-picker-slide",onAfterLeave:i[1]||(i[1]=k=>r.$emit("closed"))},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",ne,[e.renderSlot(r.$slots,"default")],512),[[e.vShow,r.modelValue]])]),_:3})],8,["to"]))}}),ce=16,O=48,le=.52,H=150,N=300,ae=15,ie=.008,R=5,se="Select Date",ue=["year","month","day"],de="Select Time",me=["hour","minute","second"];function fe(){const o={startX:0,startY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0};let a="",n=!0;const s=()=>a==="vertical",r=()=>a==="horizontal";function i(){o.deltaX=0,o.deltaY=0,o.offsetX=0,o.offsetY=0,a="",n=!0}function k(f){const T="touches"in f?f.touches[0]:f;i(),o.startX=T.clientX,o.startY=T.clientY}function b(f){if(!o.startX||!o.startY)return!0;const T="touches"in f?f.touches[0]:f;o.deltaX=Math.max(T.clientX,0)-o.startX,o.deltaY=T.clientY-o.startY,o.offsetX=Math.abs(o.deltaX),o.offsetY=Math.abs(o.deltaY);const g=10;(!a||o.offsetX<g&&o.offsetY<g)&&(a=Q(o.offsetX,o.offsetY)),n&&(o.offsetX>R||o.offsetY>R)&&(n=!1)}function h(){o.startX=0,o.startY=0}return{pointer:o,move:b,start:k,stop:h,reset:i,isVertical:s,isHorizontal:r}}function pe({column:o,onChange:a}){const s=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)/ce,r=e.ref(0),i=e.ref(0),{pointer:k,start:b,move:h,stop:f}=fe();let T=0,g=0,D=0,y=!1,x=null;function w(p){b(p),y=!0,i.value=0,g=Date.now(),T=r.value,D=T,x=null}function c(p){if(h(p))return;const v=e.isRef(o)?o.value.length:o.length,E=T+k.deltaY,F=V((v-1)*-48),_=Math.min(Math.max(E,F),0),j=Date.now();r.value=_,!(j-g<=N)&&(g=j,D=_)}function u(){f();const p=r.value-D,M=Date.now()-g;if(M<N&&Math.abs(p)>ae){t(p,M);return}const v=m(r.value);i.value=H,d(v),y=!1}function t(p,M){const v=Math.abs(p/M),E=r.value+v/ie*(p<0?-1:1),F=m(E);i.value=N,d(F)}function l(){i.value=0,y=!1,x&&(x(),x=null)}function d(p){const M=-p*V(O),v=()=>a==null?void 0:a(p);y&&M!==r.value?x=v:v(),r.value=M}function m(p){const M=e.isRef(o)?o.value.length:o.length,v=Math.round(-p/V(O));return v<0?0:v>=M?M-1:v}function V(p){return p*s}function S(p,M="auto"){y&&M==="smooth"||(x=null,y=M==="smooth",i.value=M==="smooth"?H:0,d(p))}return{offsetY:e.readonly(r),transitionDuration:e.readonly(i),onPointerDown:w,onPointerMove:c,onPointerUp:u,stopInertialSliding:l,scrollToIndex:S}}const ke=["onClick"],he=e.defineComponent({__name:"PickerColumn",props:{column:{},fields:{},selectedIndex:{default:0}},emits:["change"],setup(o,{expose:a,emit:n}){const s=o,r=n,{offsetY:i,transitionDuration:k,onPointerDown:b,onPointerMove:h,onPointerUp:f,stopInertialSliding:T,scrollToIndex:g}=pe({column:e.toRef(s,"column"),onChange:D});function D(w){w!==s.selectedIndex&&r("change",w)}function y(w=s.selectedIndex,c){g(w,c)}function x(w){w!==s.selectedIndex&&y(w,"smooth")}return a({scrollToSelected:y}),(w,c)=>(e.openBlock(),e.createElementBlock("div",{class:"chook-picker-column",onTouchstartPassive:c[1]||(c[1]=(...u)=>e.unref(b)&&e.unref(b)(...u)),onTouchmovePassive:c[2]||(c[2]=(...u)=>e.unref(h)&&e.unref(h)(...u)),onTouchendPassive:c[3]||(c[3]=(...u)=>e.unref(f)&&e.unref(f)(...u)),onTouchcancel:c[4]||(c[4]=(...u)=>e.unref(f)&&e.unref(f)(...u)),onMousedownPassive:c[5]||(c[5]=(...u)=>e.unref(b)&&e.unref(b)(...u)),onMousemovePassive:c[6]||(c[6]=(...u)=>e.unref(h)&&e.unref(h)(...u)),onMouseupPassive:c[7]||(c[7]=(...u)=>e.unref(f)&&e.unref(f)(...u))},[e.createElementVNode("ul",{style:e.normalizeStyle({overflowY:"hidden",transform:`translate3d(0, ${e.unref(i)}px, 0)`,transitionDuration:`${e.unref(k)}ms`,transitionProperty:e.unref(k)?"all":"none"}),onTransitionend:c[0]||(c[0]=(...u)=>e.unref(T)&&e.unref(T)(...u))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.column,(u,t)=>(e.openBlock(),e.createElementBlock("li",{key:u[w.fields.value],class:"chook-picker-column-item",role:"button",tabindex:"0",onClick:l=>x(t)},[e.createElementVNode("p",{class:"chook-picker-column-label",style:e.normalizeStyle({transform:`rotate3d(1, 0, 0, ${(t*e.unref(O)+e.unref(i))*e.unref(le)}deg)`})},e.toDisplayString(u[w.fields.label]),5)],8,ke))),128))],36)],32))}}),ge={class:"chook-picker-header"},be={class:"chook-picker-title"},Te={key:0,class:"chook-picker-loading"},P=e.defineComponent({__name:"Picker",props:{show:{type:Boolean},modelValue:{},title:{},columns:{},linkage:{type:Boolean},loading:{type:Boolean},teleport:{},confirmButtonText:{default:"Confirm"},cancelButtonText:{default:"Cancel"},columnsFieldNames:{}},emits:["update:show","update:modelValue","confirm","cancel","open","closed"],setup(o,{emit:a}){const n=o,s=a,r=e.ref([]),i=e.ref([]),k=e.ref([]),b=e.ref(null),h=e.computed({get:()=>n.show,set:t=>s("update:show",t)}),f=e.computed(()=>K(n.columnsFieldNames)),T=e.computed(()=>G(n.columns,f.value)),g=e.computed(()=>{const{columns:t}=n;return T.value==="single"?[t]:T.value==="multiple"?t:Z(t,i.value,f.value)});function D(t,l){const d=g.value[t],m=d[l][f.value.value],V=i.value[t];if(m===V)return;const S=[...i.value];if(S[t]=m,T.value==="cascade"){const p=d[l];i.value=J(p,t,S,f.value)}else i.value=S;n.linkage&&y()}function y(){s("update:modelValue",i.value),r.value=i.value}function x(){s("update:show",!1)}async function w(){s("open"),await e.nextTick(),i.value=n.modelValue?[...n.modelValue]:[...r.value]}function c(){n.linkage||y(),x(),s("confirm",i.value)}function u(){x(),s("cancel")}return e.watchEffect(()=>{var d;const t=g.value.length,l=[];for(let m=0;m<t;m++){const V=g.value[m],S=i.value[m],p=z(V,S,f.value);if(p===-1){const v=(k.value[m]??0)>=V.length?V.length-1:0;i.value[m]=V[v][f.value.value],l[m]=v}else l[m]=p;l[m]!==k.value[m]&&((d=b.value)==null||d[m].scrollToSelected(l[m]))}k.value=l}),(t,l)=>(e.openBlock(),e.createBlock(re,{modelValue:h.value,"onUpdate:modelValue":l[1]||(l[1]=d=>h.value=d),teleport:t.teleport,onOpen:w,onClosed:l[2]||(l[2]=d=>t.$emit("closed"))},{default:e.withCtx(()=>[e.createElementVNode("div",ge,[e.createElementVNode("button",{class:"chook-picker-cancel",onClick:u},e.toDisplayString(t.cancelButtonText),1),e.createElementVNode("p",be,e.toDisplayString(t.title),1),e.createElementVNode("button",{class:"chook-picker-confirm",onClick:c},e.toDisplayString(t.confirmButtonText),1)]),e.createElementVNode("div",{class:"chook-picker-columns chook-picker-columns-backdrop",onTouchmove:l[0]||(l[0]=e.withModifiers(()=>{},["stop"]))},[!t.loading&&!t.columns.length?e.renderSlot(t.$slots,"empty",{key:0}):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(d,m)=>(e.openBlock(),e.createBlock(he,{key:m,ref_for:!0,ref_key:"columnsRef",ref:b,column:d,fields:f.value,"selected-index":k.value[m],onChange:V=>D(m,V)},null,8,["column","fields","selected-index","onChange"]))),128)),l[3]||(l[3]=e.createElementVNode("div",{class:"chook-picker-mask-backdrop"},null,-1))],64))],32),t.loading?(e.openBlock(),e.createElementBlock("div",Te,[e.renderSlot(t.$slots,"loading")])):e.createCommentVNode("",!0)]),_:3},8,["modelValue","teleport"]))}}),ye=e.defineComponent({__name:"DatePicker",props:{show:{type:Boolean},modelValue:{},title:{default:se},columnsType:{default:()=>ue},minDate:{default:()=>new Date(new Date().getFullYear()-10,0,1)},maxDate:{default:()=>new Date(new Date().getFullYear()+10,11,31)},teleport:{},confirmButtonText:{},cancelButtonText:{},formatYearLabel:{type:Function,default:I},formatMonthLabel:{type:Function,default:I},formatDayLabel:{type:Function,default:I}},emits:["update:show","update:modelValue","confirm","cancel","open","closed"],setup(o,{emit:a}){const n=o,s=a,r=e.ref([]),i=e.ref([]),k=e.computed({get:()=>n.show,set:c=>s("update:show",c)}),b=e.computed(()=>{const{columnsType:c,minDate:u,maxDate:t}=n,l={year:h,month:f,day:T};return c.map(d=>l[d](u,t))});function h(c,u){const t=c.getFullYear(),l=u.getFullYear();return C(t,l,n.formatYearLabel)}function f(c,u){const t=g("year"),l=$(t,c)?c.getMonth()+1:1,d=U(t,u)?u.getMonth()+1:12;return C(l,d,n.formatMonthLabel)}function T(c,u){const t=g("year"),l=g("month"),d=$(t,c)&&W(l,c),m=U(t,u)&&ee(l,u),V=d?c.getDate():1,S=m?u.getDate():oe(t,l);return C(V,S,n.formatDayLabel)}function g(c){const{columnsType:u}=n,t=u.indexOf(c),l=r.value[t];return l?Number(l):c==="year"?new Date().getFullYear():c==="month"?new Date().getMonth()+1:new Date().getDate()}function D(c){s("update:modelValue",c),i.value=c,s("confirm",c)}function y(){s("cancel")}function x(){if(s("open"),n.modelValue&&n.modelValue.length){r.value=[...n.modelValue];return}const{columnsType:c}=n;r.value=c.map(u=>g(u))}function w(){r.value=n.modelValue?[...n.modelValue]:[...i.value],s("closed")}return(c,u)=>(e.openBlock(),e.createBlock(P,{modelValue:r.value,"onUpdate:modelValue":u[0]||(u[0]=t=>r.value=t),show:k.value,"onUpdate:show":u[1]||(u[1]=t=>k.value=t),title:c.title,columns:b.value,teleport:c.teleport,"confirm-button-text":c.confirmButtonText,"cancel-button-text":c.cancelButtonText,linkage:"",onConfirm:D,onCancel:y,onOpen:x,onClosed:w},null,8,["modelValue","show","title","columns","teleport","confirm-button-text","cancel-button-text"]))}}),we=e.defineComponent({__name:"TimePicker",props:{show:{type:Boolean},modelValue:{},title:{default:de},columnsType:{default:()=>me},minTime:{},maxTime:{},teleport:{},confirmButtonText:{},cancelButtonText:{},formatHourLabel:{type:Function,default:Y},formatMinuteLabel:{type:Function,default:Y},formatSecondLabel:{type:Function,default:Y}},emits:["update:show","update:modelValue","confirm","cancel","open","closed"],setup(o,{emit:a}){const n=o,s=a,r=e.ref([]),i=e.ref([]),k=e.computed({get:()=>n.show,set:t=>s("update:show",t)}),b=e.computed(()=>{const{columnsType:t}=n,l={hour:T,minute:g,second:D};return t.map(d=>l[d]())}),h=e.computed(()=>X(n.minTime??"")??{hour:0,minute:0,second:0}),f=e.computed(()=>X(n.maxTime??"")??{hour:23,minute:59,second:59});function T(){const t=h.value.hour,l=f.value.hour;return C(t,l,n.formatHourLabel)}function g(){const t=y("hour"),{hour:l,minute:d}=h.value,{hour:m,minute:V}=f.value;return C(t===l?d:0,t===m?V:59,n.formatMinuteLabel)}function D(){const t=y("hour"),l=y("minute"),{hour:d,minute:m,second:V}=h.value,{hour:S,minute:p,second:M}=f.value;return C(t===d&&l===m?V:0,t===S&&l===p?M:59,n.formatSecondLabel)}function y(t){const{columnsType:l}=n,d=l.indexOf(t),m=r.value[d];return m!==void 0?Number(m):t==="hour"?new Date().getHours():t==="minute"?new Date().getMinutes():new Date().getSeconds()}function x(t){s("update:modelValue",t),i.value=t,s("confirm",t)}function w(){s("cancel")}function c(){if(s("open"),n.modelValue&&n.modelValue.length){r.value=[...n.modelValue];return}const{columnsType:t}=n;r.value=t.map(l=>y(l))}function u(){r.value=n.modelValue?[...n.modelValue]:[...i.value],s("closed")}return(t,l)=>(e.openBlock(),e.createBlock(P,{modelValue:r.value,"onUpdate:modelValue":l[0]||(l[0]=d=>r.value=d),show:k.value,"onUpdate:show":l[1]||(l[1]=d=>k.value=d),title:t.title,columns:b.value,teleport:t.teleport,"confirm-button-text":t.confirmButtonText,"cancel-button-text":t.cancelButtonText,linkage:"",onConfirm:x,onCancel:w,onOpen:c,onClosed:u},null,8,["modelValue","show","title","columns","teleport","confirm-button-text","cancel-button-text"]))}});B.DatePicker=ye,B.Picker=P,B.TimePicker=we,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@component-hook/picker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
4
|
"description": "Picker component with vue3 and react",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,8 +40,6 @@
|
|
|
40
40
|
"better-scroll"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@better-scroll/core": "^2.5.1",
|
|
44
|
-
"@better-scroll/wheel": "^2.5.1",
|
|
45
43
|
"react-transition-group": "^4.4.5"
|
|
46
44
|
},
|
|
47
45
|
"peerDependencies": {
|
|
@@ -51,12 +49,13 @@
|
|
|
51
49
|
},
|
|
52
50
|
"devDependencies": {
|
|
53
51
|
"@types/react-transition-group": "^4.4.12",
|
|
54
|
-
"
|
|
52
|
+
"sass-embedded": "^1.83.4",
|
|
53
|
+
"vite-plugin-dts": "^4.5.0"
|
|
55
54
|
},
|
|
56
55
|
"scripts": {
|
|
57
56
|
"build": "pnpm build:vue && pnpm build:react",
|
|
58
|
-
"build:vue": "FRAMEWORK=vue vite build",
|
|
59
|
-
"build:react": "FRAMEWORK=react vite build",
|
|
57
|
+
"build:vue": "cross-env FRAMEWORK=vue vite build",
|
|
58
|
+
"build:react": "cross-env FRAMEWORK=react vite build",
|
|
60
59
|
"typecheck": "vue-tsc --noEmit"
|
|
61
60
|
}
|
|
62
61
|
}
|