@firestitch/common 12.6.3 → 12.6.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.
- package/bundles/firestitch-common.umd.js +903 -898
- package/bundles/firestitch-common.umd.js.map +1 -1
- package/esm2015/libs/format/currency/currency.js +5 -2
- package/esm2015/libs/format/number/number.js +5 -1
- package/fesm2015/firestitch-common.js +752 -747
- package/fesm2015/firestitch-common.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Pipe, LOCALE_ID, Inject, Directive, HostListener, Optional, Host, Input, NgModule } from '@angular/core';
|
|
3
3
|
import { CurrencyPipe, CommonModule } from '@angular/common';
|
|
4
|
-
import * as i1 from '@angular/material/input';
|
|
5
4
|
import { Subject, Observable, of, combineLatest, iif, throwError, timer, fromEvent, merge } from 'rxjs';
|
|
6
5
|
import { takeUntil, take, map, delay, finalize, shareReplay, retryWhen, tap, concatMap, distinctUntilChanged, share, filter as filter$1 } from 'rxjs/operators';
|
|
6
|
+
import * as i1 from '@angular/material/input';
|
|
7
7
|
|
|
8
8
|
class FsArray {
|
|
9
9
|
/**
|
|
@@ -610,878 +610,883 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
610
610
|
}]
|
|
611
611
|
}] });
|
|
612
612
|
|
|
613
|
-
function
|
|
614
|
-
return
|
|
613
|
+
function boolean(value) {
|
|
614
|
+
return String(value).toLowerCase() !== 'false' && !!value;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
const digitsInfo = Array.isArray(precision) ? precision : [precision, precision];
|
|
633
|
-
return new CurrencyPipe(locale).transform(amount, currencyCode, 'symbol', `1.${digitsInfo[0]}-${digitsInfo[1]}`);
|
|
617
|
+
function debounce(func, wait, immediate) {
|
|
618
|
+
let timeout;
|
|
619
|
+
return function () {
|
|
620
|
+
const context = this, args = arguments;
|
|
621
|
+
const later = function () {
|
|
622
|
+
timeout = null;
|
|
623
|
+
if (!immediate)
|
|
624
|
+
func.apply(context, args);
|
|
625
|
+
};
|
|
626
|
+
const callNow = immediate && !timeout;
|
|
627
|
+
clearTimeout(timeout);
|
|
628
|
+
timeout = setTimeout(later, wait);
|
|
629
|
+
if (callNow)
|
|
630
|
+
func.apply(context, args);
|
|
631
|
+
};
|
|
634
632
|
}
|
|
635
633
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
634
|
+
const KEY_CANCEL = 3;
|
|
635
|
+
const KEY_HELP = 6;
|
|
636
|
+
const KEY_BACKSPACE = 8;
|
|
637
|
+
const KEY_TAB = 9;
|
|
638
|
+
const KEY_CLEAR = 12;
|
|
639
|
+
const KEY_RETURN = 13;
|
|
640
|
+
const KEY_ENTER = 14;
|
|
641
|
+
const KEY_SHIFT = 16;
|
|
642
|
+
const KEY_CONTROL = 17;
|
|
643
|
+
const KEY_ALT = 18;
|
|
644
|
+
const KEY_PAUSE = 19;
|
|
645
|
+
const KEY_CAPS_LOCK = 20;
|
|
646
|
+
const KEY_ESCAPE = 27;
|
|
647
|
+
const KEY_SPACE = 32;
|
|
648
|
+
const KEY_PAGE_UP = 33;
|
|
649
|
+
const KEY_PAGE_DOWN = 34;
|
|
650
|
+
const KEY_END = 35;
|
|
651
|
+
const KEY_HOME = 36;
|
|
652
|
+
const KEY_LEFT = 37;
|
|
653
|
+
const KEY_UP = 38;
|
|
654
|
+
const KEY_RIGHT = 39;
|
|
655
|
+
const KEY_DOWN = 40;
|
|
656
|
+
const KEY_PRINTSCREEN = 44;
|
|
657
|
+
const KEY_INSERT = 45;
|
|
658
|
+
const KEY_DELETE = 46;
|
|
659
|
+
const KEY_0 = 48;
|
|
660
|
+
const KEY_1 = 49;
|
|
661
|
+
const KEY_2 = 50;
|
|
662
|
+
const KEY_3 = 51;
|
|
663
|
+
const KEY_4 = 52;
|
|
664
|
+
const KEY_5 = 53;
|
|
665
|
+
const KEY_6 = 54;
|
|
666
|
+
const KEY_7 = 55;
|
|
667
|
+
const KEY_8 = 56;
|
|
668
|
+
const KEY_9 = 57;
|
|
669
|
+
const KEY_SEMICOLON = 59;
|
|
670
|
+
const KEY_EQUALS = 61;
|
|
655
671
|
|
|
656
|
-
function
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
limit = value.substr(0, limit).lastIndexOf(' ');
|
|
672
|
+
function length(object) {
|
|
673
|
+
if (Array.isArray(object)) {
|
|
674
|
+
return object.length;
|
|
660
675
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
result += ellipsis;
|
|
676
|
+
if (object instanceof Object) {
|
|
677
|
+
return Object.keys(object).length;
|
|
664
678
|
}
|
|
665
|
-
return
|
|
679
|
+
return 0;
|
|
666
680
|
}
|
|
667
681
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
type: Pipe,
|
|
678
|
-
args: [{
|
|
679
|
-
name: 'fsFormatTruncate'
|
|
680
|
-
}]
|
|
681
|
-
}], ctorParameters: function () { return []; } });
|
|
682
|
-
|
|
683
|
-
class FsStopPropagationDirective {
|
|
684
|
-
preventClick(event) {
|
|
685
|
-
event.stopPropagation();
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
FsStopPropagationDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsStopPropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
689
|
-
FsStopPropagationDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsStopPropagationDirective, selector: "[fsStopPropagation]", host: { listeners: { "click": "preventClick($event)" } }, ngImport: i0 });
|
|
690
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsStopPropagationDirective, decorators: [{
|
|
691
|
-
type: Directive,
|
|
692
|
-
args: [{
|
|
693
|
-
selector: '[fsStopPropagation]',
|
|
694
|
-
}]
|
|
695
|
-
}], propDecorators: { preventClick: [{
|
|
696
|
-
type: HostListener,
|
|
697
|
-
args: ['click', ['$event']]
|
|
698
|
-
}] } });
|
|
682
|
+
function resolve(promise, defaults = []) {
|
|
683
|
+
const result = defaults;
|
|
684
|
+
return new Promise(resolve => {
|
|
685
|
+
promise.then(function (data) {
|
|
686
|
+
Object.keys(data).forEach(key => result[key] = data[key]);
|
|
687
|
+
resolve(result);
|
|
688
|
+
});
|
|
689
|
+
});
|
|
690
|
+
}
|
|
699
691
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
FsPreventDefaultDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPreventDefaultDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
706
|
-
FsPreventDefaultDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsPreventDefaultDirective, selector: "[fsPreventDefault]", host: { listeners: { "click": "preventClick($event)" } }, ngImport: i0 });
|
|
707
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPreventDefaultDirective, decorators: [{
|
|
708
|
-
type: Directive,
|
|
709
|
-
args: [{
|
|
710
|
-
selector: '[fsPreventDefault]',
|
|
711
|
-
}]
|
|
712
|
-
}], propDecorators: { preventClick: [{
|
|
713
|
-
type: HostListener,
|
|
714
|
-
args: ['click', ['$event']]
|
|
715
|
-
}] } });
|
|
692
|
+
function uuid() {
|
|
693
|
+
return guid('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
|
|
694
|
+
}
|
|
716
695
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
this.fsAutofocus = true;
|
|
722
|
-
}
|
|
723
|
-
ngAfterViewInit() {
|
|
724
|
-
if (this.fsAutofocus || this.fsAutofocus === undefined) {
|
|
725
|
-
this.focus();
|
|
696
|
+
function value(object, key, def) {
|
|
697
|
+
if (typeof object === 'object' || Array.isArray(object)) {
|
|
698
|
+
if (object.hasOwnProperty(key)) {
|
|
699
|
+
return object[key];
|
|
726
700
|
}
|
|
727
701
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
tmpEl.focus();
|
|
739
|
-
if (this._matInput) {
|
|
740
|
-
this._matInput.focus();
|
|
702
|
+
return def;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function isClass(value, cls) {
|
|
706
|
+
if (typeof value === 'object') {
|
|
707
|
+
if (typeof cls === 'string') {
|
|
708
|
+
if (value.constructor) {
|
|
709
|
+
if (value.constructor.name === cls) {
|
|
710
|
+
return true;
|
|
711
|
+
}
|
|
741
712
|
}
|
|
742
|
-
|
|
743
|
-
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
if (value instanceof cls) {
|
|
716
|
+
return true;
|
|
744
717
|
}
|
|
745
|
-
|
|
746
|
-
}, 50);
|
|
718
|
+
}
|
|
747
719
|
}
|
|
748
|
-
|
|
749
|
-
FsAutofocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAutofocusDirective, deps: [{ token: i1.MatInput, host: true, optional: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
750
|
-
FsAutofocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsAutofocusDirective, selector: "[fsAutofocus],[autofocus]", inputs: { fsAutofocus: "fsAutofocus" }, ngImport: i0 });
|
|
751
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAutofocusDirective, decorators: [{
|
|
752
|
-
type: Directive,
|
|
753
|
-
args: [{
|
|
754
|
-
selector: '[fsAutofocus],[autofocus]',
|
|
755
|
-
}]
|
|
756
|
-
}], ctorParameters: function () { return [{ type: i1.MatInput, decorators: [{
|
|
757
|
-
type: Optional
|
|
758
|
-
}, {
|
|
759
|
-
type: Host
|
|
760
|
-
}] }, { type: i0.ElementRef }]; }, propDecorators: { fsAutofocus: [{
|
|
761
|
-
type: Input
|
|
762
|
-
}] } });
|
|
763
|
-
|
|
764
|
-
function ordinalNumber(value) {
|
|
765
|
-
value = String(value);
|
|
766
|
-
const index = value.match `1?.$`;
|
|
767
|
-
const endings = [, 'st', 'nd', 'rd'];
|
|
768
|
-
const ending = endings[index] || 'th';
|
|
769
|
-
return value + ending;
|
|
720
|
+
return false;
|
|
770
721
|
}
|
|
771
722
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
FsFormatOrdinalNumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatOrdinalNumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
778
|
-
FsFormatOrdinalNumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatOrdinalNumberPipe, name: "fsFormatOrdinalNumber" });
|
|
779
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatOrdinalNumberPipe, decorators: [{
|
|
780
|
-
type: Pipe,
|
|
781
|
-
args: [{
|
|
782
|
-
name: 'fsFormatOrdinalNumber',
|
|
783
|
-
}]
|
|
784
|
-
}] });
|
|
723
|
+
function isNumeric(value) {
|
|
724
|
+
const str = String(value);
|
|
725
|
+
return str.length && !!str.match(/^-?\d*\.?\d*$/);
|
|
726
|
+
}
|
|
785
727
|
|
|
786
|
-
function
|
|
787
|
-
return !!
|
|
728
|
+
function isObject(value) {
|
|
729
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
788
730
|
}
|
|
789
731
|
|
|
790
|
-
function
|
|
791
|
-
|
|
792
|
-
return
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
function url(value) {
|
|
802
|
-
const expression = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#%[\]@!\$&'\(\)\*\+,;=.]+$/gm;
|
|
803
|
-
const regexp = new RegExp(expression);
|
|
804
|
-
return !!String(value).match(regexp);
|
|
732
|
+
function throttle(func, wait) {
|
|
733
|
+
let waiting = false; // Initially, we're not waiting
|
|
734
|
+
return function () {
|
|
735
|
+
if (!waiting) { // If we're not waiting
|
|
736
|
+
func.apply(null, arguments); // Execute users function
|
|
737
|
+
waiting = true; // Prevent future invocations
|
|
738
|
+
setTimeout(function () {
|
|
739
|
+
waiting = false; // And allow future invocations
|
|
740
|
+
}, wait);
|
|
741
|
+
}
|
|
742
|
+
};
|
|
805
743
|
}
|
|
806
744
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
745
|
+
class Operation {
|
|
746
|
+
constructor(target, name) {
|
|
747
|
+
this.ready$ = new Subject();
|
|
748
|
+
this.name = name ? name : guid();
|
|
749
|
+
if (target instanceof Observable) {
|
|
750
|
+
this.target = target;
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
this.target = of(target);
|
|
754
|
+
}
|
|
811
755
|
}
|
|
812
|
-
return value;
|
|
813
756
|
}
|
|
814
757
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
758
|
+
var QueueState;
|
|
759
|
+
(function (QueueState) {
|
|
760
|
+
QueueState["Idle"] = "idle";
|
|
761
|
+
QueueState["Processing"] = "processing";
|
|
762
|
+
})(QueueState || (QueueState = {}));
|
|
763
|
+
|
|
764
|
+
class Queue {
|
|
765
|
+
constructor(_limit = Infinity) {
|
|
766
|
+
this._limit = _limit;
|
|
767
|
+
this._queueStats = {
|
|
768
|
+
completed: 0,
|
|
769
|
+
total: 0,
|
|
770
|
+
errors: [],
|
|
771
|
+
};
|
|
772
|
+
this._doneQueueStats = {
|
|
773
|
+
completed: 0,
|
|
774
|
+
total: 0,
|
|
775
|
+
errors: [],
|
|
776
|
+
};
|
|
777
|
+
this._completeQueueStats = {
|
|
778
|
+
completed: 0,
|
|
779
|
+
total: 0,
|
|
780
|
+
errors: [],
|
|
820
781
|
};
|
|
782
|
+
this._done = new Subject();
|
|
783
|
+
this._queue = [];
|
|
784
|
+
this._inProgress = [];
|
|
785
|
+
this._state = QueueState.Idle;
|
|
786
|
+
this._destroy$ = new Subject();
|
|
787
|
+
// if(_targets) {
|
|
788
|
+
// _targets.forEach((target) => {
|
|
789
|
+
// this.push(target);
|
|
790
|
+
// });
|
|
791
|
+
// }
|
|
821
792
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
if (isarray) {
|
|
825
|
-
array.forEach(function (item, idx) {
|
|
826
|
-
if (query(item)) {
|
|
827
|
-
list.push(item);
|
|
828
|
-
}
|
|
829
|
-
});
|
|
793
|
+
get total() {
|
|
794
|
+
return this._queueStats.total;
|
|
830
795
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
if (query(array[key])) {
|
|
834
|
-
list[key] = array[key];
|
|
835
|
-
}
|
|
836
|
-
});
|
|
796
|
+
get completed() {
|
|
797
|
+
return this._queueStats.completed;
|
|
837
798
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
function inArray(values, array) {
|
|
842
|
-
if (!Array.isArray(values)) {
|
|
843
|
-
values = [values];
|
|
799
|
+
get pending() {
|
|
800
|
+
return this._queue.length;
|
|
844
801
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
return true;
|
|
848
|
-
}
|
|
802
|
+
get inProgress() {
|
|
803
|
+
return this._inProgress.length;
|
|
849
804
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
function index(array, name, value = null) {
|
|
854
|
-
const list = {};
|
|
855
|
-
array.forEach(function (item) {
|
|
856
|
-
list[item[name]] = value ? item[value] : item;
|
|
857
|
-
});
|
|
858
|
-
return list;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
function indexOf(array, query) {
|
|
862
|
-
if (typeof query !== 'function') {
|
|
863
|
-
const queryObj = query;
|
|
864
|
-
query = (item) => {
|
|
865
|
-
return compare(queryObj, item);
|
|
866
|
-
};
|
|
805
|
+
get errors() {
|
|
806
|
+
return this._queueStats.errors;
|
|
867
807
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
808
|
+
get state() {
|
|
809
|
+
return this._state;
|
|
810
|
+
}
|
|
811
|
+
get empty() {
|
|
812
|
+
return !this._queue.length && !this._inProgress.length;
|
|
813
|
+
}
|
|
814
|
+
get pendingOperations() {
|
|
815
|
+
return this._queue
|
|
816
|
+
.map((operation) => operation.name);
|
|
817
|
+
}
|
|
818
|
+
get inProgressOperations() {
|
|
819
|
+
return this._inProgress
|
|
820
|
+
.map((operation) => operation.name);
|
|
821
|
+
}
|
|
822
|
+
isProcessing() {
|
|
823
|
+
return this._state === QueueState.Processing;
|
|
824
|
+
}
|
|
825
|
+
isIdle() {
|
|
826
|
+
return this._state === QueueState.Idle;
|
|
827
|
+
}
|
|
828
|
+
setLimit(value) {
|
|
829
|
+
this._limit = value;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* @depreated
|
|
833
|
+
*/
|
|
834
|
+
subscribe(fun, err, complete) {
|
|
835
|
+
this.observe$
|
|
836
|
+
.subscribe(fun, err, complete);
|
|
837
|
+
}
|
|
838
|
+
get observe$() {
|
|
839
|
+
return this._done
|
|
840
|
+
.pipe(takeUntil(this._destroy$));
|
|
841
|
+
}
|
|
842
|
+
get complete$() {
|
|
843
|
+
if (!this.isProcessing()) {
|
|
844
|
+
return of({ total: 0, completed: 0, errors: [] });
|
|
871
845
|
}
|
|
846
|
+
return this.observe$
|
|
847
|
+
.pipe(take(1), map(() => (this._completeQueueStats)));
|
|
872
848
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
unordered[key] = value;
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
function list(array, property, index = null) {
|
|
889
|
-
const resultList = index ? {} : [];
|
|
890
|
-
array.forEach(function (item, idx) {
|
|
891
|
-
if (index) {
|
|
892
|
-
resultList[item[index]] = item[property];
|
|
849
|
+
complete(fun, err, complete) {
|
|
850
|
+
this.complete$.subscribe(fun, err, complete);
|
|
851
|
+
}
|
|
852
|
+
push(target, name) {
|
|
853
|
+
const operation = new Operation(target, name);
|
|
854
|
+
this._queueStats.total++;
|
|
855
|
+
this._doneQueueStats.total++;
|
|
856
|
+
this._completeQueueStats.total++;
|
|
857
|
+
this._state = QueueState.Processing;
|
|
858
|
+
if (this._inProgress.length < this._limit) {
|
|
859
|
+
this._processOperation(operation);
|
|
893
860
|
}
|
|
894
861
|
else {
|
|
895
|
-
|
|
862
|
+
this._queue.push(operation);
|
|
896
863
|
}
|
|
897
|
-
|
|
898
|
-
return resultList;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
function nameValue(array, name, value) {
|
|
902
|
-
const list = [];
|
|
903
|
-
if (name || value) {
|
|
904
|
-
const nameFn = typeof name === 'function' ? name : function (item) {
|
|
905
|
-
return item[name];
|
|
906
|
-
};
|
|
907
|
-
const valueFn = typeof value === 'function' ? value : function (item) {
|
|
908
|
-
return item[value];
|
|
909
|
-
};
|
|
910
|
-
array.forEach(function (item) {
|
|
911
|
-
list.push({ name: nameFn(item), value: valueFn(item) });
|
|
912
|
-
});
|
|
864
|
+
return operation.ready$;
|
|
913
865
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
866
|
+
clear() {
|
|
867
|
+
this._queue = [];
|
|
868
|
+
this._state = QueueState.Idle;
|
|
869
|
+
this._queueStats = {
|
|
870
|
+
total: 0,
|
|
871
|
+
errors: [],
|
|
872
|
+
completed: 0,
|
|
873
|
+
};
|
|
874
|
+
this._clearDoneQueueStats();
|
|
918
875
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
function remove(array, query) {
|
|
923
|
-
const idx = indexOf(array, query);
|
|
924
|
-
if (idx >= 0) {
|
|
925
|
-
return array.splice(idx, 1);
|
|
876
|
+
destroy() {
|
|
877
|
+
this._done.complete();
|
|
878
|
+
this.clear();
|
|
926
879
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
if (
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
else if (a[queryStr] > b[queryStr]) {
|
|
939
|
-
return -1;
|
|
940
|
-
}
|
|
880
|
+
_processOperation(operation) {
|
|
881
|
+
this._inProgress.push(operation);
|
|
882
|
+
operation.target
|
|
883
|
+
.pipe(delay(200), // Hack to prevent extra quick proccess execution
|
|
884
|
+
finalize(() => {
|
|
885
|
+
const opIndex = this._inProgress.indexOf(operation);
|
|
886
|
+
this._inProgress.splice(opIndex, 1);
|
|
887
|
+
if (this.empty) {
|
|
888
|
+
this._state = QueueState.Idle;
|
|
889
|
+
this._done.next(this._doneQueueStats);
|
|
890
|
+
this._clearDoneQueueStats();
|
|
941
891
|
}
|
|
942
892
|
else {
|
|
943
|
-
if (
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
else if (a[queryStr] < b[queryStr]) {
|
|
947
|
-
return -1;
|
|
893
|
+
if (this._queue.length) {
|
|
894
|
+
const queueItem = this._queue.shift();
|
|
895
|
+
this._processOperation(queueItem);
|
|
948
896
|
}
|
|
949
897
|
}
|
|
950
|
-
|
|
898
|
+
}), takeUntil(this._destroy$)).subscribe({
|
|
899
|
+
next: (data) => {
|
|
900
|
+
operation.ready$.next(data);
|
|
901
|
+
},
|
|
902
|
+
error: (error) => {
|
|
903
|
+
this._queueStats.errors.push(error);
|
|
904
|
+
this._doneQueueStats.errors.push(error);
|
|
905
|
+
this._completeQueueStats.errors.push(error);
|
|
906
|
+
operation.ready$.error(error);
|
|
907
|
+
},
|
|
908
|
+
complete: () => {
|
|
909
|
+
this._queueStats.completed++;
|
|
910
|
+
this._doneQueueStats.completed++;
|
|
911
|
+
this._completeQueueStats.completed++;
|
|
912
|
+
operation.ready$.complete();
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
_clearDoneQueueStats() {
|
|
917
|
+
this._doneQueueStats = {
|
|
918
|
+
total: 0,
|
|
919
|
+
errors: [],
|
|
920
|
+
completed: 0,
|
|
951
921
|
};
|
|
952
922
|
}
|
|
953
|
-
array.sort(query);
|
|
954
|
-
return array;
|
|
955
923
|
}
|
|
956
924
|
|
|
957
|
-
function
|
|
958
|
-
return
|
|
925
|
+
function removeQueryParams(path) {
|
|
926
|
+
return path.split('?')[0];
|
|
959
927
|
}
|
|
960
928
|
|
|
961
|
-
function
|
|
962
|
-
const
|
|
963
|
-
return
|
|
929
|
+
function getNormalizedPath(locationSrv) {
|
|
930
|
+
const path = locationSrv.prepareExternalUrl(locationSrv.path());
|
|
931
|
+
return removeQueryParams(path);
|
|
964
932
|
}
|
|
965
933
|
|
|
966
|
-
function
|
|
967
|
-
|
|
934
|
+
function ordinalNumber(value) {
|
|
935
|
+
value = String(value);
|
|
936
|
+
const index = value.match `1?.$`;
|
|
937
|
+
const endings = [, 'st', 'nd', 'rd'];
|
|
938
|
+
const ending = endings[index] || 'th';
|
|
939
|
+
return value + ending;
|
|
968
940
|
}
|
|
969
941
|
|
|
970
|
-
function
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
const later = function () {
|
|
975
|
-
timeout = null;
|
|
976
|
-
if (!immediate)
|
|
977
|
-
func.apply(context, args);
|
|
978
|
-
};
|
|
979
|
-
const callNow = immediate && !timeout;
|
|
980
|
-
clearTimeout(timeout);
|
|
981
|
-
timeout = setTimeout(later, wait);
|
|
982
|
-
if (callNow)
|
|
983
|
-
func.apply(context, args);
|
|
984
|
-
};
|
|
942
|
+
function round(num, decimalPlaces = 0) {
|
|
943
|
+
num = parseFloat(parseFloat(num).toPrecision(Number.MAX_SAFE_INTEGER.toString().length - 1));
|
|
944
|
+
const p = Math.pow(10, decimalPlaces);
|
|
945
|
+
return Math.round(num * p) / p;
|
|
985
946
|
}
|
|
986
947
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
const KEY_TAB = 9;
|
|
991
|
-
const KEY_CLEAR = 12;
|
|
992
|
-
const KEY_RETURN = 13;
|
|
993
|
-
const KEY_ENTER = 14;
|
|
994
|
-
const KEY_SHIFT = 16;
|
|
995
|
-
const KEY_CONTROL = 17;
|
|
996
|
-
const KEY_ALT = 18;
|
|
997
|
-
const KEY_PAUSE = 19;
|
|
998
|
-
const KEY_CAPS_LOCK = 20;
|
|
999
|
-
const KEY_ESCAPE = 27;
|
|
1000
|
-
const KEY_SPACE = 32;
|
|
1001
|
-
const KEY_PAGE_UP = 33;
|
|
1002
|
-
const KEY_PAGE_DOWN = 34;
|
|
1003
|
-
const KEY_END = 35;
|
|
1004
|
-
const KEY_HOME = 36;
|
|
1005
|
-
const KEY_LEFT = 37;
|
|
1006
|
-
const KEY_UP = 38;
|
|
1007
|
-
const KEY_RIGHT = 39;
|
|
1008
|
-
const KEY_DOWN = 40;
|
|
1009
|
-
const KEY_PRINTSCREEN = 44;
|
|
1010
|
-
const KEY_INSERT = 45;
|
|
1011
|
-
const KEY_DELETE = 46;
|
|
1012
|
-
const KEY_0 = 48;
|
|
1013
|
-
const KEY_1 = 49;
|
|
1014
|
-
const KEY_2 = 50;
|
|
1015
|
-
const KEY_3 = 51;
|
|
1016
|
-
const KEY_4 = 52;
|
|
1017
|
-
const KEY_5 = 53;
|
|
1018
|
-
const KEY_6 = 54;
|
|
1019
|
-
const KEY_7 = 55;
|
|
1020
|
-
const KEY_8 = 56;
|
|
1021
|
-
const KEY_9 = 57;
|
|
1022
|
-
const KEY_SEMICOLON = 59;
|
|
1023
|
-
const KEY_EQUALS = 61;
|
|
1024
|
-
|
|
1025
|
-
function length(object) {
|
|
1026
|
-
if (Array.isArray(object)) {
|
|
1027
|
-
return object.length;
|
|
1028
|
-
}
|
|
1029
|
-
if (object instanceof Object) {
|
|
1030
|
-
return Object.keys(object).length;
|
|
948
|
+
function clone(obj) {
|
|
949
|
+
if (obj instanceof Date) {
|
|
950
|
+
return new Date(obj);
|
|
1031
951
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
const result = defaults;
|
|
1037
|
-
return new Promise(resolve => {
|
|
1038
|
-
promise.then(function (data) {
|
|
1039
|
-
Object.keys(data).forEach(key => result[key] = data[key]);
|
|
1040
|
-
resolve(result);
|
|
1041
|
-
});
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
function uuid() {
|
|
1046
|
-
return guid('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
function value(object, key, def) {
|
|
1050
|
-
if (typeof object === 'object' || Array.isArray(object)) {
|
|
1051
|
-
if (object.hasOwnProperty(key)) {
|
|
1052
|
-
return object[key];
|
|
952
|
+
else if (Array.isArray(obj)) {
|
|
953
|
+
const arr = [];
|
|
954
|
+
for (let i = 0; i < obj.length; i++) {
|
|
955
|
+
arr[i] = clone(obj[i]);
|
|
1053
956
|
}
|
|
957
|
+
return arr;
|
|
1054
958
|
}
|
|
1055
|
-
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
if (typeof value === 'object') {
|
|
1060
|
-
if (typeof cls === 'string') {
|
|
1061
|
-
if (value.constructor) {
|
|
1062
|
-
if (value.constructor.name === cls) {
|
|
1063
|
-
return true;
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
else {
|
|
1068
|
-
if (value instanceof cls) {
|
|
1069
|
-
return true;
|
|
1070
|
-
}
|
|
959
|
+
else if (typeof (obj) === 'object') {
|
|
960
|
+
const cloned = {};
|
|
961
|
+
for (let key in obj) {
|
|
962
|
+
cloned[key] = clone(obj[key]);
|
|
1071
963
|
}
|
|
964
|
+
return cloned;
|
|
1072
965
|
}
|
|
1073
|
-
return
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function isNumeric(value) {
|
|
1077
|
-
const str = String(value);
|
|
1078
|
-
return str.length && !!str.match(/^-?\d*\.?\d*$/);
|
|
966
|
+
return obj;
|
|
1079
967
|
}
|
|
1080
968
|
|
|
1081
|
-
function
|
|
1082
|
-
|
|
969
|
+
function toString(value) {
|
|
970
|
+
if (value === null || value === undefined) {
|
|
971
|
+
return '';
|
|
972
|
+
}
|
|
973
|
+
return `${value}`;
|
|
1083
974
|
}
|
|
1084
975
|
|
|
1085
|
-
function
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
waiting = false; // And allow future invocations
|
|
1093
|
-
}, wait);
|
|
976
|
+
function isArrayEqual(arr1, arr2) {
|
|
977
|
+
if (!Array.isArray(arr1) || !Array.isArray(arr2) || arr1.length !== arr2.length) {
|
|
978
|
+
return false;
|
|
979
|
+
}
|
|
980
|
+
const sortFn = (a, b) => {
|
|
981
|
+
if (a < b) {
|
|
982
|
+
return -1;
|
|
1094
983
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
class Operation {
|
|
1099
|
-
constructor(target, name) {
|
|
1100
|
-
this.ready$ = new Subject();
|
|
1101
|
-
this.name = name ? name : guid();
|
|
1102
|
-
if (target instanceof Observable) {
|
|
1103
|
-
this.target = target;
|
|
984
|
+
else if (a > b) {
|
|
985
|
+
return 1;
|
|
1104
986
|
}
|
|
1105
987
|
else {
|
|
1106
|
-
|
|
988
|
+
return 0;
|
|
1107
989
|
}
|
|
1108
|
-
}
|
|
990
|
+
};
|
|
991
|
+
arr1 = [...arr1].sort(sortFn);
|
|
992
|
+
arr2 = [...arr2].sort(sortFn);
|
|
993
|
+
return arr1.every((value, index) => {
|
|
994
|
+
return value === arr2[index];
|
|
995
|
+
});
|
|
1109
996
|
}
|
|
1110
997
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
total: 0,
|
|
1123
|
-
errors: [],
|
|
1124
|
-
};
|
|
1125
|
-
this._doneQueueStats = {
|
|
1126
|
-
completed: 0,
|
|
1127
|
-
total: 0,
|
|
1128
|
-
errors: [],
|
|
1129
|
-
};
|
|
1130
|
-
this._completeQueueStats = {
|
|
1131
|
-
completed: 0,
|
|
1132
|
-
total: 0,
|
|
1133
|
-
errors: [],
|
|
1134
|
-
};
|
|
1135
|
-
this._done = new Subject();
|
|
1136
|
-
this._queue = [];
|
|
1137
|
-
this._inProgress = [];
|
|
1138
|
-
this._state = QueueState.Idle;
|
|
1139
|
-
this._destroy$ = new Subject();
|
|
1140
|
-
// if(_targets) {
|
|
1141
|
-
// _targets.forEach((target) => {
|
|
1142
|
-
// this.push(target);
|
|
1143
|
-
// });
|
|
1144
|
-
// }
|
|
998
|
+
const fsSourceLoader = (function () {
|
|
999
|
+
let _document;
|
|
1000
|
+
let _headElement;
|
|
1001
|
+
const _sources = new Map();
|
|
1002
|
+
const _loadedResources = new Map();
|
|
1003
|
+
// bad way but don't want to bother developer
|
|
1004
|
+
setDocument(document);
|
|
1005
|
+
// but developer can set document at any time
|
|
1006
|
+
function setDocument(document) {
|
|
1007
|
+
_document = document;
|
|
1008
|
+
_headElement = _document === null || _document === void 0 ? void 0 : _document.head;
|
|
1145
1009
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1010
|
+
/**
|
|
1011
|
+
* register a list of the resources for future loading
|
|
1012
|
+
*
|
|
1013
|
+
* example:
|
|
1014
|
+
* sourceLoader.registerResources({
|
|
1015
|
+
* froala: [
|
|
1016
|
+
* '/assets/js/froala/froala_editor.min.js',
|
|
1017
|
+
* '/assets/css/froala_editor.pkgd.min.css',
|
|
1018
|
+
* ],
|
|
1019
|
+
* froala_align: '/assets/js/froala/plugins/align.min.js',
|
|
1020
|
+
* froala_colors: '/assets/js/froala/plugins/colors.min.js',
|
|
1021
|
+
* froala_image: '/assets/js/froala/plugins/image.min.js',
|
|
1022
|
+
* });
|
|
1023
|
+
*
|
|
1024
|
+
*/
|
|
1025
|
+
function registerResources(resources) {
|
|
1026
|
+
Object.entries(resources)
|
|
1027
|
+
.forEach(([name, path]) => {
|
|
1028
|
+
if (typeof path === 'string') {
|
|
1029
|
+
path = [path];
|
|
1030
|
+
}
|
|
1031
|
+
if (!_sources.has(name)) {
|
|
1032
|
+
_sources.set(name, new Set());
|
|
1033
|
+
}
|
|
1034
|
+
const resourcesList = _sources.get(name);
|
|
1035
|
+
path.forEach((p) => {
|
|
1036
|
+
resourcesList.add(p);
|
|
1037
|
+
});
|
|
1038
|
+
});
|
|
1148
1039
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* load any resource previously registered
|
|
1042
|
+
*
|
|
1043
|
+
* sourceLoader.loadResource('froala')
|
|
1044
|
+
*
|
|
1045
|
+
* or load any js/css file
|
|
1046
|
+
*
|
|
1047
|
+
* sourceLoader.loadResource('/assets/my-source.js')
|
|
1048
|
+
*
|
|
1049
|
+
*/
|
|
1050
|
+
function loadResource(name) {
|
|
1051
|
+
if (_loadedResources.has(name)) {
|
|
1052
|
+
return _loadedResources.get(name);
|
|
1053
|
+
}
|
|
1054
|
+
if (_sources.has(name)) {
|
|
1055
|
+
const sourcesForLoading = [..._sources.get(name)]
|
|
1056
|
+
.map((path) => {
|
|
1057
|
+
return _loadResource(path);
|
|
1058
|
+
})
|
|
1059
|
+
.filter((v) => !!v);
|
|
1060
|
+
return combineLatest(sourcesForLoading);
|
|
1061
|
+
}
|
|
1062
|
+
return _loadResource(name);
|
|
1151
1063
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1064
|
+
/**
|
|
1065
|
+
* the same as `loadResource` but you can pass list of the resources for loading
|
|
1066
|
+
*/
|
|
1067
|
+
function loadResources(listOfResources) {
|
|
1068
|
+
const resourcesToLoad = listOfResources
|
|
1069
|
+
.reduce((acc, name) => {
|
|
1070
|
+
const loading$ = loadResource(name);
|
|
1071
|
+
if (loading$) {
|
|
1072
|
+
acc.push(loading$);
|
|
1073
|
+
}
|
|
1074
|
+
return acc;
|
|
1075
|
+
}, []);
|
|
1076
|
+
return combineLatest(resourcesToLoad);
|
|
1154
1077
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1078
|
+
///
|
|
1079
|
+
function _loadResource(path) {
|
|
1080
|
+
if (_isStylesUrl(path)) {
|
|
1081
|
+
return _loadStyles(path);
|
|
1082
|
+
}
|
|
1083
|
+
if (_isJavascriptUrl(path)) {
|
|
1084
|
+
return _loadJs(path);
|
|
1085
|
+
}
|
|
1086
|
+
console.warn(`Resource ${path} can not be identified and loaded`);
|
|
1087
|
+
return null;
|
|
1157
1088
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1089
|
+
function _loadJs(scriptPath) {
|
|
1090
|
+
if (!_loadedResources.has(scriptPath)) {
|
|
1091
|
+
const obs$ = new Observable((obs) => {
|
|
1092
|
+
const script = document.createElement('script');
|
|
1093
|
+
script.src = scriptPath;
|
|
1094
|
+
_headElement.appendChild(script);
|
|
1095
|
+
script.onload = () => {
|
|
1096
|
+
obs.next();
|
|
1097
|
+
obs.complete();
|
|
1098
|
+
};
|
|
1099
|
+
script.onerror = (err) => {
|
|
1100
|
+
obs.error(err);
|
|
1101
|
+
};
|
|
1102
|
+
}).pipe(shareReplay(1));
|
|
1103
|
+
_loadedResources.set(scriptPath, obs$);
|
|
1104
|
+
}
|
|
1105
|
+
return _loadedResources.get(scriptPath);
|
|
1160
1106
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1107
|
+
function _loadStyles(stylePath) {
|
|
1108
|
+
if (!_loadedResources.has(stylePath)) {
|
|
1109
|
+
const obs$ = new Observable((obs) => {
|
|
1110
|
+
const style = document.createElement('link');
|
|
1111
|
+
style.id = stylePath;
|
|
1112
|
+
style.rel = 'stylesheet';
|
|
1113
|
+
style.href = `${stylePath}`;
|
|
1114
|
+
_headElement.appendChild(style);
|
|
1115
|
+
style.onload = () => {
|
|
1116
|
+
obs.next();
|
|
1117
|
+
obs.complete();
|
|
1118
|
+
};
|
|
1119
|
+
style.onerror = (err) => {
|
|
1120
|
+
obs.error(err);
|
|
1121
|
+
};
|
|
1122
|
+
});
|
|
1123
|
+
_loadedResources.set(stylePath, obs$);
|
|
1124
|
+
}
|
|
1125
|
+
return _loadedResources.get(stylePath);
|
|
1163
1126
|
}
|
|
1164
|
-
|
|
1165
|
-
return
|
|
1127
|
+
function _isJavascriptUrl(url) {
|
|
1128
|
+
return url.endsWith('.js');
|
|
1166
1129
|
}
|
|
1167
|
-
|
|
1168
|
-
return
|
|
1169
|
-
.map((operation) => operation.name);
|
|
1130
|
+
function _isStylesUrl(url) {
|
|
1131
|
+
return url.endsWith('.css');
|
|
1170
1132
|
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1133
|
+
return {
|
|
1134
|
+
setDocument,
|
|
1135
|
+
registerResources,
|
|
1136
|
+
loadResource,
|
|
1137
|
+
loadResources,
|
|
1138
|
+
};
|
|
1139
|
+
})();
|
|
1140
|
+
|
|
1141
|
+
function number(value, decimals) {
|
|
1142
|
+
if (isNumeric(decimals)) {
|
|
1143
|
+
value = round(value, decimals);
|
|
1174
1144
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1145
|
+
return Number(value || 0).toLocaleString(undefined, { maximumFractionDigits: decimals });
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
class FsFormatNumberPipe {
|
|
1149
|
+
transform(value, decimals) {
|
|
1150
|
+
return number(value, decimals);
|
|
1177
1151
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1152
|
+
}
|
|
1153
|
+
FsFormatNumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatNumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1154
|
+
FsFormatNumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatNumberPipe, name: "fsFormatNumber" });
|
|
1155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatNumberPipe, decorators: [{
|
|
1156
|
+
type: Pipe,
|
|
1157
|
+
args: [{
|
|
1158
|
+
name: 'fsFormatNumber'
|
|
1159
|
+
}]
|
|
1160
|
+
}] });
|
|
1161
|
+
|
|
1162
|
+
function currency(amount, precision = [2, 10], currencyCode = 'USD', locale = 'en-US') {
|
|
1163
|
+
const digitsInfo = Array.isArray(precision) ? precision : [precision, precision];
|
|
1164
|
+
amount = round(amount, digitsInfo[1]);
|
|
1165
|
+
return new CurrencyPipe(locale)
|
|
1166
|
+
.transform(amount, currencyCode, 'symbol', `1.${digitsInfo[0]}-${digitsInfo[1]}`);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
class FsFormatCurrencyPipe {
|
|
1170
|
+
constructor(locale) {
|
|
1171
|
+
this.locale = locale;
|
|
1180
1172
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1173
|
+
transform(amount, precision = 2, currencyCode) {
|
|
1174
|
+
return currency(amount, precision, currencyCode);
|
|
1183
1175
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1176
|
+
}
|
|
1177
|
+
FsFormatCurrencyPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatCurrencyPipe, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1178
|
+
FsFormatCurrencyPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatCurrencyPipe, name: "fsFormatCurrency" });
|
|
1179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatCurrencyPipe, decorators: [{
|
|
1180
|
+
type: Pipe,
|
|
1181
|
+
args: [{
|
|
1182
|
+
name: 'fsFormatCurrency'
|
|
1183
|
+
}]
|
|
1184
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1185
|
+
type: Inject,
|
|
1186
|
+
args: [LOCALE_ID]
|
|
1187
|
+
}] }]; } });
|
|
1188
|
+
|
|
1189
|
+
function truncate(value, limit = 100, completeWords = false, ellipsis = '...') {
|
|
1190
|
+
value = value || '';
|
|
1191
|
+
if (completeWords) {
|
|
1192
|
+
limit = value.substr(0, limit).lastIndexOf(' ');
|
|
1190
1193
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
+
let result = `${value.substr(0, limit)}`;
|
|
1195
|
+
if (result !== value) {
|
|
1196
|
+
result += ellipsis;
|
|
1194
1197
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1198
|
+
return result;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
class FsFormatTruncatePipe {
|
|
1202
|
+
constructor() { }
|
|
1203
|
+
transform(value, limit, completeWords, ellipsis) {
|
|
1204
|
+
return truncate(value, limit, completeWords, ellipsis);
|
|
1201
1205
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1206
|
+
}
|
|
1207
|
+
FsFormatTruncatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatTruncatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1208
|
+
FsFormatTruncatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatTruncatePipe, name: "fsFormatTruncate" });
|
|
1209
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatTruncatePipe, decorators: [{
|
|
1210
|
+
type: Pipe,
|
|
1211
|
+
args: [{
|
|
1212
|
+
name: 'fsFormatTruncate'
|
|
1213
|
+
}]
|
|
1214
|
+
}], ctorParameters: function () { return []; } });
|
|
1215
|
+
|
|
1216
|
+
class FsStopPropagationDirective {
|
|
1217
|
+
preventClick(event) {
|
|
1218
|
+
event.stopPropagation();
|
|
1204
1219
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1220
|
+
}
|
|
1221
|
+
FsStopPropagationDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsStopPropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1222
|
+
FsStopPropagationDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsStopPropagationDirective, selector: "[fsStopPropagation]", host: { listeners: { "click": "preventClick($event)" } }, ngImport: i0 });
|
|
1223
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsStopPropagationDirective, decorators: [{
|
|
1224
|
+
type: Directive,
|
|
1225
|
+
args: [{
|
|
1226
|
+
selector: '[fsStopPropagation]',
|
|
1227
|
+
}]
|
|
1228
|
+
}], propDecorators: { preventClick: [{
|
|
1229
|
+
type: HostListener,
|
|
1230
|
+
args: ['click', ['$event']]
|
|
1231
|
+
}] } });
|
|
1232
|
+
|
|
1233
|
+
class FsPreventDefaultDirective {
|
|
1234
|
+
preventClick(event) {
|
|
1235
|
+
event.preventDefault();
|
|
1218
1236
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1237
|
+
}
|
|
1238
|
+
FsPreventDefaultDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPreventDefaultDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1239
|
+
FsPreventDefaultDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsPreventDefaultDirective, selector: "[fsPreventDefault]", host: { listeners: { "click": "preventClick($event)" } }, ngImport: i0 });
|
|
1240
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsPreventDefaultDirective, decorators: [{
|
|
1241
|
+
type: Directive,
|
|
1242
|
+
args: [{
|
|
1243
|
+
selector: '[fsPreventDefault]',
|
|
1244
|
+
}]
|
|
1245
|
+
}], propDecorators: { preventClick: [{
|
|
1246
|
+
type: HostListener,
|
|
1247
|
+
args: ['click', ['$event']]
|
|
1248
|
+
}] } });
|
|
1249
|
+
|
|
1250
|
+
class FsAutofocusDirective {
|
|
1251
|
+
constructor(_matInput, _el) {
|
|
1252
|
+
this._matInput = _matInput;
|
|
1253
|
+
this._el = _el;
|
|
1254
|
+
this.fsAutofocus = true;
|
|
1228
1255
|
}
|
|
1229
|
-
|
|
1230
|
-
this.
|
|
1231
|
-
|
|
1256
|
+
ngAfterViewInit() {
|
|
1257
|
+
if (this.fsAutofocus || this.fsAutofocus === undefined) {
|
|
1258
|
+
this.focus();
|
|
1259
|
+
}
|
|
1232
1260
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
.
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
if (this._queue.length) {
|
|
1247
|
-
const queueItem = this._queue.shift();
|
|
1248
|
-
this._processOperation(queueItem);
|
|
1249
|
-
}
|
|
1261
|
+
focus() {
|
|
1262
|
+
setTimeout(() => {
|
|
1263
|
+
const tmpEl = document.createElement('input');
|
|
1264
|
+
tmpEl.style.width = '0';
|
|
1265
|
+
tmpEl.style.height = '0';
|
|
1266
|
+
tmpEl.style.margin = '0';
|
|
1267
|
+
tmpEl.style.padding = '0';
|
|
1268
|
+
tmpEl.style.border = '0';
|
|
1269
|
+
tmpEl.style.opacity = '0';
|
|
1270
|
+
document.body.appendChild(tmpEl);
|
|
1271
|
+
tmpEl.focus();
|
|
1272
|
+
if (this._matInput) {
|
|
1273
|
+
this._matInput.focus();
|
|
1250
1274
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
operation.ready$.next(data);
|
|
1254
|
-
},
|
|
1255
|
-
error: (error) => {
|
|
1256
|
-
this._queueStats.errors.push(error);
|
|
1257
|
-
this._doneQueueStats.errors.push(error);
|
|
1258
|
-
this._completeQueueStats.errors.push(error);
|
|
1259
|
-
operation.ready$.error(error);
|
|
1260
|
-
},
|
|
1261
|
-
complete: () => {
|
|
1262
|
-
this._queueStats.completed++;
|
|
1263
|
-
this._doneQueueStats.completed++;
|
|
1264
|
-
this._completeQueueStats.completed++;
|
|
1265
|
-
operation.ready$.complete();
|
|
1275
|
+
else if (this._el.nativeElement.focus) {
|
|
1276
|
+
this._el.nativeElement.focus();
|
|
1266
1277
|
}
|
|
1267
|
-
|
|
1278
|
+
document.body.removeChild(tmpEl);
|
|
1279
|
+
}, 50);
|
|
1268
1280
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1281
|
+
}
|
|
1282
|
+
FsAutofocusDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAutofocusDirective, deps: [{ token: i1.MatInput, host: true, optional: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1283
|
+
FsAutofocusDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsAutofocusDirective, selector: "[fsAutofocus],[autofocus]", inputs: { fsAutofocus: "fsAutofocus" }, ngImport: i0 });
|
|
1284
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsAutofocusDirective, decorators: [{
|
|
1285
|
+
type: Directive,
|
|
1286
|
+
args: [{
|
|
1287
|
+
selector: '[fsAutofocus],[autofocus]',
|
|
1288
|
+
}]
|
|
1289
|
+
}], ctorParameters: function () { return [{ type: i1.MatInput, decorators: [{
|
|
1290
|
+
type: Optional
|
|
1291
|
+
}, {
|
|
1292
|
+
type: Host
|
|
1293
|
+
}] }, { type: i0.ElementRef }]; }, propDecorators: { fsAutofocus: [{
|
|
1294
|
+
type: Input
|
|
1295
|
+
}] } });
|
|
1296
|
+
|
|
1297
|
+
class FsFormatOrdinalNumberPipe {
|
|
1298
|
+
transform(value) {
|
|
1299
|
+
return ordinalNumber(value);
|
|
1275
1300
|
}
|
|
1301
|
+
}
|
|
1302
|
+
FsFormatOrdinalNumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatOrdinalNumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1303
|
+
FsFormatOrdinalNumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatOrdinalNumberPipe, name: "fsFormatOrdinalNumber" });
|
|
1304
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsFormatOrdinalNumberPipe, decorators: [{
|
|
1305
|
+
type: Pipe,
|
|
1306
|
+
args: [{
|
|
1307
|
+
name: 'fsFormatOrdinalNumber',
|
|
1308
|
+
}]
|
|
1309
|
+
}] });
|
|
1310
|
+
|
|
1311
|
+
function email(value) {
|
|
1312
|
+
return !!String(value).match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
|
|
1276
1313
|
}
|
|
1277
1314
|
|
|
1278
|
-
function
|
|
1279
|
-
|
|
1315
|
+
function phone(value) {
|
|
1316
|
+
const valid = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4}/.test(value);
|
|
1317
|
+
return valid || !String(value).length;
|
|
1280
1318
|
}
|
|
1281
1319
|
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1320
|
+
/**
|
|
1321
|
+
* Check validity of the url.
|
|
1322
|
+
* Protocol (http/https) isn't required.
|
|
1323
|
+
* @param value
|
|
1324
|
+
* @returns {boolean}
|
|
1325
|
+
*/
|
|
1326
|
+
function url(value) {
|
|
1327
|
+
const expression = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#%[\]@!\$&'\(\)\*\+,;=.]+$/gm;
|
|
1328
|
+
const regexp = new RegExp(expression);
|
|
1329
|
+
return !!String(value).match(regexp);
|
|
1285
1330
|
}
|
|
1286
1331
|
|
|
1287
|
-
function
|
|
1288
|
-
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1332
|
+
function compare(query, item) {
|
|
1333
|
+
let value = true;
|
|
1334
|
+
for (const key in query) {
|
|
1335
|
+
value = value && item[key] == query[key];
|
|
1336
|
+
}
|
|
1337
|
+
return value;
|
|
1291
1338
|
}
|
|
1292
1339
|
|
|
1293
|
-
function
|
|
1294
|
-
if (
|
|
1295
|
-
|
|
1340
|
+
function filter(array, query) {
|
|
1341
|
+
if (typeof query !== 'function') {
|
|
1342
|
+
const queryObj = query;
|
|
1343
|
+
query = (item) => {
|
|
1344
|
+
return compare(queryObj, item);
|
|
1345
|
+
};
|
|
1296
1346
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1347
|
+
const isarray = Array.isArray(array);
|
|
1348
|
+
const list = isarray ? [] : {};
|
|
1349
|
+
if (isarray) {
|
|
1350
|
+
array.forEach(function (item, idx) {
|
|
1351
|
+
if (query(item)) {
|
|
1352
|
+
list.push(item);
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1303
1355
|
}
|
|
1304
|
-
else
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1356
|
+
else {
|
|
1357
|
+
Object.keys(array).forEach(key => {
|
|
1358
|
+
if (query(array[key])) {
|
|
1359
|
+
list[key] = array[key];
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
return list;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function inArray(values, array) {
|
|
1367
|
+
if (!Array.isArray(values)) {
|
|
1368
|
+
values = [values];
|
|
1369
|
+
}
|
|
1370
|
+
for (let i = 0, len = values.length; i < len; i++) {
|
|
1371
|
+
if (array.indexOf(values[i]) >= 0) {
|
|
1372
|
+
return true;
|
|
1308
1373
|
}
|
|
1309
|
-
return cloned;
|
|
1310
1374
|
}
|
|
1311
|
-
return
|
|
1375
|
+
return false;
|
|
1312
1376
|
}
|
|
1313
1377
|
|
|
1314
|
-
function
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1378
|
+
function index(array, name, value = null) {
|
|
1379
|
+
const list = {};
|
|
1380
|
+
array.forEach(function (item) {
|
|
1381
|
+
list[item[name]] = value ? item[value] : item;
|
|
1382
|
+
});
|
|
1383
|
+
return list;
|
|
1319
1384
|
}
|
|
1320
1385
|
|
|
1321
|
-
function
|
|
1322
|
-
if (
|
|
1323
|
-
|
|
1386
|
+
function indexOf(array, query) {
|
|
1387
|
+
if (typeof query !== 'function') {
|
|
1388
|
+
const queryObj = query;
|
|
1389
|
+
query = (item) => {
|
|
1390
|
+
return compare(queryObj, item);
|
|
1391
|
+
};
|
|
1324
1392
|
}
|
|
1325
|
-
|
|
1326
|
-
if (
|
|
1327
|
-
return
|
|
1393
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
1394
|
+
if (query(array[i])) {
|
|
1395
|
+
return i;
|
|
1328
1396
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1397
|
+
}
|
|
1398
|
+
return -1;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
function keyExists(array, key) {
|
|
1402
|
+
return array.hasOwnProperty(key);
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
function ksort(unordered) {
|
|
1406
|
+
Object.keys(unordered).sort().forEach(function (key) {
|
|
1407
|
+
const value = unordered[key];
|
|
1408
|
+
delete unordered[key];
|
|
1409
|
+
unordered[key] = value;
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
function list(array, property, index = null) {
|
|
1414
|
+
const resultList = index ? {} : [];
|
|
1415
|
+
array.forEach(function (item, idx) {
|
|
1416
|
+
if (index) {
|
|
1417
|
+
resultList[item[index]] = item[property];
|
|
1331
1418
|
}
|
|
1332
1419
|
else {
|
|
1333
|
-
|
|
1420
|
+
resultList.push(item[property]);
|
|
1334
1421
|
}
|
|
1335
|
-
};
|
|
1336
|
-
arr1 = [...arr1].sort(sortFn);
|
|
1337
|
-
arr2 = [...arr2].sort(sortFn);
|
|
1338
|
-
return arr1.every((value, index) => {
|
|
1339
|
-
return value === arr2[index];
|
|
1340
1422
|
});
|
|
1423
|
+
return resultList;
|
|
1341
1424
|
}
|
|
1342
1425
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1426
|
+
function nameValue(array, name, value) {
|
|
1427
|
+
const list = [];
|
|
1428
|
+
if (name || value) {
|
|
1429
|
+
const nameFn = typeof name === 'function' ? name : function (item) {
|
|
1430
|
+
return item[name];
|
|
1431
|
+
};
|
|
1432
|
+
const valueFn = typeof value === 'function' ? value : function (item) {
|
|
1433
|
+
return item[value];
|
|
1434
|
+
};
|
|
1435
|
+
array.forEach(function (item) {
|
|
1436
|
+
list.push({ name: nameFn(item), value: valueFn(item) });
|
|
1437
|
+
});
|
|
1354
1438
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
* example:
|
|
1359
|
-
* sourceLoader.registerResources({
|
|
1360
|
-
* froala: [
|
|
1361
|
-
* '/assets/js/froala/froala_editor.min.js',
|
|
1362
|
-
* '/assets/css/froala_editor.pkgd.min.css',
|
|
1363
|
-
* ],
|
|
1364
|
-
* froala_align: '/assets/js/froala/plugins/align.min.js',
|
|
1365
|
-
* froala_colors: '/assets/js/froala/plugins/colors.min.js',
|
|
1366
|
-
* froala_image: '/assets/js/froala/plugins/image.min.js',
|
|
1367
|
-
* });
|
|
1368
|
-
*
|
|
1369
|
-
*/
|
|
1370
|
-
function registerResources(resources) {
|
|
1371
|
-
Object.entries(resources)
|
|
1372
|
-
.forEach(([name, path]) => {
|
|
1373
|
-
if (typeof path === 'string') {
|
|
1374
|
-
path = [path];
|
|
1375
|
-
}
|
|
1376
|
-
if (!_sources.has(name)) {
|
|
1377
|
-
_sources.set(name, new Set());
|
|
1378
|
-
}
|
|
1379
|
-
const resourcesList = _sources.get(name);
|
|
1380
|
-
path.forEach((p) => {
|
|
1381
|
-
resourcesList.add(p);
|
|
1382
|
-
});
|
|
1439
|
+
else {
|
|
1440
|
+
array.forEach(function (n, v) {
|
|
1441
|
+
list.push({ name: n, value: v });
|
|
1383
1442
|
});
|
|
1384
1443
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
* sourceLoader.loadResource('/assets/my-source.js')
|
|
1393
|
-
*
|
|
1394
|
-
*/
|
|
1395
|
-
function loadResource(name) {
|
|
1396
|
-
if (_loadedResources.has(name)) {
|
|
1397
|
-
return _loadedResources.get(name);
|
|
1398
|
-
}
|
|
1399
|
-
if (_sources.has(name)) {
|
|
1400
|
-
const sourcesForLoading = [..._sources.get(name)]
|
|
1401
|
-
.map((path) => {
|
|
1402
|
-
return _loadResource(path);
|
|
1403
|
-
})
|
|
1404
|
-
.filter((v) => !!v);
|
|
1405
|
-
return combineLatest(sourcesForLoading);
|
|
1406
|
-
}
|
|
1407
|
-
return _loadResource(name);
|
|
1444
|
+
return list;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
function remove(array, query) {
|
|
1448
|
+
const idx = indexOf(array, query);
|
|
1449
|
+
if (idx >= 0) {
|
|
1450
|
+
return array.splice(idx, 1);
|
|
1408
1451
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
if (
|
|
1417
|
-
|
|
1452
|
+
return idx;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
function sort(array, query, reverse = false) {
|
|
1456
|
+
if (typeof query !== 'function') {
|
|
1457
|
+
const queryStr = query;
|
|
1458
|
+
query = function (a, b) {
|
|
1459
|
+
if (reverse) {
|
|
1460
|
+
if (a[queryStr] < b[queryStr]) {
|
|
1461
|
+
return 1;
|
|
1462
|
+
}
|
|
1463
|
+
else if (a[queryStr] > b[queryStr]) {
|
|
1464
|
+
return -1;
|
|
1465
|
+
}
|
|
1418
1466
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
return _loadJs(path);
|
|
1430
|
-
}
|
|
1431
|
-
console.warn(`Resource ${path} can not be identified and loaded`);
|
|
1432
|
-
return null;
|
|
1433
|
-
}
|
|
1434
|
-
function _loadJs(scriptPath) {
|
|
1435
|
-
if (!_loadedResources.has(scriptPath)) {
|
|
1436
|
-
const obs$ = new Observable((obs) => {
|
|
1437
|
-
const script = document.createElement('script');
|
|
1438
|
-
script.src = scriptPath;
|
|
1439
|
-
_headElement.appendChild(script);
|
|
1440
|
-
script.onload = () => {
|
|
1441
|
-
obs.next();
|
|
1442
|
-
obs.complete();
|
|
1443
|
-
};
|
|
1444
|
-
script.onerror = (err) => {
|
|
1445
|
-
obs.error(err);
|
|
1446
|
-
};
|
|
1447
|
-
}).pipe(shareReplay(1));
|
|
1448
|
-
_loadedResources.set(scriptPath, obs$);
|
|
1449
|
-
}
|
|
1450
|
-
return _loadedResources.get(scriptPath);
|
|
1451
|
-
}
|
|
1452
|
-
function _loadStyles(stylePath) {
|
|
1453
|
-
if (!_loadedResources.has(stylePath)) {
|
|
1454
|
-
const obs$ = new Observable((obs) => {
|
|
1455
|
-
const style = document.createElement('link');
|
|
1456
|
-
style.id = stylePath;
|
|
1457
|
-
style.rel = 'stylesheet';
|
|
1458
|
-
style.href = `${stylePath}`;
|
|
1459
|
-
_headElement.appendChild(style);
|
|
1460
|
-
style.onload = () => {
|
|
1461
|
-
obs.next();
|
|
1462
|
-
obs.complete();
|
|
1463
|
-
};
|
|
1464
|
-
style.onerror = (err) => {
|
|
1465
|
-
obs.error(err);
|
|
1466
|
-
};
|
|
1467
|
-
});
|
|
1468
|
-
_loadedResources.set(stylePath, obs$);
|
|
1469
|
-
}
|
|
1470
|
-
return _loadedResources.get(stylePath);
|
|
1471
|
-
}
|
|
1472
|
-
function _isJavascriptUrl(url) {
|
|
1473
|
-
return url.endsWith('.js');
|
|
1474
|
-
}
|
|
1475
|
-
function _isStylesUrl(url) {
|
|
1476
|
-
return url.endsWith('.css');
|
|
1467
|
+
else {
|
|
1468
|
+
if (a[queryStr] > b[queryStr]) {
|
|
1469
|
+
return 1;
|
|
1470
|
+
}
|
|
1471
|
+
else if (a[queryStr] < b[queryStr]) {
|
|
1472
|
+
return -1;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
return 0;
|
|
1476
|
+
};
|
|
1477
1477
|
}
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
}
|
|
1478
|
+
array.sort(query);
|
|
1479
|
+
return array;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
function rsort(array, query) {
|
|
1483
|
+
return sort(array, query, true);
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
function find(array, query) {
|
|
1487
|
+
const data = filter(array, query);
|
|
1488
|
+
return data.length ? data[0] : null;
|
|
1489
|
+
}
|
|
1485
1490
|
|
|
1486
1491
|
function acronym(str, length = 2) {
|
|
1487
1492
|
const splittedString = str
|