@lenne.tech/ng-base 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-angular'), require('apollo-angular/http'), require('@angular/core'), require('rxjs'), require('@apollo/client/core'), require('@apollo/client/cache'), require('@apollo/client/link/ws'), require('@apollo/client/utilities'), require('@angular/platform-browser'), require('@angular/router'), require('graphql'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@lenne.tech/ng-base/src/lib/base', ['exports', 'apollo-angular', 'apollo-angular/http', '@angular/core', 'rxjs', '@apollo/client/core', '@apollo/client/cache', '@apollo/client/link/ws', '@apollo/client/utilities', '@angular/platform-browser', '@angular/router', 'graphql', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lenne = global.lenne || {}, global.lenne.tech = global.lenne.tech || {}, global.lenne.tech["ng-base"] = global.lenne.tech["ng-base"] || {}, global.lenne.tech["ng-base"].src = global.lenne.tech["ng-base"].src || {}, global.lenne.tech["ng-base"].src.lib = global.lenne.tech["ng-base"].src.lib || {}, global.lenne.tech["ng-base"].src.lib.base = {}), global.i1$1, global.http, global.ng.core, global.rxjs, global.core, global.cache, global.ws, global.utilities, global.ng.platformBrowser, global.ng.router, global.graphql, global.rxjs.operators));
5
- })(this, (function (exports, i1$1, http, i0, rxjs, core, cache, ws, utilities, i1, i1$2, graphql, operators) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-angular'), require('apollo-angular/http'), require('@angular/core'), require('rxjs'), require('@apollo/client/core'), require('@apollo/client/cache'), require('@apollo/client/link/ws'), require('@apollo/client/utilities'), require('@angular/common'), require('@angular/platform-browser'), require('@angular/router'), require('graphql'), require('rxjs/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@lenne.tech/ng-base/src/lib/base', ['exports', 'apollo-angular', 'apollo-angular/http', '@angular/core', 'rxjs', '@apollo/client/core', '@apollo/client/cache', '@apollo/client/link/ws', '@apollo/client/utilities', '@angular/common', '@angular/platform-browser', '@angular/router', 'graphql', 'rxjs/operators'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lenne = global.lenne || {}, global.lenne.tech = global.lenne.tech || {}, global.lenne.tech["ng-base"] = global.lenne.tech["ng-base"] || {}, global.lenne.tech["ng-base"].src = global.lenne.tech["ng-base"].src || {}, global.lenne.tech["ng-base"].src.lib = global.lenne.tech["ng-base"].src.lib || {}, global.lenne.tech["ng-base"].src.lib.base = {}), global.i1$1, global.http, global.ng.core, global.rxjs, global.core, global.cache, global.ws, global.utilities, global.ng.common, global.ng.platformBrowser, global.ng.router, global.graphql, global.rxjs.operators));
5
+ })(this, (function (exports, i1$1, http, i0, rxjs, core, cache, ws, utilities, common, i1, i1$2, graphql, operators) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -787,804 +787,841 @@
787
787
  };
788
788
 
789
789
  /**
790
- * Image service
790
+ * Helper class
791
791
  */
792
- var ImageService = /** @class */ (function () {
793
- function ImageService() {
792
+ var Helper = /** @class */ (function () {
793
+ function Helper() {
794
794
  }
795
795
  /**
796
- * Preaload images (for lazy handling)
797
- *
798
- * @param options
799
- * @protected
796
+ * Simple filter function for plain objects
800
797
  */
801
- ImageService.prototype.preLoadImages = function (options) {
802
- var _this = this;
803
- // Init configuration
804
- var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined, timeout: undefined }, options);
805
- return new Promise(function (resolve) {
806
- var e_1, _b;
807
- var _a;
808
- // Init variables
809
- var resolved = false;
810
- var timeoutId;
811
- // HTMLCollection to array
812
- if (config.elements instanceof HTMLCollection) {
813
- config.elements = Array.from(config.elements);
814
- }
815
- // Single element to array
816
- if (!Array.isArray(config.elements)) {
817
- config.elements = [config.elements];
818
- }
819
- // Init loading
820
- var promises = [];
821
- // Get all images
822
- var images = [];
823
- config.elements.forEach(function (element) {
824
- images = images.concat(Array.from(element.getElementsByTagName('img')));
825
- });
826
- var _loop_1 = function (image) {
827
- var src = image.getAttribute('src');
828
- // Check if changes are necessary and possible
829
- if ((image.complete && image.naturalHeight !== 0) || // already laoded
830
- image.getAttribute('loading') !== 'lazy' || // loading attribute !== lazy
831
- !src || // Image has no src
832
- ((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
833
- ) {
834
- return "continue";
835
- }
836
- // Replace lazy loading image with immediately loading image
837
- var newImage = document.createElement('img');
838
- Array.from(image.attributes).forEach(function (attr) {
839
- if (attr.name !== 'loading' && attr.name !== 'src') {
840
- newImage.setAttribute(attr.name, attr.value);
841
- }
842
- });
843
- image.replaceWith(newImage);
844
- // Wait for laoding
845
- promises.push(_this.loadImage(newImage, src));
846
- };
798
+ Helper.filter = function (objects, filter) {
799
+ return ((objects === null || objects === void 0 ? void 0 : objects.filter(function (element) {
800
+ var e_1, _d, e_2, _e;
847
801
  try {
848
- // Prepare images
849
- for (var images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
850
- var image = images_1_1.value;
851
- _loop_1(image);
802
+ for (var _f = __values(Object.entries(filter)), _g = _f.next(); !_g.done; _g = _f.next()) {
803
+ var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
804
+ if (Array.isArray(element[key])) {
805
+ try {
806
+ for (var _j = (e_2 = void 0, __values(element[key])), _k = _j.next(); !_k.done; _k = _j.next()) {
807
+ var item = _k.value;
808
+ if (!element[key].includs(value)) {
809
+ return false;
810
+ }
811
+ }
812
+ }
813
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
814
+ finally {
815
+ try {
816
+ if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
817
+ }
818
+ finally { if (e_2) throw e_2.error; }
819
+ }
820
+ }
821
+ else if (element[key] !== value) {
822
+ return false;
823
+ }
852
824
  }
853
825
  }
854
826
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
855
827
  finally {
856
828
  try {
857
- if (images_1_1 && !images_1_1.done && (_b = images_1.return)) _b.call(images_1);
829
+ if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
858
830
  }
859
831
  finally { if (e_1) throw e_1.error; }
860
832
  }
861
- if (config.timeout) {
862
- timeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
863
- return __generator(this, function (_b) {
864
- switch (_b.label) {
865
- case 0:
866
- resolved = true;
867
- if (!config.doneFunnction) return [3 /*break*/, 2];
868
- return [4 /*yield*/, config.doneFunction()];
869
- case 1:
870
- _b.sent();
871
- _b.label = 2;
872
- case 2:
873
- resolve(undefined);
874
- return [2 /*return*/];
875
- }
876
- });
877
- }); });
878
- }
879
- // Wait until all images loaded
880
- Promise.all(promises)
881
- .catch(function (e) { return console.error('Error during image loading', e); })
882
- .finally(function () { return __awaiter(_this, void 0, void 0, function () {
883
- var result;
884
- return __generator(this, function (_b) {
885
- switch (_b.label) {
886
- case 0:
887
- // Check if already resolved
888
- if (resolved) {
889
- return [2 /*return*/];
890
- }
891
- // Stop timeout
892
- if (timeoutId) {
893
- clearTimeout(timeoutId);
833
+ return true;
834
+ })) || []);
835
+ };
836
+ /**
837
+ * Convert to a url/uri conform string
838
+ * Only:
839
+ * - lower case
840
+ * - chars, numbers and hyphens
841
+ */
842
+ Helper.urlString = function (str, options) {
843
+ if (options === void 0) { options = {}; }
844
+ // Config
845
+ var config = Object.assign({ allowAll: false }, options);
846
+ // To string
847
+ str = str + '';
848
+ // Trim
849
+ str = str.trim();
850
+ // Lower case
851
+ str = str.toLowerCase();
852
+ if (!config.allowAll) {
853
+ // Replace spaces
854
+ str = str.trim().replace(/\s+/g, '-');
855
+ // Replace some special chars
856
+ str = str.replace('ä', 'ae');
857
+ str = str.replace('ö', 'oe');
858
+ str = str.replace('ü', 'ue');
859
+ str = str.replace('ß', 'ss');
860
+ // Remove other special chars
861
+ str = str.replace(/[^a-zA-Z0-9-]/g, '');
862
+ }
863
+ // Return url conform string
864
+ return encodeURI(str);
865
+ };
866
+ /**
867
+ * Simple map function
868
+ */
869
+ Helper.map = function (source, target, options) {
870
+ var e_3, _d;
871
+ if (options === void 0) { options = {}; }
872
+ // Set config
873
+ var config = Object.assign({ funcAllowed: false, dateStringToDate: true }, options);
874
+ // Check source
875
+ if (!source || typeof source !== 'object' || Array.isArray(source)) {
876
+ return target;
877
+ }
878
+ try {
879
+ // Update properties
880
+ for (var _e = __values(Object.keys(target)), _f = _e.next(); !_f.done; _f = _e.next()) {
881
+ var key = _f.value;
882
+ if (source[key] !== undefined && (config.funcAllowed || typeof (source[key] !== 'function'))) {
883
+ if (typeof source[key] === 'string' && config.dateStringToDate) {
884
+ if (Array.isArray(config.dateStringToDate)) {
885
+ if (config.dateStringToDate.includes(key)) {
886
+ target[key] = Helper.parseDate(source[key]);
894
887
  }
895
- if (!config.doneFunnction) return [3 /*break*/, 2];
896
- return [4 /*yield*/, config.doneFunction()];
897
- case 1:
898
- result = _b.sent();
899
- _b.label = 2;
900
- case 2:
901
- resolve(result);
902
- return [2 /*return*/];
888
+ }
889
+ else {
890
+ target[key] = Helper.parseDate(source[key]);
891
+ }
903
892
  }
904
- });
905
- }); });
906
- });
893
+ else {
894
+ target[key] = source[key];
895
+ }
896
+ }
897
+ }
898
+ }
899
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
900
+ finally {
901
+ try {
902
+ if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
903
+ }
904
+ finally { if (e_3) throw e_3.error; }
905
+ }
906
+ // Return target
907
+ return target;
907
908
  };
908
909
  /**
909
- * Load image for image element
910
- *
911
- * @param imageElement
912
- * @param src
913
- * @protected
910
+ * Create Object or Objects of specified type with specified data
914
911
  */
915
- ImageService.prototype.loadImage = function (imageElement, src) {
916
- return __awaiter(this, void 0, void 0, function () {
917
- return __generator(this, function (_b) {
918
- src = src || imageElement.src;
919
- return [2 /*return*/, new Promise(function (resolve, reject) {
920
- imageElement.onload = function () { return resolve(imageElement); };
921
- imageElement.onerror = reject;
922
- imageElement.src = src;
923
- })];
924
- });
912
+ Helper.maps = function (data, targetClass) {
913
+ // Check data
914
+ if (!data || typeof data !== 'object') {
915
+ return undefined;
916
+ }
917
+ // Check array
918
+ if (!Array.isArray(data)) {
919
+ data = [data];
920
+ }
921
+ // Map
922
+ return data.map(function (item) {
923
+ return targetClass.map(item);
925
924
  });
926
925
  };
927
- return ImageService;
928
- }());
929
- ImageService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ImageService_Factory() { return new ImageService(); }, token: ImageService, providedIn: "root" });
930
- ImageService.decorators = [
931
- { type: i0.Injectable, args: [{
932
- providedIn: 'root',
933
- },] }
934
- ];
935
-
936
- /**
937
- * Set same height (maximum) to different elements
938
- */
939
- var MatchHeightDirective = /** @class */ (function () {
940
- function MatchHeightDirective(el, imageService, zone) {
941
- this.el = el;
942
- this.imageService = imageService;
943
- this.zone = zone;
944
- this.loadLazyImages = true;
945
- }
946
- MatchHeightDirective.prototype.onResize = function () {
947
- this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
926
+ /**
927
+ * Get plain parameter
928
+ */
929
+ Helper.getPlainParameter = function (parameter) {
930
+ var _a, _b, _c;
931
+ if (!parameter) {
932
+ return parameter;
933
+ }
934
+ return (_c = (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.split('?')) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.split('#')) === null || _c === void 0 ? void 0 : _c.shift();
948
935
  };
949
- MatchHeightDirective.prototype.ngAfterViewChecked = function () {
950
- this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
951
- };
952
- MatchHeightDirective.prototype.matchHeight = function (parent, target) {
953
- var _this = this;
954
- // Timeout is set to force Angular to wait for all actions and only continue once the process has run through.
955
- // Otherwise, an infinite loop will occur.
956
- setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
957
- var classNames, _loop_1, this_1, classNames_1, classNames_1_1, className, e_1_1;
958
- var e_1, _a;
959
- return __generator(this, function (_b) {
960
- switch (_b.label) {
961
- case 0:
962
- if (!parent) {
963
- return [2 /*return*/];
964
- }
965
- if (!Array.isArray(target)) {
966
- classNames = [target];
967
- }
968
- else {
969
- classNames = target;
970
- }
971
- _loop_1 = function (className) {
972
- var children, itemHeights, maxHeight;
973
- return __generator(this, function (_c) {
974
- switch (_c.label) {
975
- case 0:
976
- children = parent.getElementsByClassName(className);
977
- if (!children || children.length < 2) {
978
- return [2 /*return*/, "continue"];
979
- }
980
- if (!this_1.loadLazyImages) return [3 /*break*/, 2];
981
- return [4 /*yield*/, this_1.imageService.preLoadImages({ elements: children })];
982
- case 1:
983
- _c.sent();
984
- _c.label = 2;
985
- case 2:
986
- // reset all children height
987
- Array.from(children).forEach(function (element) {
988
- element.style.height = 'initial';
989
- });
990
- itemHeights = Array.from(children).map(function (x) { return x.getBoundingClientRect().height; });
991
- maxHeight = itemHeights.reduce(function (prev, curr) { return (curr > prev ? curr : prev); }, 0);
992
- // update the child structureElements height to the tallest one
993
- Array.from(children).forEach(function (element) { return (element.style.height = maxHeight + "px"); });
994
- return [2 /*return*/];
995
- }
996
- });
997
- };
998
- this_1 = this;
999
- _b.label = 1;
1000
- case 1:
1001
- _b.trys.push([1, 6, 7, 8]);
1002
- classNames_1 = __values(classNames), classNames_1_1 = classNames_1.next();
1003
- _b.label = 2;
1004
- case 2:
1005
- if (!!classNames_1_1.done) return [3 /*break*/, 5];
1006
- className = classNames_1_1.value;
1007
- return [5 /*yield**/, _loop_1(className)];
1008
- case 3:
1009
- _b.sent();
1010
- _b.label = 4;
1011
- case 4:
1012
- classNames_1_1 = classNames_1.next();
1013
- return [3 /*break*/, 2];
1014
- case 5: return [3 /*break*/, 8];
1015
- case 6:
1016
- e_1_1 = _b.sent();
1017
- e_1 = { error: e_1_1 };
1018
- return [3 /*break*/, 8];
1019
- case 7:
1020
- try {
1021
- if (classNames_1_1 && !classNames_1_1.done && (_a = classNames_1.return)) _a.call(classNames_1);
1022
- }
1023
- finally { if (e_1) throw e_1.error; }
1024
- return [7 /*endfinally*/];
1025
- case 8: return [2 /*return*/];
1026
- }
1027
- });
1028
- }); }, 1);
1029
- };
1030
- return MatchHeightDirective;
1031
- }());
1032
- MatchHeightDirective.decorators = [
1033
- { type: i0.Directive, args: [{
1034
- selector: '[ltMatchHeight]',
1035
- },] }
1036
- ];
1037
- MatchHeightDirective.ctorParameters = function () { return [
1038
- { type: i0.ElementRef },
1039
- { type: ImageService },
1040
- { type: i0.NgZone }
1041
- ]; };
1042
- MatchHeightDirective.propDecorators = {
1043
- ltMatchHeight: [{ type: i0.Input }],
1044
- loadLazyImages: [{ type: i0.Input }],
1045
- onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
1046
- };
1047
-
1048
- /**
1049
- * Reszise detection
1050
- * (inpsired by: https://stackblitz.com/edit/angular-resizable)
1051
- */
1052
- var ResizableDirective = /** @class */ (function () {
1053
- function ResizableDirective(el) {
1054
- this.el = el;
1055
- this.resizableGrabWidth = 8;
1056
- this.resizableMinWidth = 10;
1057
- this.dragging = false;
1058
- }
1059
- ResizableDirective.prototype.ngOnInit = function () {
1060
- this.addListenerToDocument();
1061
- this.addListenerToElement();
1062
- };
1063
- ResizableDirective.prototype.mouseMoveG = function (evt) {
1064
- if (!this.dragging) {
1065
- return;
1066
- }
1067
- this.newWidth(evt.clientX - this.el.nativeElement.offsetLeft);
1068
- evt.stopPropagation();
1069
- };
1070
- ResizableDirective.prototype.newWidth = function (wid) {
1071
- var result = Math.max(this.resizableMinWidth, wid);
1072
- this.el.nativeElement.style.width = result + 'px';
1073
- };
1074
- ResizableDirective.prototype.mouseDown = function (evt) {
1075
- if (this.inDragRegion(evt)) {
1076
- this.dragging = true;
1077
- this.preventGlobalMouseEvents();
1078
- evt.stopPropagation();
936
+ /**
937
+ * Get ID of an url parameter
938
+ */
939
+ Helper.getParameterId = function (parameter) {
940
+ var _a;
941
+ if (!parameter) {
942
+ return parameter;
1079
943
  }
944
+ return (_a = Helper.getPlainParameter(parameter)) === null || _a === void 0 ? void 0 : _a.split('-').pop();
1080
945
  };
1081
- ResizableDirective.prototype.restoreGlobalMouseEvents = function () {
1082
- document.body.style['pointer-events'] = 'auto';
946
+ /**
947
+ * Delay
948
+ */
949
+ Helper.delay = function (ms) {
950
+ var promise = new Promise(function (resolve) { return setTimeout(resolve, ms); });
951
+ return promise;
1083
952
  };
1084
- ResizableDirective.prototype.mouseUpG = function (evt) {
1085
- if (!this.dragging) {
1086
- return;
953
+ /**
954
+ * Deep freeze
955
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#What_is_shallow_freeze
956
+ */
957
+ Helper.deepFreeze = function (object, preparedObjects) {
958
+ var e_4, _d;
959
+ if (preparedObjects === void 0) { preparedObjects = []; }
960
+ // Prevent infinit regress
961
+ if (preparedObjects.includes(object)) {
962
+ return object;
1087
963
  }
1088
- this.restoreGlobalMouseEvents();
1089
- this.dragging = false;
1090
- evt.stopPropagation();
1091
- };
1092
- ResizableDirective.prototype.mouseMove = function (evt) {
1093
- if (this.inDragRegion(evt) || this.dragging) {
1094
- this.el.nativeElement.style.cursor = 'col-resize';
964
+ preparedObjects.push(object);
965
+ // Retrieve the property names defined on object
966
+ var propNames = Object.getOwnPropertyNames(object);
967
+ try {
968
+ // Freeze properties before freezing self
969
+ for (var propNames_1 = __values(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
970
+ var name = propNames_1_1.value;
971
+ var value = object[name];
972
+ if (value && typeof value === 'object') {
973
+ Helper.deepFreeze(value, preparedObjects);
974
+ }
975
+ }
1095
976
  }
1096
- else {
1097
- this.el.nativeElement.style.cursor = 'default';
977
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
978
+ finally {
979
+ try {
980
+ if (propNames_1_1 && !propNames_1_1.done && (_d = propNames_1.return)) _d.call(propNames_1);
981
+ }
982
+ finally { if (e_4) throw e_4.error; }
1098
983
  }
984
+ return Object.freeze(object);
1099
985
  };
1100
- ResizableDirective.prototype.preventGlobalMouseEvents = function () {
1101
- document.body.style['pointer-events'] = 'none';
1102
- };
1103
- ResizableDirective.prototype.inDragRegion = function (evt) {
1104
- return this.el.nativeElement.clientWidth - evt.clientX + this.el.nativeElement.offsetLeft < this.resizableGrabWidth;
1105
- };
1106
- ResizableDirective.prototype.addListenerToDocument = function () {
1107
- var _this = this;
1108
- document.addEventListener('mousemove', function (e) {
1109
- _this.mouseMoveG(e);
1110
- }, true);
1111
- document.addEventListener('mouseup', function (e) {
1112
- _this.mouseUpG(e);
1113
- }, true);
1114
- };
1115
- ResizableDirective.prototype.addListenerToElement = function () {
1116
- var _this = this;
1117
- this.el.nativeElement.addEventListener('mousedown', function (e) {
1118
- _this.mouseDown(e);
1119
- }, true);
1120
- this.el.nativeElement.addEventListener('mousemove', function (e) {
1121
- _this.mouseMove(e);
1122
- }, true);
986
+ /**
987
+ * Generates an unique identifier with 24 characters
988
+ */
989
+ Helper.getUID = function () {
990
+ var dt = new Date().getTime();
991
+ var uuid = 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
992
+ // eslint-disable-next-line no-bitwise
993
+ var r = (dt + Math.random() * 16) % 16 | 0;
994
+ dt = Math.floor(dt / 16);
995
+ // eslint-disable-next-line no-bitwise
996
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
997
+ });
998
+ return uuid;
1123
999
  };
1124
- return ResizableDirective;
1125
- }());
1126
- ResizableDirective.decorators = [
1127
- { type: i0.Directive, args: [{
1128
- selector: '[ltResizable]',
1129
- },] }
1130
- ];
1131
- ResizableDirective.ctorParameters = function () { return [
1132
- { type: i0.ElementRef }
1133
- ]; };
1134
- ResizableDirective.propDecorators = {
1135
- resizableGrabWidth: [{ type: i0.Input }],
1136
- resizableMinWidth: [{ type: i0.Input }]
1137
- };
1138
-
1139
- /**
1140
- * Truncate string with ellipses
1141
- */
1142
- var EllipsesPipe = /** @class */ (function () {
1143
- function EllipsesPipe() {
1144
- }
1145
- EllipsesPipe.prototype.transform = function (value, limit) {
1146
- if (!value) {
1147
- return null;
1000
+ /**
1001
+ * Parse date string to date object
1002
+ */
1003
+ Helper.parseDate = function (dateString) {
1004
+ var reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
1005
+ var reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
1006
+ if (typeof dateString === 'string') {
1007
+ var isoExec = reISO.exec(dateString);
1008
+ if (isoExec) {
1009
+ return new Date(dateString);
1010
+ }
1011
+ var msAjaxExec = reMsAjax.exec(dateString);
1012
+ if (msAjaxExec) {
1013
+ var cleaned = msAjaxExec[1].split(/[-+,.]/);
1014
+ return new Date(cleaned[0] ? +cleaned[0] : 0 - +cleaned[1]);
1015
+ }
1148
1016
  }
1149
- return value.length > limit ? value.substring(0, limit) + '...' : value;
1150
- };
1151
- return EllipsesPipe;
1152
- }());
1153
- EllipsesPipe.decorators = [
1154
- { type: i0.Pipe, args: [{
1155
- name: 'ltEllipses',
1156
- },] }
1157
- ];
1158
-
1159
- /**
1160
- * Declarate html as safe
1161
- */
1162
- var SafeHtmlPipe = /** @class */ (function () {
1163
- function SafeHtmlPipe(sanitized) {
1164
- this.sanitized = sanitized;
1165
- }
1166
- SafeHtmlPipe.prototype.transform = function (value) {
1167
- return this.sanitized.bypassSecurityTrustHtml(value);
1017
+ return dateString;
1168
1018
  };
1169
- return SafeHtmlPipe;
1170
- }());
1171
- SafeHtmlPipe.decorators = [
1172
- { type: i0.Pipe, args: [{ name: 'ltSafeHtml' },] }
1173
- ];
1174
- SafeHtmlPipe.ctorParameters = function () { return [
1175
- { type: i1.DomSanitizer }
1176
- ]; };
1177
-
1178
- // Imported and exported elements
1179
- var elements = [
1180
- // Directives
1181
- ContextMenuDirective,
1182
- LazyLoadDirective,
1183
- MatchHeightDirective,
1184
- ResizableDirective,
1185
- // Pipes
1186
- EllipsesPipe,
1187
- SafeHtmlPipe,
1188
- ];
1189
- /**
1190
- * Base module
1191
- */
1192
- var BaseModule = /** @class */ (function () {
1193
- function BaseModule() {
1194
- }
1195
1019
  /**
1196
- * Set configuration of base module in root module of the app
1020
+ * Get browser name and version
1197
1021
  */
1198
- BaseModule.forRoot = function (baseModuleConfig) {
1199
- if (baseModuleConfig === void 0) { baseModuleConfig = {}; }
1200
- // Default config
1201
- var config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
1202
- // Prepare providers
1203
- var providers = [
1204
- {
1205
- provide: BASE_MODULE_CONFIG,
1206
- useValue: baseModuleConfig,
1207
- },
1208
- ];
1209
- // Add apollo features if API URL is set
1210
- if (baseModuleConfig.apiUrl) {
1211
- providers.push({
1212
- provide: i1$1.APOLLO_OPTIONS,
1213
- useFactory: apolloOptionsFactory,
1214
- deps: [BASE_MODULE_CONFIG, http.HttpLink, AuthService],
1215
- });
1022
+ Helper.getBrowser = function () {
1023
+ var userAgent = navigator.userAgent;
1024
+ var data = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
1025
+ var version;
1026
+ if (/trident/i.test(data[1])) {
1027
+ version = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
1028
+ return { name: 'IE', version: version[1] || '' };
1216
1029
  }
1217
- else if (config.logging) {
1218
- console.log('apiUrl is missing, ApolloLink is not initialized');
1030
+ if (data[1] === 'Chrome') {
1031
+ version = userAgent.match(/\bOPR|Edge\/(\d+)/);
1032
+ if (version != null) {
1033
+ return { name: 'Opera', version: version[1] };
1034
+ }
1035
+ }
1036
+ data = data[2] ? [data[1], data[2]] : [navigator.appName, navigator.appVersion, '-?'];
1037
+ version = userAgent.match(/version\/(\d+)/i);
1038
+ if (version !== null) {
1039
+ data.splice(1, 1, version[1]);
1219
1040
  }
1220
- // Return root module
1221
1041
  return {
1222
- ngModule: BaseModule,
1223
- providers: providers,
1042
+ name: data[0],
1043
+ version: data[1],
1224
1044
  };
1225
1045
  };
1226
- return BaseModule;
1227
- }());
1228
- BaseModule.decorators = [
1229
- { type: i0.NgModule, args: [{
1230
- declarations: elements,
1231
- exports: elements,
1232
- },] }
1233
- ];
1234
-
1235
- /**
1236
- * Helper class
1237
- */
1238
- var Helper = /** @class */ (function () {
1239
- function Helper() {
1240
- }
1241
1046
  /**
1242
- * Simple filter function for plain objects
1047
+ * Whether first parameter is a deep subset of second parameter
1048
+ * Hint: functions will be ignored
1243
1049
  */
1244
- Helper.filter = function (objects, filter) {
1245
- return ((objects === null || objects === void 0 ? void 0 : objects.filter(function (element) {
1246
- var e_1, _d, e_2, _e;
1050
+ Helper.isSubset = function (a, b) {
1051
+ var e_5, _d, e_6, _e;
1052
+ // Equal
1053
+ if (a === b) {
1054
+ return true;
1055
+ }
1056
+ // Different type
1057
+ if (typeof a !== typeof b) {
1058
+ return false;
1059
+ }
1060
+ // Process array
1061
+ if (Array.isArray(a)) {
1247
1062
  try {
1248
- for (var _f = __values(Object.entries(filter)), _g = _f.next(); !_g.done; _g = _f.next()) {
1063
+ for (var _f = __values(Object.entries(a)), _g = _f.next(); !_g.done; _g = _f.next()) {
1249
1064
  var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
1250
- if (Array.isArray(element[key])) {
1251
- try {
1252
- for (var _j = (e_2 = void 0, __values(element[key])), _k = _j.next(); !_k.done; _k = _j.next()) {
1253
- var item = _k.value;
1254
- if (!element[key].includs(value)) {
1255
- return false;
1256
- }
1257
- }
1258
- }
1259
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1260
- finally {
1261
- try {
1262
- if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
1263
- }
1264
- finally { if (e_2) throw e_2.error; }
1265
- }
1266
- }
1267
- else if (element[key] !== value) {
1065
+ if (Helper.isSubset(value, b[key])) {
1268
1066
  return false;
1269
1067
  }
1270
1068
  }
1271
1069
  }
1272
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1070
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1273
1071
  finally {
1274
1072
  try {
1275
1073
  if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
1276
1074
  }
1277
- finally { if (e_1) throw e_1.error; }
1075
+ finally { if (e_5) throw e_5.error; }
1278
1076
  }
1279
1077
  return true;
1280
- })) || []);
1078
+ }
1079
+ // Process object
1080
+ if (typeof a === 'object') {
1081
+ var plain = JSON.parse(JSON.stringify(a));
1082
+ try {
1083
+ for (var _j = __values(Object.entries(plain)), _k = _j.next(); !_k.done; _k = _j.next()) {
1084
+ var _l = __read(_k.value, 2), key = _l[0], value = _l[1];
1085
+ if (Helper.isSubset(value, b[key])) {
1086
+ return false;
1087
+ }
1088
+ }
1089
+ }
1090
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1091
+ finally {
1092
+ try {
1093
+ if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
1094
+ }
1095
+ finally { if (e_6) throw e_6.error; }
1096
+ }
1097
+ return true;
1098
+ }
1099
+ // Else
1100
+ return true;
1281
1101
  };
1282
1102
  /**
1283
- * Convert to a url/uri conform string
1284
- * Only:
1285
- * - lower case
1286
- * - chars, numbers and hyphens
1103
+ * Whether parameters are equal (have equal properties)
1104
+ * Hint: functions will be ignored
1287
1105
  */
1288
- Helper.urlString = function (str, options) {
1289
- if (options === void 0) { options = {}; }
1290
- // Config
1291
- var config = Object.assign({ allowAll: false }, options);
1292
- // To string
1293
- str = str + '';
1294
- // Trim
1295
- str = str.trim();
1296
- // Lower case
1297
- str = str.toLowerCase();
1298
- if (!config.allowAll) {
1299
- // Replace spaces
1300
- str = str.trim().replace(/\s+/g, '-');
1301
- // Replace some special chars
1302
- str = str.replace('ä', 'ae');
1303
- str = str.replace('ö', 'oe');
1304
- str = str.replace('ü', 'ue');
1305
- str = str.replace('ß', 'ss');
1306
- // Remove other special chars
1307
- str = str.replace(/[^a-zA-Z0-9-]/g, '');
1308
- }
1309
- // Return url conform string
1310
- return encodeURI(str);
1106
+ Helper.isEqual = function (a, b) {
1107
+ return Helper.isSubset(a, b) && Helper.isSubset(b, a);
1311
1108
  };
1312
1109
  /**
1313
- * Simple map function
1110
+ * First level difference of two objects
1111
+ * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
1112
+ *
1113
+ * @returns Record<string, any> Object with properties from first object
1314
1114
  */
1315
- Helper.map = function (source, target, options) {
1316
- var e_3, _d;
1317
- if (options === void 0) { options = {}; }
1318
- // Set config
1319
- var config = Object.assign({ funcAllowed: false, dateStringToDate: true }, options);
1320
- // Check source
1321
- if (!source || typeof source !== 'object' || Array.isArray(source)) {
1322
- return target;
1115
+ Helper.getDiff = function (a, b, clone) {
1116
+ var e_7, _d;
1117
+ if (clone === void 0) { clone = true; }
1118
+ var result = {};
1119
+ var firstObject = a;
1120
+ if (clone) {
1121
+ firstObject = JSON.parse(JSON.stringify(a));
1323
1122
  }
1324
1123
  try {
1325
- // Update properties
1326
- for (var _e = __values(Object.keys(target)), _f = _e.next(); !_f.done; _f = _e.next()) {
1327
- var key = _f.value;
1328
- if (source[key] !== undefined && (config.funcAllowed || typeof (source[key] !== 'function'))) {
1329
- if (typeof source[key] === 'string' && config.dateStringToDate) {
1330
- if (Array.isArray(config.dateStringToDate)) {
1331
- if (config.dateStringToDate.includes(key)) {
1332
- target[key] = Helper.parseDate(source[key]);
1333
- }
1334
- }
1335
- else {
1336
- target[key] = Helper.parseDate(source[key]);
1337
- }
1338
- }
1339
- else {
1340
- target[key] = source[key];
1341
- }
1124
+ for (var _e = __values(Object.entries(firstObject)), _f = _e.next(); !_f.done; _f = _e.next()) {
1125
+ var _g = __read(_f.value, 2), key = _g[0], value = _g[1];
1126
+ if (!Helper.isSubset(value, b[key])) {
1127
+ result[key] = value;
1342
1128
  }
1343
1129
  }
1344
1130
  }
1345
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1131
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1346
1132
  finally {
1347
1133
  try {
1348
1134
  if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
1349
1135
  }
1350
- finally { if (e_3) throw e_3.error; }
1136
+ finally { if (e_7) throw e_7.error; }
1351
1137
  }
1352
- // Return target
1353
- return target;
1138
+ return result;
1354
1139
  };
1355
1140
  /**
1356
- * Create Object or Objects of specified type with specified data
1141
+ * Check if propertie is type of HTMLCollection or NodeList
1142
+ * See https://stackoverflow.com/a/7238344
1143
+ *
1144
+ * @param nodes
1357
1145
  */
1358
- Helper.maps = function (data, targetClass) {
1359
- // Check data
1360
- if (!data || typeof data !== 'object') {
1361
- return undefined;
1146
+ Helper.isNodeList = function (nodes) {
1147
+ try {
1148
+ var stringRepr = Object.prototype.toString.call(nodes);
1149
+ return (typeof nodes === 'object' &&
1150
+ /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
1151
+ typeof nodes.length === 'number' &&
1152
+ (nodes.length === 0 || (typeof nodes[0] === 'object' && nodes[0].nodeType > 0)));
1362
1153
  }
1363
- // Check array
1364
- if (!Array.isArray(data)) {
1365
- data = [data];
1154
+ catch (e) {
1155
+ return false;
1366
1156
  }
1367
- // Map
1368
- return data.map(function (item) {
1369
- return targetClass.map(item);
1157
+ };
1158
+ return Helper;
1159
+ }());
1160
+
1161
+ /**
1162
+ * Image service
1163
+ */
1164
+ var ImageService = /** @class */ (function () {
1165
+ function ImageService() {
1166
+ }
1167
+ /**
1168
+ * Preaload images (for lazy handling)
1169
+ *
1170
+ * @param options
1171
+ * @protected
1172
+ */
1173
+ ImageService.prototype.preLoadImages = function (options) {
1174
+ var _this = this;
1175
+ // Init configuration
1176
+ var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined, timeout: undefined }, options);
1177
+ return new Promise(function (resolve) {
1178
+ var e_1, _b;
1179
+ var _a;
1180
+ // Init variables
1181
+ var resolved = false;
1182
+ var timeoutId;
1183
+ // Convert element(s) into array
1184
+ if (!Array.isArray(config.elements)) {
1185
+ // NodeList or HTMLCollection
1186
+ if (Helper.isNodeList(config.elements)) {
1187
+ config.elements = Array.from(config.elements);
1188
+ }
1189
+ // Single element
1190
+ else {
1191
+ config.elements = [config.elements];
1192
+ }
1193
+ }
1194
+ // Init loading
1195
+ var promises = [];
1196
+ // Get all images
1197
+ var images = [];
1198
+ config.elements.forEach(function (element) {
1199
+ images = images.concat(Array.from(element.getElementsByTagName('img')));
1200
+ });
1201
+ var _loop_1 = function (image) {
1202
+ var src = image.getAttribute('src');
1203
+ // Check if changes are necessary and possible
1204
+ if ((image.complete && image.naturalHeight !== 0) || // already laoded
1205
+ image.getAttribute('loading') !== 'lazy' || // loading attribute !== lazy
1206
+ !src || // Image has no src
1207
+ ((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
1208
+ ) {
1209
+ return "continue";
1210
+ }
1211
+ // Replace lazy loading image with immediately loading image
1212
+ var newImage = document.createElement('img');
1213
+ Array.from(image.attributes).forEach(function (attr) {
1214
+ if (attr.name !== 'loading' && attr.name !== 'src') {
1215
+ newImage.setAttribute(attr.name, attr.value);
1216
+ }
1217
+ });
1218
+ image.replaceWith(newImage);
1219
+ // Wait for laoding
1220
+ promises.push(_this.loadImage(newImage, src));
1221
+ };
1222
+ try {
1223
+ // Prepare images
1224
+ for (var images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
1225
+ var image = images_1_1.value;
1226
+ _loop_1(image);
1227
+ }
1228
+ }
1229
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1230
+ finally {
1231
+ try {
1232
+ if (images_1_1 && !images_1_1.done && (_b = images_1.return)) _b.call(images_1);
1233
+ }
1234
+ finally { if (e_1) throw e_1.error; }
1235
+ }
1236
+ if (config.timeout) {
1237
+ timeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
1238
+ return __generator(this, function (_b) {
1239
+ switch (_b.label) {
1240
+ case 0:
1241
+ resolved = true;
1242
+ if (!config.doneFunnction) return [3 /*break*/, 2];
1243
+ return [4 /*yield*/, config.doneFunction()];
1244
+ case 1:
1245
+ _b.sent();
1246
+ _b.label = 2;
1247
+ case 2:
1248
+ resolve(undefined);
1249
+ return [2 /*return*/];
1250
+ }
1251
+ });
1252
+ }); });
1253
+ }
1254
+ // Wait until all images loaded
1255
+ Promise.all(promises)
1256
+ .catch(function (e) { return console.error('Error during image loading', e); })
1257
+ .finally(function () { return __awaiter(_this, void 0, void 0, function () {
1258
+ var result;
1259
+ return __generator(this, function (_b) {
1260
+ switch (_b.label) {
1261
+ case 0:
1262
+ // Check if already resolved
1263
+ if (resolved) {
1264
+ return [2 /*return*/];
1265
+ }
1266
+ // Stop timeout
1267
+ if (timeoutId) {
1268
+ clearTimeout(timeoutId);
1269
+ }
1270
+ if (!config.doneFunnction) return [3 /*break*/, 2];
1271
+ return [4 /*yield*/, config.doneFunction()];
1272
+ case 1:
1273
+ result = _b.sent();
1274
+ _b.label = 2;
1275
+ case 2:
1276
+ resolve(result);
1277
+ return [2 /*return*/];
1278
+ }
1279
+ });
1280
+ }); });
1370
1281
  });
1371
1282
  };
1372
1283
  /**
1373
- * Get plain parameter
1284
+ * Load image for image element
1285
+ *
1286
+ * @param imageElement
1287
+ * @param src
1288
+ * @protected
1374
1289
  */
1375
- Helper.getPlainParameter = function (parameter) {
1376
- var _a, _b, _c;
1377
- if (!parameter) {
1378
- return parameter;
1379
- }
1380
- return (_c = (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.split('?')) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.split('#')) === null || _c === void 0 ? void 0 : _c.shift();
1290
+ ImageService.prototype.loadImage = function (imageElement, src) {
1291
+ return __awaiter(this, void 0, void 0, function () {
1292
+ return __generator(this, function (_b) {
1293
+ src = src || imageElement.src;
1294
+ return [2 /*return*/, new Promise(function (resolve, reject) {
1295
+ imageElement.onload = function () { return resolve(imageElement); };
1296
+ imageElement.onerror = reject;
1297
+ imageElement.src = src;
1298
+ })];
1299
+ });
1300
+ });
1381
1301
  };
1382
- /**
1383
- * Get ID of an url parameter
1384
- */
1385
- Helper.getParameterId = function (parameter) {
1386
- var _a;
1387
- if (!parameter) {
1388
- return parameter;
1389
- }
1390
- return (_a = Helper.getPlainParameter(parameter)) === null || _a === void 0 ? void 0 : _a.split('-').pop();
1302
+ return ImageService;
1303
+ }());
1304
+ ImageService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ImageService_Factory() { return new ImageService(); }, token: ImageService, providedIn: "root" });
1305
+ ImageService.decorators = [
1306
+ { type: i0.Injectable, args: [{
1307
+ providedIn: 'root',
1308
+ },] }
1309
+ ];
1310
+
1311
+ /**
1312
+ * Set same height (maximum) to different elements
1313
+ */
1314
+ var MatchHeightDirective = /** @class */ (function () {
1315
+ function MatchHeightDirective(el, imageService, platformId) {
1316
+ this.el = el;
1317
+ this.imageService = imageService;
1318
+ // Replace lazy loading images with immediate loading images
1319
+ this.loadLazyImages = true;
1320
+ this.isBrowser = common.isPlatformBrowser(platformId);
1321
+ }
1322
+ MatchHeightDirective.prototype.onResize = function () {
1323
+ this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
1391
1324
  };
1392
- /**
1393
- * Delay
1394
- */
1395
- Helper.delay = function (ms) {
1396
- var promise = new Promise(function (resolve) { return setTimeout(resolve, ms); });
1397
- return promise;
1325
+ MatchHeightDirective.prototype.ngAfterViewChecked = function () {
1326
+ this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
1398
1327
  };
1399
- /**
1400
- * Deep freeze
1401
- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#What_is_shallow_freeze
1402
- */
1403
- Helper.deepFreeze = function (object, preparedObjects) {
1404
- var e_4, _d;
1405
- if (preparedObjects === void 0) { preparedObjects = []; }
1406
- // Prevent infinit regress
1407
- if (preparedObjects.includes(object)) {
1408
- return object;
1409
- }
1410
- preparedObjects.push(object);
1411
- // Retrieve the property names defined on object
1412
- var propNames = Object.getOwnPropertyNames(object);
1413
- try {
1414
- // Freeze properties before freezing self
1415
- for (var propNames_1 = __values(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
1416
- var name = propNames_1_1.value;
1417
- var value = object[name];
1418
- if (value && typeof value === 'object') {
1419
- Helper.deepFreeze(value, preparedObjects);
1420
- }
1421
- }
1328
+ MatchHeightDirective.prototype.matchHeight = function (parent, target) {
1329
+ var _this = this;
1330
+ if (this.isBrowser) {
1331
+ // Timeout is set to force Angular to wait for all actions and only continue once the process has run through.
1332
+ // Otherwise, an infinite loop will occur.
1333
+ setTimeout(function () {
1334
+ _this.matchHeightHelper(parent, target);
1335
+ }, 1);
1422
1336
  }
1423
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1424
- finally {
1425
- try {
1426
- if (propNames_1_1 && !propNames_1_1.done && (_d = propNames_1.return)) _d.call(propNames_1);
1427
- }
1428
- finally { if (e_4) throw e_4.error; }
1337
+ else {
1338
+ this.matchHeightHelper(parent, target);
1429
1339
  }
1430
- return Object.freeze(object);
1431
1340
  };
1432
- /**
1433
- * Generates an unique identifier with 24 characters
1434
- */
1435
- Helper.getUID = function () {
1436
- var dt = new Date().getTime();
1437
- var uuid = 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1438
- // eslint-disable-next-line no-bitwise
1439
- var r = (dt + Math.random() * 16) % 16 | 0;
1440
- dt = Math.floor(dt / 16);
1441
- // eslint-disable-next-line no-bitwise
1442
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
1341
+ MatchHeightDirective.prototype.matchHeightHelper = function (parent, target) {
1342
+ return __awaiter(this, void 0, void 0, function () {
1343
+ var classNames, _loop_1, this_1, classNames_1, classNames_1_1, className, e_1_1;
1344
+ var e_1, _a;
1345
+ return __generator(this, function (_b) {
1346
+ switch (_b.label) {
1347
+ case 0:
1348
+ if (!parent) {
1349
+ return [2 /*return*/];
1350
+ }
1351
+ if (!Array.isArray(target)) {
1352
+ classNames = [target];
1353
+ }
1354
+ else {
1355
+ classNames = target;
1356
+ }
1357
+ _loop_1 = function (className) {
1358
+ var children, itemHeights, maxHeight;
1359
+ return __generator(this, function (_c) {
1360
+ switch (_c.label) {
1361
+ case 0:
1362
+ children = parent.getElementsByClassName(className);
1363
+ if (!children || children.length < 2) {
1364
+ return [2 /*return*/, "continue"];
1365
+ }
1366
+ if (!this_1.loadLazyImages) return [3 /*break*/, 2];
1367
+ return [4 /*yield*/, this_1.imageService.preLoadImages({ elements: children })];
1368
+ case 1:
1369
+ _c.sent();
1370
+ _c.label = 2;
1371
+ case 2:
1372
+ // reset all children height
1373
+ Array.from(children).forEach(function (element) {
1374
+ element.style.height = 'initial';
1375
+ });
1376
+ itemHeights = Array.from(children).map(function (element) {
1377
+ if (element.getBoundingClientRect) {
1378
+ return element.getBoundingClientRect().height;
1379
+ }
1380
+ return 0;
1381
+ });
1382
+ maxHeight = itemHeights.reduce(function (prev, curr) { return (curr > prev ? curr : prev); }, 0);
1383
+ // update the child structureElements height to the tallest one
1384
+ Array.from(children).forEach(function (element) { return (element.style.height = maxHeight + "px"); });
1385
+ return [2 /*return*/];
1386
+ }
1387
+ });
1388
+ };
1389
+ this_1 = this;
1390
+ _b.label = 1;
1391
+ case 1:
1392
+ _b.trys.push([1, 6, 7, 8]);
1393
+ classNames_1 = __values(classNames), classNames_1_1 = classNames_1.next();
1394
+ _b.label = 2;
1395
+ case 2:
1396
+ if (!!classNames_1_1.done) return [3 /*break*/, 5];
1397
+ className = classNames_1_1.value;
1398
+ return [5 /*yield**/, _loop_1(className)];
1399
+ case 3:
1400
+ _b.sent();
1401
+ _b.label = 4;
1402
+ case 4:
1403
+ classNames_1_1 = classNames_1.next();
1404
+ return [3 /*break*/, 2];
1405
+ case 5: return [3 /*break*/, 8];
1406
+ case 6:
1407
+ e_1_1 = _b.sent();
1408
+ e_1 = { error: e_1_1 };
1409
+ return [3 /*break*/, 8];
1410
+ case 7:
1411
+ try {
1412
+ if (classNames_1_1 && !classNames_1_1.done && (_a = classNames_1.return)) _a.call(classNames_1);
1413
+ }
1414
+ finally { if (e_1) throw e_1.error; }
1415
+ return [7 /*endfinally*/];
1416
+ case 8: return [2 /*return*/];
1417
+ }
1418
+ });
1443
1419
  });
1444
- return uuid;
1445
- };
1446
- /**
1447
- * Parse date string to date object
1448
- */
1449
- Helper.parseDate = function (dateString) {
1450
- var reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
1451
- var reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
1452
- if (typeof dateString === 'string') {
1453
- var isoExec = reISO.exec(dateString);
1454
- if (isoExec) {
1455
- return new Date(dateString);
1456
- }
1457
- var msAjaxExec = reMsAjax.exec(dateString);
1458
- if (msAjaxExec) {
1459
- var cleaned = msAjaxExec[1].split(/[-+,.]/);
1460
- return new Date(cleaned[0] ? +cleaned[0] : 0 - +cleaned[1]);
1461
- }
1462
- }
1463
- return dateString;
1464
1420
  };
1465
- /**
1466
- * Get browser name and version
1467
- */
1468
- Helper.getBrowser = function () {
1469
- var userAgent = navigator.userAgent;
1470
- var data = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
1471
- var version;
1472
- if (/trident/i.test(data[1])) {
1473
- version = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
1474
- return { name: 'IE', version: version[1] || '' };
1475
- }
1476
- if (data[1] === 'Chrome') {
1477
- version = userAgent.match(/\bOPR|Edge\/(\d+)/);
1478
- if (version != null) {
1479
- return { name: 'Opera', version: version[1] };
1480
- }
1421
+ return MatchHeightDirective;
1422
+ }());
1423
+ MatchHeightDirective.decorators = [
1424
+ { type: i0.Directive, args: [{
1425
+ selector: '[ltMatchHeight]',
1426
+ },] }
1427
+ ];
1428
+ MatchHeightDirective.ctorParameters = function () { return [
1429
+ { type: i0.ElementRef },
1430
+ { type: ImageService },
1431
+ { type: String, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] }
1432
+ ]; };
1433
+ MatchHeightDirective.propDecorators = {
1434
+ ltMatchHeight: [{ type: i0.Input }],
1435
+ loadLazyImages: [{ type: i0.Input }],
1436
+ onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
1437
+ };
1438
+
1439
+ /**
1440
+ * Reszise detection
1441
+ * (inpsired by: https://stackblitz.com/edit/angular-resizable)
1442
+ */
1443
+ var ResizableDirective = /** @class */ (function () {
1444
+ function ResizableDirective(el) {
1445
+ this.el = el;
1446
+ this.resizableGrabWidth = 8;
1447
+ this.resizableMinWidth = 10;
1448
+ this.dragging = false;
1449
+ }
1450
+ ResizableDirective.prototype.ngOnInit = function () {
1451
+ this.addListenerToDocument();
1452
+ this.addListenerToElement();
1453
+ };
1454
+ ResizableDirective.prototype.mouseMoveG = function (evt) {
1455
+ if (!this.dragging) {
1456
+ return;
1481
1457
  }
1482
- data = data[2] ? [data[1], data[2]] : [navigator.appName, navigator.appVersion, '-?'];
1483
- version = userAgent.match(/version\/(\d+)/i);
1484
- if (version !== null) {
1485
- data.splice(1, 1, version[1]);
1458
+ this.newWidth(evt.clientX - this.el.nativeElement.offsetLeft);
1459
+ evt.stopPropagation();
1460
+ };
1461
+ ResizableDirective.prototype.newWidth = function (wid) {
1462
+ var result = Math.max(this.resizableMinWidth, wid);
1463
+ this.el.nativeElement.style.width = result + 'px';
1464
+ };
1465
+ ResizableDirective.prototype.mouseDown = function (evt) {
1466
+ if (this.inDragRegion(evt)) {
1467
+ this.dragging = true;
1468
+ this.preventGlobalMouseEvents();
1469
+ evt.stopPropagation();
1486
1470
  }
1487
- return {
1488
- name: data[0],
1489
- version: data[1],
1490
- };
1491
1471
  };
1492
- /**
1493
- * Whether first parameter is a deep subset of second parameter
1494
- * Hint: functions will be ignored
1495
- */
1496
- Helper.isSubset = function (a, b) {
1497
- var e_5, _d, e_6, _e;
1498
- // Equal
1499
- if (a === b) {
1500
- return true;
1472
+ ResizableDirective.prototype.restoreGlobalMouseEvents = function () {
1473
+ document.body.style['pointer-events'] = 'auto';
1474
+ };
1475
+ ResizableDirective.prototype.mouseUpG = function (evt) {
1476
+ if (!this.dragging) {
1477
+ return;
1501
1478
  }
1502
- // Different type
1503
- if (typeof a !== typeof b) {
1504
- return false;
1479
+ this.restoreGlobalMouseEvents();
1480
+ this.dragging = false;
1481
+ evt.stopPropagation();
1482
+ };
1483
+ ResizableDirective.prototype.mouseMove = function (evt) {
1484
+ if (this.inDragRegion(evt) || this.dragging) {
1485
+ this.el.nativeElement.style.cursor = 'col-resize';
1505
1486
  }
1506
- // Process array
1507
- if (Array.isArray(a)) {
1508
- try {
1509
- for (var _f = __values(Object.entries(a)), _g = _f.next(); !_g.done; _g = _f.next()) {
1510
- var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
1511
- if (Helper.isSubset(value, b[key])) {
1512
- return false;
1513
- }
1514
- }
1515
- }
1516
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1517
- finally {
1518
- try {
1519
- if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
1520
- }
1521
- finally { if (e_5) throw e_5.error; }
1522
- }
1523
- return true;
1487
+ else {
1488
+ this.el.nativeElement.style.cursor = 'default';
1524
1489
  }
1525
- // Process object
1526
- if (typeof a === 'object') {
1527
- var plain = JSON.parse(JSON.stringify(a));
1528
- try {
1529
- for (var _j = __values(Object.entries(plain)), _k = _j.next(); !_k.done; _k = _j.next()) {
1530
- var _l = __read(_k.value, 2), key = _l[0], value = _l[1];
1531
- if (Helper.isSubset(value, b[key])) {
1532
- return false;
1533
- }
1534
- }
1535
- }
1536
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1537
- finally {
1538
- try {
1539
- if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
1540
- }
1541
- finally { if (e_6) throw e_6.error; }
1542
- }
1543
- return true;
1490
+ };
1491
+ ResizableDirective.prototype.preventGlobalMouseEvents = function () {
1492
+ document.body.style['pointer-events'] = 'none';
1493
+ };
1494
+ ResizableDirective.prototype.inDragRegion = function (evt) {
1495
+ return this.el.nativeElement.clientWidth - evt.clientX + this.el.nativeElement.offsetLeft < this.resizableGrabWidth;
1496
+ };
1497
+ ResizableDirective.prototype.addListenerToDocument = function () {
1498
+ var _this = this;
1499
+ document.addEventListener('mousemove', function (e) {
1500
+ _this.mouseMoveG(e);
1501
+ }, true);
1502
+ document.addEventListener('mouseup', function (e) {
1503
+ _this.mouseUpG(e);
1504
+ }, true);
1505
+ };
1506
+ ResizableDirective.prototype.addListenerToElement = function () {
1507
+ var _this = this;
1508
+ this.el.nativeElement.addEventListener('mousedown', function (e) {
1509
+ _this.mouseDown(e);
1510
+ }, true);
1511
+ this.el.nativeElement.addEventListener('mousemove', function (e) {
1512
+ _this.mouseMove(e);
1513
+ }, true);
1514
+ };
1515
+ return ResizableDirective;
1516
+ }());
1517
+ ResizableDirective.decorators = [
1518
+ { type: i0.Directive, args: [{
1519
+ selector: '[ltResizable]',
1520
+ },] }
1521
+ ];
1522
+ ResizableDirective.ctorParameters = function () { return [
1523
+ { type: i0.ElementRef }
1524
+ ]; };
1525
+ ResizableDirective.propDecorators = {
1526
+ resizableGrabWidth: [{ type: i0.Input }],
1527
+ resizableMinWidth: [{ type: i0.Input }]
1528
+ };
1529
+
1530
+ /**
1531
+ * Truncate string with ellipses
1532
+ */
1533
+ var EllipsesPipe = /** @class */ (function () {
1534
+ function EllipsesPipe() {
1535
+ }
1536
+ EllipsesPipe.prototype.transform = function (value, limit) {
1537
+ if (!value) {
1538
+ return null;
1544
1539
  }
1545
- // Else
1546
- return true;
1540
+ return value.length > limit ? value.substring(0, limit) + '...' : value;
1547
1541
  };
1548
- /**
1549
- * Whether parameters are equal (have equal properties)
1550
- * Hint: functions will be ignored
1551
- */
1552
- Helper.isEqual = function (a, b) {
1553
- return Helper.isSubset(a, b) && Helper.isSubset(b, a);
1542
+ return EllipsesPipe;
1543
+ }());
1544
+ EllipsesPipe.decorators = [
1545
+ { type: i0.Pipe, args: [{
1546
+ name: 'ltEllipses',
1547
+ },] }
1548
+ ];
1549
+
1550
+ /**
1551
+ * Declarate html as safe
1552
+ */
1553
+ var SafeHtmlPipe = /** @class */ (function () {
1554
+ function SafeHtmlPipe(sanitized) {
1555
+ this.sanitized = sanitized;
1556
+ }
1557
+ SafeHtmlPipe.prototype.transform = function (value) {
1558
+ return this.sanitized.bypassSecurityTrustHtml(value);
1554
1559
  };
1560
+ return SafeHtmlPipe;
1561
+ }());
1562
+ SafeHtmlPipe.decorators = [
1563
+ { type: i0.Pipe, args: [{ name: 'ltSafeHtml' },] }
1564
+ ];
1565
+ SafeHtmlPipe.ctorParameters = function () { return [
1566
+ { type: i1.DomSanitizer }
1567
+ ]; };
1568
+
1569
+ // Imported and exported elements
1570
+ var elements = [
1571
+ // Directives
1572
+ ContextMenuDirective,
1573
+ LazyLoadDirective,
1574
+ MatchHeightDirective,
1575
+ ResizableDirective,
1576
+ // Pipes
1577
+ EllipsesPipe,
1578
+ SafeHtmlPipe,
1579
+ ];
1580
+ /**
1581
+ * Base module
1582
+ */
1583
+ var BaseModule = /** @class */ (function () {
1584
+ function BaseModule() {
1585
+ }
1555
1586
  /**
1556
- * First level difference of two objects
1557
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
1558
- *
1559
- * @returns Record<string, any> Object with properties from first object
1587
+ * Set configuration of base module in root module of the app
1560
1588
  */
1561
- Helper.getDiff = function (a, b, clone) {
1562
- var e_7, _d;
1563
- if (clone === void 0) { clone = true; }
1564
- var result = {};
1565
- var firstObject = a;
1566
- if (clone) {
1567
- firstObject = JSON.parse(JSON.stringify(a));
1568
- }
1569
- try {
1570
- for (var _e = __values(Object.entries(firstObject)), _f = _e.next(); !_f.done; _f = _e.next()) {
1571
- var _g = __read(_f.value, 2), key = _g[0], value = _g[1];
1572
- if (!Helper.isSubset(value, b[key])) {
1573
- result[key] = value;
1574
- }
1575
- }
1589
+ BaseModule.forRoot = function (baseModuleConfig) {
1590
+ if (baseModuleConfig === void 0) { baseModuleConfig = {}; }
1591
+ // Default config
1592
+ var config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
1593
+ // Prepare providers
1594
+ var providers = [
1595
+ {
1596
+ provide: BASE_MODULE_CONFIG,
1597
+ useValue: baseModuleConfig,
1598
+ },
1599
+ ];
1600
+ // Add apollo features if API URL is set
1601
+ if (baseModuleConfig.apiUrl) {
1602
+ providers.push({
1603
+ provide: i1$1.APOLLO_OPTIONS,
1604
+ useFactory: apolloOptionsFactory,
1605
+ deps: [BASE_MODULE_CONFIG, http.HttpLink, AuthService],
1606
+ });
1576
1607
  }
1577
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1578
- finally {
1579
- try {
1580
- if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
1581
- }
1582
- finally { if (e_7) throw e_7.error; }
1608
+ else if (config.logging) {
1609
+ console.log('apiUrl is missing, ApolloLink is not initialized');
1583
1610
  }
1584
- return result;
1611
+ // Return root module
1612
+ return {
1613
+ ngModule: BaseModule,
1614
+ providers: providers,
1615
+ };
1585
1616
  };
1586
- return Helper;
1617
+ return BaseModule;
1587
1618
  }());
1619
+ BaseModule.decorators = [
1620
+ { type: i0.NgModule, args: [{
1621
+ declarations: elements,
1622
+ exports: elements,
1623
+ },] }
1624
+ ];
1588
1625
 
1589
1626
  /**
1590
1627
  * Standard class