UNPKG

@lunaeme/circe-core

Version:
1,152 lines (1,100 loc) 48.1 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('lodash'), require('uuid'), require('@angular/platform-browser'), require('ngx-order-pipe'), require('rxjs')) : typeof define === 'function' && define.amd ? define('@lunaeme/circe-core', ['exports', '@angular/core', '@angular/common', 'lodash', 'uuid', '@angular/platform-browser', 'ngx-order-pipe', 'rxjs'], factory) : (global = global || self, factory((global.lunaeme = global.lunaeme || {}, global.lunaeme['circe-core'] = {}), global.ng.core, global.ng.common, global.lodash, global.uuid, global.ng.platformBrowser, global['ngx-order-pipe'], global.rxjs)); }(this, (function (exports, core, common, lodash, uuid, platformBrowser, ngxOrderPipe, rxjs) { '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. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); function __exportStar(m, exports) { for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __setModuleDefault = Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } // ############################################# // ###### OPTION CONSTANTS DEFINITION API ###### // ############################################# var ccStringTransform = { start: 'start', camel: 'camel', kebab: 'kebab' }; var ToolService = /** @class */ (function () { function ToolService() { this.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; } ToolService.getValueFromMultiLevelObject = function (object, key, separator) { var _separator = separator || '.'; if (object[key] !== undefined) { return object[key]; } try { return key.split(_separator).reduce(function (obj, index) { return obj[index]; }, object); } catch (e) { if (e instanceof TypeError) { return undefined; } else { throw e; } } }; ToolService.setValueInMultiLevelObject = function (object, key, value, separator) { var _separator = separator || '.'; return key.split(_separator).reduce(function (o, i) { if (o && typeof o[i] === 'object') { return o[i]; } if (o && i in o) { o[i] = value; return o; } }, object); }; ToolService.waitFor = function (milliseconds) { var _now = Date.now(); var _timeOut = false; do { _timeOut = (Date.now() - _now >= milliseconds); } while (!_timeOut); }; /** * repeatedValuesInArray * @description * This method returns an array of uniques values if parameter "unique" is true; or returns * an array of ONLY repeated values (unique values are discarded) if unique is false. * Default value por parameter unique is true. */ ToolService.repeatedValuesInArray = function (values, unique) { var _unique = (unique === undefined) ? true : unique; return (_unique) ? Array.from(new Set(values)) : values.filter(function (e, i) { return values.indexOf(e) !== i; }); }; ToolService.checkLastChar = function (text, char) { if (text && text[text.length - 1] !== char) { return "" + text + char; } return text; }; ToolService.hexToRgb = function (hex) { var _output = hex .replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) { return '#' + r + r + g + g + b + b; }) .substring(1) .match(/.{2}/g); return _output.map(function (e) { return parseInt(e, 16); }); }; ToolService.rgbToHex = function (r, g, b) { var _output = [r, g, b].map(function (e) { var _hex = e.toString(16); return (_hex.length === 1) ? "0" + _hex : _hex; }); return _output.join(''); }; /** * generateUuid * @description * Generates a new uuid using uuid dependency. */ ToolService.generateUuid = function () { return uuid.v4(); }; /** * checkArray * @description * Returns true if parameter given "array" is an array, otherwise returns false; * If optional parameter "filled" is given, then this method checks the array is not empty. * Default value for "filled" is true. */ ToolService.checkArray = function (array, filled) { if (filled === void 0) { filled = true; } var _checkStructure = (!!array && Array.isArray(array)); if (filled) { return (_checkStructure && !!array.length); } return _checkStructure; }; /** * @deprecated */ ToolService.getValueFromDotedKey = function (object, dotedKey, separator) { var _separator = separator || '.'; if (object[dotedKey] !== undefined) { return object[dotedKey]; } try { return dotedKey.split(_separator).reduce(function (obj, index) { return obj[index]; }, object); } catch (e) { if (e instanceof TypeError) { return undefined; } else { throw e; } } }; /** * @deprecated */ ToolService.formatString = function (text) { if (isNaN(Number(text))) { return lodash.startCase(text); } else { return text; } }; ToolService.prototype.identifier = function (index, item) { var _output = (typeof item === 'string') ? item : index; ['code', 'id', 'param', 'key'].forEach(function (e) { if (item.hasOwnProperty(e)) { _output = item[e]; return; } }); return _output; }; ToolService.prototype.stringTransform = function (text, transformType) { var _transformType = transformType || ccStringTransform.start; var _output = text; if (isNaN(Number(text))) { switch (_transformType) { case ccStringTransform.start: _output = lodash.startCase(text); break; case ccStringTransform.camel: _output = lodash.camelCase(text); break; case ccStringTransform.kebab: _output = lodash.kebabCase(text); break; } } return _output; }; ToolService = __decorate([ core.Injectable() ], ToolService); return ToolService; }()); // ############################################### // ###### POSITION CONSTANTS DEFINITION API ###### // ############################################### var ccHashTypes = { class: 'class', tag: 'tag', id: 'id' }; var ccElementFields = { name: 'name', type: 'type', query: 'query', shadowElement: 'shadowElement' }; var boxModelTypeConstants = { HORIZONTAL: 'horizontal', VERTICAL: 'vertical' }; var BoxModelService = /** @class */ (function () { function BoxModelService() { this._defaultBoxModelType = boxModelTypeConstants.VERTICAL; this._defaultElementHashType = ccHashTypes.class; this._defaultComputedStylePropertyProcessed = false; 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: boxModelTypeConstants.HORIZONTAL }; } BoxModelService_1 = BoxModelService; /** * _isElementHash * * @description * Checks if element given param is ElementHash type. */ BoxModelService._isElementHash = function (element) { return !!(typeof element === 'object' && ccElementFields.type in element && ccElementFields.name in element && (Object.keys(element).length === 2 || Object.keys(element).length === 3)); }; /** * _isElementQuery * * @description * Checks if element given param is ElementQuery type. */ BoxModelService._isElementQuery = function (element) { return !!(typeof element === 'object' && ccElementFields.query in element && (Object.keys(element).length === 1 || Object.keys(element).length === 2)); }; /** * _isNativeDomElement * * @description * Checks if element given param is a native DOM element. */ BoxModelService._isNativeDomElement = function (param) { var _paramsToCheck = [ 'getBoundingClientRect', 'getElementsByClassName', 'getElementsByTagName', 'querySelector' ]; return (!!param) ? (_paramsToCheck.map(function (e) { return e in param; })).every(function (el) { return !!el; }) : false; }; /** * _convertToElementIdArray * * @description * Transform elementId type to array of Dom elements. */ BoxModelService.prototype._convertToElementIdArray = function (elementId) { var e_1, _a; var _auxArgument = []; var _elementId = (Array.isArray(elementId)) ? elementId : [elementId]; try { for (var _elementId_1 = __values(_elementId), _elementId_1_1 = _elementId_1.next(); !_elementId_1_1.done; _elementId_1_1 = _elementId_1.next()) { var element = _elementId_1_1.value; _auxArgument.push(this.getElement(element)); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_elementId_1_1 && !_elementId_1_1.done && (_a = _elementId_1.return)) _a.call(_elementId_1); } finally { if (e_1) throw e_1.error; } } return _auxArgument; }; BoxModelService.prototype._getElementAdditions = function (element, boxModelType) { var _this = this; var _type = boxModelType || this._defaultBoxModelType; var _elementStyle = window.getComputedStyle(element); var _output = { boxModelAdditionInside: 0, boxModelAdditionOutside: 0 }; var _auxOutputInside = []; var _auxOutputOutside = []; if (_type === boxModelTypeConstants.HORIZONTAL) { this._additionHorizontalInsideClasses.forEach(function (e) { _auxOutputInside.push(_elementStyle.getPropertyValue(e)); }); this._additionHorizontalOutsideClasses.forEach(function (e) { _auxOutputOutside.push(_elementStyle.getPropertyValue(e)); }); } else { this._additionVerticalInsideClasses.forEach(function (e) { _auxOutputInside.push(_elementStyle.getPropertyValue(e)); }); this._additionVerticalOutsideClasses.forEach(function (e) { _auxOutputOutside.push(_elementStyle.getPropertyValue(e)); }); } _auxOutputInside.forEach(function (el) { if (el !== '0px') { _output.boxModelAdditionInside += _this.readCssUnits(el).value; } }); _auxOutputOutside.forEach(function (el) { if (el !== '0px') { _output.boxModelAdditionOutside += _this.readCssUnits(el).value; } }); return _output; }; BoxModelService.prototype.getComputedStyleProperty = function (element, property, processed) { var _processed = processed || this._defaultComputedStylePropertyProcessed; var _elementComputedStyles = window.getComputedStyle(element); var _output = _elementComputedStyles.getPropertyValue(property); if (_output && _processed) { return this.readCssUnits(_output); } return _output; }; BoxModelService.prototype.processElementForSpecialRules = function (element) { if (this._fontSizeRule.applyOnElements.includes(element.tagName.toLowerCase())) { var _elementBoxModel = this.getBoxModel(element, boxModelTypeConstants.HORIZONTAL); var _elementFontSize = this.getComputedStyleProperty(element, 'font-size', true); if (_elementBoxModel.boxModelExtractedInside !== _elementFontSize.value) { element.style.width = _elementFontSize.value + "px"; return element; } } return element; }; BoxModelService.prototype.readCssUnits = function (expression) { var _output = { value: 0, unit: '' }; this._allowCssUnits.forEach(function (e) { if (expression.includes(e)) { _output.unit = e; var _aux = expression.split(e).filter(function (el) { return !!el; }); if (_aux.length === 1) { _output.value = Number(_aux[0]); } return; } }); return (_output.value && _output.unit) ? _output : null; }; BoxModelService.prototype.processSizeString = function (sizeString) { var _output = { with: null, height: null }; if (sizeString) { var _auxSize = sizeString.split(' '); if (_auxSize.length === 1) { var _cssUnit = this.readCssUnits(_auxSize[0]); _output.with = _cssUnit; _output.height = _cssUnit; } else if (_auxSize.length === 2) { _output.height = this.readCssUnits(_auxSize[0]); _output.with = this.readCssUnits(_auxSize[1]); } } return (_output.with && _output.height) ? _output : null; }; /** * getElement * * @description * Returns an element DOM native object from different types of given params. */ BoxModelService.prototype.getElement = function (element) { var _output = element; var _element = element; var _shadowElement = document; if (typeof element === 'string') { _element = { type: this._defaultElementHashType, name: element }; } else { if (ccElementFields.shadowElement in _element) { _shadowElement = this.getElement(_element.shadowElement); } } if (!BoxModelService_1._isNativeDomElement(_element)) { if (BoxModelService_1._isElementHash(_element)) { switch (_element.type) { case ccHashTypes.class: _output = _shadowElement.getElementsByClassName(_element.name).item(0); break; case ccHashTypes.tag: _output = _shadowElement.getElementsByTagName(_element.name).item(0); break; case ccHashTypes.id: _output = document.getElementById(_element.name); break; } } else if (BoxModelService_1._isElementQuery(_element)) { _output = _shadowElement.querySelector(_element.query); } } if (!BoxModelService_1._isNativeDomElement(_output)) { throw new Error('BoxModel.getElement: Unrecognizable element.'); } return _output; }; BoxModelService.prototype.getBoxModel = function (elementId, boxModelType) { var _this = this; var _output = { type: boxModelType || this._defaultBoxModelType, boxModel: 0, boxModelAdditions: 0, boxModelAggregated: 0, boxModelExtracted: 0, boxModelAdditionsInside: 0, boxModelAdditionsOutside: 0, boxModelAggregatedInside: 0, boxModelAggregatedOutside: 0, boxModelExtractedInside: 0, boxModelExtractedOutside: 0 }; var _elementId = this._convertToElementIdArray(elementId); _elementId.forEach(function (e) { var _elementRect = e.getBoundingClientRect(); var _additions = _this._getElementAdditions(e, _output.type); _output.boxModel += (_output.type === boxModelTypeConstants.HORIZONTAL) ? _elementRect.width : _elementRect.height; _output.boxModelAdditions += _additions.boxModelAdditionInside + _additions.boxModelAdditionOutside; _output.boxModelAdditionsInside += _additions.boxModelAdditionInside; _output.boxModelAdditionsOutside += _additions.boxModelAdditionOutside; }); _output.boxModelAggregated = _output.boxModel + _output.boxModelAdditions; _output.boxModelExtracted = _output.boxModel - _output.boxModelAdditions; _output.boxModelAggregatedInside = _output.boxModel + _output.boxModelAdditionsInside; _output.boxModelAggregatedOutside = _output.boxModel + _output.boxModelAdditionsOutside; _output.boxModelExtractedInside = _output.boxModel - _output.boxModelAdditionsInside; _output.boxModelExtractedOutside = _output.boxModel - _output.boxModelAdditionsOutside; return _output; }; var BoxModelService_1; BoxModelService = BoxModelService_1 = __decorate([ core.Injectable() ], BoxModelService); return BoxModelService; }()); var EventsService = /** @class */ (function () { function EventsService(_bm) { this._bm = _bm; this._defaultEventImmediatePropagation = true; this._defaultSelectDomElement = { type: ccHashTypes.tag, name: 'main' }; } EventsService.prototype.preventNeededEvent = function (event, immediatePropagation) { var _immediate = immediatePropagation || this._defaultEventImmediatePropagation; if (_immediate) { event.stopImmediatePropagation(); } else { event.stopPropagation(); } }; EventsService.prototype.preventNoNeededEvent = function (event, immediatePropagation) { var _immediate = immediatePropagation || this._defaultEventImmediatePropagation; this.preventNeededEvent(event, _immediate); if (event.cancelable) { event.preventDefault(); } }; EventsService.prototype.scrollTop = function (element) { var _element = element || this._defaultSelectDomElement; var _target = this._bm.getElement(_element); if (_target) { _target.scroll(0, 0); } }; /** * @deprecated */ EventsService.prototype.preventMouseEvent = function (event, immediatePropagation) { var _immediate = immediatePropagation || this._defaultEventImmediatePropagation; if (_immediate) { event.stopImmediatePropagation(); } else { event.stopPropagation(); } event.preventDefault(); }; /** * @deprecated */ EventsService.prototype.preventKeyEvent = function (event, immediatePropagation) { var _immediate = immediatePropagation || this._defaultEventImmediatePropagation; if (_immediate) { event.stopImmediatePropagation(); } else { event.stopPropagation(); } }; EventsService.ctorParameters = function () { return [ { type: BoxModelService } ]; }; EventsService = __decorate([ core.Injectable() ], EventsService); return EventsService; }()); var CustomValidationService = /** @class */ (function () { function CustomValidationService() { this._customMessages = { repeated: 'There can not be repeated values' }; } CustomValidationService.formArrayRepeatedValues = function (control) { var _output = null; var _repeatedValues = ToolService.repeatedValuesInArray(control.value); if (_repeatedValues && Array.isArray(_repeatedValues) && _repeatedValues.length) { _output = { repeated: { repeatedValues: _repeatedValues.join(', ') } }; } return _output; }; CustomValidationService.prototype.getCustomMessages = function (keys) { var _this = this; var _keys = (keys && typeof keys === 'string') ? [keys] : keys; var _output = {}; _keys.forEach(function (e) { _output[e] = _this._customMessages[e]; }); return _output; }; CustomValidationService = __decorate([ core.Injectable() ], CustomValidationService); return CustomValidationService; }()); var SanitizeHtmlPipe = /** @class */ (function () { function SanitizeHtmlPipe(_sanitizer) { this._sanitizer = _sanitizer; } SanitizeHtmlPipe.prototype.transform = function (value) { return this._sanitizer.bypassSecurityTrustHtml(value); }; SanitizeHtmlPipe.ctorParameters = function () { return [ { type: platformBrowser.DomSanitizer } ]; }; SanitizeHtmlPipe = __decorate([ core.Pipe({ name: 'sanitizeHtml' }) ], SanitizeHtmlPipe); return SanitizeHtmlPipe; }()); var SanitizeHtmlModule = /** @class */ (function () { function SanitizeHtmlModule() { } SanitizeHtmlModule = __decorate([ core.NgModule({ exports: [SanitizeHtmlPipe], declarations: [SanitizeHtmlPipe], imports: [common.CommonModule] }) ], SanitizeHtmlModule); return SanitizeHtmlModule; }()); var OrderConditionPipe = /** @class */ (function () { function OrderConditionPipe(_o) { this._o = _o; } OrderConditionPipe.prototype.transform = function (value, orderBy, condition, reverse, caseSensitive) { var _condition = (condition === undefined) ? true : !!condition; return (_condition) ? this._o.transform(value, orderBy, !!reverse, !!caseSensitive) : value; }; OrderConditionPipe.ctorParameters = function () { return [ { type: ngxOrderPipe.OrderPipe } ]; }; OrderConditionPipe = __decorate([ core.Pipe({ name: 'orderCondition' }) ], OrderConditionPipe); return OrderConditionPipe; }()); var OrderConditionModule = /** @class */ (function () { function OrderConditionModule() { } OrderConditionModule = __decorate([ core.NgModule({ exports: [OrderConditionPipe], declarations: [OrderConditionPipe], imports: [ common.CommonModule, ngxOrderPipe.OrderModule ], providers: [OrderConditionPipe] }) ], OrderConditionModule); return OrderConditionModule; }()); var CoreModule = /** @class */ (function () { function CoreModule() { } CoreModule_1 = CoreModule; CoreModule.forChild = function () { return { ngModule: CoreModule_1, providers: [ BoxModelService, EventsService, CustomValidationService, ToolService ] }; }; var CoreModule_1; CoreModule = CoreModule_1 = __decorate([ core.NgModule({ exports: [ OrderConditionPipe, SanitizeHtmlPipe ], imports: [ common.CommonModule, OrderConditionModule, SanitizeHtmlModule ] }) ], CoreModule); return CoreModule; }()); var BoxModelModule = /** @class */ (function () { function BoxModelModule() { } BoxModelModule_1 = BoxModelModule; BoxModelModule.forChild = function () { return { ngModule: BoxModelModule_1, providers: [BoxModelService] }; }; var BoxModelModule_1; BoxModelModule = BoxModelModule_1 = __decorate([ core.NgModule({ imports: [common.CommonModule] }) ], BoxModelModule); return BoxModelModule; }()); var CustomValidationModule = /** @class */ (function () { function CustomValidationModule() { } CustomValidationModule_1 = CustomValidationModule; CustomValidationModule.forChild = function () { return { ngModule: CustomValidationModule_1, providers: [CustomValidationService] }; }; var CustomValidationModule_1; CustomValidationModule = CustomValidationModule_1 = __decorate([ core.NgModule({ imports: [common.CommonModule] }) ], CustomValidationModule); return CustomValidationModule; }()); var EventsModule = /** @class */ (function () { function EventsModule() { } EventsModule_1 = EventsModule; EventsModule.forChild = function () { return { ngModule: EventsModule_1, providers: [EventsService] }; }; var EventsModule_1; EventsModule = EventsModule_1 = __decorate([ core.NgModule({ imports: [ common.CommonModule, BoxModelModule.forChild() ] }) ], EventsModule); return EventsModule; }()); var ToolModule = /** @class */ (function () { function ToolModule() { } ToolModule_1 = ToolModule; ToolModule.forChild = function () { return { ngModule: ToolModule_1, providers: [ToolService] }; }; var ToolModule_1; ToolModule = ToolModule_1 = __decorate([ core.NgModule({ imports: [common.CommonModule] }) ], ToolModule); return ToolModule; }()); // ##################################################### // ###### PRIVATE TYPES, INTERFACES AND CONSTANTS ###### // ##################################################### // ############################################# // ###### OPTION CONSTANTS DEFINITION API ###### // ############################################# var ccOptionFields = { value: 'value', label: 'label', color: 'color', icon: 'icon' }; // ############################################### // ###### POSITION CONSTANTS DEFINITION API ###### // ############################################### var 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' }; var ccPositionsVertical = { top: 'top', center: 'center', bottom: 'bottom' }; var ccPositionsHorizontal = { left: 'left', center: 'center', right: 'right' }; // ############################################# // ###### STATUS CONSTANTS DEFINITION API ###### // ############################################# var ccStatuses = { info: 'info', success: 'success', warning: 'warning', critical: 'critical' }; var ɵ0 = function () { }, ɵ1 = function () { }; var defaultConfig = { timeShowing: 400, timeToStop: 400, callbackShow: ɵ0, callbackStop: ɵ1 }; var AsynchronousPairVariables = /** @class */ (function () { function AsynchronousPairVariables(config) { if (config === void 0) { config = defaultConfig; } this.trigger$ = new rxjs.Subject(); this.show$ = new rxjs.Subject(); this._startArguments = []; this._stopArguments = []; this._config = {}; if (!!config) { this._config.timeShowing = (!!config.timeShowing) ? config.timeShowing : defaultConfig.timeShowing; this._config.timeToStop = (!!config.timeToStop) ? config.timeToStop : defaultConfig.timeToStop; this._config.callbackShow = (!!config.callbackShow) ? config.callbackShow : defaultConfig.callbackShow; this._config.callbackStop = config.callbackStop; if (!!!this._config.callbackStop) { this._config.callbackStop = (!!config.callbackShow) ? config.callbackShow : defaultConfig.callbackStop; } } } Object.defineProperty(AsynchronousPairVariables.prototype, "_trigger", { set: function (state) { var _this = this; this.trigger$.next(state); if (state) { setTimeout(function () { var _a; (_a = _this._config).callbackShow.apply(_a, __spread(_this._startArguments)); _this._show = true; _this._timeoutShow = setTimeout(function () { _this._show = false; }, _this._config.timeShowing); }); } }, enumerable: true, configurable: true }); Object.defineProperty(AsynchronousPairVariables.prototype, "_show", { set: function (state) { var _this = this; this.show$.next(state); if (!state) { setTimeout(function () { var _a; (_a = _this._config).callbackStop.apply(_a, __spread(_this._stopArguments)); _this._trigger = false; }, this._config.timeToStop); } }, enumerable: true, configurable: true }); AsynchronousPairVariables.prototype._setStopArguments = function () { var arg = []; for (var _i = 0; _i < arguments.length; _i++) { arg[_i] = arguments[_i]; } this._stopArguments = arg; }; AsynchronousPairVariables.prototype.setConfig = function (config) { if (!!config.timeShowing) { this._config.timeShowing = config.timeShowing; } if (!!config.timeToStop) { this._config.timeToStop = config.timeToStop; } if (!!config.callbackShow) { this._config.callbackShow = config.callbackShow; } if (!!config.callbackStop) { this._config.callbackStop = config.callbackStop; } }; AsynchronousPairVariables.prototype.start = function () { var arg = []; for (var _i = 0; _i < arguments.length; _i++) { arg[_i] = arguments[_i]; } clearTimeout(this._timeoutShow); this._startArguments = arg; this._trigger = true; return this._setStopArguments.bind(this); }; AsynchronousPairVariables.prototype.stop = function () { clearTimeout(this._timeoutShow); }; AsynchronousPairVariables.prototype.remove = function () { this.stop(); this._show = false; }; return AsynchronousPairVariables; }()); var iconsClassBaseDefault = 'mda-icon'; var Icons = /** @class */ (function () { function Icons(classBase) { if (classBase === void 0) { classBase = iconsClassBaseDefault; } this.classBase = classBase; this.defaultKeys = __assign(__assign({}, ccStatuses), { 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' }; } Icons.prototype._applyClassBase = function (icon) { return (!!this.classBase) ? this.classBase + " " + icon : icon; }; Icons.prototype.get = function (defaultKey) { var _icon = this._defaults[defaultKey]; if (!!_icon) { return this._applyClassBase(_icon); } return ''; }; Icons.prototype.getCustom = function (icon) { if (!!icon) { return this._applyClassBase(icon); } return ''; }; return Icons; }()); exports.AsynchronousPairVariables = AsynchronousPairVariables; exports.BoxModelModule = BoxModelModule; exports.BoxModelService = BoxModelService; exports.CoreModule = CoreModule; exports.CustomValidationModule = CustomValidationModule; exports.CustomValidationService = CustomValidationService; exports.EventsModule = EventsModule; exports.EventsService = EventsService; exports.Icons = Icons; exports.OrderConditionModule = OrderConditionModule; exports.OrderConditionPipe = OrderConditionPipe; exports.SanitizeHtmlModule = SanitizeHtmlModule; exports.SanitizeHtmlPipe = SanitizeHtmlPipe; exports.ToolModule = ToolModule; exports.ToolService = ToolService; exports.boxModelTypeConstants = boxModelTypeConstants; exports.ccElementFields = ccElementFields; exports.ccHashTypes = ccHashTypes; exports.ccOptionFields = ccOptionFields; exports.ccPositions = ccPositions; exports.ccPositionsHorizontal = ccPositionsHorizontal; exports.ccPositionsVertical = ccPositionsVertical; exports.ccStatuses = ccStatuses; exports.ccStringTransform = ccStringTransform; exports0 = ɵ0; exports1 = ɵ1; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=lunaeme-circe-core.umd.js.map