@tarojs/components
Version:
Taro 组件库。
1 lines • 3.38 kB
JavaScript
import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-5bd7cbab.js";import{c as classnames}from"./index-cd1a2d33.js";function convertStyle(t){if(t){var e=/([\w-]*)\s*:\s*([^;]*)/g;var i={};var r=void 0;while(r=e.exec(t))i[""+r[1]]=r[2].trim();return i}}var indexCss=".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 PickerView=function(){function t(t){registerInstance(this,t);this.onChange=createEvent(this,"change",7);this.onPickStart=createEvent(this,"pickstart",7);this.onPickEnd=createEvent(this,"pickend",7)}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(){var t=this;var e=this.el.querySelectorAll("taro-picker-view-column-core");e.forEach((function(e,i){var r;e.setAttribute("col",""+i);var a="0";if(!!t.value&&t.value.length>i){a=""+t.value[i]}var o=t.el.getBoundingClientRect().height;var n=((r=t.indicator)===null||r===void 0?void 0:r.offsetHeight)||0;var s=(o-n)/2;e.setAttribute("initial-position",""+a);e.setAttribute("padding-vertical",""+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=classnames("taro-picker-view-mask-indicator",this.indicatorClass);var i=classnames("taro-picker-view-mask-top",this.maskClass);var r=classnames("taro-picker-view-mask-bottom",this.maskClass);var a=convertStyle(this.indicatorStyle);var o=convertStyle(this.maskStyle);var n=convertStyle(this.maskStyle);return h(Host,{class:"taro-picker-view-container"},h("slot",null),h("div",{class:"taro-picker-view-mask-container"},h("div",{class:i,style:o}),h("div",{class:e,style:a,ref:function(e){return t.indicator=e}}),h("div",{class:r,style:n})))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();PickerView.style=indexCss;export{PickerView as taro_picker_view_core};