@osovitny/anatoly 3.17.3 → 3.17.5

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.
@@ -13,7 +13,6 @@ import { BrowserUtils, EventType, InteractionStatus, InteractionType, Interactio
13
13
  import * as i1$2 from '@angular/common';
14
14
  import { LOCATION_INITIALIZED, DOCUMENT, CommonModule } from '@angular/common';
15
15
  import { format, formatDistance, formatDistanceToNow } from 'date-fns';
16
- import { utcToZonedTime } from 'date-fns-tz';
17
16
  import enUS from 'date-fns/locale/en-US';
18
17
  import * as i1$3 from '@ngx-translate/core';
19
18
  import { TranslateService, TranslateModule, TranslateLoader } from '@ngx-translate/core';
@@ -96,9 +95,16 @@ const ClientApps = AppCoreSettings?.clientApps;
96
95
  const AppName = document.getElementById('appName').getAttribute('data-appname');
97
96
  const AppSettings = getAppSettingsByName(AppName);
98
97
  //DateFormats
99
- const DateFormats = {
100
- date: 'dd MMM yyyy',
101
- dateTime: 'dd MMM yyyy HH:mm'
98
+ const dateFormats = {
99
+ medium: "dd MMM yyyy",
100
+ short: "dd/MM/yyyy"
101
+ };
102
+ const timeFormats = {
103
+ medium: "HH:mm:ss",
104
+ short: "HH:mm"
105
+ };
106
+ const dateTimeFormats = {
107
+ medium: 'dd MMM yyyy HH:mm'
102
108
  };
103
109
 
104
110
  /*
@@ -1677,35 +1683,54 @@ class is {
1677
1683
  static dateInvalid(date) {
1678
1684
  return !is.dateValid(date);
1679
1685
  }
1686
+ static objectNullOrEmpty(obj) {
1687
+ return !obj || Object.keys(obj).length == 0;
1688
+ }
1680
1689
  static string(value) {
1681
1690
  return (typeof value === 'string' || value instanceof String);
1682
1691
  }
1692
+ static emptyString(value) {
1693
+ return (is.string(value) && (value.length == 0));
1694
+ }
1695
+ static notEmptyString(value) {
1696
+ return (is.string(value) && (value.length > 0));
1697
+ }
1683
1698
  static number(value) {
1684
1699
  return (typeof value === 'number');
1685
1700
  }
1686
1701
  static boolean(value) {
1687
1702
  return (typeof value === 'boolean');
1688
1703
  }
1689
- static objectNullOrEmpty(obj) {
1690
- return !obj || Object.keys(obj).length == 0;
1704
+ static array(value) {
1705
+ return (value instanceof Array);
1706
+ }
1707
+ static emptyArray(value) {
1708
+ return (is.array(value) && (value.length == 0));
1709
+ }
1710
+ static notEmptyArray(value) {
1711
+ return (is.array(value) && (value.length > 0));
1712
+ }
1713
+ static undefined(value) {
1714
+ return (typeof value === 'undefined');
1691
1715
  }
1692
1716
  }
1693
1717
  /*
1694
-
1695
1718
  is = {
1696
1719
  DONE string: function (obj) { return (typeof obj === 'string'); },
1720
+ DONE emptyString: function (obj) { return (is.string(obj) && (obj.length == 0)); },
1721
+ DONE nonEmptyString: function (obj) { return (is.string(obj) && (obj.length > 0)); },
1697
1722
  DONE number: function (obj) { return (typeof obj === 'number'); },
1698
1723
  DONE bool: function (obj) { return (typeof obj === 'boolean'); },
1699
- array: function (obj) { return (obj instanceof Array); },
1700
- undefined: function (obj) { return (typeof obj === 'undefined'); },
1724
+ DONE array: function (obj) { return (obj instanceof Array); },
1725
+ DONE emptyArray: function (obj) { return (is.array(obj) && (obj.length == 0)); },
1726
+ DONE notEmptyArray: function (obj) { return (is.array(obj) && (obj.length > 0)); },
1727
+ DONE undefined: function (obj) { return (typeof obj === 'undefined'); },
1728
+
1701
1729
  'null': function (obj) { return (obj === null); },
1702
1730
  notNull: function (obj) { return (obj !== null); },
1703
1731
  invalid: function (obj) { return (is['null'](obj) || is.undefined(obj)); },
1704
1732
  valid: function (obj) { return (!is['null'](obj) && !is.undefined(obj)); },
1705
- emptyString: function (obj) { return (is.string(obj) && (obj.length == 0)); },
1706
- nonEmptyString: function (obj) { return (is.string(obj) && (obj.length > 0)); },
1707
- emptyArray: function (obj) { return (is.array(obj) && (obj.length == 0)); },
1708
- nonEmptyArray: function (obj) { return (is.array(obj) && (obj.length > 0)); },
1733
+
1709
1734
  document: function (obj) { return (obj === document); },
1710
1735
  window: function (obj) { return (obj === window); },
1711
1736
  element: function (obj) { return (obj instanceof HTMLElement); },
@@ -1714,6 +1739,257 @@ is = {
1714
1739
  };
1715
1740
  */
1716
1741
 
1742
+ /*
1743
+ <file>
1744
+ Project:
1745
+ @osovitny/anatoly
1746
+
1747
+ Authors:
1748
+ Vadim Osovitny vadim@osovitny.com
1749
+ Anatoly Osovitny anatoly@osovitny.com
1750
+
1751
+ Created:
1752
+ 10 Feb 2024
1753
+
1754
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1755
+ </file>
1756
+ */
1757
+ /**
1758
+ * Returns the [year, month, day, hour, minute, seconds] tokens of the provided
1759
+ * `date` as it will be rendered in the `timeZone`.
1760
+ */
1761
+ function tzTokenizeDate(date, timeZone) {
1762
+ var dtf = getDateTimeFormat(timeZone);
1763
+ return dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date);
1764
+ }
1765
+ var typeToPos = {
1766
+ year: 0,
1767
+ month: 1,
1768
+ day: 2,
1769
+ hour: 3,
1770
+ minute: 4,
1771
+ second: 5,
1772
+ };
1773
+ function partsOffset(dtf, date) {
1774
+ try {
1775
+ var formatted = dtf.formatToParts(date);
1776
+ var filled = [];
1777
+ for (var i = 0; i < formatted.length; i++) {
1778
+ var pos = typeToPos[formatted[i].type];
1779
+ if (pos >= 0) {
1780
+ filled[pos] = parseInt(formatted[i].value, 10);
1781
+ }
1782
+ }
1783
+ return filled;
1784
+ }
1785
+ catch (error) {
1786
+ if (error instanceof RangeError) {
1787
+ return [NaN];
1788
+ }
1789
+ throw error;
1790
+ }
1791
+ }
1792
+ function hackyOffset(dtf, date) {
1793
+ var formatted = dtf.format(date).replace(/\u200E/g, '');
1794
+ var parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted);
1795
+ // var [, fMonth, fDay, fYear, fHour, fMinute, fSecond] = parsed
1796
+ // return [fYear, fMonth, fDay, fHour, fMinute, fSecond]
1797
+ return [parsed[3], parsed[1], parsed[2], parsed[4], parsed[5], parsed[6]];
1798
+ }
1799
+ // Get a cached Intl.DateTimeFormat instance for the IANA `timeZone`. This can be used
1800
+ // to get deterministic local date/time output according to the `en-US` locale which
1801
+ // can be used to extract local time parts as necessary.
1802
+ var dtfCache = {};
1803
+ function getDateTimeFormat(timeZone) {
1804
+ if (!dtfCache[timeZone]) {
1805
+ // New browsers use `hourCycle`, IE and Chrome <73 does not support it and uses `hour12`
1806
+ var testDateFormatted = new Intl.DateTimeFormat('en-US', {
1807
+ hour12: false,
1808
+ timeZone: 'America/New_York',
1809
+ year: 'numeric',
1810
+ month: 'numeric',
1811
+ day: '2-digit',
1812
+ hour: '2-digit',
1813
+ minute: '2-digit',
1814
+ second: '2-digit',
1815
+ }).format(new Date('2014-06-25T04:00:00.123Z'));
1816
+ var hourCycleSupported = testDateFormatted === '06/25/2014, 00:00:00' ||
1817
+ testDateFormatted === '06/25/2014 00:00:00';
1818
+ dtfCache[timeZone] = hourCycleSupported
1819
+ ? new Intl.DateTimeFormat('en-US', {
1820
+ hour12: false,
1821
+ timeZone: timeZone,
1822
+ year: 'numeric',
1823
+ month: 'numeric',
1824
+ day: '2-digit',
1825
+ hour: '2-digit',
1826
+ minute: '2-digit',
1827
+ second: '2-digit',
1828
+ })
1829
+ : new Intl.DateTimeFormat('en-US', {
1830
+ hourCycle: 'h23',
1831
+ timeZone: timeZone,
1832
+ year: 'numeric',
1833
+ month: 'numeric',
1834
+ day: '2-digit',
1835
+ hour: '2-digit',
1836
+ minute: '2-digit',
1837
+ second: '2-digit',
1838
+ });
1839
+ }
1840
+ return dtfCache[timeZone];
1841
+ }
1842
+
1843
+ /*
1844
+ <file>
1845
+ Project:
1846
+ @osovitny/anatoly
1847
+
1848
+ Authors:
1849
+ Vadim Osovitny vadim@osovitny.com
1850
+ Anatoly Osovitny anatoly@osovitny.com
1851
+
1852
+ Created:
1853
+ 10 Feb 2024
1854
+
1855
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1856
+ </file>
1857
+ */
1858
+ function tzParseTimezone(timezoneString, date, isUtcDate) {
1859
+ var token;
1860
+ var absoluteOffset;
1861
+ // Empty string
1862
+ if (!timezoneString) {
1863
+ return 0;
1864
+ }
1865
+ // Z
1866
+ token = patterns.timezoneZ.exec(timezoneString);
1867
+ if (token) {
1868
+ return 0;
1869
+ }
1870
+ var hours;
1871
+ // ±hh
1872
+ token = patterns.timezoneHH.exec(timezoneString);
1873
+ if (token) {
1874
+ hours = parseInt(token[1], 10);
1875
+ if (!validateTimezone(hours)) {
1876
+ return NaN;
1877
+ }
1878
+ return -(hours * MILLISECONDS_IN_HOUR);
1879
+ }
1880
+ // ±hh:mm or ±hhmm
1881
+ token = patterns.timezoneHHMM.exec(timezoneString);
1882
+ if (token) {
1883
+ hours = parseInt(token[1], 10);
1884
+ var minutes = parseInt(token[2], 10);
1885
+ if (!validateTimezone(hours, minutes)) {
1886
+ return NaN;
1887
+ }
1888
+ absoluteOffset = Math.abs(hours) * MILLISECONDS_IN_HOUR + minutes * MILLISECONDS_IN_MINUTE;
1889
+ return hours > 0 ? -absoluteOffset : absoluteOffset;
1890
+ }
1891
+ // IANA time zone
1892
+ if (isValidTimezoneIANAString(timezoneString)) {
1893
+ date = new Date(date || Date.now());
1894
+ var utcDate = isUtcDate ? date : toUtcDate(date);
1895
+ var offset = calcOffset(utcDate, timezoneString);
1896
+ var fixedOffset = isUtcDate ? offset : fixOffset(date, offset, timezoneString);
1897
+ return -fixedOffset;
1898
+ }
1899
+ return NaN;
1900
+ }
1901
+ var MILLISECONDS_IN_HOUR = 3600000;
1902
+ var MILLISECONDS_IN_MINUTE = 60000;
1903
+ var patterns = {
1904
+ timezone: /([Z+-].*)$/,
1905
+ timezoneZ: /^(Z)$/,
1906
+ timezoneHH: /^([+-]\d{2})$/,
1907
+ timezoneHHMM: /^([+-]\d{2}):?(\d{2})$/,
1908
+ };
1909
+ function newDateUTC(fullYear, month, day, hour, minute, second, millisecond) {
1910
+ var utcDate = new Date(0);
1911
+ utcDate.setUTCFullYear(fullYear, month, day);
1912
+ utcDate.setUTCHours(hour, minute, second, millisecond);
1913
+ return utcDate;
1914
+ }
1915
+ function toUtcDate(date) {
1916
+ return newDateUTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
1917
+ }
1918
+ function calcOffset(date, timezoneString) {
1919
+ var tokens = tzTokenizeDate(date, timezoneString);
1920
+ // ms dropped because it's not provided by tzTokenizeDate
1921
+ var asUTC = newDateUTC(tokens[0], tokens[1] - 1, tokens[2], tokens[3] % 24, tokens[4], tokens[5], 0).getTime();
1922
+ var asTS = date.getTime();
1923
+ var over = asTS % 1000;
1924
+ asTS -= over >= 0 ? over : 1000 + over;
1925
+ return asUTC - asTS;
1926
+ }
1927
+ function fixOffset(date, offset, timezoneString) {
1928
+ var localTS = date.getTime();
1929
+ // Our UTC time is just a guess because our offset is just a guess
1930
+ var utcGuess = localTS - offset;
1931
+ // Test whether the zone matches the offset for this ts
1932
+ var o2 = calcOffset(new Date(utcGuess), timezoneString);
1933
+ // If so, offset didn't change, and we're done
1934
+ if (offset === o2) {
1935
+ return offset;
1936
+ }
1937
+ // If not, change the ts by the difference in the offset
1938
+ utcGuess -= o2 - offset;
1939
+ // If that gives us the local time we want, we're done
1940
+ var o3 = calcOffset(new Date(utcGuess), timezoneString);
1941
+ if (o2 === o3) {
1942
+ return o2;
1943
+ }
1944
+ // If it's different, we're in a hole time. The offset has changed, but we don't adjust the time
1945
+ return Math.max(o2, o3);
1946
+ }
1947
+ function validateTimezone(hours, minutes = null) {
1948
+ return -23 <= hours && hours <= 23 && (minutes == null || (0 <= minutes && minutes <= 59));
1949
+ }
1950
+ var validIANATimezoneCache = {};
1951
+ function isValidTimezoneIANAString(timeZoneString) {
1952
+ if (validIANATimezoneCache[timeZoneString])
1953
+ return true;
1954
+ try {
1955
+ new Intl.DateTimeFormat(undefined, { timeZone: timeZoneString });
1956
+ validIANATimezoneCache[timeZoneString] = true;
1957
+ return true;
1958
+ }
1959
+ catch (error) {
1960
+ return false;
1961
+ }
1962
+ }
1963
+
1964
+ /*
1965
+ <file>
1966
+ Project:
1967
+ @osovitny/anatoly
1968
+
1969
+ Authors:
1970
+ Vadim Osovitny vadim@osovitny.com
1971
+ Anatoly Osovitny anatoly@osovitny.com
1972
+
1973
+ Created:
1974
+ 10 Feb 2024
1975
+
1976
+ Source:
1977
+ https://github.com/marnusw/date-fns-tz/blob/master/src/utcToZonedTime/index.js
1978
+ https://github.com/marnusw/date-fns-tz/blob/master/src/_lib/tzParseTimezone/index.js
1979
+
1980
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
1981
+ </file>
1982
+ */
1983
+ function utcToZonedTime(dirtyDate, timeZone) {
1984
+ let date = DateConvert.toDate(dirtyDate);
1985
+ let offsetMilliseconds = tzParseTimezone(timeZone, date, true);
1986
+ let d = new Date(date.getTime() - offsetMilliseconds);
1987
+ let resultDate = new Date(0);
1988
+ resultDate.setFullYear(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
1989
+ resultDate.setHours(d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());
1990
+ return resultDate;
1991
+ }
1992
+
1717
1993
  /*
1718
1994
  <file>
1719
1995
  Project:
@@ -1807,21 +2083,21 @@ class LocalizationService {
1807
2083
  if (is.dateInvalid(date)) {
1808
2084
  return "Invalid Date";
1809
2085
  }
1810
- return format(date, DateFormats.date, this.dateFnsLocale);
2086
+ return format(date, dateFormats.medium, this.dateFnsLocale);
1811
2087
  }
1812
2088
  getLocalizedDateTime(value) {
1813
2089
  let date = DateConvert.toDate(value);
1814
2090
  if (is.dateInvalid(date)) {
1815
2091
  return "Invalid Date";
1816
2092
  }
1817
- return format(date, DateFormats.dateTime, this.dateFnsLocale);
2093
+ return format(date, dateTimeFormats.medium, this.dateFnsLocale);
1818
2094
  }
1819
2095
  //UTC ---------------------------------------------------------------------BEGIN
1820
2096
  getUTCToLocalizedDate(value) {
1821
- return this.safeUtcToZonedTime(value, DateFormats.date);
2097
+ return this.safeUtcToZonedTime(value, dateFormats.medium);
1822
2098
  }
1823
2099
  getUTCToLocalizedDateTime(value) {
1824
- return this.safeUtcToZonedTime(value, DateFormats.dateTime);
2100
+ return this.safeUtcToZonedTime(value, dateTimeFormats.medium);
1825
2101
  }
1826
2102
  safeUtcToZonedTime(date, conversionFormat = null) {
1827
2103
  if (!date) {
@@ -7432,5 +7708,5 @@ class AnatolyModule {
7432
7708
  * Generated bundle index. Do not edit.
7433
7709
  */
7434
7710
 
7435
- 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, DateFormats, 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, is, localizationInitializerFactory, throwIfAlreadyLoaded, translateLoaderFactory };
7711
+ 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 };
7436
7712
  //# sourceMappingURL=osovitny-anatoly.mjs.map