UNPKG

@lunaeme/circe-core

Version:
16 lines (14 loc) 16 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("lodash"),require("uuid"),require("@angular/platform-browser"),require("ngx-order-pipe"),require("rxjs")):"function"==typeof define&&define.amd?define("@lunaeme/circe-core",["exports","@angular/core","@angular/common","lodash","uuid","@angular/platform-browser","ngx-order-pipe","rxjs"],t):t(((e=e||self).lunaeme=e.lunaeme||{},e.lunaeme["circe-core"]={}),e.ng.core,e.ng.common,e.lodash,e.uuid,e.ng.platformBrowser,e["ngx-order-pipe"],e.rxjs)}(this,(function(e,t,o,n,r,i,a,s){"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. ***************************************************************************** */var l=function(){return(l=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function c(e,t,o,n){var r,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(i<3?r(a):i>3?r(t,o,a):r(t,o))||a);return i>3&&a&&Object.defineProperty(t,o,a),a}Object.create;function u(e){var t="function"==typeof Symbol&&Symbol.iterator,o=t&&e[t],n=0;if(o)return o.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var n,r,i=o.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return a}function f(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(d(arguments[t]));return e}Object.create;var p={start:"start",camel:"camel",kebab:"kebab"},h=function(){function e(){this.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}return e.getValueFromMultiLevelObject=function(e,t,o){var n=o||".";if(void 0!==e[t])return e[t];try{return t.split(n).reduce((function(e,t){return e[t]}),e)}catch(e){if(e instanceof TypeError)return;throw e}},e.setValueInMultiLevelObject=function(e,t,o,n){var r=n||".";return t.split(r).reduce((function(e,t){return e&&"object"==typeof e[t]?e[t]:e&&t in e?(e[t]=o,e):void 0}),e)},e.waitFor=function(e){var t=Date.now(),o=!1;do{o=Date.now()-t>=e}while(!o)},e.repeatedValuesInArray=function(e,t){return void 0===t||t?Array.from(new Set(e)):e.filter((function(t,o){return e.indexOf(t)!==o}))},e.checkLastChar=function(e,t){return e&&e[e.length-1]!==t?""+e+t:e},e.hexToRgb=function(e){return e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,o,n){return"#"+t+t+o+o+n+n})).substring(1).match(/.{2}/g).map((function(e){return parseInt(e,16)}))},e.rgbToHex=function(e,t,o){return[e,t,o].map((function(e){var t=e.toString(16);return 1===t.length?"0"+t:t})).join("")},e.generateUuid=function(){return r.v4()},e.checkArray=function(e,t){void 0===t&&(t=!0);var o=!!e&&Array.isArray(e);return t?o&&!!e.length:o},e.getValueFromDotedKey=function(e,t,o){var n=o||".";if(void 0!==e[t])return e[t];try{return t.split(n).reduce((function(e,t){return e[t]}),e)}catch(e){if(e instanceof TypeError)return;throw e}},e.formatString=function(e){return isNaN(Number(e))?n.startCase(e):e},e.prototype.identifier=function(e,t){var o="string"==typeof t?t:e;return["code","id","param","key"].forEach((function(e){t.hasOwnProperty(e)&&(o=t[e])})),o},e.prototype.stringTransform=function(e,t){var o=t||p.start,r=e;if(isNaN(Number(e)))switch(o){case p.start:r=n.startCase(e);break;case p.camel:r=n.camelCase(e);break;case p.kebab:r=n.kebabCase(e)}return r},e=c([t.Injectable()],e)}(),m={class:"class",tag:"tag",id:"id"},g={name:"name",type:"type",query:"query",shadowElement:"shadowElement"},y={HORIZONTAL:"horizontal",VERTICAL:"vertical"},b=function(){function e(){this._defaultBoxModelType=y.VERTICAL,this._defaultElementHashType=m.class,this._defaultComputedStylePropertyProcessed=!1,this._allowCssUnits=["px","%"],this._additionHorizontalInsideClasses=["padding-left","padding-right","border-left-width","border-right-width"],this._additionHorizontalOutsideClasses=["margin-left","margin-right"],this._additionVerticalInsideClasses=["padding-top","padding-bottom","border-top-width","border-bottom-width"],this._additionVerticalOutsideClasses=["margin-top","margin-bottom"],this._fontSizeRule={applyOnElements:["i"],boxModelType:y.HORIZONTAL}}var o;return o=e,e._isElementHash=function(e){return!("object"!=typeof e||!(g.type in e)||!(g.name in e)||2!==Object.keys(e).length&&3!==Object.keys(e).length)},e._isElementQuery=function(e){return!("object"!=typeof e||!(g.query in e)||1!==Object.keys(e).length&&2!==Object.keys(e).length)},e._isNativeDomElement=function(e){return!!e&&["getBoundingClientRect","getElementsByClassName","getElementsByTagName","querySelector"].map((function(t){return t in e})).every((function(e){return!!e}))},e.prototype._convertToElementIdArray=function(e){var t,o,n=[],r=Array.isArray(e)?e:[e];try{for(var i=u(r),a=i.next();!a.done;a=i.next()){var s=a.value;n.push(this.getElement(s))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(t)throw t.error}}return n},e.prototype._getElementAdditions=function(e,t){var o=this,n=t||this._defaultBoxModelType,r=window.getComputedStyle(e),i={boxModelAdditionInside:0,boxModelAdditionOutside:0},a=[],s=[];return n===y.HORIZONTAL?(this._additionHorizontalInsideClasses.forEach((function(e){a.push(r.getPropertyValue(e))})),this._additionHorizontalOutsideClasses.forEach((function(e){s.push(r.getPropertyValue(e))}))):(this._additionVerticalInsideClasses.forEach((function(e){a.push(r.getPropertyValue(e))})),this._additionVerticalOutsideClasses.forEach((function(e){s.push(r.getPropertyValue(e))}))),a.forEach((function(e){"0px"!==e&&(i.boxModelAdditionInside+=o.readCssUnits(e).value)})),s.forEach((function(e){"0px"!==e&&(i.boxModelAdditionOutside+=o.readCssUnits(e).value)})),i},e.prototype.getComputedStyleProperty=function(e,t,o){var n=o||this._defaultComputedStylePropertyProcessed,r=window.getComputedStyle(e).getPropertyValue(t);return r&&n?this.readCssUnits(r):r},e.prototype.processElementForSpecialRules=function(e){if(this._fontSizeRule.applyOnElements.includes(e.tagName.toLowerCase())){var t=this.getBoxModel(e,y.HORIZONTAL),o=this.getComputedStyleProperty(e,"font-size",!0);if(t.boxModelExtractedInside!==o.value)return e.style.width=o.value+"px",e}return e},e.prototype.readCssUnits=function(e){var t={value:0,unit:""};return this._allowCssUnits.forEach((function(o){if(e.includes(o)){t.unit=o;var n=e.split(o).filter((function(e){return!!e}));1===n.length&&(t.value=Number(n[0]))}else;})),t.value&&t.unit?t:null},e.prototype.processSizeString=function(e){var t={with:null,height:null};if(e){var o=e.split(" ");if(1===o.length){var n=this.readCssUnits(o[0]);t.with=n,t.height=n}else 2===o.length&&(t.height=this.readCssUnits(o[0]),t.with=this.readCssUnits(o[1]))}return t.with&&t.height?t:null},e.prototype.getElement=function(e){var t=e,n=e,r=document;if("string"==typeof e?n={type:this._defaultElementHashType,name:e}:g.shadowElement in n&&(r=this.getElement(n.shadowElement)),!o._isNativeDomElement(n))if(o._isElementHash(n))switch(n.type){case m.class:t=r.getElementsByClassName(n.name).item(0);break;case m.tag:t=r.getElementsByTagName(n.name).item(0);break;case m.id:t=document.getElementById(n.name)}else o._isElementQuery(n)&&(t=r.querySelector(n.query));if(!o._isNativeDomElement(t))throw new Error("BoxModel.getElement: Unrecognizable element.");return t},e.prototype.getBoxModel=function(e,t){var o=this,n={type:t||this._defaultBoxModelType,boxModel:0,boxModelAdditions:0,boxModelAggregated:0,boxModelExtracted:0,boxModelAdditionsInside:0,boxModelAdditionsOutside:0,boxModelAggregatedInside:0,boxModelAggregatedOutside:0,boxModelExtractedInside:0,boxModelExtractedOutside:0};return this._convertToElementIdArray(e).forEach((function(e){var t=e.getBoundingClientRect(),r=o._getElementAdditions(e,n.type);n.boxModel+=n.type===y.HORIZONTAL?t.width:t.height,n.boxModelAdditions+=r.boxModelAdditionInside+r.boxModelAdditionOutside,n.boxModelAdditionsInside+=r.boxModelAdditionInside,n.boxModelAdditionsOutside+=r.boxModelAdditionOutside})),n.boxModelAggregated=n.boxModel+n.boxModelAdditions,n.boxModelExtracted=n.boxModel-n.boxModelAdditions,n.boxModelAggregatedInside=n.boxModel+n.boxModelAdditionsInside,n.boxModelAggregatedOutside=n.boxModel+n.boxModelAdditionsOutside,n.boxModelExtractedInside=n.boxModel-n.boxModelAdditionsInside,n.boxModelExtractedOutside=n.boxModel-n.boxModelAdditionsOutside,n},e=o=c([t.Injectable()],e)}(),v=function(){function e(e){this._bm=e,this._defaultEventImmediatePropagation=!0,this._defaultSelectDomElement={type:m.tag,name:"main"}}return e.prototype.preventNeededEvent=function(e,t){t||this._defaultEventImmediatePropagation?e.stopImmediatePropagation():e.stopPropagation()},e.prototype.preventNoNeededEvent=function(e,t){var o=t||this._defaultEventImmediatePropagation;this.preventNeededEvent(e,o),e.cancelable&&e.preventDefault()},e.prototype.scrollTop=function(e){var t=e||this._defaultSelectDomElement,o=this._bm.getElement(t);o&&o.scroll(0,0)},e.prototype.preventMouseEvent=function(e,t){t||this._defaultEventImmediatePropagation?e.stopImmediatePropagation():e.stopPropagation(),e.preventDefault()},e.prototype.preventKeyEvent=function(e,t){t||this._defaultEventImmediatePropagation?e.stopImmediatePropagation():e.stopPropagation()},e.ctorParameters=function(){return[{type:b}]},e=c([t.Injectable()],e)}(),M=function(){function e(){this._customMessages={repeated:"There can not be repeated values"}}return e.formArrayRepeatedValues=function(e){var t=null,o=h.repeatedValuesInArray(e.value);return o&&Array.isArray(o)&&o.length&&(t={repeated:{repeatedValues:o.join(", ")}}),t},e.prototype.getCustomMessages=function(e){var t=this,o={};return(e&&"string"==typeof e?[e]:e).forEach((function(e){o[e]=t._customMessages[e]})),o},e=c([t.Injectable()],e)}(),_=function(){function e(e){this._sanitizer=e}return e.prototype.transform=function(e){return this._sanitizer.bypassSecurityTrustHtml(e)},e.ctorParameters=function(){return[{type:i.DomSanitizer}]},e=c([t.Pipe({name:"sanitizeHtml"})],e)}(),x=function(){function e(){}return e=c([t.NgModule({exports:[_],declarations:[_],imports:[o.CommonModule]})],e)}(),S=function(){function e(e){this._o=e}return e.prototype.transform=function(e,t,o,n,r){return void 0===o||!!o?this._o.transform(e,t,!!n,!!r):e},e.ctorParameters=function(){return[{type:a.OrderPipe}]},e=c([t.Pipe({name:"orderCondition"})],e)}(),w=function(){function e(){}return e=c([t.NgModule({exports:[S],declarations:[S],imports:[o.CommonModule,a.OrderModule],providers:[S]})],e)}(),E=function(){function e(){}var n;return n=e,e.forChild=function(){return{ngModule:n,providers:[b,v,M,h]}},e=n=c([t.NgModule({exports:[S,_],imports:[o.CommonModule,w,x]})],e)}(),C=function(){function e(){}var n;return n=e,e.forChild=function(){return{ngModule:n,providers:[b]}},e=n=c([t.NgModule({imports:[o.CommonModule]})],e)}(),A=function(){function e(){}var n;return n=e,e.forChild=function(){return{ngModule:n,providers:[M]}},e=n=c([t.NgModule({imports:[o.CommonModule]})],e)}(),O=function(){function e(){}var n;return n=e,e.forChild=function(){return{ngModule:n,providers:[v]}},e=n=c([t.NgModule({imports:[o.CommonModule,C.forChild()]})],e)}(),I=function(){function e(){}var n;return n=e,e.forChild=function(){return{ngModule:n,providers:[h]}},e=n=c([t.NgModule({imports:[o.CommonModule]})],e)}(),T={info:"info",success:"success",warning:"warning",critical:"critical"},P=function(){},k=function(){},j={timeShowing:400,timeToStop:400,callbackShow:P,callbackStop:k},N=function(){function e(e){void 0===e&&(e=j),this.trigger$=new s.Subject,this.show$=new s.Subject,this._startArguments=[],this._stopArguments=[],this._config={},e&&(this._config.timeShowing=e.timeShowing?e.timeShowing:j.timeShowing,this._config.timeToStop=e.timeToStop?e.timeToStop:j.timeToStop,this._config.callbackShow=e.callbackShow?e.callbackShow:j.callbackShow,this._config.callbackStop=e.callbackStop,this._config.callbackStop||(this._config.callbackStop=e.callbackShow?e.callbackShow:j.callbackStop))}return Object.defineProperty(e.prototype,"_trigger",{set:function(e){var t=this;this.trigger$.next(e),e&&setTimeout((function(){var e;(e=t._config).callbackShow.apply(e,f(t._startArguments)),t._show=!0,t._timeoutShow=setTimeout((function(){t._show=!1}),t._config.timeShowing)}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_show",{set:function(e){var t=this;this.show$.next(e),e||setTimeout((function(){var e;(e=t._config).callbackStop.apply(e,f(t._stopArguments)),t._trigger=!1}),this._config.timeToStop)},enumerable:!0,configurable:!0}),e.prototype._setStopArguments=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._stopArguments=e},e.prototype.setConfig=function(e){e.timeShowing&&(this._config.timeShowing=e.timeShowing),e.timeToStop&&(this._config.timeToStop=e.timeToStop),e.callbackShow&&(this._config.callbackShow=e.callbackShow),e.callbackStop&&(this._config.callbackStop=e.callbackStop)},e.prototype.start=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return clearTimeout(this._timeoutShow),this._startArguments=e,this._trigger=!0,this._setStopArguments.bind(this)},e.prototype.stop=function(){clearTimeout(this._timeoutShow)},e.prototype.remove=function(){this.stop(),this._show=!1},e}(),B=function(){function e(e){void 0===e&&(e="mda-icon"),this.classBase=e,this.defaultKeys=l(l({},T),{close:"close"}),this._defaults={info:"icon-info",success:"icon-circle-check",warning:"icon-alert",critical:"icon-shield",close:"icon-cross"},this.ccIconSetFields={iconLeft:"iconLeft",iconRight:"iconRight"},this.ccIconFields={classes:"classes",color:"color"}}return e.prototype._applyClassBase=function(e){return this.classBase?this.classBase+" "+e:e},e.prototype.get=function(e){var t=this._defaults[e];return t?this._applyClassBase(t):""},e.prototype.getCustom=function(e){return e?this._applyClassBase(e):""},e}();e.AsynchronousPairVariables=N,e.BoxModelModule=C,e.BoxModelService=b,e.CoreModule=E,e.CustomValidationModule=A,e.CustomValidationService=M,e.EventsModule=O,e.EventsService=v,e.Icons=B,e.OrderConditionModule=w,e.OrderConditionPipe=S,e.SanitizeHtmlModule=x,e.SanitizeHtmlPipe=_,e.ToolModule=I,e.ToolService=h,e.boxModelTypeConstants=y,e.ccElementFields=g,e.ccHashTypes=m,e.ccOptionFields={value:"value",label:"label",color:"color",icon:"icon"},e.ccPositions={topLeft:"top left",topCenter:"top center",topRight:"top right",centerLeft:"center left",centerCenter:"center center",centerRight:"center right",bottomLeft:"bottom left",bottomCenter:"bottom center",bottomRight:"bottom right"},e.ccPositionsHorizontal={left:"left",center:"center",right:"right"},e.ccPositionsVertical={top:"top",center:"center",bottom:"bottom"},e.ccStatuses=T,e.ccStringTransform=p,e.ɵ0=P,e.ɵ1=k,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=lunaeme-circe-core.umd.min.js.map