UNPKG

@tarojs/components

Version:
1 lines 5.36 kB
System.register(["./p-2b70c348.system.js","./p-010faa87.system.js","./p-2ec68968.system.js"],(function(e){"use strict";var t,i,o,n,r,a,s;return{setters:[function(e){t=e.r;i=e.c;o=e.h;n=e.g;r=e.H},function(e){a=e.d},function(e){s=e.c}],execute:function(){function c(e){if(e){var t=/([\w-]*)\s*:\s*([^;]*)/g;var i={};var o=void 0;while(o=t.exec(e))i["".concat(o[1])]=o[2].trim();return i}}var l=".taro-picker-view-column-container{text-align:center;-ms-flex-direction:column;flex-direction:column;-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;position:relative;overflow:hidden scroll}.taro-picker-view-column-container::-webkit-scrollbar{display:none}";var d=e("taro_picker_view_column_core",function(){function e(e){var o=this;t(this,e);this.onChange=i(this,"onselect",7);this.onSelectStart=i(this,"onselectstart",7);this.onSelectEnd=i(this,"onselectend",7);this.handleSelected=a((function(){var e=o.el.childNodes;var t=0;var i="0";for(var n in e){var r=e[n];var a=r.offsetHeight;if(t+a/2>o.el.scrollTop){i=n;break}t+=a}o.el.scrollTo({top:t,behavior:"smooth"});o.onChange.emit({curIndex:o.col,selectedIndex:i});o.onSelectEnd.emit()}),500);this.col=undefined;this.initialPosition="0";this.paddingVertical=0;this.isInit=false}e.prototype.onTouchStart=function(){this.onSelectStart.emit()};e.prototype.onTouchEnd=function(){this.handleSelected()};e.prototype.componentDidLoad=function(){this.handleChange()};e.prototype.componentDidUpdate=function(){this.handleChange()};e.prototype.handleChange=function(){var e=this.el.childNodes;var t=0;var i=0;for(var o in e){var n=e[o];if(this.initialPosition===o||!n||typeof n.offsetHeight!=="number"){break}i+=n.offsetHeight;t++}this.el.scrollTo({top:i});if(t>=e.length){this.onChange.emit({curIndex:this.col,selectedIndex:t-1})}};e.prototype.render=function(){var e=this.paddingVertical,t=e===void 0?0:e;return o(r,{class:"taro-picker-view-column-container",style:{"padding-top":"".concat(t,"px"),"padding-bottom":"".concat(t,"px")}})};Object.defineProperty(e.prototype,"el",{get:function(){return n(this)},enumerable:false,configurable:true});return e}());d.style=l;var p=".taro-picker-view-container{display:-ms-flexbox;display:flex;position:relative}.taro-picker-view-mask-container{pointer-events:none;-ms-flex-direction:column;flex-direction:column;display:-ms-flexbox;display:flex;position:absolute;inset:0}.taro-picker-view-mask-indicator{border-top:1px solid #ddd;border-bottom:1px solid #ddd;height:50px;display:-ms-flexbox;display:flex}.taro-picker-view-mask-top{background-image:-webkit-gradient(linear,left top, left bottom,from(rgba(255,255,255,.95)),to(rgba(255,255,255,.6)));background-image:linear-gradient(rgba(255,255,255,.95),rgba(255,255,255,.6));-ms-flex:1;flex:1}.taro-picker-view-mask-bottom{background:-webkit-gradient(linear,left top, left bottom,from(rgba(255,255,255,.6)),to(rgba(255,255,255,.95)));background:linear-gradient(rgba(255,255,255,.6),rgba(255,255,255,.95));-ms-flex:1;flex:1}";var h=e("taro_picker_view_core",function(){function e(e){t(this,e);this.onChange=i(this,"change",7);this.onPickStart=i(this,"pickstart",7);this.onPickEnd=i(this,"pickend",7);this.indicatorStyle=undefined;this.indicatorClass=undefined;this.value=undefined;this.maskStyle=undefined;this.maskClass=undefined}e.prototype.onPropsChange=function(){this.handleValueChange()};e.prototype.onSelect=function(e){e.stopPropagation();if(e.target.tagName!=="TARO-PICKER-VIEW-COLUMN-CORE")return;var t=+e.detail.curIndex;var i=+e.detail.selectedIndex;this.value[t]=i;this.onChange.emit({value:this.value})};e.prototype.onSelectStart=function(e){e.stopPropagation();if(e.target.tagName!=="TARO-PICKER-VIEW-COLUMN-CORE")return;this.onPickStart.emit()};e.prototype.onPickerColEnd=function(e){e.stopPropagation();if(e.target.tagName!=="TARO-PICKER-VIEW-COLUMN-CORE")return;this.onPickEnd.emit()};e.prototype.componentDidLoad=function(){this.handleValueChange()};e.prototype.handleValueChange=function(){var e=this;var t=this.el.querySelectorAll("taro-picker-view-column-core");t.forEach((function(t,i){var o;t.setAttribute("col","".concat(i));var n=0;if(!!e.value&&e.value.length>i){n=e.value[i]}var r=e.el.getBoundingClientRect().height;var a=((o=e.indicator)===null||o===void 0?void 0:o.offsetHeight)||0;var s=(r-a)/2;t.setAttribute("initial-position","".concat(n));t.setAttribute("padding-vertical","".concat(s))}))};e.prototype.componentDidRender=function(){var e=this;this.el.childNodes.forEach((function(t){var i=t;if("TARO-PICKER-VIEW-COLUMN-CORE"!==i.tagName&&i.className!=="taro-picker-view-mask-container"){e.el.removeChild(t)}}))};e.prototype.render=function(){var e=this;var t=s("taro-picker-view-mask-indicator",this.indicatorClass);var i=s("taro-picker-view-mask-top",this.maskClass);var n=s("taro-picker-view-mask-bottom",this.maskClass);var a=c(this.indicatorStyle);var l=c(this.maskStyle);var d=c(this.maskStyle);return o(r,{class:"taro-picker-view-container"},o("slot",null),o("div",{class:"taro-picker-view-mask-container"},o("div",{class:i,style:l}),o("div",{class:t,style:a,ref:function(t){return e.indicator=t}}),o("div",{class:n,style:d})))};Object.defineProperty(e.prototype,"el",{get:function(){return n(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{value:["onPropsChange"]}},enumerable:false,configurable:true});return e}());h.style=p}}}));