UNPKG

ng-zorro-antd

Version:

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

76 lines (74 loc) 13.6 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=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. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)l.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 l}function u(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(l(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 l="$$__"+o;return Object.prototype.hasOwnProperty.call(n,l)&&r.warn('The prop "'+l+'" is already exist, it will be overrided by '+e+" decorator."),Object.defineProperty(n,l,{configurable:!0,writable:!0}),{get:function(){return i&&i.get?i.get.bind(this)():this[l]},set:function(e){i&&i.set&&i.set.bind(this)(t(e)),this[l]=t(e)}}}}function p(e){return e.type.startsWith("touch")} /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ 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} /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */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"} /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */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(){return s("InputNumber",c)} /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */,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= /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ 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 l=i.style,u=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,d="INPUT"===e.nodeName;l.whiteSpace="pre-wrap",d||(l.wordWrap="break-word"),l.position="absolute",r||(l.visibility="hidden"),m.forEach((function(e){d&&"lineHeight"===e?l.lineHeight=u.height:l[e]=u[e]})),b?e.scrollHeight>w(u.height)&&(l.overflowY="scroll"):l.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(u.borderTopWidth),left:a.offsetLeft+w(u.borderLeftWidth),height:w(u.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()})):[]} /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */,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 l,u=window.getComputedStyle(e),d=(l=u,Array.prototype.slice.apply(l).map((function(e){return e+": "+l.getPropertyValue(e)+";"})).join("")),a=S(u.lineHeight)*(t+1)+S(u.paddingTop)+S(u.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 c,f=(c=[],n.forEach((function(e){var t=c[c.length-1];t&&3===e.nodeType&&3===t.nodeType?t.data+=e.data:c.push(e)})),c),s=document.createElement("div"),p=document.createElement("span"),h=document.createTextNode(i),g=document.createElement("span");function y(){return C.offsetHeight<a}if(Object.assign(s.style,T),Object.assign(p.style,T),Object.assign(g.style,T),f.forEach((function(e){p.appendChild(e)})),p.appendChild(h),r.forEach((function(e){g.appendChild(e.cloneNode(!0))})),s.appendChild(p),s.appendChild(g),C.appendChild(s),y()){var m=C.innerHTML;return C.removeChild(s),{contentNodes:n,text:m,ellipsis:!1}}var v=Array.prototype.slice.apply(C.childNodes[0].childNodes[0].cloneNode(!0).childNodes).filter((function(e){return 8!==e.nodeType})),b=Array.prototype.slice.apply(C.childNodes[0].childNodes[1].cloneNode(!0).childNodes);C.removeChild(s),C.innerHTML="";var w=document.createElement("span");C.appendChild(w);var x=document.createTextNode(o+i);function N(e,t){var n,r=e.nodeType;if(1===r)return y()?{finished:!1,node:f[t]}:(w.removeChild(e),{finished:!0,node:null});if(3===r){var o=e.textContent||"",i=document.createTextNode(o);return n=i,w.insertBefore(n,x),function e(t,n,r,o,i){void 0===r&&(r=0),void 0===o&&(o=n.length),void 0===i&&(i=0);var l=Math.floor((r+o)/2);if(t.textContent=n.slice(0,l),r>=o-1)for(var u=o;u>=r;u-=1){var d=n.slice(0,u);if(t.textContent=d,y()||!d)return u===n.length?{finished:!1,node:document.createTextNode(n)}:{finished:!0,node:document.createTextNode(d)}}return y()?e(t,n,l,o,l):e(t,n,r,l,i)}(i,o)}return{finished:!1,node:null}}w.appendChild(x),b.forEach((function(e){C.appendChild(e)}));var E=[];v.some((function(e,t){var n=N(e,t),r=n.finished,o=n.node;return o&&E.push(o),r}));for(var j={contentNodes:E,text:C.innerHTML,ellipsis:!0};C.firstChild;)C.removeChild(C.firstChild);return j} /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE * @type {?} */,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 l=n[i];if(!o(l))return!1;if(e[l]!==t[l])return!1}return!0},e.silentEvent=function(e){e.stopPropagation(),e.preventDefault()},e.toArray= /** * @license * Copyright Alibaba.com All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ 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,u(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