@ui5/webcomponents-localization 1.14.0 → 1.15.0-rc.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/CHANGELOG.md +11 -0
- package/dist/dates/modifyDateBy.d.ts +2 -1
- package/dist/dates/modifyDateBy.js +34 -19
- package/dist/dates/modifyDateBy.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.15.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0...v1.15.0-rc.0) (2023-06-08)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **ui5-calendar:** prevent focus loss during arrow navigation with mouse/touch ([#6957](https://github.com/SAP/ui5-webcomponents/issues/6957)) ([216f6a7](https://github.com/SAP/ui5-webcomponents/commit/216f6a7a476d18a0f6fdf7ff189f953085e30b47))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
6
17
|
# [1.14.0](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0-rc.2...v1.14.0) (2023-06-01)
|
7
18
|
|
8
19
|
**Note:** Version bump only for package @ui5/webcomponents-localization
|
@@ -6,8 +6,9 @@ import CalendarDate from "./CalendarDate.js";
|
|
6
6
|
* @param date CalendarDate instance
|
7
7
|
* @param amount how many days/months/years to add (can be a negative number)
|
8
8
|
* @param unit what to modify: "day", "month" or "year"
|
9
|
+
* @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
|
9
10
|
* @param minDate minimum date to enforce
|
10
11
|
* @param maxDate maximum date to enforce
|
11
12
|
*/
|
12
|
-
declare const modifyDateBy: (date: CalendarDate, amount: number, unit: string, minDate?: CalendarDate, maxDate?: CalendarDate) => CalendarDate;
|
13
|
+
declare const modifyDateBy: (date: CalendarDate, amount: number, unit: string, preserveDate?: boolean, minDate?: CalendarDate, maxDate?: CalendarDate) => CalendarDate;
|
13
14
|
export default modifyDateBy;
|
@@ -6,32 +6,47 @@ import CalendarDate from "./CalendarDate.js";
|
|
6
6
|
* @param date CalendarDate instance
|
7
7
|
* @param amount how many days/months/years to add (can be a negative number)
|
8
8
|
* @param unit what to modify: "day", "month" or "year"
|
9
|
+
* @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
|
9
10
|
* @param minDate minimum date to enforce
|
10
11
|
* @param maxDate maximum date to enforce
|
11
12
|
*/
|
12
|
-
const modifyDateBy = (date, amount, unit, minDate, maxDate) => {
|
13
|
+
const modifyDateBy = (date, amount, unit, preserveDate = true, minDate, maxDate) => {
|
13
14
|
const newDate = new CalendarDate(date);
|
14
|
-
|
15
|
-
|
15
|
+
switch (unit) {
|
16
|
+
case "day":
|
17
|
+
newDate.setDate(date.getDate() + amount);
|
18
|
+
break;
|
19
|
+
case "month":
|
20
|
+
if (preserveDate) {
|
21
|
+
newDate.setMonth(date.getMonth() + amount);
|
22
|
+
const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
|
23
|
+
const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
|
24
|
+
if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
|
25
|
+
newDate.setDate(0);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
if (amount === 1) {
|
30
|
+
newDate.setMonth(newDate.getMonth() + 1, 1);
|
31
|
+
}
|
32
|
+
if (amount === -1) {
|
33
|
+
newDate.setDate(0);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
break;
|
37
|
+
case "year":
|
38
|
+
newDate.setYear(date.getYear() + amount);
|
39
|
+
if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
|
40
|
+
newDate.setDate(0); // Select the last day of the month
|
41
|
+
}
|
42
|
+
break;
|
43
|
+
default:
|
44
|
+
break;
|
16
45
|
}
|
17
|
-
|
18
|
-
newDate.setMonth(date.getMonth() + amount);
|
19
|
-
const stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month
|
20
|
-
const monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month
|
21
|
-
if (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios
|
22
|
-
newDate.setDate(0);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
newDate.setYear(date.getYear() + amount);
|
27
|
-
if (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year
|
28
|
-
newDate.setDate(0); // Select the last day of the month
|
29
|
-
}
|
30
|
-
}
|
31
|
-
if (minDate && newDate.valueOf() < minDate.valueOf()) {
|
46
|
+
if (minDate && newDate.isBefore(minDate)) {
|
32
47
|
return new CalendarDate(minDate);
|
33
48
|
}
|
34
|
-
if (maxDate && newDate.
|
49
|
+
if (maxDate && newDate.isAfter(maxDate)) {
|
35
50
|
return new CalendarDate(maxDate);
|
36
51
|
}
|
37
52
|
return newDate;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"modifyDateBy.js","sourceRoot":"","sources":["../../src/dates/modifyDateBy.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C
|
1
|
+
{"version":3,"file":"modifyDateBy.js","sourceRoot":"","sources":["../../src/dates/modifyDateBy.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,MAAc,EAAE,IAAY,EAAE,YAAY,GAAG,IAAI,EAAE,OAAsB,EAAE,OAAsB,EAAE,EAAE;IAC9I,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,I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AC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACzC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACxC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import CalendarDate from \"./CalendarDate.js\";\n\n/**\n * Adds or subtracts a given amount of days/months/years from a date.\n * If minDate or maxDate are given, the result will be enforced within these limits\n *\n * @param date CalendarDate instance\n * @param amount how many days/months/years to add (can be a negative number)\n * @param unit what to modify: \"day\", \"month\" or \"year\"\n * @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)\n * @param minDate minimum date to enforce\n * @param maxDate maximum date to enforce\n */\nconst modifyDateBy = (date: CalendarDate, amount: number, unit: string, preserveDate = true, minDate?: CalendarDate, maxDate?: CalendarDate) => {\n\tconst newDate = new CalendarDate(date);\n\n\tswitch (unit) {\n\tcase \"day\":\n\t\tnewDate.setDate(date.getDate() + amount);\n\t\tbreak;\n\tcase \"month\":\n\t\tif (preserveDate) {\n\t\t\tnewDate.setMonth(date.getMonth() + amount);\n\t\t\tconst stillSameMonth = amount === -1 && newDate.getMonth() === date.getMonth(); // f.e. PageUp remained in the same month\n\t\t\tconst monthSkipped = amount === 1 && newDate.getMonth() - date.getMonth() > 1; // f.e. PageDown skipped a whole month\n\t\t\tif (stillSameMonth || monthSkipped) { // Select the last day of the month in any of these 2 scenarios\n\t\t\t\tnewDate.setDate(0);\n\t\t\t}\n\t\t} else {\n\t\t\tif (amount === 1) {\n\t\t\t\tnewDate.setMonth(newDate.getMonth() + 1, 1);\n\t\t\t}\n\t\t\tif (amount === -1) {\n\t\t\t\tnewDate.setDate(0);\n\t\t\t}\n\t\t}\n\t\tbreak;\n\tcase \"year\":\n\t\tnewDate.setYear(date.getYear() + amount);\n\t\tif (newDate.getMonth() !== date.getMonth()) { // f.e. 29th Feb to next/prev year\n\t\t\tnewDate.setDate(0); // Select the last day of the month\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (minDate && newDate.isBefore(minDate)) {\n\t\treturn new CalendarDate(minDate);\n\t}\n\n\tif (maxDate && newDate.isAfter(maxDate)) {\n\t\treturn new CalendarDate(maxDate);\n\t}\n\n\treturn newDate;\n};\n\nexport default modifyDateBy;\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-localization",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.15.0-rc.0",
|
4
4
|
"description": "Localization for UI5 Web Components",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -29,14 +29,14 @@
|
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
31
|
"@openui5/sap.ui.core": "1.112.0",
|
32
|
-
"@ui5/webcomponents-tools": "1.
|
33
|
-
"chromedriver": "
|
32
|
+
"@ui5/webcomponents-tools": "1.15.0-rc.0",
|
33
|
+
"chromedriver": "113.0.0",
|
34
34
|
"mkdirp": "^1.0.4",
|
35
35
|
"resolve": "^1.20.0"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
38
|
"@types/openui5": "^1.113.0",
|
39
|
-
"@ui5/webcomponents-base": "1.
|
39
|
+
"@ui5/webcomponents-base": "1.15.0-rc.0"
|
40
40
|
},
|
41
|
-
"gitHead": "
|
41
|
+
"gitHead": "a4417c86ab2c94b5d1b7ce2d72f77c9510a0b279"
|
42
42
|
}
|