@ptcwebops/ptcw-design 5.6.0 → 5.6.2

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.
Files changed (26) hide show
  1. package/dist/cjs/homepage-clickable-tab.cjs.entry.js +2 -2
  2. package/dist/cjs/ptc-mobile-select.cjs.entry.js +436 -436
  3. package/dist/cjs/ptc-readmore-v3.cjs.entry.js +3 -3
  4. package/dist/collection/components/homepage-clickable-tab/homepage-clickable-tab.css +5 -1
  5. package/dist/collection/components/homepage-clickable-tab/homepage-clickable-tab.js +1 -1
  6. package/dist/collection/components/ptc-mobile-select/mobile-select/dist/mobile-select.es.js +441 -0
  7. package/dist/collection/components/ptc-mobile-select/mobile-select/dist/mobile-select.iife.js +661 -0
  8. package/dist/collection/components/ptc-mobile-select/mobile-select/dist/mobile-select.iife.min.js +7 -0
  9. package/dist/collection/components/ptc-mobile-select/mobile-select/dist/mobile-select.umd.js +22 -0
  10. package/dist/collection/components/ptc-mobile-select/ptc-mobile-select.css +164 -164
  11. package/dist/collection/components/ptc-mobile-select/ptc-mobile-select.js +1 -1
  12. package/dist/collection/components/ptc-readmore-v3/ptc-readmore-v3.css +74 -21
  13. package/dist/collection/components/ptc-readmore-v3/ptc-readmore-v3.js +3 -3
  14. package/dist/custom-elements/index.js +441 -441
  15. package/dist/esm/homepage-clickable-tab.entry.js +2 -2
  16. package/dist/esm/ptc-mobile-select.entry.js +436 -436
  17. package/dist/esm/ptc-readmore-v3.entry.js +3 -3
  18. package/dist/ptcw-design/p-6d024b2f.entry.js +1 -0
  19. package/dist/ptcw-design/p-768ceec1.entry.js +1 -0
  20. package/dist/ptcw-design/ptcw-design.esm.js +1 -1
  21. package/dist/types/components/ptc-mobile-select/mobile-select/dist/mobile-select.d.ts +209 -0
  22. package/dist/types/components/ptc-mobile-select/ptc-mobile-select.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/readme.md +1 -1
  25. package/dist/ptcw-design/p-5a1fe09a.entry.js +0 -1
  26. package/dist/ptcw-design/p-ad774d00.entry.js +0 -1
