@osovitny/anatoly 3.17.2 → 3.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/core/consts/settings.mjs +13 -1
- package/esm2022/lib/core/converts/convert.mjs +1 -34
- package/esm2022/lib/core/converts/dateConvert.mjs +58 -0
- package/esm2022/lib/core/index.mjs +3 -1
- package/esm2022/lib/core/is.mjs +98 -0
- package/esm2022/lib/core/localization/localization.service.mjs +63 -87
- package/esm2022/lib/core/localization/localize.pipe.mjs +13 -14
- package/esm2022/lib/core/services/starter.service.mjs +3 -3
- package/esm2022/lib/core/utils.mjs +1 -7
- package/fesm2022/osovitny-anatoly.mjs +281 -178
- package/fesm2022/osovitny-anatoly.mjs.map +1 -1
- package/lib/core/consts/settings.d.ts +11 -0
- package/lib/core/converts/convert.d.ts +0 -5
- package/lib/core/converts/dateConvert.d.ts +7 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/is.d.ts +23 -0
- package/lib/core/localization/localization.service.d.ts +7 -8
- package/lib/core/utils.d.ts +0 -2
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ import { MSAL_GUARD_CONFIG, MsalGuard, MsalInterceptor, MSAL_INTERCEPTOR_CONFIG,
|
|
|
12
12
|
import { BrowserUtils, EventType, InteractionStatus, InteractionType, InteractionRequiredAuthError, PromptValue, PublicClientApplication, LogLevel } from '@azure/msal-browser';
|
|
13
13
|
import * as i1$2 from '@angular/common';
|
|
14
14
|
import { LOCATION_INITIALIZED, DOCUMENT, CommonModule } from '@angular/common';
|
|
15
|
-
import {
|
|
15
|
+
import { format, formatDistance, formatDistanceToNow } from 'date-fns';
|
|
16
16
|
import { utcToZonedTime } from 'date-fns-tz';
|
|
17
17
|
import enUS from 'date-fns/locale/en-US';
|
|
18
18
|
import * as i1$3 from '@ngx-translate/core';
|
|
@@ -95,6 +95,18 @@ const ClientApps = AppCoreSettings?.clientApps;
|
|
|
95
95
|
//ClientApp
|
|
96
96
|
const AppName = document.getElementById('appName').getAttribute('data-appname');
|
|
97
97
|
const AppSettings = getAppSettingsByName(AppName);
|
|
98
|
+
//DateFormats
|
|
99
|
+
const dateFormats = {
|
|
100
|
+
medium: "dd MMM yyyy",
|
|
101
|
+
short: "dd/MM/yyyy"
|
|
102
|
+
};
|
|
103
|
+
const timeFormats = {
|
|
104
|
+
medium: "HH:mm:ss",
|
|
105
|
+
short: "HH:mm"
|
|
106
|
+
};
|
|
107
|
+
const dateTimeFormats = {
|
|
108
|
+
medium: 'dd MMM yyyy HH:mm'
|
|
109
|
+
};
|
|
98
110
|
|
|
99
111
|
/*
|
|
100
112
|
<file>
|
|
@@ -191,7 +203,40 @@ class Convert {
|
|
|
191
203
|
return Boolean(value);
|
|
192
204
|
}
|
|
193
205
|
}
|
|
194
|
-
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/*
|
|
209
|
+
<file>
|
|
210
|
+
Project:
|
|
211
|
+
@osovitny/anatoly
|
|
212
|
+
|
|
213
|
+
Authors:
|
|
214
|
+
Vadim Osovitny vadim@osovitny.com
|
|
215
|
+
Anatoly Osovitny anatoly@osovitny.com
|
|
216
|
+
|
|
217
|
+
Created:
|
|
218
|
+
09 Feb 2024
|
|
219
|
+
|
|
220
|
+
Source:
|
|
221
|
+
https://github.com/date-fns/date-fns/blob/main/src/toDate/index.ts
|
|
222
|
+
|
|
223
|
+
Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
|
|
224
|
+
</file>
|
|
225
|
+
*/
|
|
226
|
+
class DateConvert {
|
|
227
|
+
static toDate(argument) {
|
|
228
|
+
const argStr = Object.prototype.toString.call(argument);
|
|
229
|
+
if (argument instanceof Date || (typeof argument === "object" && argStr === "[object Date]")) {
|
|
230
|
+
return argument;
|
|
231
|
+
}
|
|
232
|
+
else if (typeof argument === "number" || argStr === "[object Number]" ||
|
|
233
|
+
typeof argument === "string" || argStr === "[object String]") {
|
|
234
|
+
return new Date(argument);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
return new Date(NaN);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
195
240
|
static localToUtcDate(value) {
|
|
196
241
|
if (value) {
|
|
197
242
|
return new Date(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());
|
|
@@ -216,14 +261,6 @@ class Convert {
|
|
|
216
261
|
}
|
|
217
262
|
return null;
|
|
218
263
|
}
|
|
219
|
-
static dateToString(date) {
|
|
220
|
-
return date.getFullYear() +
|
|
221
|
-
'-' + this.pad(date.getMonth() + 1) +
|
|
222
|
-
'-' + this.pad(date.getDate()) +
|
|
223
|
-
' ' + this.pad(date.getHours()) +
|
|
224
|
-
':' + this.pad(date.getMinutes()) +
|
|
225
|
-
':' + this.pad(date.getSeconds());
|
|
226
|
-
}
|
|
227
264
|
}
|
|
228
265
|
|
|
229
266
|
/*
|
|
@@ -1615,92 +1652,93 @@ class Subs {
|
|
|
1615
1652
|
Anatoly Osovitny anatoly@osovitny.com
|
|
1616
1653
|
|
|
1617
1654
|
Created:
|
|
1618
|
-
|
|
1655
|
+
09 Feb 2024
|
|
1656
|
+
|
|
1657
|
+
Sources:
|
|
1658
|
+
https://github.com/date-fns/date-fns/blob/main/src/isDate/index.ts
|
|
1659
|
+
https://github.com/date-fns/date-fns/blob/main/src/isValid/index.ts
|
|
1619
1660
|
|
|
1620
1661
|
Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
|
|
1621
1662
|
</file>
|
|
1622
1663
|
*/
|
|
1623
|
-
class
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1664
|
+
class is {
|
|
1665
|
+
/**
|
|
1666
|
+
* @name isDate
|
|
1667
|
+
* @summary Is the given value a date?
|
|
1668
|
+
*/
|
|
1669
|
+
static date(value) {
|
|
1670
|
+
return (value instanceof Date ||
|
|
1671
|
+
(typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"));
|
|
1629
1672
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1673
|
+
/**
|
|
1674
|
+
* @name isDateValid
|
|
1675
|
+
* @summary Is the given date valid?
|
|
1676
|
+
*/
|
|
1677
|
+
static dateValid(date) {
|
|
1678
|
+
if (!is.date(date) && typeof date !== "number") {
|
|
1679
|
+
return false;
|
|
1680
|
+
}
|
|
1681
|
+
let d = new Date(date);
|
|
1682
|
+
return !isNaN(Number(d));
|
|
1632
1683
|
}
|
|
1633
|
-
static
|
|
1634
|
-
|
|
1635
|
-
// tslint:disable-next-line:one-variable-per-declaration
|
|
1636
|
-
const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
|
|
1637
|
-
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
|
1684
|
+
static dateInvalid(date) {
|
|
1685
|
+
return !is.dateValid(date);
|
|
1638
1686
|
}
|
|
1639
|
-
static
|
|
1640
|
-
|
|
1641
|
-
const selBox = document.createElement('textarea');
|
|
1642
|
-
selBox.style.position = 'fixed';
|
|
1643
|
-
selBox.style.left = '0';
|
|
1644
|
-
selBox.style.top = '0';
|
|
1645
|
-
selBox.style.opacity = '0';
|
|
1646
|
-
selBox.value = val;
|
|
1647
|
-
document.body.appendChild(selBox);
|
|
1648
|
-
selBox.focus();
|
|
1649
|
-
selBox.select();
|
|
1650
|
-
document.execCommand('copy');
|
|
1651
|
-
document.body.removeChild(selBox);
|
|
1687
|
+
static objectNullOrEmpty(obj) {
|
|
1688
|
+
return !obj || Object.keys(obj).length == 0;
|
|
1652
1689
|
}
|
|
1653
|
-
static
|
|
1654
|
-
|
|
1655
|
-
link.download = name;
|
|
1656
|
-
link.href = url;
|
|
1657
|
-
link.click();
|
|
1690
|
+
static string(value) {
|
|
1691
|
+
return (typeof value === 'string' || value instanceof String);
|
|
1658
1692
|
}
|
|
1659
|
-
static
|
|
1660
|
-
|
|
1661
|
-
if (nav.msSaveOrOpenBlob) {
|
|
1662
|
-
nav.msSaveOrOpenBlob(value, fileName);
|
|
1663
|
-
}
|
|
1664
|
-
else {
|
|
1665
|
-
const downloadURL = window.URL.createObjectURL(value);
|
|
1666
|
-
Utils.downloadFile(fileName, downloadURL);
|
|
1667
|
-
}
|
|
1693
|
+
static emptyString(value) {
|
|
1694
|
+
return (is.string(value) && (value.length == 0));
|
|
1668
1695
|
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
https://medium.com/@mhagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
|
|
1672
|
-
*/
|
|
1673
|
-
static slugify(text, prefix = '', postfix = '') {
|
|
1674
|
-
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;';
|
|
1675
|
-
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------';
|
|
1676
|
-
const p = new RegExp(a.split('').join('|'), 'g');
|
|
1677
|
-
/*
|
|
1678
|
-
https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
|
|
1679
|
-
https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
|
|
1680
|
-
*/
|
|
1681
|
-
text = text.replace(/(<([^>]+)>)/gi, '');
|
|
1682
|
-
let result = text
|
|
1683
|
-
.toString()
|
|
1684
|
-
.toLowerCase()
|
|
1685
|
-
.replace(/\s+/g, '-') // Replace spaces with -
|
|
1686
|
-
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
|
|
1687
|
-
.replace(/&/g, '-and-') // Replace & with 'and'
|
|
1688
|
-
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
|
|
1689
|
-
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
|
1690
|
-
.replace(/^-+/, '') // Trim - from start of text
|
|
1691
|
-
.replace(/-+$/, ''); // Trim - from end of text
|
|
1692
|
-
return prefix + result + postfix;
|
|
1696
|
+
static notEmptyString(value) {
|
|
1697
|
+
return (is.string(value) && (value.length > 0));
|
|
1693
1698
|
}
|
|
1694
|
-
static
|
|
1695
|
-
return
|
|
1699
|
+
static number(value) {
|
|
1700
|
+
return (typeof value === 'number');
|
|
1696
1701
|
}
|
|
1697
|
-
static
|
|
1698
|
-
return
|
|
1702
|
+
static boolean(value) {
|
|
1703
|
+
return (typeof value === 'boolean');
|
|
1704
|
+
}
|
|
1705
|
+
static array(value) {
|
|
1706
|
+
return (value instanceof Array);
|
|
1707
|
+
}
|
|
1708
|
+
static emptyArray(value) {
|
|
1709
|
+
return (is.array(value) && (value.length == 0));
|
|
1699
1710
|
}
|
|
1700
|
-
static
|
|
1701
|
-
return
|
|
1711
|
+
static notEmptyArray(value) {
|
|
1712
|
+
return (is.array(value) && (value.length > 0));
|
|
1713
|
+
}
|
|
1714
|
+
static undefined(value) {
|
|
1715
|
+
return (typeof value === 'undefined');
|
|
1702
1716
|
}
|
|
1703
1717
|
}
|
|
1718
|
+
/*
|
|
1719
|
+
is = {
|
|
1720
|
+
DONE string: function (obj) { return (typeof obj === 'string'); },
|
|
1721
|
+
DONE emptyString: function (obj) { return (is.string(obj) && (obj.length == 0)); },
|
|
1722
|
+
DONE nonEmptyString: function (obj) { return (is.string(obj) && (obj.length > 0)); },
|
|
1723
|
+
DONE number: function (obj) { return (typeof obj === 'number'); },
|
|
1724
|
+
DONE bool: function (obj) { return (typeof obj === 'boolean'); },
|
|
1725
|
+
DONE array: function (obj) { return (obj instanceof Array); },
|
|
1726
|
+
DONE emptyArray: function (obj) { return (is.array(obj) && (obj.length == 0)); },
|
|
1727
|
+
DONE notEmptyArray: function (obj) { return (is.array(obj) && (obj.length > 0)); },
|
|
1728
|
+
DONE undefined: function (obj) { return (typeof obj === 'undefined'); },
|
|
1729
|
+
|
|
1730
|
+
'null': function (obj) { return (obj === null); },
|
|
1731
|
+
notNull: function (obj) { return (obj !== null); },
|
|
1732
|
+
invalid: function (obj) { return (is['null'](obj) || is.undefined(obj)); },
|
|
1733
|
+
valid: function (obj) { return (!is['null'](obj) && !is.undefined(obj)); },
|
|
1734
|
+
|
|
1735
|
+
document: function (obj) { return (obj === document); },
|
|
1736
|
+
window: function (obj) { return (obj === window); },
|
|
1737
|
+
element: function (obj) { return (obj instanceof HTMLElement); },
|
|
1738
|
+
event: function (obj) { return (obj instanceof Event); },
|
|
1739
|
+
link: function (obj) { return (is.element(obj) && (obj.tagName == 'A')); }
|
|
1740
|
+
};
|
|
1741
|
+
*/
|
|
1704
1742
|
|
|
1705
1743
|
/*
|
|
1706
1744
|
<file>
|
|
@@ -1714,6 +1752,10 @@ class Utils {
|
|
|
1714
1752
|
Created:
|
|
1715
1753
|
05 May 2020
|
|
1716
1754
|
|
|
1755
|
+
Source:
|
|
1756
|
+
https://date-fns.org/v3.3.1/docs/formatDistance
|
|
1757
|
+
https://date-fns.org/v3.3.1/docs/formatDistanceToNow
|
|
1758
|
+
|
|
1717
1759
|
Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
|
|
1718
1760
|
</file>
|
|
1719
1761
|
*/
|
|
@@ -1778,7 +1820,7 @@ class LocalizationService {
|
|
|
1778
1820
|
}
|
|
1779
1821
|
return dfnLocale;
|
|
1780
1822
|
}
|
|
1781
|
-
//getLocalized
|
|
1823
|
+
//getLocalized
|
|
1782
1824
|
getLocalizedValue(key, params) {
|
|
1783
1825
|
const value = this.translate.instant(key);
|
|
1784
1826
|
if (!params || params.length === 0) {
|
|
@@ -1786,91 +1828,36 @@ class LocalizationService {
|
|
|
1786
1828
|
}
|
|
1787
1829
|
return this.format(value, params);
|
|
1788
1830
|
}
|
|
1789
|
-
getLocalizedDate(
|
|
1790
|
-
let date =
|
|
1791
|
-
if (
|
|
1792
|
-
|
|
1793
|
-
return format(localDate, 'dd MMM yyyy', this.dateFnsLocale);
|
|
1794
|
-
}
|
|
1795
|
-
return "Invalid Date";
|
|
1796
|
-
}
|
|
1797
|
-
getLocalizedDateTime(key) {
|
|
1798
|
-
let date = new Date(key);
|
|
1799
|
-
if (isValid(date)) {
|
|
1800
|
-
let localDate = Convert.utcToLocalDateTime(date);
|
|
1801
|
-
return format(localDate, 'dd MMM yyyy HH:mm', this.dateFnsLocale);
|
|
1802
|
-
}
|
|
1803
|
-
return "Invalid Date";
|
|
1804
|
-
}
|
|
1805
|
-
getLocalizedDistanceInWords(endedDate, startedDate) {
|
|
1806
|
-
if (isValid(new Date(endedDate)) && isValid(new Date(startedDate))) {
|
|
1807
|
-
return formatDistance(new Date(endedDate), new Date(startedDate), this.dateFnsLocale);
|
|
1831
|
+
getLocalizedDate(value) {
|
|
1832
|
+
let date = DateConvert.toDate(value);
|
|
1833
|
+
if (is.dateInvalid(date)) {
|
|
1834
|
+
return "Invalid Date";
|
|
1808
1835
|
}
|
|
1809
|
-
return
|
|
1836
|
+
return format(date, dateFormats.medium, this.dateFnsLocale);
|
|
1810
1837
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1838
|
+
getLocalizedDateTime(value) {
|
|
1839
|
+
let date = DateConvert.toDate(value);
|
|
1840
|
+
if (is.dateInvalid(date)) {
|
|
1841
|
+
return "Invalid Date";
|
|
1814
1842
|
}
|
|
1815
|
-
return
|
|
1843
|
+
return format(date, dateTimeFormats.medium, this.dateFnsLocale);
|
|
1816
1844
|
}
|
|
1817
|
-
//UTC
|
|
1818
|
-
getUTCToLocalizedDate(
|
|
1819
|
-
|
|
1820
|
-
key = key.toString();
|
|
1821
|
-
}
|
|
1822
|
-
if (key) {
|
|
1823
|
-
if (key.indexOf("T") == -1) {
|
|
1824
|
-
key = key.replace(" ", "T");
|
|
1825
|
-
}
|
|
1826
|
-
if (key.indexOf("Z") == -1) {
|
|
1827
|
-
key = key + "Z";
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1831
|
-
if (browserTimeZone) {
|
|
1832
|
-
let localDateTime = utcToZonedTime(key, browserTimeZone);
|
|
1833
|
-
return format(localDateTime, 'dd.MM.yyyy', this.dateFnsLocale);
|
|
1834
|
-
}
|
|
1835
|
-
else {
|
|
1836
|
-
return format(new Date(key), 'dd.MM.yyyy', this.dateFnsLocale);
|
|
1837
|
-
}
|
|
1845
|
+
//UTC ---------------------------------------------------------------------BEGIN
|
|
1846
|
+
getUTCToLocalizedDate(value) {
|
|
1847
|
+
return this.safeUtcToZonedTime(value, dateFormats.medium);
|
|
1838
1848
|
}
|
|
1839
|
-
getUTCToLocalizedDateTime(
|
|
1840
|
-
|
|
1841
|
-
key = key.toString();
|
|
1842
|
-
}
|
|
1843
|
-
if (key) {
|
|
1844
|
-
if (key.indexOf("T") == -1) {
|
|
1845
|
-
key = key.replace(" ", "T");
|
|
1846
|
-
}
|
|
1847
|
-
if (key.indexOf("Z") == -1) {
|
|
1848
|
-
key = key + "Z";
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1852
|
-
if (browserTimeZone) {
|
|
1853
|
-
let localDateTime = utcToZonedTime(key, browserTimeZone);
|
|
1854
|
-
return format(localDateTime, 'dd.MM.yyyy HH:mm', this.dateFnsLocale);
|
|
1855
|
-
}
|
|
1856
|
-
else {
|
|
1857
|
-
return format(new Date(key), 'dd.MM.yyyy HH:mm', this.dateFnsLocale);
|
|
1858
|
-
}
|
|
1849
|
+
getUTCToLocalizedDateTime(value) {
|
|
1850
|
+
return this.safeUtcToZonedTime(value, dateTimeFormats.medium);
|
|
1859
1851
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
if (isValid(new Date(date))) {
|
|
1864
|
-
return formatDistanceToNow(new Date(date), this.dateFnsLocale);
|
|
1852
|
+
safeUtcToZonedTime(date, conversionFormat = null) {
|
|
1853
|
+
if (!date) {
|
|
1854
|
+
return null;
|
|
1865
1855
|
}
|
|
1866
|
-
return "Invalid Date";
|
|
1867
|
-
}
|
|
1868
|
-
safeUtcToZonedTime(date) {
|
|
1869
1856
|
let result = date;
|
|
1870
1857
|
try {
|
|
1871
|
-
if (date) {
|
|
1872
|
-
if (date.indexOf("T")
|
|
1873
|
-
date = date.replace("
|
|
1858
|
+
if (typeof date === 'string') {
|
|
1859
|
+
if (date.indexOf("T") > -1) {
|
|
1860
|
+
date = date.replace("T", " ");
|
|
1874
1861
|
}
|
|
1875
1862
|
if (date.indexOf("Z") == -1) {
|
|
1876
1863
|
date = date + "Z";
|
|
@@ -1878,19 +1865,45 @@ class LocalizationService {
|
|
|
1878
1865
|
}
|
|
1879
1866
|
let browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1880
1867
|
if (browserTimeZone) {
|
|
1881
|
-
|
|
1868
|
+
if (conversionFormat) {
|
|
1869
|
+
result = utcToZonedTime(date, browserTimeZone);
|
|
1870
|
+
result = format(result, conversionFormat, this.dateFnsLocale);
|
|
1871
|
+
}
|
|
1872
|
+
else {
|
|
1873
|
+
result = utcToZonedTime(date, browserTimeZone).toString();
|
|
1874
|
+
}
|
|
1882
1875
|
}
|
|
1883
1876
|
else {
|
|
1884
|
-
|
|
1877
|
+
if (conversionFormat) {
|
|
1878
|
+
result = format(new Date(date), conversionFormat, this.dateFnsLocale);
|
|
1879
|
+
}
|
|
1880
|
+
else {
|
|
1881
|
+
result = new Date(date).toString();
|
|
1882
|
+
}
|
|
1885
1883
|
}
|
|
1886
1884
|
}
|
|
1887
1885
|
catch {
|
|
1888
|
-
|
|
1889
|
-
console.log("UTC to Local conversion failed for :" + date.toString());
|
|
1890
|
-
}
|
|
1886
|
+
result = "Invalid Date";
|
|
1891
1887
|
}
|
|
1892
1888
|
return result;
|
|
1893
1889
|
}
|
|
1890
|
+
//UTC ---------------------------------------------------------------------END
|
|
1891
|
+
//Distance ----------------------------------------------------------------BEGIN
|
|
1892
|
+
getLocalizedDistanceInWords(endedDateStr, startedDateStr) {
|
|
1893
|
+
let endedDate = DateConvert.toDate(endedDateStr);
|
|
1894
|
+
let startedDate = DateConvert.toDate(startedDateStr);
|
|
1895
|
+
if (is.dateInvalid(endedDate) || is.dateInvalid(startedDate)) {
|
|
1896
|
+
return "Invalid Date";
|
|
1897
|
+
}
|
|
1898
|
+
return formatDistance(endedDate, startedDate, this.dateFnsLocale);
|
|
1899
|
+
}
|
|
1900
|
+
getLocalizedDistanceToNowInWords(value) {
|
|
1901
|
+
let date = DateConvert.toDate(value);
|
|
1902
|
+
if (is.dateInvalid(date)) {
|
|
1903
|
+
return "Invalid Date";
|
|
1904
|
+
}
|
|
1905
|
+
return formatDistanceToNow(date, this.dateFnsLocale);
|
|
1906
|
+
}
|
|
1894
1907
|
static { this.ɵfac = function LocalizationService_Factory(t) { return new (t || LocalizationService)(i0.ɵɵinject(i1$3.TranslateService)); }; }
|
|
1895
1908
|
static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LocalizationService, factory: LocalizationService.ɵfac, providedIn: 'root' }); }
|
|
1896
1909
|
}
|
|
@@ -1942,6 +1955,17 @@ class LocalizePipe {
|
|
|
1942
1955
|
if (type === 'dt') {
|
|
1943
1956
|
return this.localizeService.getLocalizedDateTime(inputData);
|
|
1944
1957
|
}
|
|
1958
|
+
//UTC ---------------------------------------------------------------------BEGIN
|
|
1959
|
+
//Date
|
|
1960
|
+
if (type === 'utc2d') {
|
|
1961
|
+
return this.localizeService.getUTCToLocalizedDate(inputData);
|
|
1962
|
+
}
|
|
1963
|
+
//DateTime
|
|
1964
|
+
if (type === 'utc2dt') {
|
|
1965
|
+
return this.localizeService.getUTCToLocalizedDateTime(inputData);
|
|
1966
|
+
}
|
|
1967
|
+
//UTC ---------------------------------------------------------------------END
|
|
1968
|
+
//Distance ----------------------------------------------------------------BEGIN
|
|
1945
1969
|
//DistanceInWords
|
|
1946
1970
|
if (type === 'dis') {
|
|
1947
1971
|
return this.localizeService.getLocalizedDistanceInWords(inputData, param2);
|
|
@@ -1950,19 +1974,7 @@ class LocalizePipe {
|
|
|
1950
1974
|
if (type === 'dis2now') {
|
|
1951
1975
|
return this.localizeService.getLocalizedDistanceToNowInWords(inputData);
|
|
1952
1976
|
}
|
|
1953
|
-
//
|
|
1954
|
-
//UTC Date
|
|
1955
|
-
if (type === 'utcd') {
|
|
1956
|
-
return this.localizeService.getUTCToLocalizedDate(inputData);
|
|
1957
|
-
}
|
|
1958
|
-
//UTC DateTime
|
|
1959
|
-
if (type === 'utcdt') {
|
|
1960
|
-
return this.localizeService.getUTCToLocalizedDateTime(inputData);
|
|
1961
|
-
}
|
|
1962
|
-
//UTC DistanceToNowInWords
|
|
1963
|
-
if (type === 'utcdis2now') {
|
|
1964
|
-
return this.localizeService.getUTCToLocalizedDistanceToNowInWords(inputData);
|
|
1965
|
-
}
|
|
1977
|
+
//Distance ----------------------------------------------------------------END
|
|
1966
1978
|
return inputData;
|
|
1967
1979
|
}
|
|
1968
1980
|
static { this.ɵfac = function LocalizePipe_Factory(t) { return new (t || LocalizePipe)(i0.ɵɵdirectiveInject(LocalizationService, 16)); }; }
|
|
@@ -2648,7 +2660,7 @@ class StarterServiceBase extends ApiServiceBase {
|
|
|
2648
2660
|
}
|
|
2649
2661
|
applicationStarting() {
|
|
2650
2662
|
let context = this.appContext.current;
|
|
2651
|
-
if (!
|
|
2663
|
+
if (!is.objectNullOrEmpty(context)) {
|
|
2652
2664
|
this.appContext.init(context);
|
|
2653
2665
|
return of(context);
|
|
2654
2666
|
}
|
|
@@ -2901,6 +2913,97 @@ class Guid {
|
|
|
2901
2913
|
}
|
|
2902
2914
|
}
|
|
2903
2915
|
|
|
2916
|
+
/*
|
|
2917
|
+
<file>
|
|
2918
|
+
Project:
|
|
2919
|
+
@osovitny/anatoly
|
|
2920
|
+
|
|
2921
|
+
Authors:
|
|
2922
|
+
Vadim Osovitny vadim@osovitny.com
|
|
2923
|
+
Anatoly Osovitny anatoly@osovitny.com
|
|
2924
|
+
|
|
2925
|
+
Created:
|
|
2926
|
+
19 March 2020
|
|
2927
|
+
|
|
2928
|
+
Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
|
|
2929
|
+
</file>
|
|
2930
|
+
*/
|
|
2931
|
+
class Utils {
|
|
2932
|
+
static idExistsInQS() {
|
|
2933
|
+
let id = Utils.getValueByNameInQS("id");
|
|
2934
|
+
if (id)
|
|
2935
|
+
return true;
|
|
2936
|
+
return false;
|
|
2937
|
+
}
|
|
2938
|
+
static getValueByNameInQS(name) {
|
|
2939
|
+
return Utils.getValueByName(location.search, name);
|
|
2940
|
+
}
|
|
2941
|
+
static getValueByName(url, name) {
|
|
2942
|
+
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
|
2943
|
+
// tslint:disable-next-line:one-variable-per-declaration
|
|
2944
|
+
const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'), results = regex.exec(url);
|
|
2945
|
+
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
|
2946
|
+
}
|
|
2947
|
+
static copyToClipBoard(event, val) {
|
|
2948
|
+
event.preventDefault();
|
|
2949
|
+
const selBox = document.createElement('textarea');
|
|
2950
|
+
selBox.style.position = 'fixed';
|
|
2951
|
+
selBox.style.left = '0';
|
|
2952
|
+
selBox.style.top = '0';
|
|
2953
|
+
selBox.style.opacity = '0';
|
|
2954
|
+
selBox.value = val;
|
|
2955
|
+
document.body.appendChild(selBox);
|
|
2956
|
+
selBox.focus();
|
|
2957
|
+
selBox.select();
|
|
2958
|
+
document.execCommand('copy');
|
|
2959
|
+
document.body.removeChild(selBox);
|
|
2960
|
+
}
|
|
2961
|
+
static downloadFile(name, url) {
|
|
2962
|
+
const link = document.createElement('a');
|
|
2963
|
+
link.download = name;
|
|
2964
|
+
link.href = url;
|
|
2965
|
+
link.click();
|
|
2966
|
+
}
|
|
2967
|
+
static downloadBlobFile(value, fileName) {
|
|
2968
|
+
const nav = window.navigator;
|
|
2969
|
+
if (nav.msSaveOrOpenBlob) {
|
|
2970
|
+
nav.msSaveOrOpenBlob(value, fileName);
|
|
2971
|
+
}
|
|
2972
|
+
else {
|
|
2973
|
+
const downloadURL = window.URL.createObjectURL(value);
|
|
2974
|
+
Utils.downloadFile(fileName, downloadURL);
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
/*
|
|
2978
|
+
Author:
|
|
2979
|
+
https://medium.com/@mhagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
|
|
2980
|
+
*/
|
|
2981
|
+
static slugify(text, prefix = '', postfix = '') {
|
|
2982
|
+
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;';
|
|
2983
|
+
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------';
|
|
2984
|
+
const p = new RegExp(a.split('').join('|'), 'g');
|
|
2985
|
+
/*
|
|
2986
|
+
https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
|
|
2987
|
+
https://stackoverflow.com/questions/822452/strip-html-from-text-javascript
|
|
2988
|
+
*/
|
|
2989
|
+
text = text.replace(/(<([^>]+)>)/gi, '');
|
|
2990
|
+
let result = text
|
|
2991
|
+
.toString()
|
|
2992
|
+
.toLowerCase()
|
|
2993
|
+
.replace(/\s+/g, '-') // Replace spaces with -
|
|
2994
|
+
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
|
|
2995
|
+
.replace(/&/g, '-and-') // Replace & with 'and'
|
|
2996
|
+
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
|
|
2997
|
+
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
|
2998
|
+
.replace(/^-+/, '') // Trim - from start of text
|
|
2999
|
+
.replace(/-+$/, ''); // Trim - from end of text
|
|
3000
|
+
return prefix + result + postfix;
|
|
3001
|
+
}
|
|
3002
|
+
static generateRandom(start, end) {
|
|
3003
|
+
return Math.floor(Math.random() * (end - start + 1)) + start;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
|
|
2904
3007
|
/*
|
|
2905
3008
|
<file>
|
|
2906
3009
|
Project:
|
|
@@ -7355,5 +7458,5 @@ class AnatolyModule {
|
|
|
7355
7458
|
* Generated bundle index. Do not edit.
|
|
7356
7459
|
*/
|
|
7357
7460
|
|
|
7358
|
-
export { AddressComponent, AdminGuard, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AuthService, AuthenticationGuard, BaseGoService, Browser, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, DOM, DataPagerComponent, DefaultEditorOptions, DialogBase, DigitalMarketingService, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, InjectorInstance, ItemValidationSummaryComponent, L10NUrl, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, NativeElementDirective, NodataComponent, NotificationService, PageBase, PageSpinnerComponent, PagedPageBase, ReplaceTextPipe, SafeHtmlPipe, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterServiceBase, Stopwatch, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, getAppSettingsById, getAppSettingsByName, localizationInitializerFactory, throwIfAlreadyLoaded, translateLoaderFactory };
|
|
7461
|
+
export { AddressComponent, AdminGuard, Alerts, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AuthService, AuthenticationGuard, BaseGoService, Browser, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, DOM, DataPagerComponent, DateConvert, DefaultEditorOptions, DialogBase, DigitalMarketingService, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FileSizePipe, FormValidationSummaryComponent, FormsHtmlEditorComponent, GlobalErrorHandler, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, InjectorInstance, ItemValidationSummaryComponent, L10NUrl, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationInjectorInstance, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, NativeElementDirective, NodataComponent, NotificationService, PageBase, PageSpinnerComponent, PagedPageBase, ReplaceTextPipe, SafeHtmlPipe, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterServiceBase, Stopwatch, Subs, SubscribePlanButtonComponent, TimezoneDropdownlist, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, dateFormats, dateTimeFormats, getAppSettingsById, getAppSettingsByName, is, localizationInitializerFactory, throwIfAlreadyLoaded, timeFormats, translateLoaderFactory };
|
|
7359
7462
|
//# sourceMappingURL=osovitny-anatoly.mjs.map
|