ngx-sfc-common 0.0.31 → 0.0.33
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/esm2020/lib/components/load-container/load-container.component.mjs +3 -3
- package/esm2020/lib/components/load-container/models/load-container-parameters.model.mjs +1 -1
- package/esm2020/lib/components/tag/tag.component.mjs +15 -12
- package/esm2020/lib/components/tag/tag.model.mjs +1 -1
- package/esm2020/lib/utils/common.utils.mjs +85 -1
- package/esm2020/lib/utils/index.mjs +2 -2
- package/fesm2015/ngx-sfc-common.mjs +896 -808
- package/fesm2015/ngx-sfc-common.mjs.map +1 -1
- package/fesm2020/ngx-sfc-common.mjs +892 -806
- package/fesm2020/ngx-sfc-common.mjs.map +1 -1
- package/lib/components/load-container/models/load-container-parameters.model.d.ts +1 -0
- package/lib/components/tag/tag.component.d.ts +3 -3
- package/lib/components/tag/tag.model.d.ts +4 -1
- package/lib/utils/common.utils.d.ts +31 -0
- package/lib/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/styles/_colors.scss +1 -1
|
@@ -597,1067 +597,1150 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
597
597
|
}] } });
|
|
598
598
|
|
|
599
599
|
/**
|
|
600
|
-
*
|
|
601
|
-
* @param
|
|
602
|
-
* @
|
|
603
|
-
* @returns Date with minute value
|
|
600
|
+
* Return true if string has value(not empty string)
|
|
601
|
+
* @param value String value to check
|
|
602
|
+
* @returns True if string is not null and defined(not empty string)
|
|
604
603
|
*/
|
|
605
|
-
function
|
|
606
|
-
|
|
607
|
-
result.setMinutes(minute);
|
|
608
|
-
return result;
|
|
604
|
+
function isNullOrEmptyString(value) {
|
|
605
|
+
return !isDefined(value) || value === CommonConstants.EMPTY_STRING;
|
|
609
606
|
}
|
|
610
607
|
/**
|
|
611
|
-
*
|
|
612
|
-
* @param
|
|
613
|
-
* @param
|
|
614
|
-
* @returns
|
|
608
|
+
* Return true if value contains includeValue
|
|
609
|
+
* @param value String value to check
|
|
610
|
+
* @param includeValue Value to check if it include
|
|
611
|
+
* @returns True if value contains includeValue
|
|
615
612
|
*/
|
|
616
|
-
function
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
613
|
+
function contains(value, includeValue) {
|
|
614
|
+
return !isNullOrEmptyString(value) && !isNullOrEmptyString(includeValue)
|
|
615
|
+
? value.toLowerCase()
|
|
616
|
+
.includes(includeValue.toLowerCase())
|
|
617
|
+
: false;
|
|
620
618
|
}
|
|
621
619
|
/**
|
|
622
|
-
*
|
|
623
|
-
* @param
|
|
624
|
-
* @
|
|
625
|
-
* @returns Date with day number
|
|
620
|
+
* Return trimed value
|
|
621
|
+
* @param value Value for trim modification
|
|
622
|
+
* @returns Trimed value
|
|
626
623
|
*/
|
|
627
|
-
function
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}
|
|
624
|
+
function trim(value) {
|
|
625
|
+
return isNullOrEmptyString(value) ? value : value.replace(/\s/g, '');
|
|
626
|
+
}
|
|
627
|
+
|
|
632
628
|
/**
|
|
633
|
-
*
|
|
634
|
-
* @param
|
|
635
|
-
* @
|
|
636
|
-
* @returns Date with year value
|
|
629
|
+
* Return true if collection not empty
|
|
630
|
+
* @param collection Array of items
|
|
631
|
+
* @returns True if collection not empty
|
|
637
632
|
*/
|
|
638
|
-
function
|
|
639
|
-
|
|
640
|
-
result.setFullYear(year);
|
|
641
|
-
return result;
|
|
633
|
+
function any(collection) {
|
|
634
|
+
return isDefined(collection) && collection.length > 0;
|
|
642
635
|
}
|
|
643
636
|
/**
|
|
644
|
-
*
|
|
645
|
-
* @param
|
|
646
|
-
* @param value
|
|
647
|
-
* @returns
|
|
637
|
+
* Return true if collection has such value
|
|
638
|
+
* @param collection Array of items
|
|
639
|
+
* @param value Value to check
|
|
640
|
+
* @returns True if found value in collection
|
|
648
641
|
*/
|
|
649
|
-
function
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
return result;
|
|
642
|
+
function hasItem(collection, value) {
|
|
643
|
+
return any(collection)
|
|
644
|
+
&& collection.findIndex(item => item === value) !== CommonConstants.NOT_FOUND_INDEX;
|
|
653
645
|
}
|
|
654
646
|
/**
|
|
655
|
-
*
|
|
656
|
-
* @param
|
|
657
|
-
* @param
|
|
658
|
-
* @returns
|
|
647
|
+
* Return true if collection has such value by predicate function
|
|
648
|
+
* @param collection Array of items
|
|
649
|
+
* @param predicate Function to define check logic
|
|
650
|
+
* @returns True if found value in collection
|
|
659
651
|
*/
|
|
660
|
-
function
|
|
661
|
-
|
|
662
|
-
result.setMilliseconds(value);
|
|
663
|
-
return result;
|
|
652
|
+
function hasItemBy(collection, predicate) {
|
|
653
|
+
return any(collection) && collection.findIndex(predicate) !== CommonConstants.NOT_FOUND_INDEX;
|
|
664
654
|
}
|
|
665
655
|
/**
|
|
666
|
-
*
|
|
667
|
-
* @param
|
|
668
|
-
* @
|
|
656
|
+
* Return true if collection of objects has such value as object
|
|
657
|
+
* @param collection Array of objects
|
|
658
|
+
* @param property Property name
|
|
659
|
+
* @param value Value to check
|
|
660
|
+
* @returns True if found value in collection
|
|
669
661
|
*/
|
|
670
|
-
function
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
662
|
+
function hasObjectItem(collection, // TODO <-- Array<T>
|
|
663
|
+
property, value) {
|
|
664
|
+
return any(collection)
|
|
665
|
+
&& collection.findIndex(item => item.hasOwnProperty(property)
|
|
666
|
+
&& item[property] === value) !== CommonConstants.NOT_FOUND_INDEX;
|
|
675
667
|
}
|
|
676
668
|
/**
|
|
677
|
-
*
|
|
678
|
-
* @param
|
|
679
|
-
* @
|
|
669
|
+
* Return true if first collection has item in second collection
|
|
670
|
+
* @param collection1 Array of objects where search
|
|
671
|
+
* @param collection2 Array of objects where try to find
|
|
672
|
+
* @returns
|
|
680
673
|
*/
|
|
681
|
-
function
|
|
682
|
-
|
|
683
|
-
nextDate.setDate(date.getDate() + 1);
|
|
684
|
-
return nextDate;
|
|
674
|
+
function hasAnyItem(collection1, collection2) {
|
|
675
|
+
return collection1.some(item => collection2.includes(item));
|
|
685
676
|
}
|
|
686
677
|
/**
|
|
687
|
-
*
|
|
688
|
-
* @param
|
|
689
|
-
* @
|
|
678
|
+
* Return value from collection by predicate function
|
|
679
|
+
* @param collection Array of items
|
|
680
|
+
* @param predicate Function to define search logic
|
|
681
|
+
* @returns Value from collection
|
|
690
682
|
*/
|
|
691
|
-
function
|
|
692
|
-
|
|
693
|
-
nextDate.setDate(date.getDate() - 1);
|
|
694
|
-
return nextDate;
|
|
683
|
+
function firstOrDefault(collection, predicate) {
|
|
684
|
+
return any(collection) ? collection === null || collection === void 0 ? void 0 : collection.find(predicate) : undefined;
|
|
695
685
|
}
|
|
696
686
|
/**
|
|
697
|
-
*
|
|
698
|
-
* @param
|
|
699
|
-
* @returns
|
|
687
|
+
* Return first item from collection
|
|
688
|
+
* @param collection Array of items
|
|
689
|
+
* @returns First value from collection
|
|
700
690
|
*/
|
|
701
|
-
function
|
|
702
|
-
|
|
703
|
-
nextMonth.setMonth(date.getMonth() + 1);
|
|
704
|
-
return nextMonth;
|
|
691
|
+
function firstItem(collection) {
|
|
692
|
+
return any(collection) ? collection[0] : null;
|
|
705
693
|
}
|
|
706
694
|
/**
|
|
707
|
-
*
|
|
708
|
-
* @param
|
|
709
|
-
* @returns
|
|
695
|
+
* Return last item from collection
|
|
696
|
+
* @param collection Array of items
|
|
697
|
+
* @returns Last value from collection
|
|
710
698
|
*/
|
|
711
|
-
function
|
|
712
|
-
|
|
713
|
-
prevMonth.setMonth(date.getMonth() - 1);
|
|
714
|
-
return prevMonth;
|
|
699
|
+
function lastItem(collection) {
|
|
700
|
+
return any(collection) ? collection[collection.length - 1] : null;
|
|
715
701
|
}
|
|
716
702
|
/**
|
|
717
|
-
*
|
|
718
|
-
* @param
|
|
719
|
-
* @
|
|
703
|
+
* Return True if all values match predicate function
|
|
704
|
+
* @param collection Array of objects
|
|
705
|
+
* @param predicate Function to define check logic
|
|
706
|
+
* @returns True if all values match predicate
|
|
720
707
|
*/
|
|
721
|
-
function
|
|
722
|
-
|
|
723
|
-
nextYear.setFullYear(date.getFullYear() + 1);
|
|
724
|
-
return nextYear;
|
|
708
|
+
function all(collection, predicate) {
|
|
709
|
+
return any(collection) ? collection.filter(predicate).length == collection.length : false;
|
|
725
710
|
}
|
|
726
711
|
/**
|
|
727
|
-
*
|
|
728
|
-
* @param
|
|
729
|
-
* @
|
|
712
|
+
* Return count by predicate
|
|
713
|
+
* @param collection Array of objects
|
|
714
|
+
* @param predicate Function to define check logic
|
|
715
|
+
* @returns Items count
|
|
730
716
|
*/
|
|
731
|
-
function
|
|
732
|
-
|
|
733
|
-
prevYear.setFullYear(date.getFullYear() - 1);
|
|
734
|
-
return prevYear;
|
|
717
|
+
function count(collection, predicate) {
|
|
718
|
+
return collection.filter(predicate).length;
|
|
735
719
|
}
|
|
736
720
|
/**
|
|
737
|
-
* Return
|
|
738
|
-
* @param
|
|
739
|
-
* @
|
|
721
|
+
* Return items from collection by predicate function
|
|
722
|
+
* @param collection Array of items
|
|
723
|
+
* @param predicate Function to define search logic
|
|
724
|
+
* @returns Values from collection
|
|
740
725
|
*/
|
|
741
|
-
function
|
|
742
|
-
|
|
743
|
-
const year = date.getFullYear(), month = date.getMonth();
|
|
744
|
-
return new Date(year, month, 1);
|
|
745
|
-
}
|
|
746
|
-
return date;
|
|
726
|
+
function where(collection, predicate) {
|
|
727
|
+
return any(collection) ? collection.filter(predicate) : null;
|
|
747
728
|
}
|
|
748
729
|
/**
|
|
749
|
-
* Return
|
|
750
|
-
* @param
|
|
751
|
-
* @
|
|
730
|
+
* Return sliced collection by page number and page size
|
|
731
|
+
* @param collection Array of items
|
|
732
|
+
* @param page Page number
|
|
733
|
+
* @param size Page size
|
|
734
|
+
* @returns Sliced collection
|
|
752
735
|
*/
|
|
753
|
-
function
|
|
754
|
-
if (
|
|
755
|
-
|
|
756
|
-
return
|
|
736
|
+
function skip(collection, page, size) {
|
|
737
|
+
if (any(collection)) {
|
|
738
|
+
let start = (page - 1) * size;
|
|
739
|
+
return collection.slice(start, start + size);
|
|
757
740
|
}
|
|
758
|
-
return
|
|
741
|
+
return collection;
|
|
759
742
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
function getFirstDayOfYear(date) {
|
|
766
|
-
if (isDefined(date) && date instanceof Date) {
|
|
767
|
-
return new Date(date.getFullYear(), 0, 1);
|
|
743
|
+
function sort(collection, direction = SortingDirection.Ascending) {
|
|
744
|
+
if (any(collection)) {
|
|
745
|
+
return direction == SortingDirection.Ascending
|
|
746
|
+
? collection.sort((a, b) => a - b)
|
|
747
|
+
: collection.sort((a, b) => b - a);
|
|
768
748
|
}
|
|
769
|
-
return
|
|
749
|
+
return collection;
|
|
770
750
|
}
|
|
771
751
|
/**
|
|
772
|
-
* Return
|
|
773
|
-
* @param
|
|
774
|
-
* @
|
|
752
|
+
* Return sorted collection of objects by property
|
|
753
|
+
* @param collection Array of items
|
|
754
|
+
* @param property Property name
|
|
755
|
+
* @param direction Sorting direction
|
|
756
|
+
* @returns Sorted collection
|
|
775
757
|
*/
|
|
776
|
-
function
|
|
777
|
-
if (
|
|
778
|
-
|
|
758
|
+
function sortBy(collection, property, direction) {
|
|
759
|
+
if (any(collection)) {
|
|
760
|
+
let _sortFunc = (a, b) => (t1, t2) => (a[property] > b[property] ? t1 : t2);
|
|
761
|
+
return direction == SortingDirection.Ascending
|
|
762
|
+
? collection.sort((a, b) => _sortFunc(a, b)(1, -1))
|
|
763
|
+
: collection.sort((a, b) => _sortFunc(a, b)(-1, 1));
|
|
779
764
|
}
|
|
780
|
-
return
|
|
765
|
+
return collection;
|
|
781
766
|
}
|
|
782
767
|
/**
|
|
783
|
-
* Return
|
|
784
|
-
* @param
|
|
785
|
-
* @param
|
|
786
|
-
* @
|
|
787
|
-
|
|
788
|
-
function getFirstDayOfMonthByYearAndMonth(year, month) {
|
|
789
|
-
return new Date(year, month, 1);
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Return last day of month as date
|
|
793
|
-
* @param year Year value
|
|
794
|
-
* @param month Month value
|
|
795
|
-
* @returns Last day of month
|
|
768
|
+
* Return sorted collection of objects by path
|
|
769
|
+
* @param collection Array of items
|
|
770
|
+
* @param path Path to property
|
|
771
|
+
* @param direction Sorting direction
|
|
772
|
+
* @returns Sorted collection
|
|
796
773
|
*/
|
|
797
|
-
function
|
|
798
|
-
|
|
774
|
+
function sortByPath(collection, path, direction) {
|
|
775
|
+
if (any(collection)) {
|
|
776
|
+
if (isNullOrEmptyString(path))
|
|
777
|
+
throw new Error('Collection utils | Sort By Path function --> Path is empty.');
|
|
778
|
+
const pathParts = path.split('.');
|
|
779
|
+
if (!any(pathParts))
|
|
780
|
+
throw new Error('Collection utils | Sort By Path function --> Path is incorrect.');
|
|
781
|
+
const partsLength = pathParts.length;
|
|
782
|
+
collection.sort((a, b) => {
|
|
783
|
+
var i = 0;
|
|
784
|
+
while (i < partsLength) {
|
|
785
|
+
a = a[pathParts[i]];
|
|
786
|
+
b = b[pathParts[i]];
|
|
787
|
+
i++;
|
|
788
|
+
}
|
|
789
|
+
return direction == SortingDirection.Ascending
|
|
790
|
+
? a >= b ? 1 : -1
|
|
791
|
+
: a > b ? -1 : 1;
|
|
792
|
+
});
|
|
793
|
+
return collection;
|
|
794
|
+
}
|
|
795
|
+
return collection;
|
|
799
796
|
}
|
|
800
797
|
/**
|
|
801
|
-
* Return
|
|
802
|
-
* @param
|
|
803
|
-
* @returns
|
|
798
|
+
* Return collection without matches
|
|
799
|
+
* @param collection Array of items
|
|
800
|
+
* @returns Collection without matches
|
|
804
801
|
*/
|
|
805
|
-
function
|
|
806
|
-
|
|
807
|
-
|
|
802
|
+
function distinct(collection) {
|
|
803
|
+
return any(collection)
|
|
804
|
+
? collection.filter((value, index, self) => self.indexOf(value) === index)
|
|
805
|
+
: collection;
|
|
808
806
|
}
|
|
809
807
|
/**
|
|
810
|
-
* Return
|
|
811
|
-
* @param
|
|
812
|
-
* @param
|
|
813
|
-
* @returns
|
|
808
|
+
* Return sum value from collection items by map function
|
|
809
|
+
* @param collection Array of items
|
|
810
|
+
* @param select Map function
|
|
811
|
+
* @returns Sum value of colection items
|
|
814
812
|
*/
|
|
815
|
-
function
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
813
|
+
function sum(collection, select) {
|
|
814
|
+
return any(collection)
|
|
815
|
+
? collection
|
|
816
|
+
.map(select)
|
|
817
|
+
.reduce((a, b) => { return a + b; }, 0)
|
|
818
|
+
: 0;
|
|
820
819
|
}
|
|
821
820
|
/**
|
|
822
|
-
* Return
|
|
823
|
-
* @param
|
|
824
|
-
* @param
|
|
825
|
-
* @returns
|
|
821
|
+
* Return max value from collection items by map function
|
|
822
|
+
* @param collection Array of items
|
|
823
|
+
* @param select Map function
|
|
824
|
+
* @returns Max value of collection items
|
|
826
825
|
*/
|
|
827
|
-
function
|
|
828
|
-
|
|
829
|
-
|
|
826
|
+
function max(collection, select) {
|
|
827
|
+
if (any(collection))
|
|
828
|
+
return Math.max(...collection.map(select));
|
|
829
|
+
throw new Error('Collection utils | Max function --> Collection is empty.');
|
|
830
830
|
}
|
|
831
831
|
/**
|
|
832
|
-
*
|
|
833
|
-
* @param
|
|
834
|
-
* @param
|
|
835
|
-
* @returns True if first date greater than second date
|
|
832
|
+
* Delete items from collection by predicate
|
|
833
|
+
* @param collection Array of items
|
|
834
|
+
* @param predicate Function to define remove logic
|
|
836
835
|
*/
|
|
837
|
-
function
|
|
838
|
-
|
|
839
|
-
|
|
836
|
+
function remove(collection, predicate) {
|
|
837
|
+
var i = collection.length;
|
|
838
|
+
while (i--) {
|
|
839
|
+
if (predicate(collection[i])) {
|
|
840
|
+
collection.splice(i, 1);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
840
843
|
}
|
|
841
844
|
/**
|
|
842
|
-
*
|
|
843
|
-
* @param
|
|
844
|
-
* @param
|
|
845
|
-
* @
|
|
845
|
+
* Add item to collection
|
|
846
|
+
* @param collection Array of items
|
|
847
|
+
* @param item New item
|
|
848
|
+
* @param predicate Function to define if allowed to add new item
|
|
849
|
+
* @returns True if successfully added
|
|
846
850
|
*/
|
|
847
|
-
function
|
|
848
|
-
|
|
849
|
-
|
|
851
|
+
function addItem(collection, item, predicate = null) {
|
|
852
|
+
if (!isDefined(collection))
|
|
853
|
+
collection = new Array();
|
|
854
|
+
if (isDefined(predicate) && predicate(item))
|
|
855
|
+
return false;
|
|
856
|
+
collection.push(item);
|
|
857
|
+
return true;
|
|
850
858
|
}
|
|
851
859
|
/**
|
|
852
|
-
*
|
|
853
|
-
* @param
|
|
854
|
-
* @param
|
|
855
|
-
* @returns True if
|
|
860
|
+
* Delete item from collection
|
|
861
|
+
* @param collection Array of items
|
|
862
|
+
* @param item Item to delete
|
|
863
|
+
* @returns True if successfully removed
|
|
856
864
|
*/
|
|
857
|
-
function
|
|
858
|
-
|
|
859
|
-
|
|
865
|
+
function removeItem(collection, item) {
|
|
866
|
+
if (isDefined(item) && hasItem(collection, item)) {
|
|
867
|
+
collection.splice(collection.indexOf(item), 1);
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
return false;
|
|
860
871
|
}
|
|
861
872
|
/**
|
|
862
|
-
*
|
|
863
|
-
* @param
|
|
864
|
-
* @param
|
|
865
|
-
* @returns True if
|
|
873
|
+
* Delete item from collection by predicate
|
|
874
|
+
* @param collection Array of items
|
|
875
|
+
* @param predicate Function to define remove logic
|
|
876
|
+
* @returns True if successfully removed
|
|
866
877
|
*/
|
|
867
|
-
function
|
|
868
|
-
|
|
869
|
-
|
|
878
|
+
function removeItemBy(collection, predicate) {
|
|
879
|
+
const foundItem = firstOrDefault(collection, predicate);
|
|
880
|
+
if (isDefined(foundItem)) {
|
|
881
|
+
collection.splice(collection.indexOf(foundItem), 1);
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
return false;
|
|
870
885
|
}
|
|
871
886
|
/**
|
|
872
|
-
*
|
|
873
|
-
* @param
|
|
874
|
-
* @param
|
|
875
|
-
* @returns True if
|
|
887
|
+
* Update item in collection by predicate
|
|
888
|
+
* @param collection Array of items
|
|
889
|
+
* @param predicate Function to define item for deleting
|
|
890
|
+
* @returns True if successfully removed
|
|
876
891
|
*/
|
|
877
|
-
function
|
|
878
|
-
|
|
879
|
-
|
|
892
|
+
function updateItemBy(collection, predicate, newItem) {
|
|
893
|
+
const itemIndex = collection.findIndex(predicate);
|
|
894
|
+
if (itemIndex !== CommonConstants.NOT_FOUND_INDEX) {
|
|
895
|
+
const result = collection.slice(0);
|
|
896
|
+
result[itemIndex] = Object.assign(Object.assign({}, collection[itemIndex]), newItem);
|
|
897
|
+
return result;
|
|
898
|
+
}
|
|
899
|
+
return null;
|
|
880
900
|
}
|
|
881
901
|
/**
|
|
882
|
-
* Return
|
|
883
|
-
* @param
|
|
884
|
-
* @
|
|
885
|
-
* @returns True if first time less or equal to second time
|
|
902
|
+
* Return collection or empty if collection is not defined
|
|
903
|
+
* @param collection Array of items
|
|
904
|
+
* @returns Collection or empty
|
|
886
905
|
*/
|
|
887
|
-
function
|
|
888
|
-
return
|
|
889
|
-
<= new Date(0, 0, 0, date2.getHours(), date2.getMinutes());
|
|
906
|
+
function getCollectionOrEmpty(collection) {
|
|
907
|
+
return isDefined(collection) ? collection : [];
|
|
890
908
|
}
|
|
891
909
|
/**
|
|
892
|
-
*
|
|
893
|
-
* @param
|
|
894
|
-
* @param
|
|
895
|
-
* @returns True if
|
|
910
|
+
* Check if arrays are equal
|
|
911
|
+
* @param a First array
|
|
912
|
+
* @param b Second array
|
|
913
|
+
* @returns True if arrays are equal
|
|
896
914
|
*/
|
|
897
|
-
function
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
915
|
+
function isArraysEquals(a, b) {
|
|
916
|
+
if (a.length !== b.length)
|
|
917
|
+
return false;
|
|
918
|
+
a.sort();
|
|
919
|
+
b.sort();
|
|
920
|
+
for (let i = 0; i < a.length; i++) {
|
|
921
|
+
if (a[i] !== b[i])
|
|
922
|
+
return false;
|
|
923
|
+
}
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
926
|
+
|
|
901
927
|
/**
|
|
902
|
-
*
|
|
928
|
+
* Set minutes for date
|
|
903
929
|
* @param date Date value
|
|
904
|
-
* @
|
|
930
|
+
* @param minute Minute value
|
|
931
|
+
* @returns Date with minute value
|
|
905
932
|
*/
|
|
906
|
-
function
|
|
907
|
-
|
|
933
|
+
function setMinutes(date, minute) {
|
|
934
|
+
const result = new Date(date);
|
|
935
|
+
result.setMinutes(minute);
|
|
936
|
+
return result;
|
|
908
937
|
}
|
|
909
938
|
/**
|
|
910
|
-
*
|
|
911
|
-
* @param
|
|
912
|
-
* @
|
|
939
|
+
* Set hours for date
|
|
940
|
+
* @param date Date value
|
|
941
|
+
* @param hour Hour value
|
|
942
|
+
* @returns Date with hour value
|
|
913
943
|
*/
|
|
914
|
-
function
|
|
915
|
-
const
|
|
916
|
-
result.setHours(
|
|
917
|
-
result.setMinutes(+tempTime[1]);
|
|
918
|
-
result.setSeconds(+tempTime[2]);
|
|
944
|
+
function setHours(date, hour) {
|
|
945
|
+
const result = new Date(date);
|
|
946
|
+
result.setHours(hour);
|
|
919
947
|
return result;
|
|
920
948
|
}
|
|
921
949
|
/**
|
|
922
|
-
*
|
|
950
|
+
* Set day for date value
|
|
923
951
|
* @param date Date value
|
|
924
|
-
* @param
|
|
925
|
-
* @returns
|
|
952
|
+
* @param dayNumber Day number
|
|
953
|
+
* @returns Date with day number
|
|
926
954
|
*/
|
|
927
|
-
function
|
|
928
|
-
|
|
955
|
+
function setDay(date, dayNumber) {
|
|
956
|
+
const nextDate = new Date(date);
|
|
957
|
+
nextDate.setDate(dayNumber);
|
|
958
|
+
return nextDate;
|
|
929
959
|
}
|
|
930
960
|
/**
|
|
931
|
-
*
|
|
932
|
-
* @param
|
|
933
|
-
* @
|
|
961
|
+
* Set year for date
|
|
962
|
+
* @param date Date value
|
|
963
|
+
* @param year Year value
|
|
964
|
+
* @returns Date with year value
|
|
934
965
|
*/
|
|
935
|
-
function
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const monthDifference = now.getMonth() - birthdate.getMonth();
|
|
941
|
-
if (monthDifference < 0 || (monthDifference === 0 && now.getDate() < birthdate.getDate())) {
|
|
942
|
-
age--;
|
|
943
|
-
}
|
|
944
|
-
return age;
|
|
945
|
-
}
|
|
946
|
-
|
|
966
|
+
function setYear(date, year) {
|
|
967
|
+
const result = new Date(date);
|
|
968
|
+
result.setFullYear(year);
|
|
969
|
+
return result;
|
|
970
|
+
}
|
|
947
971
|
/**
|
|
948
|
-
*
|
|
949
|
-
* @param
|
|
950
|
-
* @
|
|
972
|
+
* Set seconds for date
|
|
973
|
+
* @param date Date value
|
|
974
|
+
* @param value Seconds value
|
|
975
|
+
* @returns Date with minute value
|
|
951
976
|
*/
|
|
952
|
-
function
|
|
953
|
-
|
|
977
|
+
function setSeconds(date, value) {
|
|
978
|
+
const result = new Date(date);
|
|
979
|
+
result.setSeconds(value);
|
|
980
|
+
return result;
|
|
954
981
|
}
|
|
955
982
|
/**
|
|
956
|
-
*
|
|
957
|
-
* @param
|
|
958
|
-
* @
|
|
983
|
+
* Set milliseconds for date
|
|
984
|
+
* @param date Date value
|
|
985
|
+
* @param value Milliseconds value
|
|
986
|
+
* @returns Date with minute value
|
|
959
987
|
*/
|
|
960
|
-
function
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
988
|
+
function setMilliseconds(date, value) {
|
|
989
|
+
const result = new Date(date);
|
|
990
|
+
result.setMilliseconds(value);
|
|
991
|
+
return result;
|
|
964
992
|
}
|
|
965
993
|
/**
|
|
966
|
-
*
|
|
967
|
-
* @param
|
|
968
|
-
* @returns
|
|
994
|
+
* Set 0 for seconds and milliseconds of date
|
|
995
|
+
* @param date Date value
|
|
996
|
+
* @returns Date with minute value
|
|
969
997
|
*/
|
|
970
|
-
function
|
|
971
|
-
|
|
998
|
+
function setDefaultSecondsAndMiliseconds(date) {
|
|
999
|
+
const result = new Date(date);
|
|
1000
|
+
result.setSeconds(0);
|
|
1001
|
+
result.setMilliseconds(0);
|
|
1002
|
+
return result;
|
|
972
1003
|
}
|
|
973
1004
|
/**
|
|
974
|
-
*
|
|
975
|
-
* @param
|
|
976
|
-
* @
|
|
977
|
-
* @param value Value for new property
|
|
978
|
-
* @returns Extended object with new property
|
|
1005
|
+
* Get next date
|
|
1006
|
+
* @param date Date value
|
|
1007
|
+
* @returns Next date
|
|
979
1008
|
*/
|
|
980
|
-
function
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
obj = Object.assign(Object.assign({}, obj), newObj);
|
|
985
|
-
}
|
|
986
|
-
return obj;
|
|
1009
|
+
function getNextDate(date) {
|
|
1010
|
+
const nextDate = new Date(date);
|
|
1011
|
+
nextDate.setDate(date.getDate() + 1);
|
|
1012
|
+
return nextDate;
|
|
987
1013
|
}
|
|
988
1014
|
/**
|
|
989
|
-
*
|
|
990
|
-
* @param
|
|
991
|
-
* @
|
|
1015
|
+
* Get previous date
|
|
1016
|
+
* @param date Date value
|
|
1017
|
+
* @returns Previous date
|
|
992
1018
|
*/
|
|
993
|
-
function
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1019
|
+
function getPreviousDate(date) {
|
|
1020
|
+
const nextDate = new Date(date);
|
|
1021
|
+
nextDate.setDate(date.getDate() - 1);
|
|
1022
|
+
return nextDate;
|
|
997
1023
|
}
|
|
998
1024
|
/**
|
|
999
|
-
*
|
|
1000
|
-
* @param
|
|
1001
|
-
* @
|
|
1002
|
-
* @returns Merged object
|
|
1025
|
+
* Get next month as date
|
|
1026
|
+
* @param date Date value
|
|
1027
|
+
* @returns Next month as date
|
|
1003
1028
|
*/
|
|
1004
|
-
function
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
if (isObject(target) && isObject(source)) {
|
|
1009
|
-
for (const key in source) {
|
|
1010
|
-
if (isObject(source[key])) {
|
|
1011
|
-
if (!target[key])
|
|
1012
|
-
Object.assign(target, { [key]: {} });
|
|
1013
|
-
mergeDeep(target[key], source[key]);
|
|
1014
|
-
}
|
|
1015
|
-
else {
|
|
1016
|
-
Object.assign(target, { [key]: source[key] });
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
return mergeDeep(target, ...sources);
|
|
1029
|
+
function getNextMonth(date) {
|
|
1030
|
+
const nextMonth = new Date(date);
|
|
1031
|
+
nextMonth.setMonth(date.getMonth() + 1);
|
|
1032
|
+
return nextMonth;
|
|
1021
1033
|
}
|
|
1022
1034
|
/**
|
|
1023
|
-
* Get
|
|
1024
|
-
* @param
|
|
1025
|
-
* @returns
|
|
1035
|
+
* Get previous month as date
|
|
1036
|
+
* @param date Date value
|
|
1037
|
+
* @returns Previous month as date
|
|
1026
1038
|
*/
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
* @returns - An indication if the input is a Number or can be coerced to a Number
|
|
1032
|
-
*/
|
|
1033
|
-
function isNumeric(number) {
|
|
1034
|
-
return !isNaN(parseFloat(number));
|
|
1039
|
+
function getPreviousMonth(date) {
|
|
1040
|
+
const prevMonth = new Date(date);
|
|
1041
|
+
prevMonth.setMonth(date.getMonth() - 1);
|
|
1042
|
+
return prevMonth;
|
|
1035
1043
|
}
|
|
1036
1044
|
/**
|
|
1037
|
-
*
|
|
1038
|
-
* @param
|
|
1039
|
-
* @returns
|
|
1045
|
+
* Get next year as date
|
|
1046
|
+
* @param date Date value
|
|
1047
|
+
* @returns Next year as date
|
|
1040
1048
|
*/
|
|
1041
|
-
function
|
|
1042
|
-
|
|
1049
|
+
function getNextYear(date) {
|
|
1050
|
+
const nextYear = new Date(date);
|
|
1051
|
+
nextYear.setFullYear(date.getFullYear() + 1);
|
|
1052
|
+
return nextYear;
|
|
1043
1053
|
}
|
|
1044
1054
|
/**
|
|
1045
|
-
*
|
|
1046
|
-
* @
|
|
1055
|
+
* Get previous year as date
|
|
1056
|
+
* @param date Date value
|
|
1057
|
+
* @returns Previous year as date
|
|
1047
1058
|
*/
|
|
1048
|
-
function
|
|
1049
|
-
|
|
1059
|
+
function getPreviousYear(date) {
|
|
1060
|
+
const prevYear = new Date(date);
|
|
1061
|
+
prevYear.setFullYear(date.getFullYear() - 1);
|
|
1062
|
+
return prevYear;
|
|
1050
1063
|
}
|
|
1051
1064
|
/**
|
|
1052
|
-
* Return
|
|
1053
|
-
* @
|
|
1065
|
+
* Return first day of month as date from date value
|
|
1066
|
+
* @param date Date value
|
|
1067
|
+
* @returns First day of month as date
|
|
1054
1068
|
*/
|
|
1055
|
-
function
|
|
1056
|
-
|
|
1069
|
+
function getFirstDayOfMonth(date) {
|
|
1070
|
+
if (isDefined(date) && date instanceof Date) {
|
|
1071
|
+
const year = date.getFullYear(), month = date.getMonth();
|
|
1072
|
+
return new Date(year, month, 1);
|
|
1073
|
+
}
|
|
1074
|
+
return date;
|
|
1057
1075
|
}
|
|
1058
1076
|
/**
|
|
1059
|
-
* Return
|
|
1060
|
-
* @
|
|
1077
|
+
* Return last day of month as date from date value
|
|
1078
|
+
* @param date Date value
|
|
1079
|
+
* @returns Last day of month as date
|
|
1061
1080
|
*/
|
|
1062
|
-
function
|
|
1063
|
-
|
|
1081
|
+
function getLastDayOfMonth(date) {
|
|
1082
|
+
if (isDefined(date) && date instanceof Date) {
|
|
1083
|
+
const year = date.getFullYear(), month = date.getMonth();
|
|
1084
|
+
return new Date(year, month + 1, 0);
|
|
1085
|
+
}
|
|
1086
|
+
return date;
|
|
1064
1087
|
}
|
|
1065
1088
|
/**
|
|
1066
|
-
* Return
|
|
1067
|
-
* @param
|
|
1068
|
-
* @
|
|
1069
|
-
* @returns True if equal
|
|
1089
|
+
* Return first day of year as date from date value
|
|
1090
|
+
* @param date Date value
|
|
1091
|
+
* @returns First day of year as date
|
|
1070
1092
|
*/
|
|
1071
|
-
function
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
* @param {Object} obj The object
|
|
1075
|
-
* @return {String} The object type
|
|
1076
|
-
*/
|
|
1077
|
-
function getType(obj) {
|
|
1078
|
-
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
|
|
1079
|
-
}
|
|
1080
|
-
function areArraysEqual() {
|
|
1081
|
-
// Check length
|
|
1082
|
-
if (obj1.length !== obj2.length)
|
|
1083
|
-
return false;
|
|
1084
|
-
// Check each item in the array
|
|
1085
|
-
for (let i = 0; i < obj1.length; i++) {
|
|
1086
|
-
if (!isEqual(obj1[i], obj2[i]))
|
|
1087
|
-
return false;
|
|
1088
|
-
}
|
|
1089
|
-
// If no errors, return true
|
|
1090
|
-
return true;
|
|
1091
|
-
}
|
|
1092
|
-
function areObjectsEqual() {
|
|
1093
|
-
if (Object.keys(obj1).length !== Object.keys(obj2).length)
|
|
1094
|
-
return false;
|
|
1095
|
-
// Check each item in the object
|
|
1096
|
-
for (let key in obj1) {
|
|
1097
|
-
if (Object.prototype.hasOwnProperty.call(obj1, key)) {
|
|
1098
|
-
if (!isEqual(obj1[key], obj2[key])) {
|
|
1099
|
-
return false;
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
// If no errors, return true
|
|
1104
|
-
return true;
|
|
1105
|
-
}
|
|
1106
|
-
function areFilesEqual() {
|
|
1107
|
-
return obj1.lastModified === obj2.lastModified
|
|
1108
|
-
&& obj1.size === obj2.size
|
|
1109
|
-
&& obj1.type === obj2.type;
|
|
1110
|
-
}
|
|
1111
|
-
function areFunctionsEqual() {
|
|
1112
|
-
return obj1.toString() === obj2.toString();
|
|
1113
|
-
}
|
|
1114
|
-
function arePrimativesEqual() {
|
|
1115
|
-
return obj1 === obj2;
|
|
1093
|
+
function getFirstDayOfYear(date) {
|
|
1094
|
+
if (isDefined(date) && date instanceof Date) {
|
|
1095
|
+
return new Date(date.getFullYear(), 0, 1);
|
|
1116
1096
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1097
|
+
return date;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Return last day of year as date from date value
|
|
1101
|
+
* @param date Date value
|
|
1102
|
+
* @returns Last day of year as date
|
|
1103
|
+
*/
|
|
1104
|
+
function getLastDayOfYear(date) {
|
|
1105
|
+
if (isDefined(date) && date instanceof Date) {
|
|
1106
|
+
return new Date(date.getFullYear(), 12, 0);
|
|
1119
1107
|
}
|
|
1120
|
-
|
|
1121
|
-
let type = getType(obj1);
|
|
1122
|
-
// If the two items are not the same type, return false
|
|
1123
|
-
if (type !== getType(obj2))
|
|
1124
|
-
return false;
|
|
1125
|
-
// Compare based on type
|
|
1126
|
-
if (type === 'array')
|
|
1127
|
-
return areArraysEqual();
|
|
1128
|
-
if (type === 'date')
|
|
1129
|
-
return areDatesEqual();
|
|
1130
|
-
if (type === 'file')
|
|
1131
|
-
return areFilesEqual();
|
|
1132
|
-
if (type === 'object')
|
|
1133
|
-
return areObjectsEqual();
|
|
1134
|
-
if (type === 'function')
|
|
1135
|
-
return areFunctionsEqual();
|
|
1136
|
-
return arePrimativesEqual();
|
|
1108
|
+
return date;
|
|
1137
1109
|
}
|
|
1138
1110
|
/**
|
|
1139
|
-
*
|
|
1140
|
-
* @
|
|
1111
|
+
* Return first day of month as date
|
|
1112
|
+
* @param year Year value
|
|
1113
|
+
* @param month Month value
|
|
1114
|
+
* @returns First day of month
|
|
1141
1115
|
*/
|
|
1142
|
-
function
|
|
1143
|
-
|
|
1144
|
-
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
1145
|
-
};
|
|
1146
|
-
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
|
|
1116
|
+
function getFirstDayOfMonthByYearAndMonth(year, month) {
|
|
1117
|
+
return new Date(year, month, 1);
|
|
1147
1118
|
}
|
|
1148
1119
|
/**
|
|
1149
|
-
*
|
|
1150
|
-
* @param
|
|
1151
|
-
* @
|
|
1120
|
+
* Return last day of month as date
|
|
1121
|
+
* @param year Year value
|
|
1122
|
+
* @param month Month value
|
|
1123
|
+
* @returns Last day of month
|
|
1152
1124
|
*/
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1155
|
-
const json = JSON.parse(value);
|
|
1156
|
-
return (typeof json === 'object');
|
|
1157
|
-
}
|
|
1158
|
-
catch (e) {
|
|
1159
|
-
return false;
|
|
1160
|
-
}
|
|
1125
|
+
function getLastDayOfMonthByYearAndMonth(year, month) {
|
|
1126
|
+
return new Date(year, month + 1, 0);
|
|
1161
1127
|
}
|
|
1162
1128
|
/**
|
|
1163
|
-
*
|
|
1164
|
-
* @param
|
|
1129
|
+
* Return week number in month from date value
|
|
1130
|
+
* @param date Date value
|
|
1131
|
+
* @returns Week number
|
|
1132
|
+
*/
|
|
1133
|
+
function getWeeksNumberInMonth(date) {
|
|
1134
|
+
const firstOfMonth = getFirstDayOfMonth(date), lastOfMonth = getLastDayOfMonth(date), used = firstOfMonth.getDay() + lastOfMonth.getDate();
|
|
1135
|
+
return Math.ceil(used / DateTimeConstants.DAYS_IN_WEEK);
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Return true if first and second date are equal
|
|
1139
|
+
* @param date1 First date value
|
|
1140
|
+
* @param date2 Second date value
|
|
1141
|
+
* @returns True if first and second date are equal
|
|
1142
|
+
*/
|
|
1143
|
+
function isEqualDates(date1, date2) {
|
|
1144
|
+
const date1Value = new Date(date1), date2Value = new Date(date2);
|
|
1145
|
+
date1Value.setHours(0, 0, 0, 0);
|
|
1146
|
+
date2Value.setHours(0, 0, 0, 0);
|
|
1147
|
+
return date1Value.getTime() === date2Value.getTime();
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Return true if first and second datetime are equal
|
|
1151
|
+
* @param date1 First datetime value
|
|
1152
|
+
* @param date2 Second datetime value
|
|
1153
|
+
* @returns True if first and second datetime are equal
|
|
1154
|
+
*/
|
|
1155
|
+
function isEqualDateTimes(date1, date2) {
|
|
1156
|
+
const date1Value = new Date(date1), date2Value = new Date(date2);
|
|
1157
|
+
return date1Value.getTime() === date2Value.getTime();
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Return true if first date greater than second date
|
|
1161
|
+
* @param date1 First date value
|
|
1162
|
+
* @param date2 Second date value
|
|
1163
|
+
* @returns True if first date greater than second date
|
|
1164
|
+
*/
|
|
1165
|
+
function isDateGreat(date1, date2) {
|
|
1166
|
+
return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate())
|
|
1167
|
+
> new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Return true if first date greater or equal to second date
|
|
1171
|
+
* @param date1 First date value
|
|
1172
|
+
* @param date2 Second date value
|
|
1173
|
+
* @returns True if first date greater or equal to second date
|
|
1165
1174
|
*/
|
|
1166
|
-
function
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1175
|
+
function isDateGreatOrEqual(date1, date2) {
|
|
1176
|
+
return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate())
|
|
1177
|
+
>= new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
|
1178
|
+
}
|
|
1171
1179
|
/**
|
|
1172
|
-
* Return true if
|
|
1173
|
-
* @param
|
|
1174
|
-
* @
|
|
1180
|
+
* Return true if first date time greater than second date time
|
|
1181
|
+
* @param date1 First date time value
|
|
1182
|
+
* @param date2 Second date time value
|
|
1183
|
+
* @returns True if first date time greater than second date time
|
|
1175
1184
|
*/
|
|
1176
|
-
function
|
|
1177
|
-
return
|
|
1185
|
+
function isDateTimeGreat(date1, date2) {
|
|
1186
|
+
return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate(), date1.getHours(), date1.getMinutes())
|
|
1187
|
+
> new Date(date2.getFullYear(), date2.getMonth(), date2.getDate(), date2.getHours(), date2.getMinutes());
|
|
1178
1188
|
}
|
|
1179
1189
|
/**
|
|
1180
|
-
* Return true if
|
|
1181
|
-
* @param
|
|
1182
|
-
* @param
|
|
1183
|
-
* @returns True if
|
|
1190
|
+
* Return true if first date time greater or equal to second date time
|
|
1191
|
+
* @param date1 First date time value
|
|
1192
|
+
* @param date2 Second date time value
|
|
1193
|
+
* @returns True if first date time greater or equal to second date time
|
|
1184
1194
|
*/
|
|
1185
|
-
function
|
|
1186
|
-
return
|
|
1187
|
-
|
|
1188
|
-
.includes(includeValue.toLowerCase())
|
|
1189
|
-
: false;
|
|
1195
|
+
function isDateTimeGreatOrEqual(date1, date2) {
|
|
1196
|
+
return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate(), date1.getHours(), date1.getMinutes())
|
|
1197
|
+
>= new Date(date2.getFullYear(), date2.getMonth(), date2.getDate(), date2.getHours(), date2.getMinutes());
|
|
1190
1198
|
}
|
|
1191
1199
|
/**
|
|
1192
|
-
* Return
|
|
1193
|
-
* @param
|
|
1194
|
-
* @
|
|
1200
|
+
* Return true if first time greater or equal to second time
|
|
1201
|
+
* @param date1 First date time value
|
|
1202
|
+
* @param date2 Second date time value
|
|
1203
|
+
* @returns True if first time greater or equal to second time
|
|
1195
1204
|
*/
|
|
1196
|
-
function
|
|
1197
|
-
return
|
|
1198
|
-
|
|
1199
|
-
|
|
1205
|
+
function isTimeGreatOrEqual(date1, date2) {
|
|
1206
|
+
return new Date(0, 0, 0, date1.getHours(), date1.getMinutes())
|
|
1207
|
+
>= new Date(0, 0, 0, date2.getHours(), date2.getMinutes());
|
|
1208
|
+
}
|
|
1200
1209
|
/**
|
|
1201
|
-
* Return
|
|
1202
|
-
* @param
|
|
1203
|
-
* @param
|
|
1204
|
-
* @returns
|
|
1210
|
+
* Return true if first time less or equal to second time
|
|
1211
|
+
* @param date1 First date time value
|
|
1212
|
+
* @param date2 Second date time value
|
|
1213
|
+
* @returns True if first time less or equal to second time
|
|
1205
1214
|
*/
|
|
1206
|
-
function
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
const k = 1024;
|
|
1210
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
1211
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
1212
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1213
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
1215
|
+
function isDateTimeLessOrEqual(date1, date2) {
|
|
1216
|
+
return new Date(0, 0, 0, date1.getHours(), date1.getMinutes())
|
|
1217
|
+
<= new Date(0, 0, 0, date2.getHours(), date2.getMinutes());
|
|
1214
1218
|
}
|
|
1215
1219
|
/**
|
|
1216
|
-
* Return
|
|
1217
|
-
* @param
|
|
1218
|
-
* @
|
|
1220
|
+
* Return true if first time less or equal to second time
|
|
1221
|
+
* @param date1 First date time value
|
|
1222
|
+
* @param date2 Second date time value
|
|
1223
|
+
* @returns True if first time less or equal to second time
|
|
1219
1224
|
*/
|
|
1220
|
-
function
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
if (file.name.indexOf('.') === CommonConstants.NOT_FOUND_INDEX) {
|
|
1224
|
-
return CommonConstants.EMPTY_STRING;
|
|
1225
|
-
}
|
|
1226
|
-
return file.name.split('.').pop();
|
|
1225
|
+
function isTimeLessOrEqual(date1, date2) {
|
|
1226
|
+
return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate(), date1.getHours(), date1.getMinutes())
|
|
1227
|
+
<= new Date(date2.getFullYear(), date2.getMonth(), date2.getDate(), date2.getHours(), date2.getMinutes());
|
|
1227
1228
|
}
|
|
1228
1229
|
/**
|
|
1229
|
-
*
|
|
1230
|
-
* @param
|
|
1231
|
-
* @
|
|
1230
|
+
* Convert UTC date to local
|
|
1231
|
+
* @param date Date value
|
|
1232
|
+
* @returns Locale date
|
|
1232
1233
|
*/
|
|
1233
|
-
function
|
|
1234
|
-
|
|
1235
|
-
const reader = new FileReader();
|
|
1236
|
-
reader.onload = () => onLoad(reader.result);
|
|
1237
|
-
reader.readAsDataURL(file);
|
|
1238
|
-
}
|
|
1239
|
-
else
|
|
1240
|
-
throw new Error('File utils | Read as data URL function --> File is empty.');
|
|
1234
|
+
function convertUTCDateToLocalDate(date) {
|
|
1235
|
+
return new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
|
|
1241
1236
|
}
|
|
1242
1237
|
/**
|
|
1243
|
-
*
|
|
1244
|
-
* @param
|
|
1245
|
-
* @returns
|
|
1238
|
+
* Convert Json representation of timestamp to date value
|
|
1239
|
+
* @param timestamp Timestamp for example - 12:23:45
|
|
1240
|
+
* @returns Date value
|
|
1246
1241
|
*/
|
|
1247
|
-
function
|
|
1248
|
-
|
|
1242
|
+
function convertTimestampToDate(timestamp) {
|
|
1243
|
+
const tempTime = timestamp.split(":"), result = new Date();
|
|
1244
|
+
result.setHours(+tempTime[0]);
|
|
1245
|
+
result.setMinutes(+tempTime[1]);
|
|
1246
|
+
result.setSeconds(+tempTime[2]);
|
|
1247
|
+
return result;
|
|
1249
1248
|
}
|
|
1250
1249
|
/**
|
|
1251
|
-
* Convert
|
|
1252
|
-
* @param
|
|
1253
|
-
* @
|
|
1250
|
+
* Convert Date object to timestamp string
|
|
1251
|
+
* @param date Date value
|
|
1252
|
+
* @param locale Locale value
|
|
1253
|
+
* @returns String representation of date value, for example - 12:23
|
|
1254
1254
|
*/
|
|
1255
|
-
function
|
|
1256
|
-
return
|
|
1257
|
-
const reader = new FileReader();
|
|
1258
|
-
reader.readAsDataURL(file);
|
|
1259
|
-
reader.onload = () => resolve(reader.result);
|
|
1260
|
-
reader.onerror = reject;
|
|
1261
|
-
});
|
|
1255
|
+
function convertDateToTimestamp(date, locale = DateTimeConstants.DEFAULT_LOCALE) {
|
|
1256
|
+
return `${formatDate(date, 'HH', locale)}:${formatDate(date, 'mm', locale)}`;
|
|
1262
1257
|
}
|
|
1263
1258
|
/**
|
|
1264
|
-
*
|
|
1265
|
-
* @param
|
|
1266
|
-
* @
|
|
1267
|
-
* @returns File value
|
|
1259
|
+
* Get age from
|
|
1260
|
+
* @param birthdate Date of birth
|
|
1261
|
+
* @returns Age
|
|
1268
1262
|
*/
|
|
1269
|
-
function
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1263
|
+
function getAge(birthdate) {
|
|
1264
|
+
if (!birthdate)
|
|
1265
|
+
return null;
|
|
1266
|
+
const now = new Date();
|
|
1267
|
+
let age = now.getFullYear() - birthdate.getFullYear();
|
|
1268
|
+
const monthDifference = now.getMonth() - birthdate.getMonth();
|
|
1269
|
+
if (monthDifference < 0 || (monthDifference === 0 && now.getDate() < birthdate.getDate())) {
|
|
1270
|
+
age--;
|
|
1271
|
+
}
|
|
1272
|
+
return age;
|
|
1274
1273
|
}
|
|
1275
1274
|
|
|
1276
1275
|
/**
|
|
1277
|
-
* Return
|
|
1278
|
-
* @param value Value
|
|
1279
|
-
* @returns
|
|
1280
|
-
*/
|
|
1281
|
-
function getCssLikeValue(value, type = UIConstants.CSS_PIXELS) {
|
|
1282
|
-
return value + type;
|
|
1283
|
-
}
|
|
1284
|
-
/**
|
|
1285
|
-
* Parse CSS like value to number
|
|
1286
|
-
* @param value CSS like value
|
|
1287
|
-
* @returns Number value
|
|
1276
|
+
* Return true if value defined
|
|
1277
|
+
* @param value Value to check
|
|
1278
|
+
* @returns True if value is not null and defined
|
|
1288
1279
|
*/
|
|
1289
|
-
function
|
|
1290
|
-
return
|
|
1280
|
+
function isDefined(value) {
|
|
1281
|
+
return value !== undefined && value !== null;
|
|
1291
1282
|
}
|
|
1292
1283
|
/**
|
|
1293
|
-
* Return
|
|
1294
|
-
* @param value
|
|
1295
|
-
* @
|
|
1296
|
-
* @returns Calc value
|
|
1284
|
+
* Return true if value is object
|
|
1285
|
+
* @param value Value to check
|
|
1286
|
+
* @returns True if value is object
|
|
1297
1287
|
*/
|
|
1298
|
-
function
|
|
1299
|
-
return
|
|
1288
|
+
function isObject(value) {
|
|
1289
|
+
return (isDefined(value) && typeof value === 'object'
|
|
1290
|
+
&& !Array.isArray(value)
|
|
1291
|
+
&& !(value instanceof Date || value instanceof File));
|
|
1300
1292
|
}
|
|
1301
1293
|
/**
|
|
1302
|
-
* Return
|
|
1303
|
-
* @param
|
|
1304
|
-
* @returns
|
|
1294
|
+
* Return true if data is observable
|
|
1295
|
+
* @param data Object to check
|
|
1296
|
+
* @returns True if data is observable
|
|
1305
1297
|
*/
|
|
1306
|
-
function
|
|
1307
|
-
return
|
|
1298
|
+
function isAsyncData(data) {
|
|
1299
|
+
return data instanceof Observable;
|
|
1308
1300
|
}
|
|
1309
1301
|
/**
|
|
1310
|
-
*
|
|
1311
|
-
* @param
|
|
1312
|
-
* @param
|
|
1302
|
+
* Return extended object with new property
|
|
1303
|
+
* @param obj Object to extend by property
|
|
1304
|
+
* @param property New property name
|
|
1305
|
+
* @param value Value for new property
|
|
1306
|
+
* @returns Extended object with new property
|
|
1313
1307
|
*/
|
|
1314
|
-
function
|
|
1315
|
-
if (isDefined(
|
|
1316
|
-
|
|
1308
|
+
function addPropertyToObject(obj, property, value = null) {
|
|
1309
|
+
if (isDefined(property) && !obj.hasOwnProperty(property)) {
|
|
1310
|
+
let newObj = {};
|
|
1311
|
+
newObj[property] = value;
|
|
1312
|
+
obj = Object.assign(Object.assign({}, obj), newObj);
|
|
1317
1313
|
}
|
|
1314
|
+
return obj;
|
|
1318
1315
|
}
|
|
1319
1316
|
/**
|
|
1320
|
-
* Remove
|
|
1321
|
-
* @param
|
|
1322
|
-
* @param
|
|
1317
|
+
* Remove property from object
|
|
1318
|
+
* @param obj Object for removing property
|
|
1319
|
+
* @param property Property name to remove
|
|
1323
1320
|
*/
|
|
1324
|
-
function
|
|
1325
|
-
if (
|
|
1326
|
-
|
|
1321
|
+
function removePropertyFromObject(obj, property) {
|
|
1322
|
+
if (obj.hasOwnProperty(property)) {
|
|
1323
|
+
delete obj[property];
|
|
1327
1324
|
}
|
|
1328
1325
|
}
|
|
1329
1326
|
/**
|
|
1330
|
-
*
|
|
1331
|
-
* @param
|
|
1332
|
-
* @param
|
|
1333
|
-
* @
|
|
1334
|
-
* @returns HEX value
|
|
1327
|
+
* Deep merge object with others
|
|
1328
|
+
* @param target Object to merge
|
|
1329
|
+
* @param sources Objects to be merged with target
|
|
1330
|
+
* @returns Merged object
|
|
1335
1331
|
*/
|
|
1336
|
-
function
|
|
1337
|
-
|
|
1332
|
+
function mergeDeep(target, ...sources) {
|
|
1333
|
+
if (!sources.length)
|
|
1334
|
+
return target;
|
|
1335
|
+
const source = sources.shift();
|
|
1336
|
+
if (isObject(target) && isObject(source)) {
|
|
1337
|
+
for (const key in source) {
|
|
1338
|
+
if (isObject(source[key])) {
|
|
1339
|
+
if (!target[key])
|
|
1340
|
+
Object.assign(target, { [key]: {} });
|
|
1341
|
+
mergeDeep(target[key], source[key]);
|
|
1342
|
+
}
|
|
1343
|
+
else {
|
|
1344
|
+
Object.assign(target, { [key]: source[key] });
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
return mergeDeep(target, ...sources);
|
|
1338
1349
|
}
|
|
1339
1350
|
/**
|
|
1340
|
-
*
|
|
1341
|
-
* @param
|
|
1342
|
-
* @returns
|
|
1351
|
+
* Get type's property name safety
|
|
1352
|
+
* @param name KeyOf property
|
|
1353
|
+
* @returns Type's property name
|
|
1343
1354
|
*/
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
return null;
|
|
1355
|
+
const nameof = (name) => name;
|
|
1356
|
+
/**
|
|
1357
|
+
* Determines if the input is a Number or something that can be coerced to a Number
|
|
1358
|
+
* @param number The input to be tested
|
|
1359
|
+
* @returns - An indication if the input is a Number or can be coerced to a Number
|
|
1360
|
+
*/
|
|
1361
|
+
function isNumeric(number) {
|
|
1362
|
+
return !isNaN(parseFloat(number));
|
|
1353
1363
|
}
|
|
1354
1364
|
/**
|
|
1355
|
-
*
|
|
1356
|
-
* @param
|
|
1357
|
-
* @
|
|
1358
|
-
* @returns RGB value with relevant opacity
|
|
1365
|
+
* Determines if the input is a string
|
|
1366
|
+
* @param value The input to be tested
|
|
1367
|
+
* @returns An indication if the input is a string
|
|
1359
1368
|
*/
|
|
1360
|
-
function
|
|
1361
|
-
return
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1369
|
+
function isString(value) {
|
|
1370
|
+
return typeof value === 'string';
|
|
1371
|
+
}
|
|
1364
1372
|
/**
|
|
1365
|
-
* Return true if
|
|
1366
|
-
* @
|
|
1367
|
-
* @returns True if collection not empty
|
|
1373
|
+
* Return true if current browser is Chrome
|
|
1374
|
+
* @returns If current browser is Chrome
|
|
1368
1375
|
*/
|
|
1369
|
-
function
|
|
1370
|
-
return
|
|
1376
|
+
function isChromeBrowser() {
|
|
1377
|
+
return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
|
|
1371
1378
|
}
|
|
1372
1379
|
/**
|
|
1373
|
-
* Return true if
|
|
1374
|
-
* @
|
|
1375
|
-
* @param value Value to check
|
|
1376
|
-
* @returns True if found value in collection
|
|
1380
|
+
* Return true if value is valid email address
|
|
1381
|
+
* @returns True if it's valid email address
|
|
1377
1382
|
*/
|
|
1378
|
-
function
|
|
1379
|
-
return
|
|
1380
|
-
&& collection.findIndex(item => item === value) !== CommonConstants.NOT_FOUND_INDEX;
|
|
1383
|
+
function isEmail(value) {
|
|
1384
|
+
return isDefined(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,}))$/));
|
|
1381
1385
|
}
|
|
1382
1386
|
/**
|
|
1383
|
-
* Return true if
|
|
1384
|
-
* @
|
|
1385
|
-
* @param predicate Function to define check logic
|
|
1386
|
-
* @returns True if found value in collection
|
|
1387
|
+
* Return true if string is "true"
|
|
1388
|
+
* @returns parsed string as boolean
|
|
1387
1389
|
*/
|
|
1388
|
-
function
|
|
1389
|
-
return
|
|
1390
|
+
function parseBoolean(value) {
|
|
1391
|
+
return /^true$/i.test(value);
|
|
1390
1392
|
}
|
|
1391
1393
|
/**
|
|
1392
|
-
* Return true if
|
|
1393
|
-
* @param
|
|
1394
|
-
* @param
|
|
1395
|
-
* @
|
|
1396
|
-
* @returns True if found value in collection
|
|
1394
|
+
* Return true if values equal
|
|
1395
|
+
* @param obj1 First value to compare
|
|
1396
|
+
* @param obj2 Second value to compare
|
|
1397
|
+
* @returns True if equal
|
|
1397
1398
|
*/
|
|
1398
|
-
function
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1399
|
+
function isEqual(obj1, obj2) {
|
|
1400
|
+
/**
|
|
1401
|
+
* More accurately check the type of a JavaScript object
|
|
1402
|
+
* @param {Object} obj The object
|
|
1403
|
+
* @return {String} The object type
|
|
1404
|
+
*/
|
|
1405
|
+
function getType(obj) {
|
|
1406
|
+
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
|
|
1407
|
+
}
|
|
1408
|
+
function areArraysEqual() {
|
|
1409
|
+
// Check length
|
|
1410
|
+
if (obj1.length !== obj2.length)
|
|
1411
|
+
return false;
|
|
1412
|
+
// Check each item in the array
|
|
1413
|
+
for (let i = 0; i < obj1.length; i++) {
|
|
1414
|
+
if (!isEqual(obj1[i], obj2[i]))
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
// If no errors, return true
|
|
1418
|
+
return true;
|
|
1419
|
+
}
|
|
1420
|
+
function areObjectsEqual() {
|
|
1421
|
+
if (Object.keys(obj1).length !== Object.keys(obj2).length)
|
|
1422
|
+
return false;
|
|
1423
|
+
// Check each item in the object
|
|
1424
|
+
for (let key in obj1) {
|
|
1425
|
+
if (Object.prototype.hasOwnProperty.call(obj1, key)) {
|
|
1426
|
+
if (!isEqual(obj1[key], obj2[key])) {
|
|
1427
|
+
return false;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
// If no errors, return true
|
|
1432
|
+
return true;
|
|
1433
|
+
}
|
|
1434
|
+
function areFilesEqual() {
|
|
1435
|
+
return obj1.lastModified === obj2.lastModified
|
|
1436
|
+
&& obj1.size === obj2.size
|
|
1437
|
+
&& obj1.type === obj2.type;
|
|
1438
|
+
}
|
|
1439
|
+
function areFunctionsEqual() {
|
|
1440
|
+
return obj1.toString() === obj2.toString();
|
|
1441
|
+
}
|
|
1442
|
+
function arePrimativesEqual() {
|
|
1443
|
+
return obj1 === obj2;
|
|
1444
|
+
}
|
|
1445
|
+
function areDatesEqual() {
|
|
1446
|
+
return isEqualDateTimes(obj1, obj2);
|
|
1447
|
+
}
|
|
1448
|
+
// Get the object type
|
|
1449
|
+
let type = getType(obj1);
|
|
1450
|
+
// If the two items are not the same type, return false
|
|
1451
|
+
if (type !== getType(obj2))
|
|
1452
|
+
return false;
|
|
1453
|
+
// Compare based on type
|
|
1454
|
+
if (type === 'array')
|
|
1455
|
+
return areArraysEqual();
|
|
1456
|
+
if (type === 'date')
|
|
1457
|
+
return areDatesEqual();
|
|
1458
|
+
if (type === 'file')
|
|
1459
|
+
return areFilesEqual();
|
|
1460
|
+
if (type === 'object')
|
|
1461
|
+
return areObjectsEqual();
|
|
1462
|
+
if (type === 'function')
|
|
1463
|
+
return areFunctionsEqual();
|
|
1464
|
+
return arePrimativesEqual();
|
|
1403
1465
|
}
|
|
1404
1466
|
/**
|
|
1405
|
-
*
|
|
1406
|
-
* @
|
|
1407
|
-
* @param collection2 Array of objects where try to find
|
|
1408
|
-
* @returns
|
|
1467
|
+
* Generate unique identificator
|
|
1468
|
+
* @returns Random GUID
|
|
1409
1469
|
*/
|
|
1410
|
-
function
|
|
1411
|
-
|
|
1470
|
+
function generateGuid() {
|
|
1471
|
+
let S4 = function () {
|
|
1472
|
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
1473
|
+
};
|
|
1474
|
+
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
|
|
1412
1475
|
}
|
|
1413
1476
|
/**
|
|
1414
|
-
*
|
|
1415
|
-
* @param
|
|
1416
|
-
* @
|
|
1417
|
-
* @returns Value from collection
|
|
1477
|
+
* Check if value is Json parsable string
|
|
1478
|
+
* @param value string value
|
|
1479
|
+
* @returns True if string can be JSON parsed
|
|
1418
1480
|
*/
|
|
1419
|
-
function
|
|
1420
|
-
|
|
1481
|
+
function isJsonString(value) {
|
|
1482
|
+
try {
|
|
1483
|
+
const json = JSON.parse(value);
|
|
1484
|
+
return (typeof json === 'object');
|
|
1485
|
+
}
|
|
1486
|
+
catch (e) {
|
|
1487
|
+
return false;
|
|
1488
|
+
}
|
|
1421
1489
|
}
|
|
1422
1490
|
/**
|
|
1423
|
-
*
|
|
1424
|
-
* @param
|
|
1425
|
-
* @returns First value from collection
|
|
1491
|
+
* Stop propagation and prevent default
|
|
1492
|
+
* @param event Event object
|
|
1426
1493
|
*/
|
|
1427
|
-
function
|
|
1428
|
-
|
|
1494
|
+
function stopAndPreventPropagation(event) {
|
|
1495
|
+
event.preventDefault();
|
|
1496
|
+
event.stopPropagation();
|
|
1429
1497
|
}
|
|
1430
1498
|
/**
|
|
1431
|
-
*
|
|
1432
|
-
* @param
|
|
1433
|
-
* @
|
|
1499
|
+
* Update property in object by key
|
|
1500
|
+
* @param obj Object to change
|
|
1501
|
+
* @param propertyKey Property to change
|
|
1502
|
+
* @param newPropertyValue New property value
|
|
1503
|
+
* @param oldPropertyValue Old property value
|
|
1504
|
+
* @returns Updated object
|
|
1434
1505
|
*/
|
|
1435
|
-
function
|
|
1436
|
-
|
|
1506
|
+
function updatePropertyByKey(obj, propertyKey, newPropertyValue, oldPropertyValue) {
|
|
1507
|
+
if (Array.isArray(obj)) {
|
|
1508
|
+
return obj.map(item => {
|
|
1509
|
+
return isObject(item) && item !== null
|
|
1510
|
+
? updatePropertyByKey(item, propertyKey, newPropertyValue, oldPropertyValue)
|
|
1511
|
+
: item;
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
else if (isObject(obj) && obj !== null) {
|
|
1515
|
+
const updatedObj = {};
|
|
1516
|
+
for (const key in obj) {
|
|
1517
|
+
if (key === propertyKey) {
|
|
1518
|
+
if (Array.isArray(obj[key])) {
|
|
1519
|
+
if (hasItem(obj[key], oldPropertyValue)) {
|
|
1520
|
+
removeItem(obj[key], oldPropertyValue);
|
|
1521
|
+
}
|
|
1522
|
+
else {
|
|
1523
|
+
addItem(obj[key], oldPropertyValue);
|
|
1524
|
+
}
|
|
1525
|
+
updatedObj[key] = obj[key];
|
|
1526
|
+
}
|
|
1527
|
+
else {
|
|
1528
|
+
updatedObj[key] = newPropertyValue;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
else {
|
|
1532
|
+
updatedObj[key] = updatePropertyByKey(obj[key], propertyKey, newPropertyValue, oldPropertyValue);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
return updatedObj;
|
|
1536
|
+
}
|
|
1537
|
+
return obj;
|
|
1437
1538
|
}
|
|
1438
1539
|
/**
|
|
1439
|
-
*
|
|
1440
|
-
* @param
|
|
1441
|
-
* @param
|
|
1442
|
-
* @
|
|
1540
|
+
* Get changed property path
|
|
1541
|
+
* @param previous Previous value
|
|
1542
|
+
* @param current Currency value
|
|
1543
|
+
* @param parentKey Parent object key name
|
|
1544
|
+
* @returns Path of property that was changed
|
|
1443
1545
|
*/
|
|
1444
|
-
function
|
|
1445
|
-
|
|
1546
|
+
function findChangedPropertyPath(previous, current, parentKey = '') {
|
|
1547
|
+
for (const key of Object.keys(current)) {
|
|
1548
|
+
const fullKey = parentKey ? `${parentKey}.${key}` : key;
|
|
1549
|
+
if (isObject(current[key]) && current[key] !== null && previous[key]) {
|
|
1550
|
+
const nestedChange = findChangedPropertyPath(previous[key], current[key], fullKey);
|
|
1551
|
+
if (nestedChange) {
|
|
1552
|
+
return nestedChange;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
else {
|
|
1556
|
+
if (previous[key] !== current[key]) {
|
|
1557
|
+
return fullKey;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
return null;
|
|
1446
1562
|
}
|
|
1447
1563
|
/**
|
|
1448
|
-
*
|
|
1449
|
-
* @param
|
|
1450
|
-
* @param
|
|
1451
|
-
* @returns
|
|
1564
|
+
* Get changed property key
|
|
1565
|
+
* @param previous Previous value
|
|
1566
|
+
* @param current Currency value
|
|
1567
|
+
* @returns Key of property that was changed
|
|
1452
1568
|
*/
|
|
1453
|
-
function
|
|
1454
|
-
|
|
1569
|
+
function findChangedPropertyKey(previous, current) {
|
|
1570
|
+
const path = findChangedPropertyPath(previous, current), parts = path === null || path === void 0 ? void 0 : path.split('.');
|
|
1571
|
+
return parts && parts.length ? parts[parts.length - 1] : undefined;
|
|
1455
1572
|
}
|
|
1456
1573
|
/**
|
|
1457
|
-
*
|
|
1458
|
-
* @param
|
|
1459
|
-
* @
|
|
1460
|
-
* @returns Values from collection
|
|
1574
|
+
* Clone object without any reference
|
|
1575
|
+
* @param value Object to clone
|
|
1576
|
+
* @returns Cloned object
|
|
1461
1577
|
*/
|
|
1462
|
-
function
|
|
1463
|
-
return
|
|
1464
|
-
}
|
|
1578
|
+
function deepClone(value) {
|
|
1579
|
+
return JSON.parse(JSON.stringify(value));
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1465
1582
|
/**
|
|
1466
|
-
* Return
|
|
1467
|
-
* @param
|
|
1468
|
-
* @param
|
|
1469
|
-
* @
|
|
1470
|
-
* @returns Sliced collection
|
|
1583
|
+
* Return parsed file size as string
|
|
1584
|
+
* @param bytes Bytes count
|
|
1585
|
+
* @param decimals Value after dot
|
|
1586
|
+
* @returns Parsed file size
|
|
1471
1587
|
*/
|
|
1472
|
-
function
|
|
1473
|
-
if (
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
if (any(collection)) {
|
|
1481
|
-
return direction == SortingDirection.Ascending
|
|
1482
|
-
? collection.sort((a, b) => a - b)
|
|
1483
|
-
: collection.sort((a, b) => b - a);
|
|
1484
|
-
}
|
|
1485
|
-
return collection;
|
|
1588
|
+
function parseFileSize(bytes, decimals = 2) {
|
|
1589
|
+
if (bytes === 0)
|
|
1590
|
+
return '0';
|
|
1591
|
+
const k = 1024;
|
|
1592
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
1593
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
1594
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1595
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
1486
1596
|
}
|
|
1487
1597
|
/**
|
|
1488
|
-
* Return
|
|
1489
|
-
* @param
|
|
1490
|
-
* @
|
|
1491
|
-
* @param direction Sorting direction
|
|
1492
|
-
* @returns Sorted collection
|
|
1598
|
+
* Return file extension
|
|
1599
|
+
* @param file File value
|
|
1600
|
+
* @returns File extension
|
|
1493
1601
|
*/
|
|
1494
|
-
function
|
|
1495
|
-
if (
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
: collection.sort((a, b) => _sortFunc(a, b)(-1, 1));
|
|
1602
|
+
function getFileExtension(file) {
|
|
1603
|
+
if (!isDefined(file))
|
|
1604
|
+
return CommonConstants.EMPTY_STRING;
|
|
1605
|
+
if (file.name.indexOf('.') === CommonConstants.NOT_FOUND_INDEX) {
|
|
1606
|
+
return CommonConstants.EMPTY_STRING;
|
|
1500
1607
|
}
|
|
1501
|
-
return
|
|
1608
|
+
return file.name.split('.').pop();
|
|
1502
1609
|
}
|
|
1503
1610
|
/**
|
|
1504
|
-
*
|
|
1505
|
-
* @param
|
|
1506
|
-
* @param
|
|
1507
|
-
* @param direction Sorting direction
|
|
1508
|
-
* @returns Sorted collection
|
|
1611
|
+
* Read file as data URL
|
|
1612
|
+
* @param file File value
|
|
1613
|
+
* @param onLoad On load action
|
|
1509
1614
|
*/
|
|
1510
|
-
function
|
|
1511
|
-
if (
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
if (!any(pathParts))
|
|
1516
|
-
throw new Error('Collection utils | Sort By Path function --> Path is incorrect.');
|
|
1517
|
-
const partsLength = pathParts.length;
|
|
1518
|
-
collection.sort((a, b) => {
|
|
1519
|
-
var i = 0;
|
|
1520
|
-
while (i < partsLength) {
|
|
1521
|
-
a = a[pathParts[i]];
|
|
1522
|
-
b = b[pathParts[i]];
|
|
1523
|
-
i++;
|
|
1524
|
-
}
|
|
1525
|
-
return direction == SortingDirection.Ascending
|
|
1526
|
-
? a >= b ? 1 : -1
|
|
1527
|
-
: a > b ? -1 : 1;
|
|
1528
|
-
});
|
|
1529
|
-
return collection;
|
|
1615
|
+
function readAsDataURL(file, onLoad) {
|
|
1616
|
+
if (isDefined(file)) {
|
|
1617
|
+
const reader = new FileReader();
|
|
1618
|
+
reader.onload = () => onLoad(reader.result);
|
|
1619
|
+
reader.readAsDataURL(file);
|
|
1530
1620
|
}
|
|
1531
|
-
|
|
1621
|
+
else
|
|
1622
|
+
throw new Error('File utils | Read as data URL function --> File is empty.');
|
|
1532
1623
|
}
|
|
1533
1624
|
/**
|
|
1534
|
-
* Return
|
|
1535
|
-
* @param
|
|
1536
|
-
* @returns
|
|
1625
|
+
* Return true if file is image
|
|
1626
|
+
* @param file File value
|
|
1627
|
+
* @returns True if file is image
|
|
1537
1628
|
*/
|
|
1538
|
-
function
|
|
1539
|
-
return
|
|
1540
|
-
? collection.filter((value, index, self) => self.indexOf(value) === index)
|
|
1541
|
-
: collection;
|
|
1629
|
+
function isImage(file) {
|
|
1630
|
+
return isDefined(file) && (/\.(gif|jpe?g|jpg|tiff|png|webp|bmp)$/i).test(file.name);
|
|
1542
1631
|
}
|
|
1543
1632
|
/**
|
|
1544
|
-
*
|
|
1545
|
-
* @param
|
|
1546
|
-
* @
|
|
1547
|
-
* @returns Sum value of colection items
|
|
1633
|
+
* Convert file to base64 string
|
|
1634
|
+
* @param file File value
|
|
1635
|
+
* @returns Base64 string
|
|
1548
1636
|
*/
|
|
1549
|
-
function
|
|
1550
|
-
return
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1637
|
+
function convertToBase64String(file) {
|
|
1638
|
+
return new Promise((resolve, reject) => {
|
|
1639
|
+
const reader = new FileReader();
|
|
1640
|
+
reader.readAsDataURL(file);
|
|
1641
|
+
reader.onload = () => resolve(reader.result);
|
|
1642
|
+
reader.onerror = reject;
|
|
1643
|
+
});
|
|
1555
1644
|
}
|
|
1556
1645
|
/**
|
|
1557
|
-
*
|
|
1558
|
-
* @param
|
|
1559
|
-
* @param
|
|
1560
|
-
* @returns
|
|
1646
|
+
* Convert base64 string to file
|
|
1647
|
+
* @param base64 Base64 string
|
|
1648
|
+
* @param name File name
|
|
1649
|
+
* @returns File value
|
|
1561
1650
|
*/
|
|
1562
|
-
function
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1651
|
+
function convertFromBase64String(base64, name) {
|
|
1652
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1653
|
+
const res = yield fetch(base64), blob = yield res.blob(), extension = base64.substring("data:image/".length, base64.indexOf(";base64"));
|
|
1654
|
+
return new File([blob], `${name}.${extension}`, { type: `image/${extension}` });
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/**
|
|
1659
|
+
* Return CSS like value
|
|
1660
|
+
* @param value Value as number
|
|
1661
|
+
* @returns Value as '1px'
|
|
1662
|
+
*/
|
|
1663
|
+
function getCssLikeValue(value, type = UIConstants.CSS_PIXELS) {
|
|
1664
|
+
return value + type;
|
|
1566
1665
|
}
|
|
1567
1666
|
/**
|
|
1568
|
-
*
|
|
1569
|
-
* @param
|
|
1570
|
-
* @
|
|
1667
|
+
* Parse CSS like value to number
|
|
1668
|
+
* @param value CSS like value
|
|
1669
|
+
* @returns Number value
|
|
1571
1670
|
*/
|
|
1572
|
-
function
|
|
1573
|
-
|
|
1574
|
-
while (i--) {
|
|
1575
|
-
if (predicate(collection[i])) {
|
|
1576
|
-
collection.splice(i, 1);
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1671
|
+
function getValueFromCssLikeValue(value, type = UIConstants.CSS_PIXELS) {
|
|
1672
|
+
return +value.replace(type, CommonConstants.EMPTY_STRING);
|
|
1579
1673
|
}
|
|
1580
1674
|
/**
|
|
1581
|
-
*
|
|
1582
|
-
* @param
|
|
1583
|
-
* @param
|
|
1584
|
-
* @
|
|
1585
|
-
* @returns True if successfully added
|
|
1675
|
+
* Return CCS like calc value
|
|
1676
|
+
* @param value All value (100% by default)
|
|
1677
|
+
* @param part Part value
|
|
1678
|
+
* @returns Calc value
|
|
1586
1679
|
*/
|
|
1587
|
-
function
|
|
1588
|
-
|
|
1589
|
-
collection = new Array();
|
|
1590
|
-
if (isDefined(predicate) && predicate(item))
|
|
1591
|
-
return false;
|
|
1592
|
-
collection.push(item);
|
|
1593
|
-
return true;
|
|
1680
|
+
function getCalcValue(part, value = 100) {
|
|
1681
|
+
return `calc(${value}${UIConstants.CSS_PERCENTAGE} / ${part} )`;
|
|
1594
1682
|
}
|
|
1595
1683
|
/**
|
|
1596
|
-
*
|
|
1597
|
-
* @param
|
|
1598
|
-
* @
|
|
1599
|
-
* @returns True if successfully removed
|
|
1684
|
+
* Return CCS like rotate value
|
|
1685
|
+
* @param value value as degrees
|
|
1686
|
+
* @returns Rotate value
|
|
1600
1687
|
*/
|
|
1601
|
-
function
|
|
1602
|
-
|
|
1603
|
-
collection.splice(collection.indexOf(item), 1);
|
|
1604
|
-
return true;
|
|
1605
|
-
}
|
|
1606
|
-
return false;
|
|
1688
|
+
function getRotateValue(value) {
|
|
1689
|
+
return `rotate(${value}deg)`;
|
|
1607
1690
|
}
|
|
1608
1691
|
/**
|
|
1609
|
-
*
|
|
1610
|
-
* @param
|
|
1611
|
-
* @param
|
|
1612
|
-
* @returns True if successfully removed
|
|
1692
|
+
* Add classes to HTML element
|
|
1693
|
+
* @param element HTML element
|
|
1694
|
+
* @param classNames Array of CSS classes
|
|
1613
1695
|
*/
|
|
1614
|
-
function
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
collection.splice(collection.indexOf(foundItem), 1);
|
|
1618
|
-
return true;
|
|
1696
|
+
function addClasses(element, ...classNames) {
|
|
1697
|
+
if (isDefined(element)) {
|
|
1698
|
+
classNames.forEach((className) => element.classList.add(className));
|
|
1619
1699
|
}
|
|
1620
|
-
return false;
|
|
1621
1700
|
}
|
|
1622
1701
|
/**
|
|
1623
|
-
*
|
|
1624
|
-
* @param
|
|
1625
|
-
* @param
|
|
1626
|
-
* @returns True if successfully removed
|
|
1702
|
+
* Remove classes to HTML element
|
|
1703
|
+
* @param element HTML element
|
|
1704
|
+
* @param classNames Array of CSS classes
|
|
1627
1705
|
*/
|
|
1628
|
-
function
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
const result = collection.slice(0);
|
|
1632
|
-
result[itemIndex] = Object.assign(Object.assign({}, collection[itemIndex]), newItem);
|
|
1633
|
-
return result;
|
|
1706
|
+
function removeClasses(element, ...classNames) {
|
|
1707
|
+
if (isDefined(element)) {
|
|
1708
|
+
classNames.forEach((className) => element.classList.remove(className));
|
|
1634
1709
|
}
|
|
1635
|
-
return null;
|
|
1636
1710
|
}
|
|
1637
1711
|
/**
|
|
1638
|
-
*
|
|
1639
|
-
* @param
|
|
1640
|
-
* @
|
|
1712
|
+
* Convert RGB color to HEX
|
|
1713
|
+
* @param r Red
|
|
1714
|
+
* @param g Green
|
|
1715
|
+
* @param b Blue
|
|
1716
|
+
* @returns HEX value
|
|
1641
1717
|
*/
|
|
1642
|
-
function
|
|
1643
|
-
return
|
|
1718
|
+
function rgbToHex(r, g, b) {
|
|
1719
|
+
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
1644
1720
|
}
|
|
1645
1721
|
/**
|
|
1646
|
-
*
|
|
1647
|
-
* @param
|
|
1648
|
-
* @
|
|
1649
|
-
* @returns True if arrays are equal
|
|
1722
|
+
* Convert HEX to RGB value
|
|
1723
|
+
* @param hex HEX value
|
|
1724
|
+
* @returns RGB value
|
|
1650
1725
|
*/
|
|
1651
|
-
function
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
return false;
|
|
1726
|
+
function hexToRgb(hex) {
|
|
1727
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
1728
|
+
if (result) {
|
|
1729
|
+
var r = parseInt(result[1], 16);
|
|
1730
|
+
var g = parseInt(result[2], 16);
|
|
1731
|
+
var b = parseInt(result[3], 16);
|
|
1732
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
1659
1733
|
}
|
|
1660
|
-
return
|
|
1734
|
+
return null;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Set opacity for RGB value
|
|
1738
|
+
* @param rgb Rgb value with {opacity} placeholder
|
|
1739
|
+
* @param opacity Opacity value
|
|
1740
|
+
* @returns RGB value with relevant opacity
|
|
1741
|
+
*/
|
|
1742
|
+
function replaceRgbOpacity(rgb, opacity) {
|
|
1743
|
+
return rgb.replace(UIConstants.RGB_OPACITY_PLACEHOLDER, opacity.toString());
|
|
1661
1744
|
}
|
|
1662
1745
|
|
|
1663
1746
|
/**
|
|
@@ -3247,7 +3330,7 @@ class LoadContainerComponent {
|
|
|
3247
3330
|
})), loader$ = this.pagination ? pagination$ : more$;
|
|
3248
3331
|
return loader$.pipe(map(() => ({ params: params, page: this.page })));
|
|
3249
3332
|
}));
|
|
3250
|
-
return combineLatest([this.sortingService.sorting$.pipe(startWith(this.model.sorting)), parameters$]).pipe(tap(() => this.loading = true), map(([sorting, parameters]) => ({ params: parameters.params, page: parameters.page, sorting: sorting })));
|
|
3333
|
+
return combineLatest([this.sortingService.sorting$.pipe(startWith(this.model.sorting)), parameters$]).pipe(tap(() => this.loading = true), map(([sorting, parameters]) => { var _a; return ({ params: parameters.params, page: parameters.page, size: (_a = this.model.pagination) === null || _a === void 0 ? void 0 : _a.size, sorting: sorting }); }));
|
|
3251
3334
|
}
|
|
3252
3335
|
buildDynamic(parameters$, loader) {
|
|
3253
3336
|
return parameters$.pipe(switchMap((parameters) => loader(parameters)), map((model) => (Object.assign(Object.assign({}, model), { reset: this.reset, page: this.page }))));
|
|
@@ -3255,16 +3338,16 @@ class LoadContainerComponent {
|
|
|
3255
3338
|
buildStatic(parameters$, model) {
|
|
3256
3339
|
const data$ = (model.data$ || of([])).pipe(map((data, index) => ({ data, index })), tap(model => this.source = model.index ? LoadContainerChangesSource.Data : this.source), map(model => model.data));
|
|
3257
3340
|
return combineLatest([parameters$, data$]).pipe(map(([parameters, items]) => {
|
|
3258
|
-
var _a, _b;
|
|
3341
|
+
var _a, _b, _c;
|
|
3259
3342
|
// if data changed need to start from start (pagination)
|
|
3260
3343
|
if (this.source == LoadContainerChangesSource.Data
|
|
3261
3344
|
&& parameters.page != LoadMoreService.START_PAGE) {
|
|
3262
3345
|
this.resetParameters();
|
|
3263
|
-
parameters = { params: parameters.params, page: this.page, sorting: parameters.sorting };
|
|
3346
|
+
parameters = { params: parameters.params, page: this.page, size: (_a = this.model.pagination) === null || _a === void 0 ? void 0 : _a.size, sorting: parameters.sorting };
|
|
3264
3347
|
}
|
|
3265
3348
|
const filtered = model.filter ? model.filter(items, parameters) : items, sorted = parameters.sorting ? sortBy([...filtered], parameters.sorting.id, parameters.sorting.direction) : filtered, data = sorted ? {
|
|
3266
|
-
items: this.model.pagination ? skip(sorted, parameters.page, (
|
|
3267
|
-
next: this.model.pagination ? parameters.page < Math.ceil(sorted.length / ((
|
|
3349
|
+
items: this.model.pagination ? skip(sorted, parameters.page, (_b = this.model.pagination) === null || _b === void 0 ? void 0 : _b.size) : sorted,
|
|
3350
|
+
next: this.model.pagination ? parameters.page < Math.ceil(sorted.length / ((_c = this.model.pagination) === null || _c === void 0 ? void 0 : _c.size)) : false,
|
|
3268
3351
|
reset: this.reset,
|
|
3269
3352
|
total: sorted.length,
|
|
3270
3353
|
page: parameters.page
|
|
@@ -3459,28 +3542,33 @@ TagConstants.DEFAULT_LABEL = 'Tag';
|
|
|
3459
3542
|
|
|
3460
3543
|
class TagComponent {
|
|
3461
3544
|
constructor() {
|
|
3462
|
-
this.close = false;
|
|
3463
3545
|
this.model = {
|
|
3464
3546
|
key: CommonConstants.DEFAULT_KEY_VALUE,
|
|
3465
3547
|
label: TagConstants.DEFAULT_LABEL
|
|
3466
3548
|
};
|
|
3467
|
-
this.
|
|
3549
|
+
this.removeAction = new EventEmitter();
|
|
3550
|
+
}
|
|
3551
|
+
_onClick() {
|
|
3552
|
+
if (this.model.click)
|
|
3553
|
+
this.model.click(this.model);
|
|
3468
3554
|
}
|
|
3469
3555
|
onRemove() {
|
|
3470
|
-
this.
|
|
3556
|
+
this.removeAction.emit(this.model);
|
|
3471
3557
|
}
|
|
3472
3558
|
}
|
|
3473
3559
|
TagComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: TagComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3474
|
-
TagComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: TagComponent, selector: "sfc-tag", inputs: {
|
|
3560
|
+
TagComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: TagComponent, selector: "sfc-tag", inputs: { model: "model" }, outputs: { removeAction: "remove" }, host: { listeners: { "click": "_onClick()" } }, ngImport: i0, template: "<div class=\"container\">\r\n <div class=\"content\">\r\n <sfc-icon [icon]=\"model.icon\" [imageSrc]=\"model.imageSrc\"></sfc-icon>\r\n <span>{{model.label}}</span>\r\n <sfc-close *ngIf=\"model.allowRemove\" (click)=\"onRemove()\"></sfc-close>\r\n </div>\r\n</div>", styles: [":host{display:inline-block}:host .container .content{display:flex;align-items:center;text-align:center;padding:.3em .8em;display:inline-flex;border-radius:1em;font-weight:700;-webkit-user-select:none;user-select:none;transition:color .5s ease;transition:background-color .5s ease;transition:color .5s ease,background-color .5s ease,border-color .5s ease;border:.125em solid transparent}:host .container .content,:host-context(.sfc-default-theme) :host .container .content{color:#fff}:host-context(.sfc-dark-theme) :host .container .content{color:#545e61}:host .container .content,:host-context(.sfc-default-theme) :host .container .content{background-color:#545e61}:host-context(.sfc-dark-theme) :host .container .content{background-color:#fff}:host .container .content sfc-icon{margin-right:.2em}:host .container .content sfc-icon ::ng-deep .container img{max-width:1em;max-height:1em}:host .container .content sfc-close{margin-left:.6em;color:#ed5565;font-size:.8em}:host:hover .container .content{background-color:#ffce54;color:#fff}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: CloseComponent, selector: "sfc-close" }, { kind: "component", type: IconComponent, selector: "sfc-icon", inputs: ["icon", "imageSrc"] }] });
|
|
3475
3561
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: TagComponent, decorators: [{
|
|
3476
3562
|
type: Component,
|
|
3477
|
-
args: [{ selector: 'sfc-tag', template: "<div class=\"container\">\r\n <div class=\"content\">\r\n <sfc-icon
|
|
3478
|
-
}], propDecorators: {
|
|
3479
|
-
type: Input
|
|
3480
|
-
}], model: [{
|
|
3563
|
+
args: [{ selector: 'sfc-tag', template: "<div class=\"container\">\r\n <div class=\"content\">\r\n <sfc-icon [icon]=\"model.icon\" [imageSrc]=\"model.imageSrc\"></sfc-icon>\r\n <span>{{model.label}}</span>\r\n <sfc-close *ngIf=\"model.allowRemove\" (click)=\"onRemove()\"></sfc-close>\r\n </div>\r\n</div>", styles: [":host{display:inline-block}:host .container .content{display:flex;align-items:center;text-align:center;padding:.3em .8em;display:inline-flex;border-radius:1em;font-weight:700;-webkit-user-select:none;user-select:none;transition:color .5s ease;transition:background-color .5s ease;transition:color .5s ease,background-color .5s ease,border-color .5s ease;border:.125em solid transparent}:host .container .content,:host-context(.sfc-default-theme) :host .container .content{color:#fff}:host-context(.sfc-dark-theme) :host .container .content{color:#545e61}:host .container .content,:host-context(.sfc-default-theme) :host .container .content{background-color:#545e61}:host-context(.sfc-dark-theme) :host .container .content{background-color:#fff}:host .container .content sfc-icon{margin-right:.2em}:host .container .content sfc-icon ::ng-deep .container img{max-width:1em;max-height:1em}:host .container .content sfc-close{margin-left:.6em;color:#ed5565;font-size:.8em}:host:hover .container .content{background-color:#ffce54;color:#fff}\n"] }]
|
|
3564
|
+
}], propDecorators: { model: [{
|
|
3481
3565
|
type: Input
|
|
3482
|
-
}],
|
|
3483
|
-
type: Output
|
|
3566
|
+
}], removeAction: [{
|
|
3567
|
+
type: Output,
|
|
3568
|
+
args: ['remove']
|
|
3569
|
+
}], _onClick: [{
|
|
3570
|
+
type: HostListener,
|
|
3571
|
+
args: ['click']
|
|
3484
3572
|
}] } });
|
|
3485
3573
|
|
|
3486
3574
|
class NgxSfcCommonModule {
|
|
@@ -3711,6 +3799,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
3711
3799
|
* Generated bundle index. Do not edit.
|
|
3712
3800
|
*/
|
|
3713
3801
|
|
|
3714
|
-
export { BounceLoaderComponent, BrowserDocumentRef, BrowserWindowRef, ButtonComponent, ButtonType, CheckmarkComponent, CheckmarkType, CircleLoaderComponent, CircleLoaderType, ClickOutsideDirective, CloseComponent, CollapseExpandComponent, CollapseExpandContainerComponent, CollapseExpandDirective, CommonConstants, Compare, ComponentReferenceDirective, ComponentSize, ComponentSizeDirective, DOCUMENT, DOCUMENT_PROVIDERS, DateTimeConstants, DefaultModalFooterComponent, DefaultModalHeaderComponent, DelimeterComponent, DestroyParentDirective, Direction, DocumentRef, DomChangesDirective, DotComponent, DotsComponent, HamburgerComponent, HamburgerMenuComponent, IconComponent, IfDirective, ImageLoadDirective, ImageLoadService, ItemsView, LoadContainerChangesSource, LoadContainerComponent, LoadContainerLoadType, LoadContainerType, LoadMoreButtonComponent, LoadMoreService, LoaderService, MediaLimits, MessageComponent, ModalComponent, ModalOpenDirective, ModalOpenOnClickDirective, ModalService, ModalTemplate, MouseDownDirective, NgxSfcCommonModule, NotificationType, ObservableBehaviorModel, ObservableModel, PaginationComponent, PaginationConstants, PaginationService, Position, ReloadService, RepeatPipe, ResizeService, ScrollIntoViewDirective, ScrollTrackerDirective, Select, Sequence, ShowHideElementDirective, SortByPipe, SortingDirection, SortingService, State, SwitchMultiCasePipe, TagComponent, TemplateContentComponent, TemplateReferenceDirective, Theme, ThrowElementOnHoverDirective, ToggleComponent, ToggleSwitcherComponent, TooltipComponent, TooltipType, UIClass, UIConstants, WINDOW, WINDOW_PROVIDERS, WindowRef, addClasses, addItem, addPropertyToObject, all, any, browserDocumentProvider, browserWindowProvider, buildHttpParams, contains, convertDateToTimestamp, convertFromBase64String, convertTimestampToDate, convertToBase64String, convertUTCDateToLocalDate, count, distinct, documentFactory, documentProvider, firstItem, firstOrDefault, generateGuid, getAge, getCalcValue, getCollectionOrEmpty, getCssLikeValue, getFileExtension, getFirstDayOfMonth, getFirstDayOfMonthByYearAndMonth, getFirstDayOfYear, getLastDayOfMonth, getLastDayOfMonthByYearAndMonth, getLastDayOfYear, getNextDate, getNextMonth, getNextYear, getPreviousDate, getPreviousMonth, getPreviousYear, getRotateValue, getValueFromCssLikeValue, getWeeksNumberInMonth, hasAnyItem, hasItem, hasItemBy, hasObjectItem, hexToRgb, isArraysEquals, isAsyncData, isChromeBrowser, isDateGreat, isDateGreatOrEqual, isDateTimeGreat, isDateTimeGreatOrEqual, isDateTimeLessOrEqual, isDefined, isEmail, isEqual, isEqualDateTimes, isEqualDates, isImage, isJsonString, isNullOrEmptyString, isNumeric, isObject, isString, isTimeGreatOrEqual, isTimeLessOrEqual, lastItem, max, mergeDeep, nameof, parseBoolean, parseFileSize, readAsDataURL, remove, removeClasses, removeItem, removeItemBy, removePropertyFromObject, replaceRgbOpacity, rgbToHex, setDay, setDefaultSecondsAndMiliseconds, setHours, setMilliseconds, setMinutes, setSeconds, setYear, skip, sort, sortBy, sortByPath, stopAndPreventPropagation, sum, trim, updateItemBy, where, windowFactory, windowProvider };
|
|
3802
|
+
export { BounceLoaderComponent, BrowserDocumentRef, BrowserWindowRef, ButtonComponent, ButtonType, CheckmarkComponent, CheckmarkType, CircleLoaderComponent, CircleLoaderType, ClickOutsideDirective, CloseComponent, CollapseExpandComponent, CollapseExpandContainerComponent, CollapseExpandDirective, CommonConstants, Compare, ComponentReferenceDirective, ComponentSize, ComponentSizeDirective, DOCUMENT, DOCUMENT_PROVIDERS, DateTimeConstants, DefaultModalFooterComponent, DefaultModalHeaderComponent, DelimeterComponent, DestroyParentDirective, Direction, DocumentRef, DomChangesDirective, DotComponent, DotsComponent, HamburgerComponent, HamburgerMenuComponent, IconComponent, IfDirective, ImageLoadDirective, ImageLoadService, ItemsView, LoadContainerChangesSource, LoadContainerComponent, LoadContainerLoadType, LoadContainerType, LoadMoreButtonComponent, LoadMoreService, LoaderService, MediaLimits, MessageComponent, ModalComponent, ModalOpenDirective, ModalOpenOnClickDirective, ModalService, ModalTemplate, MouseDownDirective, NgxSfcCommonModule, NotificationType, ObservableBehaviorModel, ObservableModel, PaginationComponent, PaginationConstants, PaginationService, Position, ReloadService, RepeatPipe, ResizeService, ScrollIntoViewDirective, ScrollTrackerDirective, Select, Sequence, ShowHideElementDirective, SortByPipe, SortingDirection, SortingService, State, SwitchMultiCasePipe, TagComponent, TemplateContentComponent, TemplateReferenceDirective, Theme, ThrowElementOnHoverDirective, ToggleComponent, ToggleSwitcherComponent, TooltipComponent, TooltipType, UIClass, UIConstants, WINDOW, WINDOW_PROVIDERS, WindowRef, addClasses, addItem, addPropertyToObject, all, any, browserDocumentProvider, browserWindowProvider, buildHttpParams, contains, convertDateToTimestamp, convertFromBase64String, convertTimestampToDate, convertToBase64String, convertUTCDateToLocalDate, count, deepClone, distinct, documentFactory, documentProvider, findChangedPropertyKey, findChangedPropertyPath, firstItem, firstOrDefault, generateGuid, getAge, getCalcValue, getCollectionOrEmpty, getCssLikeValue, getFileExtension, getFirstDayOfMonth, getFirstDayOfMonthByYearAndMonth, getFirstDayOfYear, getLastDayOfMonth, getLastDayOfMonthByYearAndMonth, getLastDayOfYear, getNextDate, getNextMonth, getNextYear, getPreviousDate, getPreviousMonth, getPreviousYear, getRotateValue, getValueFromCssLikeValue, getWeeksNumberInMonth, hasAnyItem, hasItem, hasItemBy, hasObjectItem, hexToRgb, isArraysEquals, isAsyncData, isChromeBrowser, isDateGreat, isDateGreatOrEqual, isDateTimeGreat, isDateTimeGreatOrEqual, isDateTimeLessOrEqual, isDefined, isEmail, isEqual, isEqualDateTimes, isEqualDates, isImage, isJsonString, isNullOrEmptyString, isNumeric, isObject, isString, isTimeGreatOrEqual, isTimeLessOrEqual, lastItem, max, mergeDeep, nameof, parseBoolean, parseFileSize, readAsDataURL, remove, removeClasses, removeItem, removeItemBy, removePropertyFromObject, replaceRgbOpacity, rgbToHex, setDay, setDefaultSecondsAndMiliseconds, setHours, setMilliseconds, setMinutes, setSeconds, setYear, skip, sort, sortBy, sortByPath, stopAndPreventPropagation, sum, trim, updateItemBy, updatePropertyByKey, where, windowFactory, windowProvider };
|
|
3715
3803
|
//# sourceMappingURL=ngx-sfc-common.mjs.map
|
|
3716
3804
|
//# sourceMappingURL=ngx-sfc-common.mjs.map
|