@skyux/datetime 7.0.0-beta.0 → 7.0.0-beta.1
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/modules/date-pipe/date-format-utility.mjs +3 -6
- package/esm2020/lib/modules/date-pipe/date.pipe.mjs +22 -15
- package/esm2020/lib/modules/date-pipe/fuzzy-date.pipe.mjs +2 -2
- package/fesm2015/skyux-datetime.mjs +25 -20
- package/fesm2015/skyux-datetime.mjs.map +1 -1
- package/fesm2020/skyux-datetime.mjs +24 -20
- package/fesm2020/skyux-datetime.mjs.map +1 -1
- package/lib/modules/date-pipe/date-format-utility.d.ts +1 -1
- package/lib/modules/date-pipe/date.pipe.d.ts +1 -7
- package/package.json +8 -8
@@ -1,3 +1,4 @@
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
|
1
2
|
import * as i0 from '@angular/core';
|
2
3
|
import { Pipe, NgModule, Injectable, EventEmitter, Component, ViewEncapsulation, Input, Output, ChangeDetectionStrategy, ViewChild, ElementRef, TemplateRef, Optional, forwardRef, Directive, HostListener } from '@angular/core';
|
3
4
|
import * as i3 from '@skyux/i18n';
|
@@ -31,7 +32,7 @@ class SkyDateFormatUtility {
|
|
31
32
|
// introduce a breaking change, so we check for it here. This could probably be removed
|
32
33
|
// in a future major version.
|
33
34
|
if (value instanceof Object && !(value instanceof Date)) {
|
34
|
-
|
35
|
+
throw new Error('Invalid value: ' + value);
|
35
36
|
}
|
36
37
|
// Use moment to avoid inconsistencies between browsers interpreting the value differently.
|
37
38
|
const momentDate = moment(value);
|
@@ -39,7 +40,7 @@ class SkyDateFormatUtility {
|
|
39
40
|
date = momentDate.toDate();
|
40
41
|
}
|
41
42
|
else {
|
42
|
-
|
43
|
+
throw new Error('Invalid value: ' + value);
|
43
44
|
}
|
44
45
|
return SkyIntlDateFormatter.format(date, locale, SkyDateFormatUtility._ALIASES[pattern] || pattern);
|
45
46
|
}
|
@@ -57,10 +58,8 @@ SkyDateFormatUtility._ALIASES = {
|
|
57
58
|
function isBlank(obj) {
|
58
59
|
return !obj;
|
59
60
|
}
|
60
|
-
function handleInvalidDate(value) {
|
61
|
-
throw new Error('Invalid value: ' + value);
|
62
|
-
}
|
63
61
|
|
62
|
+
var _SkyDatePipe_defaultFormat, _SkyDatePipe_format, _SkyDatePipe_defaultLocale, _SkyDatePipe_locale, _SkyDatePipe_value, _SkyDatePipe_formattedValue, _SkyDatePipe_ngUnsubscribe;
|
64
63
|
/**
|
65
64
|
* Formats date values according to locale rules.
|
66
65
|
* @example
|
@@ -73,20 +72,24 @@ function handleInvalidDate(value) {
|
|
73
72
|
class SkyDatePipe {
|
74
73
|
constructor(localeProvider) {
|
75
74
|
this.localeProvider = localeProvider;
|
76
|
-
this
|
77
|
-
this
|
78
|
-
this
|
75
|
+
_SkyDatePipe_defaultFormat.set(this, 'short');
|
76
|
+
_SkyDatePipe_format.set(this, void 0);
|
77
|
+
_SkyDatePipe_defaultLocale.set(this, 'en-US');
|
78
|
+
_SkyDatePipe_locale.set(this, void 0);
|
79
|
+
_SkyDatePipe_value.set(this, void 0);
|
80
|
+
_SkyDatePipe_formattedValue.set(this, void 0);
|
81
|
+
_SkyDatePipe_ngUnsubscribe.set(this, new Subject());
|
79
82
|
this.localeProvider
|
80
83
|
.getLocaleInfo()
|
81
|
-
.pipe(takeUntil(this
|
84
|
+
.pipe(takeUntil(__classPrivateFieldGet(this, _SkyDatePipe_ngUnsubscribe, "f")))
|
82
85
|
.subscribe((localeInfo) => {
|
83
|
-
this
|
86
|
+
__classPrivateFieldSet(this, _SkyDatePipe_defaultLocale, localeInfo.locale, "f");
|
84
87
|
this.updateFormattedValue();
|
85
88
|
});
|
86
89
|
}
|
87
90
|
ngOnDestroy() {
|
88
|
-
this.
|
89
|
-
this.
|
91
|
+
__classPrivateFieldGet(this, _SkyDatePipe_ngUnsubscribe, "f").next();
|
92
|
+
__classPrivateFieldGet(this, _SkyDatePipe_ngUnsubscribe, "f").complete();
|
90
93
|
}
|
91
94
|
/**
|
92
95
|
* Transforms a date value using locale and format rules.
|
@@ -97,18 +100,19 @@ class SkyDatePipe {
|
|
97
100
|
* @param locale Specifies the locale code to use in the transform.
|
98
101
|
*/
|
99
102
|
transform(value, format, locale) {
|
100
|
-
this
|
101
|
-
this
|
102
|
-
this
|
103
|
+
__classPrivateFieldSet(this, _SkyDatePipe_value, value, "f");
|
104
|
+
__classPrivateFieldSet(this, _SkyDatePipe_format, format, "f");
|
105
|
+
__classPrivateFieldSet(this, _SkyDatePipe_locale, locale, "f");
|
103
106
|
this.updateFormattedValue();
|
104
|
-
return this
|
107
|
+
return __classPrivateFieldGet(this, _SkyDatePipe_formattedValue, "f") ?? '';
|
105
108
|
}
|
106
109
|
updateFormattedValue() {
|
107
|
-
const locale = this
|
108
|
-
const format = this
|
109
|
-
this
|
110
|
+
const locale = __classPrivateFieldGet(this, _SkyDatePipe_locale, "f") || __classPrivateFieldGet(this, _SkyDatePipe_defaultLocale, "f");
|
111
|
+
const format = __classPrivateFieldGet(this, _SkyDatePipe_format, "f") || __classPrivateFieldGet(this, _SkyDatePipe_defaultFormat, "f");
|
112
|
+
__classPrivateFieldSet(this, _SkyDatePipe_formattedValue, SkyDateFormatUtility.format(locale, __classPrivateFieldGet(this, _SkyDatePipe_value, "f"), format), "f");
|
110
113
|
}
|
111
114
|
}
|
115
|
+
_SkyDatePipe_defaultFormat = new WeakMap(), _SkyDatePipe_format = new WeakMap(), _SkyDatePipe_defaultLocale = new WeakMap(), _SkyDatePipe_locale = new WeakMap(), _SkyDatePipe_value = new WeakMap(), _SkyDatePipe_formattedValue = new WeakMap(), _SkyDatePipe_ngUnsubscribe = new WeakMap();
|
112
116
|
SkyDatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: SkyDatePipe, deps: [{ token: i3.SkyAppLocaleProvider }], target: i0.ɵɵFactoryTarget.Pipe });
|
113
117
|
SkyDatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.0", ngImport: i0, type: SkyDatePipe, name: "skyDate", pure: false });
|
114
118
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: SkyDatePipe, decorators: [{
|
@@ -668,7 +672,7 @@ class SkyFuzzyDatePipe {
|
|
668
672
|
*/
|
669
673
|
transform(value, format, locale) {
|
670
674
|
if (!value) {
|
671
|
-
return
|
675
|
+
return '';
|
672
676
|
}
|
673
677
|
const fuzzyDateFormat = format || this.fuzzyDateService.getLocaleShortFormat(locale);
|
674
678
|
const fuzzyDateLocale = locale || this.fuzzyDateService.getCurrentLocale();
|