UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

2 lines (1 loc) 11.6 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=require("../ssr-window/ssr-window.esm.js");function e(t){return(e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function i(t,e,o){return(i=n()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function o(t){var n="function"==typeof Map?new Map:void 0;return o=function(t){if(null===t||(o=t,-1===Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,s)}function s(){return i(t,arguments,e(this).constructor)}return s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),r(s,t)},o(t)}var s=function(t){var e,r;function n(e){var r,n,i;return r=t.call.apply(t,[this].concat(e))||this,n=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(r),i=n.__proto__,Object.defineProperty(n,"__proto__",{get:function(){return i},set:function(t){i.__proto__=t}}),r}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,n}(o(Array));function f(t){void 0===t&&(t=[]);var e=[];return t.forEach((function(t){Array.isArray(t)?e.push.apply(e,f(t)):e.push(t)})),e}function u(t,e){return Array.prototype.filter.call(t,e)}function l(e,r){var n=t.getWindow(),i=t.getDocument(),o=[];if(!r&&e instanceof s)return e;if(!e)return new s(o);if("string"==typeof e){var f=e.trim();if(f.indexOf("<")>=0&&f.indexOf(">")>=0){var u="div";0===f.indexOf("<li")&&(u="ul"),0===f.indexOf("<tr")&&(u="tbody"),0!==f.indexOf("<td")&&0!==f.indexOf("<th")||(u="tr"),0===f.indexOf("<tbody")&&(u="table"),0===f.indexOf("<option")&&(u="select");var l=i.createElement(u);l.innerHTML=f;for(var h=0;h<l.childNodes.length;h+=1)o.push(l.childNodes[h])}else o=function(t,e){if("string"!=typeof t)return[t];for(var r=[],n=e.querySelectorAll(t),i=0;i<n.length;i+=1)r.push(n[i]);return r}(e.trim(),r||i)}else if(e.nodeType||e===n||e===i)o.push(e);else if(Array.isArray(e)){if(e instanceof s)return e;o=e}return new s(function(t){for(var e=[],r=0;r<t.length;r+=1)-1===e.indexOf(t[r])&&e.push(t[r]);return e}(o))}l.fn=s.prototype,exports.$=l,exports.addClass=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=f(e.map((function(t){return t.split(" ")})));return this.forEach((function(t){var e;(e=t.classList).add.apply(e,n)})),this},exports.append=function(){for(var e,r=t.getDocument(),n=0;n<arguments.length;n+=1){e=n<0||arguments.length<=n?void 0:arguments[n];for(var i=0;i<this.length;i+=1)if("string"==typeof e){var o=r.createElement("div");for(o.innerHTML=e;o.firstChild;)this[i].appendChild(o.firstChild)}else if(e instanceof s)for(var f=0;f<e.length;f+=1)this[i].appendChild(e[f]);else this[i].appendChild(e)}return this},exports.attr=function(t,e){if(1===arguments.length&&"string"==typeof t)return this[0]?this[0].getAttribute(t):void 0;for(var r=0;r<this.length;r+=1)if(2===arguments.length)this[r].setAttribute(t,e);else for(var n in t)this[r][n]=t[n],this[r].setAttribute(n,t[n]);return this},exports.children=function(t){for(var e=[],r=0;r<this.length;r+=1)for(var n=this[r].children,i=0;i<n.length;i+=1)t&&!l(n[i]).is(t)||e.push(n[i]);return l(e)},exports.closest=function(t){var e=this;return void 0===t?l([]):(e.is(t)||(e=e.parents(t).eq(0)),e)},exports.css=function(e,r){var n,i=t.getWindow();if(1===arguments.length){if("string"!=typeof e){for(n=0;n<this.length;n+=1)for(var o in e)this[n].style[o]=e[o];return this}if(this[0])return i.getComputedStyle(this[0],null).getPropertyValue(e)}if(2===arguments.length&&"string"==typeof e){for(n=0;n<this.length;n+=1)this[n].style[e]=r;return this}return this},exports.default=l,exports.each=function(t){return t?(this.forEach((function(e,r){t.apply(e,[e,r])})),this):this},exports.eq=function(t){if(void 0===t)return this;var e=this.length;if(t>e-1)return l([]);if(t<0){var r=e+t;return l(r<0?[]:[this[r]])}return l([this[t]])},exports.filter=function(t){return l(u(this,t))},exports.find=function(t){for(var e=[],r=0;r<this.length;r+=1)for(var n=this[r].querySelectorAll(t),i=0;i<n.length;i+=1)e.push(n[i]);return l(e)},exports.hasClass=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=f(e.map((function(t){return t.split(" ")})));return u(this,(function(t){return n.filter((function(e){return t.classList.contains(e)})).length>0})).length>0},exports.html=function(t){if(void 0===t)return this[0]?this[0].innerHTML:null;for(var e=0;e<this.length;e+=1)this[e].innerHTML=t;return this},exports.index=function(){var t,e=this[0];if(e){for(t=0;null!==(e=e.previousSibling);)1===e.nodeType&&(t+=1);return t}},exports.is=function(e){var r,n,i=t.getWindow(),o=t.getDocument(),f=this[0];if(!f||void 0===e)return!1;if("string"==typeof e){if(f.matches)return f.matches(e);if(f.webkitMatchesSelector)return f.webkitMatchesSelector(e);if(f.msMatchesSelector)return f.msMatchesSelector(e);for(r=l(e),n=0;n<r.length;n+=1)if(r[n]===f)return!0;return!1}if(e===o)return f===o;if(e===i)return f===i;if(e.nodeType||e instanceof s){for(r=e.nodeType?[e]:e,n=0;n<r.length;n+=1)if(r[n]===f)return!0;return!1}return!1},exports.next=function(t){return this.length>0?t?this[0].nextElementSibling&&l(this[0].nextElementSibling).is(t)?l([this[0].nextElementSibling]):l([]):this[0].nextElementSibling?l([this[0].nextElementSibling]):l([]):l([])},exports.nextAll=function(t){var e=[],r=this[0];if(!r)return l([]);for(;r.nextElementSibling;){var n=r.nextElementSibling;t?l(n).is(t)&&e.push(n):e.push(n),r=n}return l(e)},exports.off=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=e[0],i=e[1],o=e[2],s=e[3];"function"==typeof e[1]&&(n=e[0],o=e[1],s=e[2],i=void 0),s||(s=!1);for(var f=n.split(" "),u=0;u<f.length;u+=1)for(var l=f[u],h=0;h<this.length;h+=1){var a=this[h],p=void 0;if(!i&&a.dom7Listeners?p=a.dom7Listeners[l]:i&&a.dom7LiveListeners&&(p=a.dom7LiveListeners[l]),p&&p.length)for(var c=p.length-1;c>=0;c-=1){var v=p[c];o&&v.listener===o||o&&v.listener&&v.listener.dom7proxy&&v.listener.dom7proxy===o?(a.removeEventListener(l,v.proxyListener,s),p.splice(c,1)):o||(a.removeEventListener(l,v.proxyListener,s),p.splice(c,1))}}return this},exports.offset=function(){if(this.length>0){var e=t.getWindow(),r=t.getDocument(),n=this[0],i=n.getBoundingClientRect(),o=r.body,s=n.clientTop||o.clientTop||0,f=n.clientLeft||o.clientLeft||0,u=n===e?e.scrollY:n.scrollTop,l=n===e?e.scrollX:n.scrollLeft;return{top:i.top+u-s,left:i.left+l-f}}return null},exports.on=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=e[0],i=e[1],o=e[2],s=e[3];function f(t){var e=t.target;if(e){var r=t.target.dom7EventData||[];if(r.indexOf(t)<0&&r.unshift(t),l(e).is(i))o.apply(e,r);else for(var n=l(e).parents(),s=0;s<n.length;s+=1)l(n[s]).is(i)&&o.apply(n[s],r)}}function u(t){var e=t&&t.target&&t.target.dom7EventData||[];e.indexOf(t)<0&&e.unshift(t),o.apply(this,e)}"function"==typeof e[1]&&(n=e[0],o=e[1],s=e[2],i=void 0),s||(s=!1);for(var h,a=n.split(" "),p=0;p<this.length;p+=1){var c=this[p];if(i)for(h=0;h<a.length;h+=1){var v=a[h];c.dom7LiveListeners||(c.dom7LiveListeners={}),c.dom7LiveListeners[v]||(c.dom7LiveListeners[v]=[]),c.dom7LiveListeners[v].push({listener:o,proxyListener:f}),c.addEventListener(v,f,s)}else for(h=0;h<a.length;h+=1){var d=a[h];c.dom7Listeners||(c.dom7Listeners={}),c.dom7Listeners[d]||(c.dom7Listeners[d]=[]),c.dom7Listeners[d].push({listener:o,proxyListener:u}),c.addEventListener(d,u,s)}}return this},exports.outerHeight=function(t){if(this.length>0){if(t){var e=this.styles();return this[0].offsetHeight+parseFloat(e.getPropertyValue("margin-top"))+parseFloat(e.getPropertyValue("margin-bottom"))}return this[0].offsetHeight}return null},exports.outerWidth=function(t){if(this.length>0){if(t){var e=this.styles();return this[0].offsetWidth+parseFloat(e.getPropertyValue("margin-right"))+parseFloat(e.getPropertyValue("margin-left"))}return this[0].offsetWidth}return null},exports.parent=function(t){for(var e=[],r=0;r<this.length;r+=1)null!==this[r].parentNode&&(t?l(this[r].parentNode).is(t)&&e.push(this[r].parentNode):e.push(this[r].parentNode));return l(e)},exports.parents=function(t){for(var e=[],r=0;r<this.length;r+=1)for(var n=this[r].parentNode;n;)t?l(n).is(t)&&e.push(n):e.push(n),n=n.parentNode;return l(e)},exports.prepend=function(e){var r,n,i=t.getDocument();for(r=0;r<this.length;r+=1)if("string"==typeof e){var o=i.createElement("div");for(o.innerHTML=e,n=o.childNodes.length-1;n>=0;n-=1)this[r].insertBefore(o.childNodes[n],this[r].childNodes[0])}else if(e instanceof s)for(n=0;n<e.length;n+=1)this[r].insertBefore(e[n],this[r].childNodes[0]);else this[r].insertBefore(e,this[r].childNodes[0]);return this},exports.prev=function(t){if(this.length>0){var e=this[0];return t?e.previousElementSibling&&l(e.previousElementSibling).is(t)?l([e.previousElementSibling]):l([]):e.previousElementSibling?l([e.previousElementSibling]):l([])}return l([])},exports.prevAll=function(t){var e=[],r=this[0];if(!r)return l([]);for(;r.previousElementSibling;){var n=r.previousElementSibling;t?l(n).is(t)&&e.push(n):e.push(n),r=n}return l(e)},exports.remove=function(){for(var t=0;t<this.length;t+=1)this[t].parentNode&&this[t].parentNode.removeChild(this[t]);return this},exports.removeAttr=function(t){for(var e=0;e<this.length;e+=1)this[e].removeAttribute(t);return this},exports.removeClass=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=f(e.map((function(t){return t.split(" ")})));return this.forEach((function(t){var e;(e=t.classList).remove.apply(e,n)})),this},exports.styles=function(){var e=t.getWindow();return this[0]?e.getComputedStyle(this[0],null):{}},exports.text=function(t){if(void 0===t)return this[0]?this[0].textContent.trim():null;for(var e=0;e<this.length;e+=1)this[e].textContent=t;return this},exports.toggleClass=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=f(e.map((function(t){return t.split(" ")})));this.forEach((function(t){n.forEach((function(e){t.classList.toggle(e)}))}))},exports.transform=function(t){for(var e=0;e<this.length;e+=1)this[e].style.transform=t;return this},exports.transition=function(t){for(var e=0;e<this.length;e+=1)this[e].style.transitionDuration="string"!=typeof t?t+"ms":t;return this},exports.transitionEnd=function(t){var e=this;return t&&e.on("transitionend",(function r(n){n.target===this&&(t.call(this,n),e.off("transitionend",r))})),this},exports.trigger=function(){for(var e=t.getWindow(),r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];for(var o=n[0].split(" "),s=n[1],f=0;f<o.length;f+=1)for(var u=o[f],l=0;l<this.length;l+=1){var h=this[l];if(e.CustomEvent){var a=new e.CustomEvent(u,{detail:s,bubbles:!0,cancelable:!0});h.dom7EventData=n.filter((function(t,e){return e>0})),h.dispatchEvent(a),h.dom7EventData=[],delete h.dom7EventData}}return this};