ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 11.6 kB
JavaScript
!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=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";
/*! *****************************************************************************
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.
***************************************************************************** */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}function d(e){return e&&(1===e.nodeType&&0!==e.outerHTML.toString().trim().length||3===e.nodeType&&0!==e.textContent.toString().trim().length)?e:null}function a(e){return n.coerceBooleanProperty(e)}function c(e,t){return void 0===t&&(t=0),n._isNumberValue(e)?Number(e):t}function f(e){return n.coerceCssPixelValue(e)}function s(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 p(e){return e.type.startsWith("touch")}function h(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 g(e,t){return Array(e).fill(t).join("")}function y(e){return!!e&&"function"==typeof e.then&&"function"==typeof e.catch}var m=["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"],v="undefined"!=typeof window,b=v&&null!=window.mozInnerScreenX,w=function(e){return parseInt(e,10)};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 s("InputBoolean",a)},e.InputCssPixel=function(){return s("InputCssPixel",f)},e.InputNumber=function(e){return s("InputNumber",(function(t){return c(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.filterNotEmptyNode=d,e.getCaretCoordinates=function(e,t,n){if(!v)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,d="INPUT"===e.nodeName;u.whiteSpace="pre-wrap",d||(u.wordWrap="break-word"),u.position="absolute",r||(u.visibility="hidden"),m.forEach((function(e){d&&"lineHeight"===e?u.lineHeight=l.height:u[e]=l[e]})),b?e.scrollHeight>w(l.height)&&(u.overflowY="scroll"):u.overflow="hidden",i.textContent=e.value.substring(0,t),d&&(i.textContent=i.textContent.replace(/\s/g," "));var a=document.createElement("span");a.textContent=e.value.substring(t)||".",i.appendChild(a);var c={top:a.offsetTop+w(l.borderTopWidth),left:a.offsetLeft+w(l.borderLeftWidth),height:w(l.lineHeight)};return r?(a.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 p(e)?e.touches[0]||e.changedTouches[0]:e},e.getMentions=function(e,t){if(void 0===t&&(t="@"),"string"!=typeof e)return[];var n=h(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=h,e.getRepeatedElement=g,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.isComponent=function(e){return e instanceof t.Type},e.isEmpty=function(e){for(var t=e.childNodes,n=0;n<t.length;n++)if(d(t.item(n)))return!1;return!0},e.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},e.isNil=function(e){return null==e},e.isNonEmptyString=function(e){return"string"==typeof e&&""!==e},e.isNotNil=function(e){return null!=e},e.isPromise=y,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},e.isTouchEvent=p,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),d=(u=l,Array.prototype.slice.apply(u).map((function(e){return e+": "+u.getPropertyValue(e)+";"})).join("")),a=S(l.lineHeight),c=Math.round(a*(t+1)+S(l.paddingTop)+S(l.paddingBottom));C.setAttribute("style",d),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){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),function e(t,n,r,o,i){void 0===r&&(r=0),void 0===o&&(o=n.length),void 0===i&&(i=0);var u=Math.floor((r+o)/2);if(t.textContent=n.slice(0,u),r>=o-1)for(var l=o;l>=r;l-=1){var d=n.slice(0,l);if(t.textContent=d,m()||!d)return l===n.length?{finished:!1,node:document.createTextNode(n)}:{finished:!0,node:document.createTextNode(d)}}return m()?e(t,n,u,o,u):e(t,n,r,u,i)}(i,o)}return{finished:!1,node:null}}x.appendChild(N),w.forEach((function(e){C.appendChild(e)}));var j=[];b.some((function(e,t){var n=E(e,t),r=n.finished,o=n.node;return o&&j.push(o),r}));for(var I={contentNodes:j,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+g(t,n)).slice(0,t)},e.padStart=function(e,t,n){if(e.length>t)return e;var r=""+g(t,n)+e;return r.slice(r.length-t,r.length)},e.properties=m,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.toArray=function(e){return null==e?[]:Array.isArray(e)?e:[e]},e.toBoolean=a,e.toCssPixel=f,e.toNumber=c,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:y(e)?o.from(Promise.resolve(e)):o.of(e)},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-core-util.umd.min.js.map