ngx-sfc-common 0.0.30 → 0.0.32
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 +16 -10
- package/esm2020/lib/components/tag/tag.model.mjs +1 -1
- package/esm2020/lib/utils/common.utils.mjs +80 -1
- package/esm2020/lib/utils/index.mjs +2 -2
- package/fesm2015/ngx-sfc-common.mjs +894 -807
- package/fesm2015/ngx-sfc-common.mjs.map +1 -1
- package/fesm2020/ngx-sfc-common.mjs +890 -805
- 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 +4 -3
- package/lib/components/tag/tag.model.d.ts +4 -1
- package/lib/utils/common.utils.d.ts +26 -0
- package/lib/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -597,1067 +597,1145 @@ 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
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1125
|
+
function getLastDayOfMonthByYearAndMonth(year, month) {
|
|
1126
|
+
return new Date(year, month + 1, 0);
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
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());
|
|
1161
1168
|
}
|
|
1162
1169
|
/**
|
|
1163
|
-
*
|
|
1164
|
-
* @param
|
|
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
|
|
1335
|
-
*/
|
|
1336
|
-
function rgbToHex(r, g, b) {
|
|
1337
|
-
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
1338
|
-
}
|
|
1339
|
-
/**
|
|
1340
|
-
* Convert HEX to RGB value
|
|
1341
|
-
* @param hex HEX value
|
|
1342
|
-
* @returns RGB 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
|
|
1343
1331
|
*/
|
|
1344
|
-
function
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
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
|
+
}
|
|
1351
1347
|
}
|
|
1352
|
-
return
|
|
1348
|
+
return mergeDeep(target, ...sources);
|
|
1353
1349
|
}
|
|
1354
1350
|
/**
|
|
1355
|
-
*
|
|
1356
|
-
* @param
|
|
1357
|
-
* @
|
|
1358
|
-
* @returns RGB value with relevant opacity
|
|
1351
|
+
* Get type's property name safety
|
|
1352
|
+
* @param name KeyOf property
|
|
1353
|
+
* @returns Type's property name
|
|
1359
1354
|
*/
|
|
1360
|
-
|
|
1361
|
-
return rgb.replace(UIConstants.RGB_OPACITY_PLACEHOLDER, opacity.toString());
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1355
|
+
const nameof = (name) => name;
|
|
1364
1356
|
/**
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
function
|
|
1370
|
-
return
|
|
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));
|
|
1371
1363
|
}
|
|
1372
1364
|
/**
|
|
1373
|
-
*
|
|
1374
|
-
* @param
|
|
1375
|
-
* @
|
|
1376
|
-
* @returns True if found value in collection
|
|
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
|
|
1377
1368
|
*/
|
|
1378
|
-
function
|
|
1379
|
-
return
|
|
1380
|
-
&& collection.findIndex(item => item === value) !== CommonConstants.NOT_FOUND_INDEX;
|
|
1369
|
+
function isString(value) {
|
|
1370
|
+
return typeof value === 'string';
|
|
1381
1371
|
}
|
|
1382
1372
|
/**
|
|
1383
|
-
* Return true if
|
|
1384
|
-
* @
|
|
1385
|
-
* @param predicate Function to define check logic
|
|
1386
|
-
* @returns True if found value in collection
|
|
1373
|
+
* Return true if current browser is Chrome
|
|
1374
|
+
* @returns If current browser is Chrome
|
|
1387
1375
|
*/
|
|
1388
|
-
function
|
|
1389
|
-
return
|
|
1376
|
+
function isChromeBrowser() {
|
|
1377
|
+
return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
|
|
1390
1378
|
}
|
|
1391
1379
|
/**
|
|
1392
|
-
* Return true if
|
|
1393
|
-
* @
|
|
1394
|
-
* @param property Property name
|
|
1395
|
-
* @param value Value to check
|
|
1396
|
-
* @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
|
|
1397
1382
|
*/
|
|
1398
|
-
function
|
|
1399
|
-
|
|
1400
|
-
return any(collection)
|
|
1401
|
-
&& collection.findIndex(item => item.hasOwnProperty(property)
|
|
1402
|
-
&& item[property] === 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,}))$/));
|
|
1403
1385
|
}
|
|
1404
1386
|
/**
|
|
1405
|
-
* Return true if
|
|
1406
|
-
* @
|
|
1407
|
-
* @param collection2 Array of objects where try to find
|
|
1408
|
-
* @returns
|
|
1387
|
+
* Return true if string is "true"
|
|
1388
|
+
* @returns parsed string as boolean
|
|
1409
1389
|
*/
|
|
1410
|
-
function
|
|
1411
|
-
return
|
|
1390
|
+
function parseBoolean(value) {
|
|
1391
|
+
return /^true$/i.test(value);
|
|
1412
1392
|
}
|
|
1413
1393
|
/**
|
|
1414
|
-
* Return
|
|
1415
|
-
* @param
|
|
1416
|
-
* @param
|
|
1417
|
-
* @returns
|
|
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
|
|
1418
1398
|
*/
|
|
1419
|
-
function
|
|
1420
|
-
|
|
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();
|
|
1421
1465
|
}
|
|
1422
1466
|
/**
|
|
1423
|
-
*
|
|
1424
|
-
* @
|
|
1425
|
-
* @returns First value from collection
|
|
1467
|
+
* Generate unique identificator
|
|
1468
|
+
* @returns Random GUID
|
|
1426
1469
|
*/
|
|
1427
|
-
function
|
|
1428
|
-
|
|
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());
|
|
1429
1475
|
}
|
|
1430
1476
|
/**
|
|
1431
|
-
*
|
|
1432
|
-
* @param
|
|
1433
|
-
* @returns
|
|
1477
|
+
* Check if value is Json parsable string
|
|
1478
|
+
* @param value string value
|
|
1479
|
+
* @returns True if string can be JSON parsed
|
|
1434
1480
|
*/
|
|
1435
|
-
function
|
|
1436
|
-
|
|
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
|
+
}
|
|
1437
1489
|
}
|
|
1438
1490
|
/**
|
|
1439
|
-
*
|
|
1440
|
-
* @param
|
|
1441
|
-
* @param predicate Function to define check logic
|
|
1442
|
-
* @returns True if all values match predicate
|
|
1491
|
+
* Stop propagation and prevent default
|
|
1492
|
+
* @param event Event object
|
|
1443
1493
|
*/
|
|
1444
|
-
function
|
|
1445
|
-
|
|
1494
|
+
function stopAndPreventPropagation(event) {
|
|
1495
|
+
event.preventDefault();
|
|
1496
|
+
event.stopPropagation();
|
|
1446
1497
|
}
|
|
1447
1498
|
/**
|
|
1448
|
-
*
|
|
1449
|
-
* @param
|
|
1450
|
-
* @param
|
|
1451
|
-
* @
|
|
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
|
|
1452
1505
|
*/
|
|
1453
|
-
function
|
|
1454
|
-
|
|
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;
|
|
1455
1538
|
}
|
|
1456
1539
|
/**
|
|
1457
|
-
*
|
|
1458
|
-
* @param
|
|
1459
|
-
* @param
|
|
1460
|
-
* @
|
|
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
|
|
1461
1545
|
*/
|
|
1462
|
-
function
|
|
1463
|
-
|
|
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;
|
|
1464
1562
|
}
|
|
1465
1563
|
/**
|
|
1466
|
-
*
|
|
1467
|
-
* @param
|
|
1468
|
-
* @param
|
|
1469
|
-
* @
|
|
1470
|
-
* @returns Sliced collection
|
|
1564
|
+
* Get changed property key
|
|
1565
|
+
* @param previous Previous value
|
|
1566
|
+
* @param current Currency value
|
|
1567
|
+
* @returns Key of property that was changed
|
|
1471
1568
|
*/
|
|
1472
|
-
function
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
return collection.slice(start, start + size);
|
|
1476
|
-
}
|
|
1477
|
-
return collection;
|
|
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;
|
|
1478
1572
|
}
|
|
1479
|
-
function
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1573
|
+
function deepClone(value) {
|
|
1574
|
+
return JSON.parse(JSON.stringify(value));
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* Return parsed file size as string
|
|
1579
|
+
* @param bytes Bytes count
|
|
1580
|
+
* @param decimals Value after dot
|
|
1581
|
+
* @returns Parsed file size
|
|
1582
|
+
*/
|
|
1583
|
+
function parseFileSize(bytes, decimals = 2) {
|
|
1584
|
+
if (bytes === 0)
|
|
1585
|
+
return '0';
|
|
1586
|
+
const k = 1024;
|
|
1587
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
1588
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
1589
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1590
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
1486
1591
|
}
|
|
1487
1592
|
/**
|
|
1488
|
-
* Return
|
|
1489
|
-
* @param
|
|
1490
|
-
* @
|
|
1491
|
-
* @param direction Sorting direction
|
|
1492
|
-
* @returns Sorted collection
|
|
1593
|
+
* Return file extension
|
|
1594
|
+
* @param file File value
|
|
1595
|
+
* @returns File extension
|
|
1493
1596
|
*/
|
|
1494
|
-
function
|
|
1495
|
-
if (
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
: collection.sort((a, b) => _sortFunc(a, b)(-1, 1));
|
|
1597
|
+
function getFileExtension(file) {
|
|
1598
|
+
if (!isDefined(file))
|
|
1599
|
+
return CommonConstants.EMPTY_STRING;
|
|
1600
|
+
if (file.name.indexOf('.') === CommonConstants.NOT_FOUND_INDEX) {
|
|
1601
|
+
return CommonConstants.EMPTY_STRING;
|
|
1500
1602
|
}
|
|
1501
|
-
return
|
|
1603
|
+
return file.name.split('.').pop();
|
|
1502
1604
|
}
|
|
1503
1605
|
/**
|
|
1504
|
-
*
|
|
1505
|
-
* @param
|
|
1506
|
-
* @param
|
|
1507
|
-
* @param direction Sorting direction
|
|
1508
|
-
* @returns Sorted collection
|
|
1606
|
+
* Read file as data URL
|
|
1607
|
+
* @param file File value
|
|
1608
|
+
* @param onLoad On load action
|
|
1509
1609
|
*/
|
|
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;
|
|
1610
|
+
function readAsDataURL(file, onLoad) {
|
|
1611
|
+
if (isDefined(file)) {
|
|
1612
|
+
const reader = new FileReader();
|
|
1613
|
+
reader.onload = () => onLoad(reader.result);
|
|
1614
|
+
reader.readAsDataURL(file);
|
|
1530
1615
|
}
|
|
1531
|
-
|
|
1616
|
+
else
|
|
1617
|
+
throw new Error('File utils | Read as data URL function --> File is empty.');
|
|
1532
1618
|
}
|
|
1533
1619
|
/**
|
|
1534
|
-
* Return
|
|
1535
|
-
* @param
|
|
1536
|
-
* @returns
|
|
1620
|
+
* Return true if file is image
|
|
1621
|
+
* @param file File value
|
|
1622
|
+
* @returns True if file is image
|
|
1537
1623
|
*/
|
|
1538
|
-
function
|
|
1539
|
-
return
|
|
1540
|
-
? collection.filter((value, index, self) => self.indexOf(value) === index)
|
|
1541
|
-
: collection;
|
|
1624
|
+
function isImage(file) {
|
|
1625
|
+
return isDefined(file) && (/\.(gif|jpe?g|jpg|tiff|png|webp|bmp)$/i).test(file.name);
|
|
1542
1626
|
}
|
|
1543
1627
|
/**
|
|
1544
|
-
*
|
|
1545
|
-
* @param
|
|
1546
|
-
* @
|
|
1547
|
-
* @returns Sum value of colection items
|
|
1628
|
+
* Convert file to base64 string
|
|
1629
|
+
* @param file File value
|
|
1630
|
+
* @returns Base64 string
|
|
1548
1631
|
*/
|
|
1549
|
-
function
|
|
1550
|
-
return
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1632
|
+
function convertToBase64String(file) {
|
|
1633
|
+
return new Promise((resolve, reject) => {
|
|
1634
|
+
const reader = new FileReader();
|
|
1635
|
+
reader.readAsDataURL(file);
|
|
1636
|
+
reader.onload = () => resolve(reader.result);
|
|
1637
|
+
reader.onerror = reject;
|
|
1638
|
+
});
|
|
1555
1639
|
}
|
|
1556
1640
|
/**
|
|
1557
|
-
*
|
|
1558
|
-
* @param
|
|
1559
|
-
* @param
|
|
1560
|
-
* @returns
|
|
1641
|
+
* Convert base64 string to file
|
|
1642
|
+
* @param base64 Base64 string
|
|
1643
|
+
* @param name File name
|
|
1644
|
+
* @returns File value
|
|
1561
1645
|
*/
|
|
1562
|
-
function
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1646
|
+
function convertFromBase64String(base64, name) {
|
|
1647
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1648
|
+
const res = yield fetch(base64), blob = yield res.blob(), extension = base64.substring("data:image/".length, base64.indexOf(";base64"));
|
|
1649
|
+
return new File([blob], `${name}.${extension}`, { type: `image/${extension}` });
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* Return CSS like value
|
|
1655
|
+
* @param value Value as number
|
|
1656
|
+
* @returns Value as '1px'
|
|
1657
|
+
*/
|
|
1658
|
+
function getCssLikeValue(value, type = UIConstants.CSS_PIXELS) {
|
|
1659
|
+
return value + type;
|
|
1566
1660
|
}
|
|
1567
1661
|
/**
|
|
1568
|
-
*
|
|
1569
|
-
* @param
|
|
1570
|
-
* @
|
|
1662
|
+
* Parse CSS like value to number
|
|
1663
|
+
* @param value CSS like value
|
|
1664
|
+
* @returns Number value
|
|
1571
1665
|
*/
|
|
1572
|
-
function
|
|
1573
|
-
|
|
1574
|
-
while (i--) {
|
|
1575
|
-
if (predicate(collection[i])) {
|
|
1576
|
-
collection.splice(i, 1);
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1666
|
+
function getValueFromCssLikeValue(value, type = UIConstants.CSS_PIXELS) {
|
|
1667
|
+
return +value.replace(type, CommonConstants.EMPTY_STRING);
|
|
1579
1668
|
}
|
|
1580
1669
|
/**
|
|
1581
|
-
*
|
|
1582
|
-
* @param
|
|
1583
|
-
* @param
|
|
1584
|
-
* @
|
|
1585
|
-
* @returns True if successfully added
|
|
1670
|
+
* Return CCS like calc value
|
|
1671
|
+
* @param value All value (100% by default)
|
|
1672
|
+
* @param part Part value
|
|
1673
|
+
* @returns Calc value
|
|
1586
1674
|
*/
|
|
1587
|
-
function
|
|
1588
|
-
|
|
1589
|
-
collection = new Array();
|
|
1590
|
-
if (isDefined(predicate) && predicate(item))
|
|
1591
|
-
return false;
|
|
1592
|
-
collection.push(item);
|
|
1593
|
-
return true;
|
|
1675
|
+
function getCalcValue(part, value = 100) {
|
|
1676
|
+
return `calc(${value}${UIConstants.CSS_PERCENTAGE} / ${part} )`;
|
|
1594
1677
|
}
|
|
1595
1678
|
/**
|
|
1596
|
-
*
|
|
1597
|
-
* @param
|
|
1598
|
-
* @
|
|
1599
|
-
* @returns True if successfully removed
|
|
1679
|
+
* Return CCS like rotate value
|
|
1680
|
+
* @param value value as degrees
|
|
1681
|
+
* @returns Rotate value
|
|
1600
1682
|
*/
|
|
1601
|
-
function
|
|
1602
|
-
|
|
1603
|
-
collection.splice(collection.indexOf(item), 1);
|
|
1604
|
-
return true;
|
|
1605
|
-
}
|
|
1606
|
-
return false;
|
|
1683
|
+
function getRotateValue(value) {
|
|
1684
|
+
return `rotate(${value}deg)`;
|
|
1607
1685
|
}
|
|
1608
1686
|
/**
|
|
1609
|
-
*
|
|
1610
|
-
* @param
|
|
1611
|
-
* @param
|
|
1612
|
-
* @returns True if successfully removed
|
|
1687
|
+
* Add classes to HTML element
|
|
1688
|
+
* @param element HTML element
|
|
1689
|
+
* @param classNames Array of CSS classes
|
|
1613
1690
|
*/
|
|
1614
|
-
function
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
collection.splice(collection.indexOf(foundItem), 1);
|
|
1618
|
-
return true;
|
|
1691
|
+
function addClasses(element, ...classNames) {
|
|
1692
|
+
if (isDefined(element)) {
|
|
1693
|
+
classNames.forEach((className) => element.classList.add(className));
|
|
1619
1694
|
}
|
|
1620
|
-
return false;
|
|
1621
1695
|
}
|
|
1622
1696
|
/**
|
|
1623
|
-
*
|
|
1624
|
-
* @param
|
|
1625
|
-
* @param
|
|
1626
|
-
* @returns True if successfully removed
|
|
1697
|
+
* Remove classes to HTML element
|
|
1698
|
+
* @param element HTML element
|
|
1699
|
+
* @param classNames Array of CSS classes
|
|
1627
1700
|
*/
|
|
1628
|
-
function
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
const result = collection.slice(0);
|
|
1632
|
-
result[itemIndex] = Object.assign(Object.assign({}, collection[itemIndex]), newItem);
|
|
1633
|
-
return result;
|
|
1701
|
+
function removeClasses(element, ...classNames) {
|
|
1702
|
+
if (isDefined(element)) {
|
|
1703
|
+
classNames.forEach((className) => element.classList.remove(className));
|
|
1634
1704
|
}
|
|
1635
|
-
return null;
|
|
1636
1705
|
}
|
|
1637
1706
|
/**
|
|
1638
|
-
*
|
|
1639
|
-
* @param
|
|
1640
|
-
* @
|
|
1707
|
+
* Convert RGB color to HEX
|
|
1708
|
+
* @param r Red
|
|
1709
|
+
* @param g Green
|
|
1710
|
+
* @param b Blue
|
|
1711
|
+
* @returns HEX value
|
|
1641
1712
|
*/
|
|
1642
|
-
function
|
|
1643
|
-
return
|
|
1713
|
+
function rgbToHex(r, g, b) {
|
|
1714
|
+
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
1644
1715
|
}
|
|
1645
1716
|
/**
|
|
1646
|
-
*
|
|
1647
|
-
* @param
|
|
1648
|
-
* @
|
|
1649
|
-
* @returns True if arrays are equal
|
|
1717
|
+
* Convert HEX to RGB value
|
|
1718
|
+
* @param hex HEX value
|
|
1719
|
+
* @returns RGB value
|
|
1650
1720
|
*/
|
|
1651
|
-
function
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
return false;
|
|
1721
|
+
function hexToRgb(hex) {
|
|
1722
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
1723
|
+
if (result) {
|
|
1724
|
+
var r = parseInt(result[1], 16);
|
|
1725
|
+
var g = parseInt(result[2], 16);
|
|
1726
|
+
var b = parseInt(result[3], 16);
|
|
1727
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
1659
1728
|
}
|
|
1660
|
-
return
|
|
1729
|
+
return null;
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Set opacity for RGB value
|
|
1733
|
+
* @param rgb Rgb value with {opacity} placeholder
|
|
1734
|
+
* @param opacity Opacity value
|
|
1735
|
+
* @returns RGB value with relevant opacity
|
|
1736
|
+
*/
|
|
1737
|
+
function replaceRgbOpacity(rgb, opacity) {
|
|
1738
|
+
return rgb.replace(UIConstants.RGB_OPACITY_PLACEHOLDER, opacity.toString());
|
|
1661
1739
|
}
|
|
1662
1740
|
|
|
1663
1741
|
/**
|
|
@@ -3247,7 +3325,7 @@ class LoadContainerComponent {
|
|
|
3247
3325
|
})), loader$ = this.pagination ? pagination$ : more$;
|
|
3248
3326
|
return loader$.pipe(map(() => ({ params: params, page: this.page })));
|
|
3249
3327
|
}));
|
|
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 })));
|
|
3328
|
+
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
3329
|
}
|
|
3252
3330
|
buildDynamic(parameters$, loader) {
|
|
3253
3331
|
return parameters$.pipe(switchMap((parameters) => loader(parameters)), map((model) => (Object.assign(Object.assign({}, model), { reset: this.reset, page: this.page }))));
|
|
@@ -3255,16 +3333,16 @@ class LoadContainerComponent {
|
|
|
3255
3333
|
buildStatic(parameters$, model) {
|
|
3256
3334
|
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
3335
|
return combineLatest([parameters$, data$]).pipe(map(([parameters, items]) => {
|
|
3258
|
-
var _a, _b;
|
|
3336
|
+
var _a, _b, _c;
|
|
3259
3337
|
// if data changed need to start from start (pagination)
|
|
3260
3338
|
if (this.source == LoadContainerChangesSource.Data
|
|
3261
3339
|
&& parameters.page != LoadMoreService.START_PAGE) {
|
|
3262
3340
|
this.resetParameters();
|
|
3263
|
-
parameters = { params: parameters.params, page: this.page, sorting: parameters.sorting };
|
|
3341
|
+
parameters = { params: parameters.params, page: this.page, size: (_a = this.model.pagination) === null || _a === void 0 ? void 0 : _a.size, sorting: parameters.sorting };
|
|
3264
3342
|
}
|
|
3265
3343
|
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 / ((
|
|
3344
|
+
items: this.model.pagination ? skip(sorted, parameters.page, (_b = this.model.pagination) === null || _b === void 0 ? void 0 : _b.size) : sorted,
|
|
3345
|
+
next: this.model.pagination ? parameters.page < Math.ceil(sorted.length / ((_c = this.model.pagination) === null || _c === void 0 ? void 0 : _c.size)) : false,
|
|
3268
3346
|
reset: this.reset,
|
|
3269
3347
|
total: sorted.length,
|
|
3270
3348
|
page: parameters.page
|
|
@@ -3459,28 +3537,36 @@ TagConstants.DEFAULT_LABEL = 'Tag';
|
|
|
3459
3537
|
|
|
3460
3538
|
class TagComponent {
|
|
3461
3539
|
constructor() {
|
|
3462
|
-
this.
|
|
3540
|
+
this.remove = false;
|
|
3463
3541
|
this.model = {
|
|
3464
3542
|
key: CommonConstants.DEFAULT_KEY_VALUE,
|
|
3465
3543
|
label: TagConstants.DEFAULT_LABEL
|
|
3466
3544
|
};
|
|
3467
|
-
this.
|
|
3545
|
+
this.removeAction = new EventEmitter();
|
|
3546
|
+
}
|
|
3547
|
+
_onClick() {
|
|
3548
|
+
if (this.model.click)
|
|
3549
|
+
this.model.click(this.model);
|
|
3468
3550
|
}
|
|
3469
3551
|
onRemove() {
|
|
3470
|
-
this.
|
|
3552
|
+
this.removeAction.emit(this.model);
|
|
3471
3553
|
}
|
|
3472
3554
|
}
|
|
3473
3555
|
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-
|
|
3556
|
+
TagComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: TagComponent, selector: "sfc-tag", inputs: { remove: "remove", model: "model" }, outputs: { removeAction: "remove" }, host: { listeners: { "click": "_onClick()" } }, ngImport: i0, template: "<div class=\"container\">\r\n <div class=\"content\">\r\n <sfc-icon *ngIf=\"model.icon || model.imageSrc\" [icon]=\"model.icon\" [imageSrc]=\"model.imageSrc\"></sfc-icon>\r\n <span>{{model.label}}</span>\r\n <sfc-close *ngIf=\"model.remove\" (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
3557
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: TagComponent, decorators: [{
|
|
3476
3558
|
type: Component,
|
|
3477
|
-
args: [{ selector: 'sfc-
|
|
3478
|
-
}], propDecorators: {
|
|
3559
|
+
args: [{ selector: 'sfc-tag', template: "<div class=\"container\">\r\n <div class=\"content\">\r\n <sfc-icon *ngIf=\"model.icon || model.imageSrc\" [icon]=\"model.icon\" [imageSrc]=\"model.imageSrc\"></sfc-icon>\r\n <span>{{model.label}}</span>\r\n <sfc-close *ngIf=\"model.remove\" (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"] }]
|
|
3560
|
+
}], propDecorators: { remove: [{
|
|
3479
3561
|
type: Input
|
|
3480
3562
|
}], model: [{
|
|
3481
3563
|
type: Input
|
|
3482
|
-
}],
|
|
3483
|
-
type: Output
|
|
3564
|
+
}], removeAction: [{
|
|
3565
|
+
type: Output,
|
|
3566
|
+
args: ['remove']
|
|
3567
|
+
}], _onClick: [{
|
|
3568
|
+
type: HostListener,
|
|
3569
|
+
args: ['click']
|
|
3484
3570
|
}] } });
|
|
3485
3571
|
|
|
3486
3572
|
class NgxSfcCommonModule {
|
|
@@ -3711,5 +3797,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImpor
|
|
|
3711
3797
|
* Generated bundle index. Do not edit.
|
|
3712
3798
|
*/
|
|
3713
3799
|
|
|
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 };
|
|
3800
|
+
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 };
|
|
3801
|
+
//# sourceMappingURL=ngx-sfc-common.mjs.map
|
|
3715
3802
|
//# sourceMappingURL=ngx-sfc-common.mjs.map
|