UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

16 lines (14 loc) 11.5 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/cdk/coercion"),require("ng-zorro-antd/core/logger"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ng-zorro-antd/core/util",["exports","@angular/core","@angular/cdk/coercion","ng-zorro-antd/core/logger","rxjs","rxjs/operators"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].core=e["ng-zorro-antd"].core||{},e["ng-zorro-antd"].core.util={}),e.ng.core,e.ng.cdk.coercion,e["ng-zorro-antd"].core.logger,e.rxjs,e.rxjs.operators)}(this,(function(e,t,n,r,o,i){"use strict";Object.create;function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function l(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e}Object.create;function a(e){return n.coerceBooleanProperty(e)}function d(e,t){return void 0===t&&(t=0),n._isNumberValue(e)?Number(e):t}function c(e){return n.coerceCssPixelValue(e)}function f(e,t){return function(n,o,i){var u="$$__"+o;return Object.prototype.hasOwnProperty.call(n,u)&&r.warn('The prop "'+u+'" is already exist, it will be overrided by '+e+" decorator."),Object.defineProperty(n,u,{configurable:!0,writable:!0}),{get:function(){return i&&i.get?i.get.bind(this)():this[u]},set:function(e){i&&i.set&&i.set.bind(this)(t(e)),this[u]=t(e)}}}}function s(e){return e.type.startsWith("touch")}function p(e){var t=Array.isArray(e)?e:[e],n=t.join("").replace(/(\$|\^)/g,"\\$1");return t.length>1&&(n="["+n+"]"),new RegExp("(\\s|^)("+n+")[^\\s]*","g")}function h(e,t){return Array(e).fill(t).join("")}function g(e){return!!e&&"function"==typeof e.then&&"function"==typeof e.catch}var y=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],m="undefined"!=typeof window,v=m&&null!=window.mozInnerScreenX,b=function(e){return parseInt(e,10)},w=b;function x(e,t){var n=getComputedStyle(e).getPropertyValue("font-size"),r=document.querySelector("#DEBUG")||document.createElement("div");document.body.appendChild(r),r.id="DEBUG",r.style.position="absolute",r.style.backgroundColor="red",r.style.height=n,r.style.width="1px",r.style.top=e.getBoundingClientRect().top-e.scrollTop+window.pageYOffset+t.top+"px",r.style.left=e.getBoundingClientRect().left-e.scrollLeft+window.pageXOffset+t.left+"px"}var C,N,E,T={padding:"0",margin:"0",display:"inline",lineHeight:"inherit"};function S(e){if(!e)return 0;var t=e.match(/^\d*(\.\d*)?/);return t?Number(t[0]):0}var j={position:"absolute",top:"-9999px",width:"50px",height:"50px"};e.InputBoolean=function(){return f("InputBoolean",a)},e.InputCssPixel=function(){return f("InputCssPixel",c)},e.InputNumber=function(e){return f("InputNumber",(function(t){return d(t,e)}))},e.arraysEqual=function(e,t){if(!e||!t||e.length!==t.length)return!1;for(var n=e.length,r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0},e.createDebugEle=x,e.ensureInBounds=function(e,t){return e&&e<t?e:t},e.ensureNumberInRange=function(e,t,n){return isNaN(e)||e<t?t:e>n?n:e},e.getCaretCoordinates=function(e,t,n){if(!m)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var r=n&&n.debug||!1;if(r){var o=document.querySelector("#input-textarea-caret-position-mirror-div");o&&o.parentNode.removeChild(o)}var i=document.createElement("div");i.id="input-textarea-caret-position-mirror-div",document.body.appendChild(i);var u=i.style,l=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,a="INPUT"===e.nodeName;u.whiteSpace="pre-wrap",a||(u.wordWrap="break-word"),u.position="absolute",r||(u.visibility="hidden"),y.forEach((function(e){a&&"lineHeight"===e?u.lineHeight=l.height:u[e]=l[e]})),v?e.scrollHeight>b(l.height)&&(u.overflowY="scroll"):u.overflow="hidden",i.textContent=e.value.substring(0,t),a&&(i.textContent=i.textContent.replace(/\s/g," "));var d=document.createElement("span");d.textContent=e.value.substring(t)||".",i.appendChild(d);var c={top:d.offsetTop+b(l.borderTopWidth),left:d.offsetLeft+b(l.borderLeftWidth),height:b(l.lineHeight)};return r?(d.style.backgroundColor="#eee",x(e,c)):document.body.removeChild(i),c},e.getElementOffset=function(e){if(!e.getClientRects().length)return{top:0,left:0};var t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView;return{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}},e.getEventPosition=function(e){return s(e)?e.touches[0]||e.changedTouches[0]:e},e.getMentions=function(e,t){if(void 0===t&&(t="@"),"string"!=typeof e)return[];var n=p(t),r=e.match(n);return null!==r?r.map((function(e){return e.trim()})):[]},e.getPercent=function(e,t,n){return(n-e)/(t-e)*100},e.getPrecision=function(e){var t=e.toString(),n=t.indexOf(".");return n>=0?t.length-n-1:0},e.getRegExp=p,e.getRepeatedElement=h,e.getStyleAsText=function(e){return e?Object.keys(e).map((function(t){var n=e[t];return t+":"+("string"==typeof n?n:n+"px")})).join(";"):""},e.inNextTick=function(){var e=new o.Subject;return Promise.resolve().then((function(){return e.next()})),e.pipe(i.take(1))},e.isNil=function(e){return null==e},e.isNonEmptyString=function(e){return"string"==typeof e&&""!==e},e.isNotNil=function(e){return null!=e},e.isNumberFinite=function(e){return"number"==typeof e&&isFinite(e)},e.isPromise=g,e.isStyleSupport=function(e){if("undefined"!=typeof window&&window.document&&window.document.documentElement){var t=Array.isArray(e)?e:[e],n=window.document.documentElement;return t.some((function(e){return e in n.style}))}return!1},e.isTemplateRef=function(e){return e instanceof t.TemplateRef} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */,e.isTouchEvent=s,e.measure=function(e,t,n,r,o,i){void 0===i&&(i=""),C||((C=document.createElement("div")).setAttribute("aria-hidden","true"),document.body.appendChild(C));var u,l=window.getComputedStyle(e),a=(u=l,Array.prototype.slice.apply(u).map((function(e){return e+": "+u.getPropertyValue(e)+";"})).join("")),d=S(l.lineHeight),c=Math.round(d*(t+1)+S(l.paddingTop)+S(l.paddingBottom));C.setAttribute("style",a),C.style.position="fixed",C.style.left="0",C.style.height="auto",C.style.minHeight="auto",C.style.maxHeight="auto",C.style.top="-999999px",C.style.zIndex="-1000",C.style.textOverflow="clip",C.style.whiteSpace="normal",C.style.webkitLineClamp="none";var f,s=(f=[],n.forEach((function(e){var t=f[f.length-1];t&&3===e.nodeType&&3===t.nodeType?t.data+=e.data:f.push(e)})),f),p=document.createElement("div"),h=document.createElement("span"),g=document.createTextNode(i),y=document.createElement("span");function m(){return C.offsetHeight<c}if(Object.assign(p.style,T),Object.assign(h.style,T),Object.assign(y.style,T),s.forEach((function(e){h.appendChild(e)})),h.appendChild(g),r.forEach((function(e){y.appendChild(e.cloneNode(!0))})),p.appendChild(h),p.appendChild(y),C.appendChild(p),m()){var v=C.innerHTML;return C.removeChild(p),{contentNodes:n,text:v,ellipsis:!1}}var b=Array.prototype.slice.apply(C.childNodes[0].childNodes[0].cloneNode(!0).childNodes).filter((function(e){return 8!==e.nodeType})),w=Array.prototype.slice.apply(C.childNodes[0].childNodes[1].cloneNode(!0).childNodes);C.removeChild(p),C.innerHTML="";var x=document.createElement("span");C.appendChild(x);var N=document.createTextNode(o+i);function E(e,t,n,r,o){void 0===n&&(n=0),void 0===r&&(r=t.length),void 0===o&&(o=0);var i=Math.floor((n+r)/2);if(e.textContent=t.slice(0,i),n>=r-1)for(var u=r;u>=n;u-=1){var l=t.slice(0,u);if(e.textContent=l,m()||!l)return u===t.length?{finished:!1,node:document.createTextNode(t)}:{finished:!0,node:document.createTextNode(l)}}return m()?E(e,t,i,r,i):E(e,t,n,i,o)}function j(e,t){var n,r=e.nodeType;if(1===r)return m()?{finished:!1,node:s[t]}:(x.removeChild(e),{finished:!0,node:null});if(3===r){var o=e.textContent||"",i=document.createTextNode(o);return n=i,x.insertBefore(n,N),E(i,o)}return{finished:!1,node:null}}x.appendChild(N),w.forEach((function(e){C.appendChild(e)}));var O=[];b.some((function(e,t){var n=j(e,t),r=n.finished,o=n.node;return o&&O.push(o),r}));for(var I={contentNodes:O,text:C.innerHTML,ellipsis:!0};C.firstChild;)C.removeChild(C.firstChild);return I},e.measureScrollbar=function(e,t){if(void 0===e&&(e="vertical"),void 0===t&&(t="ant"),"undefined"==typeof document||"undefined"==typeof window)return 0;var n="vertical"===e;if(n&&N)return N;if(!n&&E)return E;var r=document.createElement("div");Object.keys(j).forEach((function(e){r.style[e]=j[e]})),r.className=t+"-hide-scrollbar scroll-div-append-to-body",n?r.style.overflowY="scroll":r.style.overflowX="scroll",document.body.appendChild(r);var o=0;return n?(o=r.offsetWidth-r.clientWidth,N=o):(o=r.offsetHeight-r.clientHeight,E=o),document.body.removeChild(r),o},e.padEnd=function(e,t,n){return(""+e+h(t,n)).slice(0,t)},e.padStart=function(e,t,n){if(e.length>t)return e;var r=""+h(t,n)+e;return r.slice(r.length-t,r.length)},e.properties=y,e.pxToNumber=S,e.scrollIntoView=function(e){var t=e;t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded(!1):e.scrollIntoView&&e.scrollIntoView(!1)},e.shallowCopyArray=function(e){return e.slice()},e.shallowEqual=function(e,t){if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty.bind(t),i=0;i<n.length;i++){var u=n[i];if(!o(u))return!1;if(e[u]!==t[u])return!1}return!0},e.silentEvent=function(e){e.stopPropagation(),e.preventDefault()},e.sum=function(e,t){return void 0===t&&(t=0),e.reduce((function(e,t){return e+t}),t)},e.toArray=function(e){return null==e?[]:Array.isArray(e)?e:[e]},e.toBoolean=a,e.toCssPixel=c,e.toDecimal=function(e,t){return Math.round(e*Math.pow(10,t))/Math.pow(10,t)},e.toNumber=d,e.valueFunctionProp=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return"function"==typeof e?e.apply(void 0,l(t)):e},e.wrapIntoObservable=function(e){return o.isObservable(e)?e:g(e)?o.from(Promise.resolve(e)):o.of(e)},e.ɵ0=w,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-core-util.umd.min.js.map