@taiga-ui/cdk 2.28.0 → 2.29.0
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/README.md +4 -5
- package/bundles/taiga-ui-cdk-date-time.umd.js +93 -14
- package/bundles/taiga-ui-cdk-date-time.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-date-time.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-date-time.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.js +2 -2
- package/bundles/taiga-ui-cdk-services.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-services.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-services.umd.min.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.min.js +1 -1
- package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.min.js.map +1 -1
- package/date-time/date-separator.d.ts +2 -0
- package/date-time/day-range.d.ts +13 -1
- package/date-time/day.d.ts +16 -3
- package/date-time/index.d.ts +1 -0
- package/date-time/taiga-ui-cdk-date-time.metadata.json +1 -1
- package/esm2015/date-time/date-separator.js +5 -0
- package/esm2015/date-time/day-range.js +28 -5
- package/esm2015/date-time/day.js +53 -11
- package/esm2015/date-time/index.js +2 -1
- package/esm2015/services/destroy.service.js +6 -3
- package/esm2015/services/obscured.service.js +1 -1
- package/esm2015/services/static-request.service.js +1 -1
- package/esm2015/utils/miscellaneous/ease-in-out-quad.js +2 -2
- package/esm5/date-time/date-separator.js +5 -0
- package/esm5/date-time/day-range.js +33 -5
- package/esm5/date-time/day.js +57 -11
- package/esm5/date-time/index.js +2 -1
- package/esm5/services/destroy.service.js +4 -4
- package/esm5/services/obscured.service.js +1 -1
- package/esm5/services/static-request.service.js +1 -1
- package/esm5/utils/miscellaneous/ease-in-out-quad.js +2 -2
- package/fesm2015/taiga-ui-cdk-date-time.js +83 -15
- package/fesm2015/taiga-ui-cdk-date-time.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-services.js +5 -2
- package/fesm2015/taiga-ui-cdk-services.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js +1 -1
- package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
- package/fesm5/taiga-ui-cdk-date-time.js +92 -15
- package/fesm5/taiga-ui-cdk-date-time.js.map +1 -1
- package/fesm5/taiga-ui-cdk-services.js +3 -3
- package/fesm5/taiga-ui-cdk-services.js.map +1 -1
- package/fesm5/taiga-ui-cdk-utils-miscellaneous.js +1 -1
- package/fesm5/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
- package/package.json +3 -3
- package/services/destroy.service.d.ts +3 -2
- package/services/obscured.service.d.ts +1 -1
- package/services/static-request.service.d.ts +1 -1
- package/services/taiga-ui-cdk-services.metadata.json +1 -1
package/README.md
CHANGED
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
[](https://discord.gg/Us8d8JVaTg)
|
|
6
6
|
|
|
7
7
|
[Website](https://taiga-ui.dev) • [Documentation](https://taiga-ui.dev/getting-started) •
|
|
8
|
-
[CDK Wiki](https://github.com/
|
|
9
|
-
[Core team](https://github.com/TinkoffCreditSystems/taiga-ui/#core-team)
|
|
8
|
+
[CDK Wiki](https://github.com/tinkoff/taiga-ui/wiki) • [Core team](https://github.com/tinkoff/taiga-ui/#core-team)
|
|
10
9
|
|
|
11
10
|
> Development kit consisting of the low level tools and abstractions used to develop Taiga UI Angular entities
|
|
12
11
|
|
|
13
|
-
It's a part of [**Taiga UI**](https://github.com/
|
|
14
|
-
|
|
12
|
+
It's a part of [**Taiga UI**](https://github.com/tinkoff/taiga-ui) that is fully-treeshakable Angular UI Kit consisting
|
|
13
|
+
of multiple base libraries and several add-ons
|
|
15
14
|
|
|
16
15
|
## How to install
|
|
17
16
|
|
|
@@ -24,4 +23,4 @@ that there is no redundant code in your bundle. Bundlphobia badge shows size of
|
|
|
24
23
|
|
|
25
24
|
## Docs
|
|
26
25
|
|
|
27
|
-
[CDK Documentation on Github Wiki](https://github.com/
|
|
26
|
+
[CDK Documentation on Github Wiki](https://github.com/tinkoff/taiga-ui/wiki/CDK)
|
|
@@ -279,6 +279,10 @@
|
|
|
279
279
|
factory: function () { return 'DMY'; },
|
|
280
280
|
});
|
|
281
281
|
|
|
282
|
+
var TUI_DATE_SEPARATOR = new core.InjectionToken('Date separator for Taiga UI components', {
|
|
283
|
+
factory: function () { return '.'; },
|
|
284
|
+
});
|
|
285
|
+
|
|
282
286
|
/**
|
|
283
287
|
* Immutable year object
|
|
284
288
|
* @nosideeffects
|
|
@@ -720,17 +724,42 @@
|
|
|
720
724
|
return Math.round((to.toLocalNativeDate().getTime() - from.toLocalNativeDate().getTime()) /
|
|
721
725
|
(1000 * 60 * 60 * 24));
|
|
722
726
|
};
|
|
727
|
+
TuiDay.parseRawDateString = function (date, dateMode) {
|
|
728
|
+
if (dateMode === void 0) { dateMode = 'DMY'; }
|
|
729
|
+
classes.tuiAssert.assert(date.length === DATE_FILLER_LENGTH, '[parseRawDateString]: wrong date string length');
|
|
730
|
+
switch (dateMode) {
|
|
731
|
+
case 'YMD':
|
|
732
|
+
return {
|
|
733
|
+
day: parseInt(date.slice(8, 10), 10),
|
|
734
|
+
month: parseInt(date.slice(5, 7), 10) - 1,
|
|
735
|
+
year: parseInt(date.slice(0, 4), 10),
|
|
736
|
+
};
|
|
737
|
+
case 'MDY':
|
|
738
|
+
return {
|
|
739
|
+
day: parseInt(date.slice(3, 5), 10),
|
|
740
|
+
month: parseInt(date.slice(0, 2), 10) - 1,
|
|
741
|
+
year: parseInt(date.slice(6, 10), 10),
|
|
742
|
+
};
|
|
743
|
+
default:
|
|
744
|
+
case 'DMY':
|
|
745
|
+
return {
|
|
746
|
+
day: parseInt(date.slice(0, 2), 10),
|
|
747
|
+
month: parseInt(date.slice(3, 5), 10) - 1,
|
|
748
|
+
year: parseInt(date.slice(6, 10), 10),
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
};
|
|
723
752
|
// TODO: Move month and year related code corresponding classes
|
|
724
753
|
/**
|
|
725
754
|
* Parsing a string with date with normalization
|
|
726
755
|
*
|
|
727
|
-
* @param
|
|
756
|
+
* @param rawDate date string
|
|
757
|
+
* @param dateMode date format of the date string (DMY | MDY | YMD)
|
|
728
758
|
* @return normalized date
|
|
729
759
|
*/
|
|
730
|
-
TuiDay.normalizeParse = function (
|
|
731
|
-
|
|
732
|
-
var
|
|
733
|
-
var year = parseInt(yearMonthDayString.slice(6, 10), 10);
|
|
760
|
+
TuiDay.normalizeParse = function (rawDate, dateMode) {
|
|
761
|
+
if (dateMode === void 0) { dateMode = 'DMY'; }
|
|
762
|
+
var _a = this.parseRawDateString(rawDate, dateMode), day = _a.day, month = _a.month, year = _a.year;
|
|
734
763
|
return TuiDay.normalizeOf(year, month, day);
|
|
735
764
|
};
|
|
736
765
|
/**
|
|
@@ -740,9 +769,7 @@
|
|
|
740
769
|
* @throws exceptions if any part of the date is invalid
|
|
741
770
|
*/
|
|
742
771
|
TuiDay.jsonParse = function (yearMonthDayString) {
|
|
743
|
-
var
|
|
744
|
-
var month = parseInt(yearMonthDayString.slice(5, 7), 10) - 1;
|
|
745
|
-
var year = parseInt(yearMonthDayString.slice(0, 4), 10);
|
|
772
|
+
var _a = this.parseRawDateString(yearMonthDayString, 'YMD'), day = _a.day, month = _a.month, year = _a.year;
|
|
746
773
|
if (!TuiYear.isValidYear(year)) {
|
|
747
774
|
throw new Error('Invalid year: ' + year);
|
|
748
775
|
}
|
|
@@ -769,6 +796,8 @@
|
|
|
769
796
|
});
|
|
770
797
|
Object.defineProperty(TuiDay.prototype, "formattedDay", {
|
|
771
798
|
/**
|
|
799
|
+
* @deprecated use {@link getFormattedDay} instead
|
|
800
|
+
* TODO remove in 3.0
|
|
772
801
|
* Formatted whole date
|
|
773
802
|
*/
|
|
774
803
|
get: function () {
|
|
@@ -894,8 +923,28 @@
|
|
|
894
923
|
}
|
|
895
924
|
return new TuiDay(years, months, days);
|
|
896
925
|
};
|
|
897
|
-
|
|
898
|
-
|
|
926
|
+
/**
|
|
927
|
+
* Returns formatted whole date
|
|
928
|
+
*/
|
|
929
|
+
TuiDay.prototype.getFormattedDay = function (dateFormat, separator) {
|
|
930
|
+
classes.tuiAssert.assert(separator.length === 1, 'Separator should consist of only 1 symbol');
|
|
931
|
+
var dd = this.formattedDayPart;
|
|
932
|
+
var mm = this.formattedMonthPart;
|
|
933
|
+
var yyyy = this.formattedYear;
|
|
934
|
+
switch (dateFormat) {
|
|
935
|
+
case 'YMD':
|
|
936
|
+
return "" + yyyy + separator + mm + separator + dd;
|
|
937
|
+
case 'MDY':
|
|
938
|
+
return "" + mm + separator + dd + separator + yyyy;
|
|
939
|
+
case 'DMY':
|
|
940
|
+
default:
|
|
941
|
+
return "" + dd + separator + mm + separator + yyyy;
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
TuiDay.prototype.toString = function (dateFormat, separator) {
|
|
945
|
+
if (dateFormat === void 0) { dateFormat = 'DMY'; }
|
|
946
|
+
if (separator === void 0) { separator = '.'; }
|
|
947
|
+
return this.getFormattedDay(dateFormat, separator);
|
|
899
948
|
};
|
|
900
949
|
TuiDay.prototype.toJSON = function () {
|
|
901
950
|
return _super.prototype.toJSON.call(this) + "-" + this.formattedDayPart;
|
|
@@ -952,6 +1001,13 @@
|
|
|
952
1001
|
return TuiMonthRange;
|
|
953
1002
|
}());
|
|
954
1003
|
|
|
1004
|
+
/**
|
|
1005
|
+
* Temporary type guard to satisfy ts-overloading of normalizeParse method
|
|
1006
|
+
* @deprecated TODO rm in v3.0
|
|
1007
|
+
*/
|
|
1008
|
+
var isDateMode = function (dateMode) {
|
|
1009
|
+
return ['DMY', 'YMD', 'MDY'].includes(dateMode);
|
|
1010
|
+
};
|
|
955
1011
|
/**
|
|
956
1012
|
* An immutable range of two {@link TuiDay} objects
|
|
957
1013
|
*/
|
|
@@ -980,14 +1036,17 @@
|
|
|
980
1036
|
* Parse and correct a day range in string format
|
|
981
1037
|
*
|
|
982
1038
|
* @param rangeString a string of dates in a format dd.mm.yyyy - dd.mm.yyyy
|
|
1039
|
+
* @param dateMode {@link TuiDateMode}
|
|
983
1040
|
* @return normalized day range object
|
|
984
1041
|
*/
|
|
985
|
-
TuiDayRange.normalizeParse = function (rangeString) {
|
|
986
|
-
|
|
1042
|
+
TuiDayRange.normalizeParse = function (rangeString, dateMode) {
|
|
1043
|
+
if (dateMode === void 0) { dateMode = 'DMY'; }
|
|
1044
|
+
var dateFormat = isDateMode(dateMode) ? dateMode : 'DMY';
|
|
1045
|
+
var leftDay = TuiDay.normalizeParse(rangeString.slice(0, DATE_FILLER_LENGTH), dateFormat);
|
|
987
1046
|
if (rangeString.length < DATE_RANGE_FILLER_LENGTH) {
|
|
988
1047
|
return new TuiDayRange(leftDay, leftDay);
|
|
989
1048
|
}
|
|
990
|
-
return TuiDayRange.sort(leftDay, TuiDay.normalizeParse(rangeString.slice(DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length)));
|
|
1049
|
+
return TuiDayRange.sort(leftDay, TuiDay.normalizeParse(rangeString.slice(DATE_FILLER_LENGTH + RANGE_SEPARATOR_CHAR.length), dateFormat));
|
|
991
1050
|
};
|
|
992
1051
|
Object.defineProperty(TuiDayRange.prototype, "isSingleDay", {
|
|
993
1052
|
get: function () {
|
|
@@ -999,9 +1058,12 @@
|
|
|
999
1058
|
Object.defineProperty(TuiDayRange.prototype, "formattedDayRange", {
|
|
1000
1059
|
/**
|
|
1001
1060
|
* Human readable format.
|
|
1061
|
+
* @deprecated use {@link getFormattedDayRange} instead
|
|
1002
1062
|
*/
|
|
1003
1063
|
get: function () {
|
|
1004
|
-
|
|
1064
|
+
var from = this.from.getFormattedDay('DMY', '.');
|
|
1065
|
+
var to = this.to.getFormattedDay('DMY', '.');
|
|
1066
|
+
return "" + from + RANGE_SEPARATOR_CHAR + to;
|
|
1005
1067
|
},
|
|
1006
1068
|
enumerable: true,
|
|
1007
1069
|
configurable: true
|
|
@@ -1025,6 +1087,21 @@
|
|
|
1025
1087
|
TuiDayRange.prototype.dayLimit = function (min, max) {
|
|
1026
1088
|
return new TuiDayRange(this.from.dayLimit(min, max), this.to.dayLimit(min, max));
|
|
1027
1089
|
};
|
|
1090
|
+
/**
|
|
1091
|
+
* Human readable format.
|
|
1092
|
+
*/
|
|
1093
|
+
TuiDayRange.prototype.getFormattedDayRange = function (dateFormat, dateSeparator) {
|
|
1094
|
+
var from = this.from.getFormattedDay(dateFormat, dateSeparator);
|
|
1095
|
+
var to = this.to.getFormattedDay(dateFormat, dateSeparator);
|
|
1096
|
+
return "" + from + RANGE_SEPARATOR_CHAR + to;
|
|
1097
|
+
};
|
|
1098
|
+
TuiDayRange.prototype.toString = function (dateFormat, dateSeparator) {
|
|
1099
|
+
if (dateFormat === void 0) { dateFormat = 'DMY'; }
|
|
1100
|
+
if (dateSeparator === void 0) { dateSeparator = '.'; }
|
|
1101
|
+
var from = this.from.getFormattedDay(dateFormat, dateSeparator);
|
|
1102
|
+
var to = this.to.getFormattedDay(dateFormat, dateSeparator);
|
|
1103
|
+
return "" + from + RANGE_SEPARATOR_CHAR + to;
|
|
1104
|
+
};
|
|
1028
1105
|
return TuiDayRange;
|
|
1029
1106
|
}(TuiMonthRange));
|
|
1030
1107
|
|
|
@@ -1171,6 +1248,7 @@
|
|
|
1171
1248
|
exports.TUI_DATE_FILLER = TUI_DATE_FILLER;
|
|
1172
1249
|
exports.TUI_DATE_FORMAT = TUI_DATE_FORMAT;
|
|
1173
1250
|
exports.TUI_DATE_RANGE_FILLER = TUI_DATE_RANGE_FILLER;
|
|
1251
|
+
exports.TUI_DATE_SEPARATOR = TUI_DATE_SEPARATOR;
|
|
1174
1252
|
exports.TUI_FIRST_DAY = TUI_FIRST_DAY;
|
|
1175
1253
|
exports.TUI_LAST_DAY = TUI_LAST_DAY;
|
|
1176
1254
|
exports.TuiDay = TuiDay;
|
|
@@ -1179,6 +1257,7 @@
|
|
|
1179
1257
|
exports.TuiMonthRange = TuiMonthRange;
|
|
1180
1258
|
exports.TuiTime = TuiTime;
|
|
1181
1259
|
exports.TuiYear = TuiYear;
|
|
1260
|
+
exports.isDateMode = isDateMode;
|
|
1182
1261
|
|
|
1183
1262
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1184
1263
|
|