UNPKG

@tarojs/components

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