@@ -0,0 +1,7 @@
1
+ /*
2
+ * mobile-select v1.4.0
3
+ * Homepage: https://github.com/onlyhom/mobile-select
4
+ * Released under the MIT License.
5
+ * (c) 2017-present
6
+ */
7
+ "use strict";function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&null!=iter[Symbol.iterator]||null!=iter["@@iterator"])return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){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 _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Map"===(n="Object"===n&&o.constructor?o.constructor.name:n)||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}function _typeof(obj){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj})(obj)}var MobileSelect=function(){function h(g,c,l){D(g,"symbol"!=_typeof(c)?c+"":c,l)}var S=Object.defineProperty,D=function(g,c,l){return c in g?S(g,c,{enumerable:!0,configurable:!0,writable:!0,value:l}):g[c]=l};var c=function(){function l(t){_classCallCheck(this,l),h(this,"mobileSelect"),h(this,"trigger"),h(this,"wheelList"),h(this,"sliderList"),h(this,"wheelsContain"),h(this,"panel"),h(this,"ensureBtn"),h(this,"cancelBtn"),h(this,"grayLayer"),h(this,"popUp"),h(this,"initPosition"),h(this,"initColWidth"),h(this,"wheelsData"),h(this,"displayJson"),h(this,"curValue"),h(this,"curIndexArr"),h(this,"isCascade"),h(this,"isJsonType"),h(this,"startY"),h(this,"moveEndY"),h(this,"moveY"),h(this,"preMoveY"),h(this,"offsetY"),h(this,"offsetSum"),h(this,"oversizeBorder"),h(this,"enableClickStatus"),h(this,"optionHeight"),h(this,"curDistance"),h(this,"cascadeJsonData"),h(this,"eventHandleMap"),h(this,"initDeepCount"),h(this,"config"),l.checkRequiredConfig(t)&&(this.config=Object.assign({},l.defaultConfig,t),this.wheelsData=t.wheels,this.isJsonType=!1,this.cascadeJsonData=[],this.displayJson=[],this.curValue=[],this.curIndexArr=[],this.isCascade=!1,this.startY,this.moveEndY,this.moveY,this.preMoveY,this.offsetY=0,this.offsetSum=0,this.oversizeBorder,this.curDistance=[],this.enableClickStatus=!1,this.optionHeight=0,this.initPosition=t.position||[],this.initColWidth=t.colWidth||[],this.init())}return _createClass(l,[{key:"init",value:function(){var _this=this;if(this.checkTriggerAvailable()){var t=this.config;if(this.isJsonType=l.checkDataType(this.wheelsData),this.renderComponent(this.wheelsData),this.wheelList=this.mobileSelect.getElementsByClassName("ms-wheel"),this.sliderList=this.mobileSelect.getElementsByClassName("ms-select-container"),this.panel=this.mobileSelect.querySelector(".ms-panel"),this.wheelsContain=this.mobileSelect.querySelector(".ms-wheels"),this.ensureBtn=this.mobileSelect.querySelector(".ms-ensure"),this.cancelBtn=this.mobileSelect.querySelector(".ms-cancel"),this.grayLayer=this.mobileSelect.querySelector(".ms-gray-layer"),this.popUp=this.mobileSelect.querySelector(".ms-content"),this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight,t.initValue&&this.setTriggerInnerText(t.initValue),this.setStyle(t),this.isCascade=this.checkCascade(),this.isCascade&&this.initCascade(),t.initValue&&(this.initPosition=this.getPositionByInitValue()),this.initPosition.length<this.sliderList.length)for(var e=this.sliderList.length-this.initPosition.length,i=0;i<e;i++)this.initPosition.push(0);this.isCascade?this.initPosition.forEach(function(e,i){_this.checkRange(i,_this.initPosition)}):this.setCurDistance(this.initPosition),this.eventHandleMap={cancelBtn:{event:"click",fn:function(){var i,e;_this.hide(),null!=(i=(e=_this.config).cancel)&&i.call(e,_this.curIndexArr,_this.curValue,_this),null!=(e=(i=_this.config).onCancel)&&e.call(i,_this.curValue,_this.curIndexArr,_this)}},ensureBtn:{event:"click",fn:function(){var i,e;_this.hide(),_this.optionHeight||(_this.optionHeight=_this.mobileSelect.querySelector("li").offsetHeight),_this.setTriggerInnerText(_this.getConnectedString()),_this.curIndexArr=_this.getIndexArr(),_this.curValue=_this.getCurValue(),null!=(i=(e=_this.config).callback)&&i.call(e,_this.curIndexArr,_this.curValue,_this),null!=(e=(i=_this.config).onChange)&&e.call(i,_this.curValue,_this.curIndexArr,_this)}},trigger:{event:"click",fn:function(){_this.show()}},grayLayer:{event:"click",fn:function(){return _this.hide()}},popUp:{event:"click",fn:function(e){return e.stopPropagation()}},panel:{event:["touchstart","touchend","touchmove"],fn:function(e){return _this.touch(e)}}},navigator.userAgent.toLowerCase().match(/ipad|iphone os|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/)||(this.eventHandleMap.panel.event=["mousedown","mousemove","mouseup"]),this.registerEvents("add"),this.fixRowStyle(),t.autoFocus&&this.show()}}},{key:"checkTriggerAvailable",value:function(){var t=this.config;return this.trigger=t.trigger instanceof HTMLElement?t.trigger:document.querySelector(t.trigger),!!this.trigger||(l.log("error","trigger HTMLElement does not found on your document."),!1)}},{key:"getPositionByInitValue",value:function(){var o,_this2=this,_this$config=this.config,t=_this$config.keyMap,e=_this$config.connector,_this$config=_this$config.initValue,_this$config=(null==_this$config?void 0:_this$config.split(e))||[];return this.isJsonType?(o=null==(e=this.wheelsData[0])?void 0:e.data,_this$config.reduce(function(r,a){var u=null==o?void 0:o.findIndex(function(f){return f[t.value]==a});return r.push(u<0?0:u),o=null==(u=o[u])?void 0:u[t.childs],r},[])):_this$config.reduce(function(o,r,a){a=null==(a=null==(a=_this2.wheelsData[a])?void 0:a.data)?void 0:a.findIndex(function(m){return m==r});return o.push(a<0?0:a),o},[])}},{key:"getConnectedString",value:function(){for(var t="",e=0;e<this.wheelList.length;e++)e==this.wheelList.length-1?t+=this.getInnerText(e):t+=this.getInnerText(e)+this.config.connector;return t}},{key:"setTriggerInnerText",value:function(t){this.config.triggerDisplayValue&&(this.trigger.textContent=t)}},{key:"setValue",value:function(t){var e,_this3=this;t&&t.length&&(this.isJsonType&&"object"!=_typeof(t[0])||!this.isJsonType&&"object"==_typeof(t[0])?l.log("error","The setValue() input format should be same with getValue(), like: ".concat(JSON.stringify(this.getValue()))):(e=this.config.keyMap,t.forEach(function(i,s){var r=_this3.isCascade?_this3.displayJson[s]:null==(r=_this3.wheelsData[s])?void 0:r.data,r=null==r?void 0:r.findIndex(function(a){return _this3.isJsonType?i[e.id]==a[e.id]||i[e.value]==a[e.value]:i==a});_this3.locatePosition(s,r)}),this.setTriggerInnerText(this.getConnectedString())))}},{key:"setTitle",value:function(t){this.mobileSelect.querySelector(".ms-title").innerHTML=t}},{key:"setStyle",value:function(t){var _e2;t.ensureBtnColor&&(this.ensureBtn.style.color=t.ensureBtnColor),t.cancelBtnColor&&(this.cancelBtn.style.color=t.cancelBtnColor),t.titleColor&&(this.mobileSelect.querySelector(".ms-title").style.color=t.titleColor),t.textColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),this.panel.style.color=t.textColor),t.titleBgColor&&(this.mobileSelect.querySelector(".ms-btn-bar").style.backgroundColor=t.titleBgColor),t.bgColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),_e2=this.mobileSelect.querySelector(".ms-shadow-mask"),this.panel.style.backgroundColor=t.bgColor,_e2.style.background="linear-gradient(to bottom, "+t.bgColor+", rgba(255, 255, 255, 0), "+t.bgColor+")"),"number"==typeof t.maskOpacity&&(this.mobileSelect.querySelector(".ms-gray-layer").style.background="rgba(0, 0, 0, "+t.maskOpacity+")")}},{key:"show",value:function(){var t,i;this.mobileSelect.classList.add("ms-show"),null!=(t=document.querySelector("body"))&&t.classList.add("ms-show"),"function"==typeof this.config.onShow&&null!=(i=(t=this.config).onShow)&&i.call(t,this.curValue,this.curIndexArr,this)}},{key:"hide",value:function(){var t,i;this.mobileSelect.classList.remove("ms-show"),null!=(t=document.querySelector("body"))&&t.classList.remove("ms-show"),"function"==typeof this.config.onHide&&null!=(i=(t=this.config).onHide)&&i.call(t,this.curValue,this.curIndexArr,this)}},{key:"registerEvents",value:function(t){for(var _this4=this,_i=0,_Object$entries=Object.entries(this.eventHandleMap);_i<_Object$entries.length;_i++)!function(){var _Object$entries$_i=_slicedToArray(_Object$entries[_i],2),e=_Object$entries$_i[0],i=_Object$entries$_i[1];"string"==typeof i.event?_this4[e]["".concat(t,"EventListener")](i.event,i.fn,{passive:!1}):i.event.forEach(function(s){_this4[e]["".concat(t,"EventListener")](s,i.fn,{passive:!1})})}()}},{key:"destroy",value:function(){var t;this.registerEvents("remove"),null!=(t=null==(t=this.mobileSelect)?void 0:t.parentNode)&&t.removeChild(this.mobileSelect)}},{key:"getOptionsHtmlStr",value:function(t){var e=this.config.keyMap,i="";if(this.isJsonType)for(var s=0;s<t.length;s++){var n=t[s][e.id],o=t[s][e.value];i+='<li data-id="'.concat(n,'">').concat(o,"</li>")}else for(var _s2=0;_s2<t.length;_s2++)i+="<li>"+t[_s2]+"</li>";return i}},{key:"renderComponent",value:function(t){this.mobileSelect=document.createElement("div"),this.mobileSelect.className="ms-mobile-select",this.mobileSelect.innerHTML='<div class="ms-gray-layer"></div>\n <div class="ms-content">\n <div class="ms-btn-bar">\n <div class="ms-fix-width">\n <div class="ms-cancel">'.concat(this.config.cancelBtnText,'</div> \n <div class="ms-title">').concat(this.config.title||"",'</div>\n <div class="ms-ensure">').concat(this.config.ensureBtnText,'</div>\n </div>\n </div>\n <div class="ms-panel">\n <div class="ms-fix-width">\n <div class="ms-wheels"></div>\n <div class="ms-select-line"></div>\n <div class="ms-shadow-mask"></div>\n </div>\n </div>'),document.body.appendChild(this.mobileSelect);for(var e="",i=0;i<t.length;i++)e=(e+='<div class="ms-wheel" data-index="'.concat(i,'"><ul class="ms-select-container">'))+this.getOptionsHtmlStr(t[i].data)+"</ul></div>";this.mobileSelect.querySelector(".ms-wheels").innerHTML=e}},{key:"reRenderWheels",value:function(){var t=this.wheelList.length-this.displayJson.length;if(0<t)for(var e=0;e<t;e++)this.wheelsContain.removeChild(this.wheelList[this.wheelList.length-1]);for(var i,_e4=0;_e4<this.displayJson.length;_e4++)this.wheelList[_e4]?this.sliderList[_e4].innerHTML=this.getOptionsHtmlStr(this.displayJson[_e4]):((i=document.createElement("div")).className="ms-wheel",i.innerHTML='<ul class="ms-select-container">'.concat(this.getOptionsHtmlStr(this.displayJson[_e4]),"</ul>"),i.setAttribute("data-index",_e4.toString()),this.wheelsContain.appendChild(i))}},{key:"checkCascade",value:function(){var e,t=this.config.keyMap;if(this.isJsonType)for(var i=this.wheelsData[0].data,s=0;s<i.length;s++)if(t.childs in i[s]&&0<(null==(e=i[s][t.childs])?void 0:e.length))return this.cascadeJsonData=this.wheelsData[0].data,!0;return!1}},{key:"initCascade",value:function(){this.displayJson.push(this.cascadeJsonData),0<this.initPosition.length?(this.initDeepCount=0,this.initCheckArrDeep(this.cascadeJsonData[this.initPosition[0]])):this.checkArrDeep(this.cascadeJsonData[0]),this.reRenderWheels()}},{key:"initCheckArrDeep",value:function(t){var e,i;t&&(e=this.config.keyMap).childs in t&&0<t[e.childs].length&&(this.displayJson.push(t[e.childs]),this.initDeepCount++,(i=t[e.childs][this.initPosition[this.initDeepCount]])?this.initCheckArrDeep(i):this.checkArrDeep(t[e.childs][0]))}},{key:"checkArrDeep",value:function(t){var e;!t||(e=this.config.keyMap).childs in t&&0<t[e.childs].length&&(this.displayJson.push(t[e.childs]),this.checkArrDeep(t[e.childs][0]))}},{key:"checkRange",value:function(t,e){for(var o,n,i=this.displayJson.length-1-t,s=this.config.keyMap,r=0;r<i;r++)this.displayJson.pop();for(var _r=0;_r<=t;_r++)n=0==_r?this.cascadeJsonData[e[0]]:null==(o=null==n?void 0:n[s.childs])?void 0:o[e[_r]];this.checkArrDeep(n),this.reRenderWheels(),this.fixRowStyle(),this.setCurDistance(this.resetPosition(t,e))}},{key:"resetPosition",value:function(t,e){var i=_toConsumableArray(e);if(this.sliderList.length>e.length)for(var s=this.sliderList.length-e.length,n=0;n<s;n++)i.push(0);else if(this.sliderList.length<e.length){s=e.length-this.sliderList.length;for(var _n2=0;_n2<s;_n2++)i.pop()}for(var _n3=t+1;_n3<i.length;_n3++)i[_n3]=0;return i}},{key:"updateWheels",value:function(t){if(this.isCascade){if(this.cascadeJsonData=t,this.displayJson=[],this.initCascade(),this.initPosition.length<this.sliderList.length)for(var e=this.sliderList.length-this.initPosition.length,i=0;i<e;i++)this.initPosition.push(0);this.setCurDistance(this.initPosition),this.fixRowStyle()}}},{key:"updateWheel",value:function(t,e){var i;this.isCascade?l.log("error","'updateWheel()' not support cascade json data, please use 'updateWheels()' instead to update the whole data source"):(i="",i+=this.getOptionsHtmlStr(e),this.wheelsData[t]=this.isJsonType?{data:e}:e,this.sliderList[t].innerHTML=i)}},{key:"fixRowStyle",value:function(){var e,_this5=this;if(this.initColWidth.length&&this.initColWidth.length===this.wheelList.length)e=this.initColWidth.reduce(function(i,s){return i+s},0),this.initColWidth.forEach(function(i,s){_this5.wheelList[s].style.width=(i/e*100).toFixed(2)+"%"});else for(var t=(100/this.wheelList.length).toFixed(2),_e5=0;_e5<this.wheelList.length;_e5++)this.wheelList[_e5].style.width=t+"%"}},{key:"getIndex",value:function(t){return Math.round((2*this.optionHeight-t)/this.optionHeight)}},{key:"getIndexArr",value:function(){for(var t=[],e=0;e<this.curDistance.length;e++)t.push(this.getIndex(this.curDistance[e]));return t}},{key:"getCurValue",value:function(){var t=[],e=this.getIndexArr(),i=this.config.keyMap;if(this.isCascade)for(var s=0;s<this.wheelList.length;s++){var _t$push,n=this.displayJson[s][e[s]];n&&t.push((_defineProperty(_t$push={},i.id,n[i.id]),_defineProperty(_t$push,i.value,n[i.value]),_t$push))}else if(this.isJsonType)for(var _s3=0;_s3<this.curDistance.length;_s3++)t.push(this.wheelsData[_s3].data[this.getIndex(this.curDistance[_s3])]);else for(var _s4=0;_s4<this.curDistance.length;_s4++)t.push(this.getInnerText(_s4));return t}},{key:"getValue",value:function(){return this.getCurValue()}},{key:"calcDistance",value:function(t){return 2*this.optionHeight-t*this.optionHeight}},{key:"setCurDistance",value:function(t){for(var e=[],i=0;i<this.sliderList.length;i++)e.push(this.calcDistance(t[i])),this.movePosition(this.sliderList[i],e[i]);this.curDistance=e}},{key:"fixPosition",value:function(t){return-(this.getIndex(t)-2)*this.optionHeight}},{key:"movePosition",value:function(t,e){t.style.transform="translate3d(0,"+e+"px, 0)"}},{key:"locatePosition",value:function(t,e){void 0===t||void 0===e||e<0||(this.curDistance[t]=this.calcDistance(e),this.movePosition(this.sliderList[t],this.curDistance[t]),this.isCascade&&this.checkRange(t,this.getIndexArr()))}},{key:"updateCurDistance",value:function(t,e){this.curDistance[e]=parseInt(t.style.transform.split(",")[1])}},{key:"getInnerText",value:function(t){var e=this.sliderList[t].getElementsByTagName("li").length,i=this.getIndex(this.curDistance[t]);return e<=i?i=e-1:i<0&&(i=0),(null==(e=this.sliderList[t].getElementsByTagName("li")[i])?void 0:e.textContent)||""}},{key:"touch",value:function(t){var r,i=(t.composedPath&&t.composedPath()).find(function(p){return null==(p=p.classList)?void 0:p.contains("ms-wheel")});if(i){var p,s=i.firstChild,n=parseInt(i.getAttribute("data-index")||"0");switch(t.type){case"touchstart":case"mousedown":s.style.transition="none 0s ease-out",this.startY=Math.floor((t instanceof TouchEvent?t.touches[0]:t).clientY),this.preMoveY=this.startY,"mousedown"===t.type&&(this.enableClickStatus=!0);break;case"touchmove":case"mousemove":if(t.preventDefault(),"mousemove"===t.type&&!this.enableClickStatus)break;this.moveY=Math.floor((t instanceof TouchEvent?t.touches[0]:t).clientY),this.offsetY=(this.moveY-this.preMoveY)*this.config.scrollSpeed,this.updateCurDistance(s,n),this.curDistance[n]=this.curDistance[n]+this.offsetY,this.movePosition(s,this.curDistance[n]),this.preMoveY=this.moveY;break;case"touchend":case"mouseup":s.style.transition="transform 0.18s ease-out",this.moveEndY=Math.floor((t instanceof TouchEvent?t.changedTouches[0]:t).clientY),this.offsetSum=this.moveEndY-this.startY,this.oversizeBorder=-(s.getElementsByTagName("li").length-3)*this.optionHeight,0==this.offsetSum?2!=(p=Math.floor((window.innerHeight-this.moveEndY)/40))&&(p=this.curDistance[n]+(p-2)*this.optionHeight)<=2*this.optionHeight&&p>=this.oversizeBorder&&(this.curDistance[n]=p,this.movePosition(s,this.curDistance[n]),null!=(r=(p=this.config).transitionEnd)&&r.call(p,this.getIndexArr(),this.getCurValue(),this),null!=(p=(r=this.config).onTransitionEnd)&&p.call(r,this.getCurValue(),this.getIndexArr(),this)):(this.updateCurDistance(s,n),this.curDistance[n]=this.fixPosition(this.curDistance[n]),this.curDistance[n]>2*this.optionHeight?this.curDistance[n]=2*this.optionHeight:this.curDistance[n]<this.oversizeBorder&&(this.curDistance[n]=this.oversizeBorder),this.movePosition(s,this.curDistance[n]),null!=(r=(p=this.config).transitionEnd)&&r.call(p,this.getIndexArr(),this.getCurValue(),this),null!=(p=(r=this.config).onTransitionEnd)&&p.call(r,this.getCurValue(),this.getIndexArr(),this)),"mouseup"===t.type&&(this.enableClickStatus=!1),this.isCascade&&this.checkRange(n,this.getIndexArr())}}}}],[{key:"checkDataType",value:function(t){return"object"==_typeof(null==(t=null==(t=t[0])?void 0:t.data)?void 0:t[0])}},{key:"checkRequiredConfig",value:function(t){var i,e=l.REQUIRED_PARAMS;if(!t)return i=e.map(function(s){return"'".concat(s,"'")}),l.log("error","missing required param ".concat(i.join(" and "),".")),!1;for(var _i2=0;_i2<e.length;_i2++){var s=e[_i2];if(!t[s])return l.log("error","missing required param '".concat(s,"'.")),!1}return!0}},{key:"log",value:function(t,e){null!=(t=console[t])&&t.call(console,"[mobile-select]: ".concat(e))}}]),l}();return h(c,"defaultConfig",{keyMap:{id:"id",value:"value",childs:"childs"},position:[],colWidth:[],title:"",connector:" ",ensureBtnText:"确认",cancelBtnText:"取消",triggerDisplayValue:!0,scrollSpeed:1}),h(c,"REQUIRED_PARAMS",["trigger","wheels"]),c}();
@@ -0,0 +1,22 @@
1
+ /*
2
+ * mobile-select v1.4.0
3
+ * Homepage: https://github.com/onlyhom/mobile-select
4
+ * Released under the MIT License.
5
+ * (c) 2017-present
6
+ */
7
+ (function(a,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("./style/mobile-select.css")):typeof define=="function"&&define.amd?define(["./style/mobile-select.css"],r):(a=typeof globalThis<"u"?globalThis:a||self,a.MobileSelect=r())})(this,function(){"use strict";var S=Object.defineProperty;var D=(a,r,c)=>r in a?S(a,r,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[r]=c;var o=(a,r,c)=>(D(a,typeof r!="symbol"?r+"":r,c),c);function a(){return!navigator.userAgent.toLowerCase().match(/ipad|iphone os|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/)}const c=class{constructor(t){o(this,"mobileSelect");o(this,"trigger");o(this,"wheelList");o(this,"sliderList");o(this,"wheelsContain");o(this,"panel");o(this,"ensureBtn");o(this,"cancelBtn");o(this,"grayLayer");o(this,"popUp");o(this,"initPosition");o(this,"initColWidth");o(this,"wheelsData");o(this,"displayJson");o(this,"curValue");o(this,"curIndexArr");o(this,"isCascade");o(this,"isJsonType");o(this,"startY");o(this,"moveEndY");o(this,"moveY");o(this,"preMoveY");o(this,"offsetY");o(this,"offsetSum");o(this,"oversizeBorder");o(this,"enableClickStatus");o(this,"optionHeight");o(this,"curDistance");o(this,"cascadeJsonData");o(this,"eventHandleMap");o(this,"initDeepCount");o(this,"config");!c.checkRequiredConfig(t)||(this.config=Object.assign({},c.defaultConfig,t),this.wheelsData=t.wheels,this.isJsonType=!1,this.cascadeJsonData=[],this.displayJson=[],this.curValue=[],this.curIndexArr=[],this.isCascade=!1,this.startY,this.moveEndY,this.moveY,this.preMoveY,this.offsetY=0,this.offsetSum=0,this.oversizeBorder,this.curDistance=[],this.enableClickStatus=!1,this.optionHeight=0,this.initPosition=t.position||[],this.initColWidth=t.colWidth||[],this.init())}init(){if(!this.checkTriggerAvailable())return;const{config:t}=this;if(this.isJsonType=c.checkDataType(this.wheelsData),this.renderComponent(this.wheelsData),this.wheelList=this.mobileSelect.getElementsByClassName("ms-wheel"),this.sliderList=this.mobileSelect.getElementsByClassName("ms-select-container"),this.panel=this.mobileSelect.querySelector(".ms-panel"),this.wheelsContain=this.mobileSelect.querySelector(".ms-wheels"),this.ensureBtn=this.mobileSelect.querySelector(".ms-ensure"),this.cancelBtn=this.mobileSelect.querySelector(".ms-cancel"),this.grayLayer=this.mobileSelect.querySelector(".ms-gray-layer"),this.popUp=this.mobileSelect.querySelector(".ms-content"),this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight,t.initValue&&this.setTriggerInnerText(t.initValue),this.setStyle(t),this.isCascade=this.checkCascade(),this.isCascade&&this.initCascade(),t.initValue&&(this.initPosition=this.getPositionByInitValue()),this.initPosition.length<this.sliderList.length){const e=this.sliderList.length-this.initPosition.length;for(let i=0;i<e;i++)this.initPosition.push(0)}this.isCascade?this.initPosition.forEach((e,i)=>{this.checkRange(i,this.initPosition)}):this.setCurDistance(this.initPosition),this.eventHandleMap={cancelBtn:{event:"click",fn:()=>{var e,i,s,n;this.hide(),(i=(e=this.config).cancel)==null||i.call(e,this.curIndexArr,this.curValue,this),(n=(s=this.config).onCancel)==null||n.call(s,this.curValue,this.curIndexArr,this)}},ensureBtn:{event:"click",fn:()=>{var e,i,s,n;this.hide(),this.optionHeight||(this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight),this.setTriggerInnerText(this.getConnectedString()),this.curIndexArr=this.getIndexArr(),this.curValue=this.getCurValue(),(i=(e=this.config).callback)==null||i.call(e,this.curIndexArr,this.curValue,this),(n=(s=this.config).onChange)==null||n.call(s,this.curValue,this.curIndexArr,this)}},trigger:{event:"click",fn:()=>{this.show()}},grayLayer:{event:"click",fn:()=>this.hide()},popUp:{event:"click",fn:e=>e.stopPropagation()},panel:{event:["touchstart","touchend","touchmove"],fn:e=>this.touch(e)}},a()&&(this.eventHandleMap.panel.event=["mousedown","mousemove","mouseup"]),this.registerEvents("add"),this.fixRowStyle(),t.autoFocus&&this.show()}static checkDataType(t){var e,i;return typeof((i=(e=t[0])==null?void 0:e.data)==null?void 0:i[0])=="object"}static checkRequiredConfig(t){const e=c.REQUIRED_PARAMS;if(!t){const i=e.map(s=>`'${s}'`);return c.log("error",`missing required param ${i.join(" and ")}.`),!1}for(let i=0;i<e.length;i++){const s=e[i];if(!t[s])return c.log("error",`missing required param '${s}'.`),!1}return!0}static log(t,e){var i;(i=console[t])==null||i.call(console,`[mobile-select]: ${e}`)}checkTriggerAvailable(){const{config:t}=this;return this.trigger=t.trigger instanceof HTMLElement?t.trigger:document.querySelector(t.trigger),this.trigger?!0:(c.log("error","trigger HTMLElement does not found on your document."),!1)}getPositionByInitValue(){var n;const{keyMap:t,connector:e,initValue:i}=this.config,s=(i==null?void 0:i.split(e))||[];if(this.isJsonType){let h=(n=this.wheelsData[0])==null?void 0:n.data;return s.reduce((l,u)=>{var g;const d=h==null?void 0:h.findIndex(f=>f[t.value]==u);return l.push(d<0?0:d),h=(g=h[d])==null?void 0:g[t.childs],l},[])}return s.reduce((h,l,u)=>{var g,f;const d=(f=(g=this.wheelsData[u])==null?void 0:g.data)==null?void 0:f.findIndex(m=>m==l);return h.push(d<0?0:d),h},[])}getConnectedString(){let t="";for(let e=0;e<this.wheelList.length;e++)e==this.wheelList.length-1?t+=this.getInnerText(e):t+=this.getInnerText(e)+this.config.connector;return t}setTriggerInnerText(t){this.config.triggerDisplayValue&&(this.trigger.textContent=t)}setValue(t){if(!t||!t.length)return;if(this.isJsonType&&typeof t[0]!="object"||!this.isJsonType&&typeof t[0]=="object"){c.log("error",`The setValue() input format should be same with getValue(), like: ${JSON.stringify(this.getValue())}`);return}const{keyMap:e}=this.config;t.forEach((i,s)=>{var l;const n=this.isCascade?this.displayJson[s]:(l=this.wheelsData[s])==null?void 0:l.data,h=n==null?void 0:n.findIndex(u=>this.isJsonType?i[e.id]==u[e.id]||i[e.value]==u[e.value]:i==u);this.locatePosition(s,h)}),this.setTriggerInnerText(this.getConnectedString())}setTitle(t){this.mobileSelect.querySelector(".ms-title").innerHTML=t}setStyle(t){if(t.ensureBtnColor&&(this.ensureBtn.style.color=t.ensureBtnColor),t.cancelBtnColor&&(this.cancelBtn.style.color=t.cancelBtnColor),t.titleColor){const e=this.mobileSelect.querySelector(".ms-title");e.style.color=t.titleColor}if(t.textColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),this.panel.style.color=t.textColor),t.titleBgColor){const e=this.mobileSelect.querySelector(".ms-btn-bar");e.style.backgroundColor=t.titleBgColor}if(t.bgColor){this.panel=this.mobileSelect.querySelector(".ms-panel");const e=this.mobileSelect.querySelector(".ms-shadow-mask");this.panel.style.backgroundColor=t.bgColor,e.style.background="linear-gradient(to bottom, "+t.bgColor+", rgba(255, 255, 255, 0), "+t.bgColor+")"}if(typeof t.maskOpacity=="number"){const e=this.mobileSelect.querySelector(".ms-gray-layer");e.style.background="rgba(0, 0, 0, "+t.maskOpacity+")"}}show(){var t,e,i;this.mobileSelect.classList.add("ms-show"),(t=document.querySelector("body"))==null||t.classList.add("ms-show"),typeof this.config.onShow=="function"&&((i=(e=this.config).onShow)==null||i.call(e,this.curValue,this.curIndexArr,this))}hide(){var t,e,i;this.mobileSelect.classList.remove("ms-show"),(t=document.querySelector("body"))==null||t.classList.remove("ms-show"),typeof this.config.onHide=="function"&&((i=(e=this.config).onHide)==null||i.call(e,this.curValue,this.curIndexArr,this))}registerEvents(t){for(const[e,i]of Object.entries(this.eventHandleMap))typeof i.event=="string"?this[e][`${t}EventListener`](i.event,i.fn,{passive:!1}):i.event.forEach(s=>{this[e][`${t}EventListener`](s,i.fn,{passive:!1})})}destroy(){var t,e;this.registerEvents("remove"),(e=(t=this.mobileSelect)==null?void 0:t.parentNode)==null||e.removeChild(this.mobileSelect)}getOptionsHtmlStr(t){const{keyMap:e}=this.config;let i="";if(this.isJsonType)for(let s=0;s<t.length;s++){const n=t[s][e.id],h=t[s][e.value];i+=`<li data-id="${n}">${h}</li>`}else for(let s=0;s<t.length;s++)i+="<li>"+t[s]+"</li>";return i}renderComponent(t){this.mobileSelect=document.createElement("div"),this.mobileSelect.className="ms-mobile-select",this.mobileSelect.innerHTML=`<div class="ms-gray-layer"></div>
8
+ <div class="ms-content">
9
+ <div class="ms-btn-bar">
10
+ <div class="ms-fix-width">
11
+ <div class="ms-cancel">${this.config.cancelBtnText}</div>
12
+ <div class="ms-title">${this.config.title||""}</div>
13
+ <div class="ms-ensure">${this.config.ensureBtnText}</div>
14
+ </div>
15
+ </div>
16
+ <div class="ms-panel">
17
+ <div class="ms-fix-width">
18
+ <div class="ms-wheels"></div>
19
+ <div class="ms-select-line"></div>
20
+ <div class="ms-shadow-mask"></div>
21
+ </div>
22
+ </div>`,document.body.appendChild(this.mobileSelect);let e="";for(let i=0;i<t.length;i++)e+=`<div class="ms-wheel" data-index="${i}"><ul class="ms-select-container">`,e+=this.getOptionsHtmlStr(t[i].data),e+="</ul></div>";this.mobileSelect.querySelector(".ms-wheels").innerHTML=e}reRenderWheels(){const t=this.wheelList.length-this.displayJson.length;if(t>0)for(let e=0;e<t;e++)this.wheelsContain.removeChild(this.wheelList[this.wheelList.length-1]);for(let e=0;e<this.displayJson.length;e++)if(this.wheelList[e])this.sliderList[e].innerHTML=this.getOptionsHtmlStr(this.displayJson[e]);else{const i=document.createElement("div");i.className="ms-wheel",i.innerHTML=`<ul class="ms-select-container">${this.getOptionsHtmlStr(this.displayJson[e])}</ul>`,i.setAttribute("data-index",e.toString()),this.wheelsContain.appendChild(i)}}checkCascade(){var e;const{keyMap:t}=this.config;if(this.isJsonType){const i=this.wheelsData[0].data;for(let s=0;s<i.length;s++)if(t.childs in i[s]&&((e=i[s][t.childs])==null?void 0:e.length)>0)return this.cascadeJsonData=this.wheelsData[0].data,!0}return!1}initCascade(){this.displayJson.push(this.cascadeJsonData),this.initPosition.length>0?(this.initDeepCount=0,this.initCheckArrDeep(this.cascadeJsonData[this.initPosition[0]])):this.checkArrDeep(this.cascadeJsonData[0]),this.reRenderWheels()}initCheckArrDeep(t){if(t){const{keyMap:e}=this.config;if(e.childs in t&&t[e.childs].length>0){this.displayJson.push(t[e.childs]),this.initDeepCount++;const i=t[e.childs][this.initPosition[this.initDeepCount]];i?this.initCheckArrDeep(i):this.checkArrDeep(t[e.childs][0])}}}checkArrDeep(t){if(!t)return;const{keyMap:e}=this.config;e.childs in t&&t[e.childs].length>0&&(this.displayJson.push(t[e.childs]),this.checkArrDeep(t[e.childs][0]))}checkRange(t,e){var h;const i=this.displayJson.length-1-t,{keyMap:s}=this.config;for(let l=0;l<i;l++)this.displayJson.pop();let n;for(let l=0;l<=t;l++)n=l==0?this.cascadeJsonData[e[0]]:(h=n==null?void 0:n[s.childs])==null?void 0:h[e[l]];this.checkArrDeep(n),this.reRenderWheels(),this.fixRowStyle(),this.setCurDistance(this.resetPosition(t,e))}resetPosition(t,e){const i=[...e];let s;if(this.sliderList.length>e.length){s=this.sliderList.length-e.length;for(let n=0;n<s;n++)i.push(0)}else if(this.sliderList.length<e.length){s=e.length-this.sliderList.length;for(let n=0;n<s;n++)i.pop()}for(let n=t+1;n<i.length;n++)i[n]=0;return i}updateWheels(t){if(this.isCascade){if(this.cascadeJsonData=t,this.displayJson=[],this.initCascade(),this.initPosition.length<this.sliderList.length){const e=this.sliderList.length-this.initPosition.length;for(let i=0;i<e;i++)this.initPosition.push(0)}this.setCurDistance(this.initPosition),this.fixRowStyle()}}updateWheel(t,e){if(this.isCascade){c.log("error","'updateWheel()' not support cascade json data, please use 'updateWheels()' instead to update the whole data source");return}let i="";i+=this.getOptionsHtmlStr(e),this.wheelsData[t]=this.isJsonType?{data:e}:e,this.sliderList[t].innerHTML=i}fixRowStyle(){if(this.initColWidth.length&&this.initColWidth.length===this.wheelList.length){const e=this.initColWidth.reduce((i,s)=>i+s,0);this.initColWidth.forEach((i,s)=>{this.wheelList[s].style.width=(i/e*100).toFixed(2)+"%"});return}const t=(100/this.wheelList.length).toFixed(2);for(let e=0;e<this.wheelList.length;e++)this.wheelList[e].style.width=t+"%"}getIndex(t){return Math.round((2*this.optionHeight-t)/this.optionHeight)}getIndexArr(){const t=[];for(let e=0;e<this.curDistance.length;e++)t.push(this.getIndex(this.curDistance[e]));return t}getCurValue(){const t=[],e=this.getIndexArr(),{keyMap:i}=this.config;if(this.isCascade)for(let s=0;s<this.wheelList.length;s++){const n=this.displayJson[s][e[s]];n&&t.push({[i.id]:n[i.id],[i.value]:n[i.value]})}else if(this.isJsonType)for(let s=0;s<this.curDistance.length;s++)t.push(this.wheelsData[s].data[this.getIndex(this.curDistance[s])]);else for(let s=0;s<this.curDistance.length;s++)t.push(this.getInnerText(s));return t}getValue(){return this.getCurValue()}calcDistance(t){return 2*this.optionHeight-t*this.optionHeight}setCurDistance(t){const e=[];for(let i=0;i<this.sliderList.length;i++)e.push(this.calcDistance(t[i])),this.movePosition(this.sliderList[i],e[i]);this.curDistance=e}fixPosition(t){return-(this.getIndex(t)-2)*this.optionHeight}movePosition(t,e){t.style.transform="translate3d(0,"+e+"px, 0)"}locatePosition(t,e){t===void 0||e===void 0||e<0||(this.curDistance[t]=this.calcDistance(e),this.movePosition(this.sliderList[t],this.curDistance[t]),this.isCascade&&this.checkRange(t,this.getIndexArr()))}updateCurDistance(t,e){this.curDistance[e]=parseInt(t.style.transform.split(",")[1])}getInnerText(t){var s;const e=this.sliderList[t].getElementsByTagName("li").length;let i=this.getIndex(this.curDistance[t]);return i>=e?i=e-1:i<0&&(i=0),((s=this.sliderList[t].getElementsByTagName("li")[i])==null?void 0:s.textContent)||""}touch(t){var h,l,u,d,g,f,m,v;const i=(t.composedPath&&t.composedPath()).find(p=>{var y;return(y=p.classList)==null?void 0:y.contains("ms-wheel")});if(!i)return;const s=i.firstChild,n=parseInt(i.getAttribute("data-index")||"0");switch(t.type){case"touchstart":case"mousedown":s.style.transition="none 0s ease-out",this.startY=Math.floor(t instanceof TouchEvent?t.touches[0].clientY:t.clientY),this.preMoveY=this.startY,t.type==="mousedown"&&(this.enableClickStatus=!0);break;case"touchmove":case"mousemove":if(t.preventDefault(),t.type==="mousemove"&&!this.enableClickStatus)break;this.moveY=Math.floor(t instanceof TouchEvent?t.touches[0].clientY:t.clientY),this.offsetY=(this.moveY-this.preMoveY)*this.config.scrollSpeed,this.updateCurDistance(s,n),this.curDistance[n]=this.curDistance[n]+this.offsetY,this.movePosition(s,this.curDistance[n]),this.preMoveY=this.moveY;break;case"touchend":case"mouseup":if(s.style.transition="transform 0.18s ease-out",this.moveEndY=Math.floor(t instanceof TouchEvent?t.changedTouches[0].clientY:t.clientY),this.offsetSum=this.moveEndY-this.startY,this.oversizeBorder=-(s.getElementsByTagName("li").length-3)*this.optionHeight,this.offsetSum==0){const p=Math.floor((window.innerHeight-this.moveEndY)/40);if(p!=2){const y=p-2,C=this.curDistance[n]+y*this.optionHeight;C<=2*this.optionHeight&&C>=this.oversizeBorder&&(this.curDistance[n]=C,this.movePosition(s,this.curDistance[n]),(l=(h=this.config).transitionEnd)==null||l.call(h,this.getIndexArr(),this.getCurValue(),this),(d=(u=this.config).onTransitionEnd)==null||d.call(u,this.getCurValue(),this.getIndexArr(),this))}}else this.updateCurDistance(s,n),this.curDistance[n]=this.fixPosition(this.curDistance[n]),this.curDistance[n]>2*this.optionHeight?this.curDistance[n]=2*this.optionHeight:this.curDistance[n]<this.oversizeBorder&&(this.curDistance[n]=this.oversizeBorder),this.movePosition(s,this.curDistance[n]),(f=(g=this.config).transitionEnd)==null||f.call(g,this.getIndexArr(),this.getCurValue(),this),(v=(m=this.config).onTransitionEnd)==null||v.call(m,this.getCurValue(),this.getIndexArr(),this);t.type==="mouseup"&&(this.enableClickStatus=!1),this.isCascade&&this.checkRange(n,this.getIndexArr());break}}};let r=c;return o(r,"defaultConfig",{keyMap:{id:"id",value:"value",childs:"childs"},position:[],colWidth:[],title:"",connector:" ",ensureBtnText:"\u786E\u8BA4",cancelBtnText:"\u53D6\u6D88",triggerDisplayValue:!0,scrollSpeed:1}),o(r,"REQUIRED_PARAMS",["trigger","wheels"]),r});
@@ -1,167 +1,167 @@
1
- /*
2
- * mobile-select v1.4.0
3
- * Homepage: https://github.com/onlyhom/mobile-select
4
- * Released under the MIT License.
5
- * (c) 2017-present
6
- */
7
- .ms-mobile-select {
8
- position: absolute;
9
- top: 0;
10
- right: 0;
11
- bottom: 0;
12
- left: 0;
13
- z-index: 0;
14
- opacity: 0;
15
- visibility: hidden;
16
- -webkit-transition: opacity 0.4s, z-index 0.4s;
17
- transition: opacity 0.4s, z-index 0.4s;
18
- transform: translate(0, 0);
19
- }
20
- .ms-mobile-select * {
21
- margin: 0;
22
- padding: 0;
23
- -webkit-box-sizing: border-box;
24
- box-sizing: border-box;
25
- }
26
- .ms-mobile-select .ms-gray-layer {
27
- position: fixed;
28
- top: 0;
29
- left: 0;
30
- bottom: 0;
31
- right: 0;
32
- background: rgba(0, 0, 0, 0.7);
33
- z-index: 888;
34
- display: block;
35
- }
36
- .ms-mobile-select .ms-content {
37
- width: 100%;
38
- display: block;
39
- position: fixed;
40
- z-index: 889;
41
- color: black;
42
- -webkit-transition: all 0.4s;
43
- transition: all 0.4s;
44
- bottom: -350px;
45
- left: 0;
46
- background: white;
47
- }
48
- .ms-mobile-select .ms-fix-width {
49
- width: 90%;
50
- margin: 0 auto;
51
- position: relative;
52
- }
53
- .ms-mobile-select .ms-fix-width:after {
54
- content: ".";
55
- display: block;
56
- height: 0;
57
- clear: both;
58
- visibility: hidden;
59
- }
60
- .ms-mobile-select .ms-btn-bar {
61
- border-bottom: 1px solid #dcdcdc;
62
- font-size: 15px;
63
- height: 45px;
64
- position: relative;
65
- text-align: center;
66
- line-height: 45px;
67
- }
68
- .ms-mobile-select .ms-cancel,
69
- .ms-mobile-select .ms-ensure {
70
- height: 45px;
71
- width: 55px;
72
- cursor: pointer;
73
- position: absolute;
74
- top: 0;
75
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
76
- }
77
- .ms-mobile-select .ms-cancel {
78
- left: 0;
79
- color: #666;
80
- }
81
- .ms-mobile-select .ms-ensure {
82
- right: 0;
83
- color: #1e83d3;
84
- }
85
- .ms-mobile-select .ms-title {
86
- font-size: 15px;
87
- padding: 0 15%;
88
- overflow: hidden;
89
- white-space: nowrap;
90
- text-overflow: ellipsis;
91
- }
92
- .ms-mobile-select .ms-panel:after {
93
- content: ".";
94
- display: block;
95
- height: 0;
96
- clear: both;
97
- visibility: hidden;
98
- }
99
- .ms-mobile-select .ms-wheels {
100
- width: 100%;
101
- height: 200px;
102
- overflow: hidden;
103
- }
104
- .ms-mobile-select .ms-wheel {
105
- position: relative;
106
- z-index: 0;
107
- float: left;
108
- width: 50%;
109
- height: 200px;
110
- overflow: hidden;
111
- -webkit-transition: width 0.3s ease;
112
- transition: width 0.3s ease;
113
- }
114
- .ms-mobile-select .ms-select-container {
115
- display: block;
116
- text-align: center;
117
- }
118
- .ms-mobile-select .ms-select-container li {
119
- font-size: 15px;
120
- display: block;
121
- height: 40px;
122
- line-height: 40px;
123
- cursor: pointer;
124
- overflow: hidden;
125
- white-space: nowrap;
126
- text-overflow: ellipsis;
127
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
128
- }
129
- .ms-mobile-select .ms-select-line {
130
- height: 40px;
131
- width: 100%;
132
- position: absolute;
133
- top: 80px;
134
- pointer-events: none;
135
- -webkit-box-sizing: border-box;
136
- box-sizing: border-box;
137
- border-top: 1px solid #dcdcdc;
138
- border-bottom: 1px solid #dcdcdc;
139
- }
140
- .ms-mobile-select .ms-shadow-mask {
141
- position: absolute;
142
- top: 0;
143
- width: 100%;
144
- height: 200px;
145
- background: linear-gradient(to bottom, #fffffff5, #ffffffcc 25%, #ffffff00 49%, #ffffff00 51%, #ffffffcc 75%, #fffffff5);
146
- opacity: 0.9;
147
- pointer-events: none;
148
- }
149
- .ms-mobile-select.ms-show {
150
- opacity: 1;
151
- z-index: 10000;
152
- visibility: visible;
153
- }
154
- .ms-mobile-select.ms-show .ms-content {
155
- bottom: 0;
156
- }
157
- .ms-default-trigger {
158
- min-height: 1em;
159
- color: #888;
160
- }
161
- /** Prevent Page Scrolling When a Modal is Open */
162
- body.ms-show {
163
- overflow-y: hidden;
164
- }
1
+ /*
2
+ * mobile-select v1.4.0
3
+ * Homepage: https://github.com/onlyhom/mobile-select
4
+ * Released under the MIT License.
5
+ * (c) 2017-present
6
+ */
7
+ .ms-mobile-select {
8
+ position: absolute;
9
+ top: 0;
10
+ right: 0;
11
+ bottom: 0;
12
+ left: 0;
13
+ z-index: 0;
14
+ opacity: 0;
15
+ visibility: hidden;
16
+ -webkit-transition: opacity 0.4s, z-index 0.4s;
17
+ transition: opacity 0.4s, z-index 0.4s;
18
+ transform: translate(0, 0);
19
+ }
20
+ .ms-mobile-select * {
21
+ margin: 0;
22
+ padding: 0;
23
+ -webkit-box-sizing: border-box;
24
+ box-sizing: border-box;
25
+ }
26
+ .ms-mobile-select .ms-gray-layer {
27
+ position: fixed;
28
+ top: 0;
29
+ left: 0;
30
+ bottom: 0;
31
+ right: 0;
32
+ background: rgba(0, 0, 0, 0.7);
33
+ z-index: 888;
34
+ display: block;
35
+ }
36
+ .ms-mobile-select .ms-content {
37
+ width: 100%;
38
+ display: block;
39
+ position: fixed;
40
+ z-index: 889;
41
+ color: black;
42
+ -webkit-transition: all 0.4s;
43
+ transition: all 0.4s;
44
+ bottom: -350px;
45
+ left: 0;
46
+ background: white;
47
+ }
48
+ .ms-mobile-select .ms-fix-width {
49
+ width: 90%;
50
+ margin: 0 auto;
51
+ position: relative;
52
+ }
53
+ .ms-mobile-select .ms-fix-width:after {
54
+ content: ".";
55
+ display: block;
56
+ height: 0;
57
+ clear: both;
58
+ visibility: hidden;
59
+ }
60
+ .ms-mobile-select .ms-btn-bar {
61
+ border-bottom: 1px solid #dcdcdc;
62
+ font-size: 15px;
63
+ height: 45px;
64
+ position: relative;
65
+ text-align: center;
66
+ line-height: 45px;
67
+ }
68
+ .ms-mobile-select .ms-cancel,
69
+ .ms-mobile-select .ms-ensure {
70
+ height: 45px;
71
+ width: 55px;
72
+ cursor: pointer;
73
+ position: absolute;
74
+ top: 0;
75
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
76
+ }
77
+ .ms-mobile-select .ms-cancel {
78
+ left: 0;
79
+ color: #666;
80
+ }
81
+ .ms-mobile-select .ms-ensure {
82
+ right: 0;
83
+ color: #1e83d3;
84
+ }
85
+ .ms-mobile-select .ms-title {
86
+ font-size: 15px;
87
+ padding: 0 15%;
88
+ overflow: hidden;
89
+ white-space: nowrap;
90
+ text-overflow: ellipsis;
91
+ }
92
+ .ms-mobile-select .ms-panel:after {
93
+ content: ".";
94
+ display: block;
95
+ height: 0;
96
+ clear: both;
97
+ visibility: hidden;
98
+ }
99
+ .ms-mobile-select .ms-wheels {
100
+ width: 100%;
101
+ height: 200px;
102
+ overflow: hidden;
103
+ }
104
+ .ms-mobile-select .ms-wheel {
105
+ position: relative;
106
+ z-index: 0;
107
+ float: left;
108
+ width: 50%;
109
+ height: 200px;
110
+ overflow: hidden;
111
+ -webkit-transition: width 0.3s ease;
112
+ transition: width 0.3s ease;
113
+ }
114
+ .ms-mobile-select .ms-select-container {
115
+ display: block;
116
+ text-align: center;
117
+ }
118
+ .ms-mobile-select .ms-select-container li {
119
+ font-size: 15px;
120
+ display: block;
121
+ height: 40px;
122
+ line-height: 40px;
123
+ cursor: pointer;
124
+ overflow: hidden;
125
+ white-space: nowrap;
126
+ text-overflow: ellipsis;
127
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
128
+ }
129
+ .ms-mobile-select .ms-select-line {
130
+ height: 40px;
131
+ width: 100%;
132
+ position: absolute;
133
+ top: 80px;
134
+ pointer-events: none;
135
+ -webkit-box-sizing: border-box;
136
+ box-sizing: border-box;
137
+ border-top: 1px solid #dcdcdc;
138
+ border-bottom: 1px solid #dcdcdc;
139
+ }
140
+ .ms-mobile-select .ms-shadow-mask {
141
+ position: absolute;
142
+ top: 0;
143
+ width: 100%;
144
+ height: 200px;
145
+ background: linear-gradient(to bottom, #fffffff5, #ffffffcc 25%, #ffffff00 49%, #ffffff00 51%, #ffffffcc 75%, #fffffff5);
146
+ opacity: 0.9;
147
+ pointer-events: none;
148
+ }
149
+ .ms-mobile-select.ms-show {
150
+ opacity: 1;
151
+ z-index: 10000;
152
+ visibility: visible;
153
+ }
154
+ .ms-mobile-select.ms-show .ms-content {
155
+ bottom: 0;
156
+ }
157
+ .ms-default-trigger {
158
+ min-height: 1em;
159
+ color: #888;
160
+ }
161
+ /** Prevent Page Scrolling When a Modal is Open */
162
+ body.ms-show {
163
+ overflow-y: hidden;
164
+ }
165
165
 
166
166
  h1,
167
167
  h2,
@@ -1,5 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
- import MobileSelect from 'mobile-select';
2
+ import MobileSelect from './mobile-select';
3
3
  class MobileSelectedItem {
4
4
  }
5
5
  export class PtcMobileSelect {
@@ -1,21 +1,74 @@
1
- :host {
2
- display: block;
3
-
4
- .description{
5
- display: inline;
6
- }
7
-
8
- .label{
9
- cursor: pointer;
10
- color: var(--color-hyperlink);
11
- font-size: var(--ptc-font-size-small);
12
- font-weight: var(--ptc-font-weight-bold);
13
- text-decoration-line: underline;
14
- line-height: var(--ptc-line-height-densest);
15
-
16
- &::before{
17
- content: '';
18
- padding-left: 8px;
19
- }
20
- }
21
- }
1
+ h1,
2
+ h2,
3
+ h3,
4
+ h4,
5
+ h5,
6
+ h6,
7
+ p,
8
+ ul,
9
+ li,
10
+ ptc-subnav,
11
+ ptc-tab-list,
12
+ ptc-link, ptc-square-card,
13
+ .hyphenate-text, ptc-footer {
14
+ word-break: break-word;
15
+ hyphens: manual;
16
+ -webkit-hyphens: manual;
17
+ -moz-hyphens: manual;
18
+ -ms-hyphens: manual;
19
+ }
20
+ @supports (hyphenate-limit-chars: 12 3 3) {
21
+ h1,
22
+ h2,
23
+ h3,
24
+ h4,
25
+ h5,
26
+ h6,
27
+ p,
28
+ ul,
29
+ li,
30
+ ptc-subnav,
31
+ ptc-tab-list,
32
+ ptc-link, ptc-square-card,
33
+ .hyphenate-text, ptc-footer {
34
+ hyphens: auto;
35
+ -webkit-hyphenate-limit-before: 3;
36
+ /* For Safari */
37
+ -webkit-hyphenate-limit-after: 3;
38
+ /* For Safari */
39
+ hyphenate-limit-chars: 12 3 3;
40
+ hyphenate-limit-lines: 2;
41
+ hyphenate-limit-last: always;
42
+ hyphenate-limit-zone: 6%;
43
+ -webkit-hyphens: auto;
44
+ -webkit-hyphenate-limit-before: 3;
45
+ -webkit-hyphenate-limit-after: 3;
46
+ -webkit-hyphenate-limit-chars: 12 3 3;
47
+ -webkit-hyphenate-limit-lines: 2;
48
+ -moz-hyphens: auto;
49
+ -moz-hyphenate-limit-chars: 12 3 3;
50
+ -moz-hyphenate-limit-lines: 2;
51
+ -ms-hyphens: auto;
52
+ -ms-hyphenate-limit-chars: 12 3 3;
53
+ -ms-hyphenate-limit-lines: 2;
54
+ }
55
+ }
56
+
57
+ :host {
58
+ display: block;
59
+ }
60
+ :host .description {
61
+ display: inline;
62
+ }
63
+ :host .label {
64
+ cursor: pointer;
65
+ color: var(--color-hyperlink);
66
+ font-size: var(--ptc-font-size-small);
67
+ font-weight: var(--ptc-font-weight-bold);
68
+ text-decoration-line: underline;
69
+ line-height: var(--ptc-line-height-densest);
70
+ }
71
+ :host .label::before {
72
+ content: "";
73
+ padding-left: 8px;
74
+ }
@@ -104,14 +104,14 @@ export class PtcReadmoreV3 {
104
104
  this.readMoreTrigger.emit(this.expanded);
105
105
  }
106
106
  render() {
107
- const parsedStyles = this.contentStyles ? this.parseStyles(this.contentStyles) : {};
108
- return (h(Host, null, h("p", { class: "description", style: parsedStyles }, this.truncated ? this.getContent() : h("slot", null)), this.truncated ? (h("label", { class: "label", onClick: () => this.toggleExpand() }, this.getLabel())) : null));
107
+ //const parsedStyles = this.contentStyles ? this.parseStyles(this.contentStyles) : {};
108
+ return (h(Host, null, this.contentStyles && h("style", null, this.contentStyles), h("p", { class: "description" }, this.truncated ? this.getContent() : h("slot", null)), this.truncated ? (h("label", { class: "label", onClick: () => this.toggleExpand() }, this.getLabel())) : null));
109
109
  }
110
110
  static get is() { return "ptc-readmore-v3"; }
111
111
  static get encapsulation() { return "shadow"; }
112
112
  static get originalStyleUrls() {
113
113
  return {
114
- "$": ["ptc-readmore-v3.css"]
114
+ "$": ["ptc-readmore-v3.scss"]
115
115
  };
116
116
  }
117
117
  static get styleUrls() {