@ui5/webcomponents-localization 1.22.0-rc.1 → 1.22.0-rc.2
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 +8 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/generated/assets/cldr/ar.json +102 -62
- package/dist/generated/assets/cldr/ar_EG.json +102 -62
- package/dist/generated/assets/cldr/ar_SA.json +102 -62
- package/dist/generated/assets/cldr/bg.json +364 -325
- package/dist/generated/assets/cldr/ca.json +491 -453
- package/dist/generated/assets/cldr/cs.json +431 -324
- package/dist/generated/assets/cldr/cy.json +608 -340
- package/dist/generated/assets/cldr/da.json +290 -227
- package/dist/generated/assets/cldr/de.json +348 -241
- package/dist/generated/assets/cldr/de_AT.json +348 -241
- package/dist/generated/assets/cldr/de_CH.json +347 -240
- package/dist/generated/assets/cldr/el.json +128 -100
- package/dist/generated/assets/cldr/el_CY.json +128 -100
- package/dist/generated/assets/cldr/en.json +538 -512
- package/dist/generated/assets/cldr/en_AU.json +583 -520
- package/dist/generated/assets/cldr/en_GB.json +485 -441
- package/dist/generated/assets/cldr/en_HK.json +519 -474
- package/dist/generated/assets/cldr/en_IE.json +485 -440
- package/dist/generated/assets/cldr/en_IN.json +465 -420
- package/dist/generated/assets/cldr/en_NZ.json +505 -460
- package/dist/generated/assets/cldr/en_PG.json +505 -460
- package/dist/generated/assets/cldr/en_SG.json +505 -460
- package/dist/generated/assets/cldr/en_ZA.json +485 -440
- package/dist/generated/assets/cldr/es.json +709 -456
- package/dist/generated/assets/cldr/es_AR.json +687 -434
- package/dist/generated/assets/cldr/es_BO.json +721 -468
- package/dist/generated/assets/cldr/es_CL.json +567 -422
- package/dist/generated/assets/cldr/es_CO.json +485 -339
- package/dist/generated/assets/cldr/es_MX.json +734 -481
- package/dist/generated/assets/cldr/es_PE.json +409 -372
- package/dist/generated/assets/cldr/es_UY.json +433 -396
- package/dist/generated/assets/cldr/es_VE.json +453 -416
- package/dist/generated/assets/cldr/et.json +340 -307
- package/dist/generated/assets/cldr/fa.json +96 -34
- package/dist/generated/assets/cldr/fi.json +359 -308
- package/dist/generated/assets/cldr/fr.json +347 -321
- package/dist/generated/assets/cldr/fr_BE.json +347 -321
- package/dist/generated/assets/cldr/fr_CA.json +458 -432
- package/dist/generated/assets/cldr/fr_CH.json +290 -264
- package/dist/generated/assets/cldr/fr_LU.json +347 -321
- package/dist/generated/assets/cldr/he.json +241 -130
- package/dist/generated/assets/cldr/hi.json +103 -53
- package/dist/generated/assets/cldr/hr.json +467 -410
- package/dist/generated/assets/cldr/hu.json +246 -195
- package/dist/generated/assets/cldr/id.json +478 -406
- package/dist/generated/assets/cldr/it.json +418 -362
- package/dist/generated/assets/cldr/it_CH.json +418 -362
- package/dist/generated/assets/cldr/ja.json +58 -18
- package/dist/generated/assets/cldr/kk.json +562 -398
- package/dist/generated/assets/cldr/ko.json +36 -15
- package/dist/generated/assets/cldr/lt.json +320 -231
- package/dist/generated/assets/cldr/lv.json +184 -120
- package/dist/generated/assets/cldr/ms.json +460 -388
- package/dist/generated/assets/cldr/nb.json +160 -92
- package/dist/generated/assets/cldr/nl.json +621 -373
- package/dist/generated/assets/cldr/nl_BE.json +621 -373
- package/dist/generated/assets/cldr/pl.json +590 -279
- package/dist/generated/assets/cldr/pt.json +696 -334
- package/dist/generated/assets/cldr/pt_PT.json +730 -454
- package/dist/generated/assets/cldr/ro.json +409 -339
- package/dist/generated/assets/cldr/ru.json +317 -279
- package/dist/generated/assets/cldr/ru_UA.json +312 -274
- package/dist/generated/assets/cldr/sk.json +454 -413
- package/dist/generated/assets/cldr/sl.json +118 -80
- package/dist/generated/assets/cldr/sr.json +294 -142
- package/dist/generated/assets/cldr/sr_Latn.json +972 -824
- package/dist/generated/assets/cldr/sv.json +382 -338
- package/dist/generated/assets/cldr/th.json +56 -36
- package/dist/generated/assets/cldr/tr.json +371 -320
- package/dist/generated/assets/cldr/uk.json +340 -290
- package/dist/generated/assets/cldr/vi.json +352 -328
- package/dist/generated/assets/cldr/zh_CN.json +34 -10
- package/dist/generated/assets/cldr/zh_HK.json +33 -9
- package/dist/generated/assets/cldr/zh_SG.json +33 -9
- package/dist/generated/assets/cldr/zh_TW.json +32 -8
- package/dist/sap/base/Event.js +59 -0
- package/dist/sap/base/Eventing.js +146 -0
- package/dist/sap/base/Log.js +2 -239
- package/dist/sap/base/assert.js +28 -1
- package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
- package/dist/sap/base/config.js +17 -0
- package/dist/sap/base/i18n/Formatting.js +1130 -0
- package/dist/sap/base/i18n/LanguageTag.js +168 -30
- package/dist/sap/base/i18n/date/CalendarType.js +36 -1
- package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +76 -1
- package/dist/sap/base/i18n/date/TimezoneUtils.js +242 -12
- package/dist/sap/base/strings/camelize.js +30 -0
- package/dist/sap/base/strings/formatMessage.js +88 -15
- package/dist/sap/base/util/ObjectPath.js +95 -3
- package/dist/sap/base/util/Version.js +157 -0
- package/dist/sap/base/util/_merge.js +83 -26
- package/dist/sap/base/util/array/uniqueSort.js +37 -15
- package/dist/sap/base/util/deepClone.js +102 -0
- package/dist/sap/base/util/deepEqual.js +75 -51
- package/dist/sap/base/util/extend.js +58 -7
- package/dist/sap/base/util/isEmptyObject.js +34 -0
- package/dist/sap/base/util/isPlainObject.js +35 -1
- package/dist/sap/base/util/now.js +24 -3
- package/dist/sap/base/util/resolveReference.js +157 -0
- package/dist/sap/base/util/uid.js +27 -0
- package/dist/sap/ui/base/DataType.js +657 -0
- package/dist/sap/ui/base/Interface.js +47 -1
- package/dist/sap/ui/base/Metadata.js +433 -180
- package/dist/sap/ui/base/Object.js +284 -48
- package/dist/sap/ui/core/CalendarType.js +23 -1
- package/dist/sap/ui/core/Locale.js +189 -57
- package/dist/sap/ui/core/LocaleData.js +2670 -1380
- package/dist/sap/ui/core/Supportability.js +5 -0
- package/dist/sap/ui/core/Theming.js +539 -0
- package/dist/sap/ui/core/date/Buddhist.js +162 -87
- package/dist/sap/ui/core/date/CalendarUtils.js +61 -21
- package/dist/sap/ui/core/date/CalendarWeekNumbering.js +29 -1
- package/dist/sap/ui/core/date/Gregorian.js +25 -10
- package/dist/sap/ui/core/date/Islamic.js +298 -185
- package/dist/sap/ui/core/date/Japanese.js +210 -115
- package/dist/sap/ui/core/date/Persian.js +324 -195
- package/dist/sap/ui/core/date/UI5Date.js +923 -237
- package/dist/sap/ui/core/date/UniversalDate.js +1238 -245
- package/dist/sap/ui/core/date/_Calendars.js +10 -1
- package/dist/sap/ui/core/format/DateFormat.js +3163 -2145
- package/dist/sap/ui/core/format/TimezoneUtil.js +23 -1
- package/package-scripts.cjs +4 -10
- package/package.json +9 -5
- package/used-modules.txt +20 -1
- package/dist/sap/ui/Device.js +0 -5
@@ -1,20 +1,93 @@
|
|
1
|
-
|
1
|
+
/*!
|
2
|
+
* OpenUI5
|
3
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
4
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
5
|
+
*/
|
6
|
+
import assert from "../assert.js";
|
7
|
+
/**
|
8
|
+
* Pattern to analyze MessageFormat strings.
|
9
|
+
*
|
10
|
+
* Group 1: captures doubled single quotes within the string
|
11
|
+
* Group 2: captures quoted fragments within the string.
|
12
|
+
* Note that java.util.MessageFormat silently forgives a missing single quote at
|
13
|
+
* the end of a pattern. This special case is handled by the RegEx as well.
|
14
|
+
* Group 3: captures placeholders
|
15
|
+
* Checks only for numerical argument index, any remainder is ignored up to the next
|
16
|
+
* closing curly brace. Nested placeholders are not accepted!
|
17
|
+
* Group 4: captures any remaining curly braces and indicates syntax errors
|
18
|
+
*
|
19
|
+
* [-1] [----- quoted string -----] [------ placeholder ------] [--]
|
20
|
+
* @private
|
21
|
+
*/
|
2
22
|
var rMessageFormat = /('')|'([^']+(?:''[^']*)*)(?:'|$)|\{([0-9]+(?:\s*,[^{}]*)?)\}|[{}]/g;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Creates a string from a pattern by replacing placeholders with concrete values.
|
26
|
+
*
|
27
|
+
* The syntax of the pattern is inspired by (but not fully equivalent to) the
|
28
|
+
* java.util.MessageFormat.
|
29
|
+
*
|
30
|
+
* Placeholders have the form <code>{ integer }</code>, where any occurrence of
|
31
|
+
* <code>{0}</code> is replaced by the value with index 0 in <code>aValues</code>,
|
32
|
+
* <code>{1}</code> by the value with index 1 in <code>aValues</code> etc.
|
33
|
+
*
|
34
|
+
* To avoid interpretation of curly braces as placeholders, any non-placeholder fragment
|
35
|
+
* of the pattern can be enclosed in single quotes. The surrounding single quotes will be
|
36
|
+
* omitted from the result. Single quotes that are not meant to escape a fragment and
|
37
|
+
* that should appear in the result, need to be doubled. In the result, only a single
|
38
|
+
* single quote will occur.
|
39
|
+
*
|
40
|
+
* Example: Pattern Strings
|
41
|
+
* <pre>
|
42
|
+
* formatMessage("Say {0}", ["Hello"]) -> "Say Hello" // normal use case
|
43
|
+
* formatMessage("Say '{0}'", ["Hello"]) -> "Say {0}" // escaped placeholder
|
44
|
+
* formatMessage("Say ''{0}''", ["Hello"]) -> "Say 'Hello'" // doubled single quote
|
45
|
+
* formatMessage("Say '{0}'''", ["Hello"]) -> "Say {0}'" // doubled single quote in quoted fragment
|
46
|
+
* </pre>
|
47
|
+
* In contrast to java.util.MessageFormat, format types or format styles are not supported.
|
48
|
+
* Everything after the argument index and up to the first closing curly brace is ignored.
|
49
|
+
* Nested placeholders (as supported by java.lang.MessageFormat for the format type choice)
|
50
|
+
* are not ignored but reported as a parse error.
|
51
|
+
*
|
52
|
+
* This method throws an Error when the pattern syntax is not fulfilled (e.g. unbalanced curly
|
53
|
+
* braces, nested placeholders or a non-numerical argument index).
|
54
|
+
*
|
55
|
+
* This method can also be used as a formatter within a binding. The first part of a composite binding
|
56
|
+
* will be used as pattern, the following parts as aValues. If there is only one value and this
|
57
|
+
* value is an array it will be handled like the default described above.
|
58
|
+
*
|
59
|
+
* @function
|
60
|
+
* @since 1.58
|
61
|
+
* @alias module:sap/base/strings/formatMessage
|
62
|
+
* @param {string} sPattern A pattern string in the described syntax
|
63
|
+
* @param {any[]} [aValues=[]] The values to be used instead of the placeholders.
|
64
|
+
* @returns {string} The formatted result string
|
65
|
+
* @SecPassthrough {*|return}
|
66
|
+
* @public
|
67
|
+
*/
|
3
68
|
var fnFormatMessage = function (sPattern, aValues) {
|
4
|
-
|
5
|
-
|
6
|
-
|
69
|
+
assert(typeof sPattern === "string" || sPattern instanceof String, "pattern must be string");
|
70
|
+
if (arguments.length > 2 || aValues != null && !Array.isArray(aValues)) {
|
71
|
+
aValues = Array.prototype.slice.call(arguments, 1);
|
72
|
+
}
|
73
|
+
aValues = aValues || [];
|
74
|
+
return sPattern.replace(rMessageFormat, function ($0, $1, $2, $3, offset) {
|
75
|
+
if ($1) {
|
76
|
+
// a doubled single quote in a normal string fragment
|
77
|
+
// --> emit a single quote
|
78
|
+
return "'";
|
79
|
+
} else if ($2) {
|
80
|
+
// a quoted sequence of chars, potentially containing doubled single quotes again
|
81
|
+
// --> emit with doubled single quotes replaced by a single quote
|
82
|
+
return $2.replace(/''/g, "'");
|
83
|
+
} else if ($3) {
|
84
|
+
// a welformed curly brace
|
85
|
+
// --> emit the argument but ignore other parameters
|
86
|
+
return String(aValues[parseInt($3)]);
|
7
87
|
}
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
} else if ($2) {
|
13
|
-
return $2.replace(/''/g, '\'');
|
14
|
-
} else if ($3) {
|
15
|
-
return String(aValues[parseInt($3)]);
|
16
|
-
}
|
17
|
-
throw new Error('formatMessage: pattern syntax error at pos. ' + offset);
|
18
|
-
});
|
88
|
+
// e.g. malformed curly braces
|
89
|
+
// --> throw Error
|
90
|
+
throw new Error("formatMessage: pattern syntax error at pos. " + offset);
|
91
|
+
});
|
19
92
|
};
|
20
93
|
export default fnFormatMessage;
|
@@ -1,21 +1,92 @@
|
|
1
|
+
/**
|
2
|
+
* Manages an object path.
|
3
|
+
*
|
4
|
+
* The object path can be just created with {@link #.create}, then an empty nested object path will be created from
|
5
|
+
* the provided string. If a value is set for an object path {@link #.set} it is also created if it not already
|
6
|
+
* exists. Values can be retrieved from the objectpath with {@link #get}.
|
7
|
+
*
|
8
|
+
* @namespace
|
9
|
+
* @since 1.58
|
10
|
+
* @alias module:sap/base/util/ObjectPath
|
11
|
+
* @public
|
12
|
+
*/ /*!
|
13
|
+
* OpenUI5
|
14
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
15
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
16
|
+
*/
|
17
|
+
|
1
18
|
var ObjectPath = {};
|
19
|
+
|
20
|
+
/**
|
21
|
+
* The default root context for the object path.
|
22
|
+
*
|
23
|
+
* @type {object}
|
24
|
+
* @private
|
25
|
+
*/
|
2
26
|
var defaultRootContext = window;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* If the provided object path is a string, it will be split and returned as an array.
|
30
|
+
*
|
31
|
+
* @private
|
32
|
+
* @param {string|string[]} vObjectPath Path as string where each name is separated by '.'. Can also be an array of names.
|
33
|
+
* @returns {string[]} The path as an array
|
34
|
+
*/
|
3
35
|
function getObjectPathArray(vObjectPath) {
|
4
36
|
return Array.isArray(vObjectPath) ? vObjectPath.slice() : vObjectPath.split(".");
|
5
37
|
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Creates a object path from the provided path in the provided root context.
|
41
|
+
*
|
42
|
+
* The provided path is used to navigate through the nested objects, starting with the root context.
|
43
|
+
*
|
44
|
+
* @example
|
45
|
+
* var root = {};
|
46
|
+
* ObjectPath.create("my.test.module", root) === root.my.test.module;
|
47
|
+
* ObjectPath.set(["my", "test", "otherModule"], root) === root.my.test.otherModule;
|
48
|
+
*
|
49
|
+
* @public
|
50
|
+
* @static
|
51
|
+
* @param {string|string[]} vObjectPath Path as string where each name is separated by '.'. Can also be an array of names.
|
52
|
+
* @param {Object} [oRootContext=window] Root context where the path starts
|
53
|
+
* @returns {Object} The newly created context object, e.g. base.my.test.module
|
54
|
+
* @throws {Error} Will throw an error if a value already exists within the path and the object path cannot be set.
|
55
|
+
*/
|
6
56
|
ObjectPath.create = function (vObjectPath, oRootContext) {
|
7
57
|
var oObject = oRootContext || defaultRootContext;
|
8
58
|
var aNames = getObjectPathArray(vObjectPath);
|
9
59
|
for (var i = 0; i < aNames.length; i++) {
|
10
60
|
var sName = aNames[i];
|
11
|
-
|
61
|
+
|
62
|
+
// we only accept nested objects and functions in the ObjectPath
|
63
|
+
// Functions in the ObjectPath are typically constructor functions
|
64
|
+
if (oObject[sName] === null || oObject[sName] !== undefined && typeof oObject[sName] !== "object" && typeof oObject[sName] !== "function") {
|
12
65
|
throw new Error("Could not set object-path for '" + aNames.join(".") + "', path segment '" + sName + "' already exists.");
|
13
66
|
}
|
14
|
-
oObject[sName] = oObject[sName] ||
|
67
|
+
oObject[sName] = oObject[sName] || {};
|
15
68
|
oObject = oObject[sName];
|
16
69
|
}
|
17
70
|
return oObject;
|
18
71
|
};
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Returns a value located in the provided path.
|
75
|
+
* If the provided path cannot be resolved completely, <code>undefined</code> is returned.
|
76
|
+
*
|
77
|
+
* The provided object path is used to navigate through the nested objects, starting with the root context.
|
78
|
+
* If no root context is provided, the object path begins with <code>window</code>.
|
79
|
+
*
|
80
|
+
* @public
|
81
|
+
* @static
|
82
|
+
* @param {string|string[]} vObjectPath Path as string where each name is separated by '.'. Can also be an array of names.
|
83
|
+
* @param {Object} [oRootContext=window] Root context where the path starts
|
84
|
+
* @returns {any|undefined} Returns the value located in the provided path, or <code>undefined</code> if the path does not exist completely.
|
85
|
+
* @example
|
86
|
+
* ObjectPath.get("my.test.module", root) === root.my.test.module
|
87
|
+
* ObjectPath.get(["my", "test", "otherModule"], root) === root.my.test.otherModule
|
88
|
+
* ObjectPath.get("globalVar") === window["globalVar"];
|
89
|
+
*/
|
19
90
|
ObjectPath.get = function (vObjectPath, oRootContext) {
|
20
91
|
var oObject = oRootContext || defaultRootContext;
|
21
92
|
var aNames = getObjectPathArray(vObjectPath);
|
@@ -25,11 +96,32 @@ ObjectPath.get = function (vObjectPath, oRootContext) {
|
|
25
96
|
}
|
26
97
|
return oObject ? oObject[sPropertyName] : undefined;
|
27
98
|
};
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Sets a value located in the provided path.
|
102
|
+
*
|
103
|
+
* The provided path is used to navigate through the nested objects, starting with the root context.
|
104
|
+
*
|
105
|
+
* <b>Note:</b> Ensures that the object path exists.
|
106
|
+
*
|
107
|
+
* @public
|
108
|
+
* @static
|
109
|
+
* @param {string|string[]} vObjectPath vObjectPath Path as string where each name is separated by '.'. Can also be an array of names.
|
110
|
+
* @param {any} vValue The value to be set in the root context's object path
|
111
|
+
* @param {Object} [oRootContext=window] Root context where the path starts
|
112
|
+
* @throws {Error} Will throw an error if a value already exists within the object path and the path cannot be set.
|
113
|
+
* @example
|
114
|
+
* var root = {};
|
115
|
+
* ObjectPath.set("my.test.module", "propertyValue", root);
|
116
|
+
* ObjectPath.set(["my", "test", "otherModule"], "otherPropertyValue", root);
|
117
|
+
*/
|
28
118
|
ObjectPath.set = function (vObjectPath, vValue, oRootContext) {
|
29
119
|
oRootContext = oRootContext || defaultRootContext;
|
30
120
|
var aNames = getObjectPathArray(vObjectPath);
|
31
121
|
var sPropertyName = aNames.pop();
|
122
|
+
|
123
|
+
// ensure object exists
|
32
124
|
var oObject = ObjectPath.create(aNames, oRootContext);
|
33
125
|
oObject[sPropertyName] = vValue;
|
34
126
|
};
|
35
|
-
export default ObjectPath;
|
127
|
+
export default ObjectPath;
|
@@ -0,0 +1,157 @@
|
|
1
|
+
// @evo-todo make it a simple object with immutable properties (Object.defineProperties)
|
2
|
+
|
3
|
+
// -------------------------- VERSION -------------------------------------
|
4
|
+
/*!
|
5
|
+
* OpenUI5
|
6
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
7
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
8
|
+
*/
|
9
|
+
|
10
|
+
var rVersion = /^[0-9]+(?:\.([0-9]+)(?:\.([0-9]+))?)?(.*)$/;
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Returns a Version instance created from the given parameters.
|
14
|
+
*
|
15
|
+
* This function can either be called as a constructor (using <code>new</code>) or as a normal function.
|
16
|
+
* It always returns an immutable Version instance.
|
17
|
+
*
|
18
|
+
* The parts of the version number (major, minor, patch, suffix) can be provided in several ways:
|
19
|
+
* <ul>
|
20
|
+
* <li>Version("1.2.3-SNAPSHOT") - as a dot-separated string. Any non-numerical char or a dot followed
|
21
|
+
* by a non-numerical char starts the suffix portion. Any missing major,
|
22
|
+
* minor or patch versions will be set to 0.</li>
|
23
|
+
* <li>Version(1,2,3,"-SNAPSHOT") - as individual parameters. Major, minor and patch must be integer numbers
|
24
|
+
* or empty, suffix must be a string not starting with digits.</li>
|
25
|
+
* <li>Version([1,2,3,"-SNAPSHOT"]) - as an array with the individual parts. The same type restrictions apply
|
26
|
+
* as before.</li>
|
27
|
+
* <li>Version(otherVersion) - as a Version instance (cast operation). Returns the given instance instead
|
28
|
+
* of creating a new one.</li>
|
29
|
+
* </ul>
|
30
|
+
*
|
31
|
+
* To keep the code size small, this implementation mainly validates the single string variant.
|
32
|
+
* All other variants are only validated to some degree. It is the responsibility of the caller to
|
33
|
+
* provide proper parts.
|
34
|
+
*
|
35
|
+
* @param {int|string|any[]|module:sap/base/util/Version} vMajor the major part of the version (int) or any of the single
|
36
|
+
* parameter variants explained above.
|
37
|
+
* @param {int} iMinor the minor part of the version number
|
38
|
+
* @param {int} iPatch the patch part of the version number
|
39
|
+
* @param {string} sSuffix the suffix part of the version number
|
40
|
+
* @class Represents a version consisting of major, minor, patch version, and suffix, for example '1.2.7-SNAPSHOT'.
|
41
|
+
* @since 1.58
|
42
|
+
* @alias module:sap/base/util/Version
|
43
|
+
* @public
|
44
|
+
*/
|
45
|
+
function Version(vMajor, iMinor, iPatch, sSuffix) {
|
46
|
+
if (vMajor instanceof Version) {
|
47
|
+
// note: even a constructor may return a value different from 'this'
|
48
|
+
return vMajor;
|
49
|
+
}
|
50
|
+
if (!(this instanceof Version)) {
|
51
|
+
// act as a cast operator when called as function (not as a constructor)
|
52
|
+
return new Version(vMajor, iMinor, iPatch, sSuffix);
|
53
|
+
}
|
54
|
+
var m;
|
55
|
+
if (typeof vMajor === "string") {
|
56
|
+
m = rVersion.exec(vMajor);
|
57
|
+
} else if (Array.isArray(vMajor)) {
|
58
|
+
m = vMajor;
|
59
|
+
} else {
|
60
|
+
m = arguments;
|
61
|
+
}
|
62
|
+
m = m || [];
|
63
|
+
function norm(v) {
|
64
|
+
v = parseInt(v);
|
65
|
+
return isNaN(v) ? 0 : v;
|
66
|
+
}
|
67
|
+
vMajor = norm(m[0]);
|
68
|
+
iMinor = norm(m[1]);
|
69
|
+
iPatch = norm(m[2]);
|
70
|
+
sSuffix = String(m[3] || "");
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Returns a string representation of this version.
|
74
|
+
*
|
75
|
+
* @return {string} a string representation of this version.
|
76
|
+
* @public
|
77
|
+
*/
|
78
|
+
this.toString = function () {
|
79
|
+
return vMajor + "." + iMinor + "." + iPatch + sSuffix;
|
80
|
+
};
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Returns the major version part of this version.
|
84
|
+
*
|
85
|
+
* @return {int} the major version part of this version
|
86
|
+
* @public
|
87
|
+
*/
|
88
|
+
this.getMajor = function () {
|
89
|
+
return vMajor;
|
90
|
+
};
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Returns the minor version part of this version.
|
94
|
+
*
|
95
|
+
* @return {int} the minor version part of this version
|
96
|
+
* @public
|
97
|
+
*/
|
98
|
+
this.getMinor = function () {
|
99
|
+
return iMinor;
|
100
|
+
};
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Returns the patch (or micro) version part of this version.
|
104
|
+
*
|
105
|
+
* @return {int} the patch version part of this version
|
106
|
+
* @public
|
107
|
+
*/
|
108
|
+
this.getPatch = function () {
|
109
|
+
return iPatch;
|
110
|
+
};
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Returns the version suffix of this version.
|
114
|
+
*
|
115
|
+
* @return {string} the version suffix of this version
|
116
|
+
* @public
|
117
|
+
*/
|
118
|
+
this.getSuffix = function () {
|
119
|
+
return sSuffix;
|
120
|
+
};
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Compares this version with a given one.
|
124
|
+
*
|
125
|
+
* The version with which this version should be compared can be given as a <code>sap/base/util/Version</code> instance,
|
126
|
+
* as a string (e.g. <code>v.compareto("1.4.5")</code>). Or major, minor, patch and suffix values can be given as
|
127
|
+
* separate parameters (e.g. <code>v.compareTo(1, 4, 5)</code>) or in an array (e.g. <code>v.compareTo([1, 4, 5])</code>).
|
128
|
+
*
|
129
|
+
* @return {int} 0, if the given version is equal to this version, a negative value if the given other version is greater
|
130
|
+
* and a positive value otherwise
|
131
|
+
* @public
|
132
|
+
*/
|
133
|
+
this.compareTo = function () {
|
134
|
+
var vOther = Version.apply(window, arguments);
|
135
|
+
/*eslint-disable no-nested-ternary */
|
136
|
+
return vMajor - vOther.getMajor() || iMinor - vOther.getMinor() || iPatch - vOther.getPatch() || (sSuffix < vOther.getSuffix() ? -1 : sSuffix === vOther.getSuffix() ? 0 : 1);
|
137
|
+
/*eslint-enable no-nested-ternary */
|
138
|
+
};
|
139
|
+
}
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Checks whether this version is in the range of the given interval (start inclusive, end exclusive).
|
143
|
+
*
|
144
|
+
* The boundaries against which this version should be checked can be given as <code>sap/base/util/Version</code>
|
145
|
+
* instances (e.g. <code>v.inRange(v1, v2)</code>), as strings (e.g. <code>v.inRange("1.4", "2.7")</code>)
|
146
|
+
* or as arrays (e.g. <code>v.inRange([1,4], [2,7])</code>).
|
147
|
+
*
|
148
|
+
* @param {string|any[]|module:sap/base/util/Version} vMin the start of the range (inclusive)
|
149
|
+
* @param {string|any[]|module:sap/base/util/Version} vMax the end of the range (exclusive)
|
150
|
+
* @return {boolean} <code>true</code> if this version is greater or equal to <code>vMin</code> and smaller
|
151
|
+
* than <code>vMax</code>, <code>false</code> otherwise.
|
152
|
+
* @public
|
153
|
+
*/
|
154
|
+
Version.prototype.inRange = function (vMin, vMax) {
|
155
|
+
return this.compareTo(vMin) >= 0 && this.compareTo(vMax) < 0;
|
156
|
+
};
|
157
|
+
export default Version;
|
@@ -1,32 +1,89 @@
|
|
1
|
-
|
1
|
+
/*!
|
2
|
+
* OpenUI5
|
3
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
4
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
5
|
+
*/
|
6
|
+
import isPlainObject from "./isPlainObject.js";
|
2
7
|
var oToken = Object.create(null);
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Performs object extension by merging source objects into a target object.
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* var oMerged = _merge(true, false, {}, {prop1:1}, {prop2:2});
|
14
|
+
*
|
15
|
+
* @function
|
16
|
+
* @since 1.71
|
17
|
+
* @private
|
18
|
+
* @alias module:sap/base/util/_merge
|
19
|
+
* @param {boolean} deep Shallow copy or deep merge
|
20
|
+
* @param {boolean} skipUndefined Whether <code>undefined</code> values will be skipped, otherwise <code>undefined</code> values will overwrite existing values
|
21
|
+
* @param {object} target The object that will receive new properties
|
22
|
+
* @param {...object} [source] One or more objects which get merged into the target object
|
23
|
+
* @return {object} the target object which is the result of the merge
|
24
|
+
*/
|
3
25
|
var fnMerge = function () {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
/*
|
27
|
+
* The code in this function is taken from jQuery 3.6.0 "jQuery.extend" and got modified.
|
28
|
+
*
|
29
|
+
* jQuery JavaScript Library v3.6.0
|
30
|
+
* https://jquery.com/
|
31
|
+
*
|
32
|
+
* Copyright OpenJS Foundation and other contributors
|
33
|
+
* Released under the MIT license
|
34
|
+
* https://jquery.org/license
|
35
|
+
*/
|
36
|
+
var src,
|
37
|
+
copyIsArray,
|
38
|
+
copy,
|
39
|
+
name,
|
40
|
+
options,
|
41
|
+
clone,
|
42
|
+
target = arguments[2] || {},
|
43
|
+
i = 3,
|
44
|
+
length = arguments.length,
|
45
|
+
deep = arguments[0] || false,
|
46
|
+
skipToken = arguments[1] ? undefined : oToken;
|
47
|
+
|
48
|
+
// Handle case when target is a string or something (possible in deep copy)
|
49
|
+
if (typeof target !== "object" && typeof target !== "function") {
|
50
|
+
target = {};
|
51
|
+
}
|
52
|
+
for (; i < length; i++) {
|
53
|
+
if ((options = arguments[i]) != null) {
|
54
|
+
// Extend the base object
|
55
|
+
for (name in options) {
|
56
|
+
src = target[name];
|
57
|
+
copy = options[name];
|
58
|
+
|
59
|
+
// Prevent never-ending loop
|
60
|
+
// Prevent Object.prototype pollution for $.extend( true, ... )
|
61
|
+
// For further information, please visit https://github.com/jquery/jquery/pull/4333
|
62
|
+
if (name === "__proto__" || target === copy) {
|
63
|
+
continue;
|
64
|
+
}
|
65
|
+
|
66
|
+
// Recurse if we're merging plain objects or arrays
|
67
|
+
if (deep && copy && (isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
|
68
|
+
if (copyIsArray) {
|
69
|
+
copyIsArray = false;
|
70
|
+
clone = src && Array.isArray(src) ? src : [];
|
71
|
+
} else {
|
72
|
+
clone = src && isPlainObject(src) ? src : {};
|
73
|
+
}
|
74
|
+
|
75
|
+
// Never move original objects, clone them
|
76
|
+
target[name] = fnMerge(deep, arguments[1], clone, copy);
|
77
|
+
|
78
|
+
// Don't bring in undefined values
|
79
|
+
} else if (copy !== skipToken) {
|
80
|
+
target[name] = copy;
|
28
81
|
}
|
82
|
+
}
|
29
83
|
}
|
30
|
-
|
84
|
+
}
|
85
|
+
|
86
|
+
// Return the modified object
|
87
|
+
return target;
|
31
88
|
};
|
32
89
|
export default fnMerge;
|
@@ -1,19 +1,41 @@
|
|
1
|
-
|
1
|
+
/*!
|
2
|
+
* OpenUI5
|
3
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
4
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
5
|
+
*/
|
6
|
+
import assert from "../../assert.js";
|
7
|
+
/**
|
8
|
+
* Sorts the given array in-place and removes any duplicates (identified by "===").
|
9
|
+
*
|
10
|
+
* Uses Array#sort()
|
11
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
|
12
|
+
*
|
13
|
+
* Use <code>jQuery.uniqueSort()</code> for arrays of DOMElements.
|
14
|
+
*
|
15
|
+
* @function
|
16
|
+
* @since 1.58
|
17
|
+
* @param {any[]} aArray An Array of any type
|
18
|
+
* @alias module:sap/base/util/array/uniqueSort
|
19
|
+
* @return {any[]} Same array as given (for chaining)
|
20
|
+
* @public
|
21
|
+
*/
|
2
22
|
var fnUniqueSort = function (aArray) {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
if (++j < iLength) {
|
14
|
-
aArray.splice(j, iLength - j);
|
15
|
-
}
|
23
|
+
assert(Array.isArray(aArray), "uniqueSort: input parameter must be an Array");
|
24
|
+
var iLength = aArray.length;
|
25
|
+
if (iLength > 1) {
|
26
|
+
aArray.sort();
|
27
|
+
var j = 0;
|
28
|
+
for (var i = 1; i < iLength; i++) {
|
29
|
+
// invariant: i is the entry to check, j is the last unique entry known so far
|
30
|
+
if (aArray.indexOf(aArray[i]) === i) {
|
31
|
+
aArray[++j] = aArray[i];
|
32
|
+
}
|
16
33
|
}
|
17
|
-
|
34
|
+
// cut off the rest - if any
|
35
|
+
if (++j < iLength) {
|
36
|
+
aArray.splice(j, iLength - j);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
return aArray;
|
18
40
|
};
|
19
41
|
export default fnUniqueSort;
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/*!
|
2
|
+
* OpenUI5
|
3
|
+
* (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
|
4
|
+
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
5
|
+
*/
|
6
|
+
import isPlainObject from "./isPlainObject.js";
|
7
|
+
/**
|
8
|
+
* Creates a deep clone of the source value.
|
9
|
+
*
|
10
|
+
* Only arrays, JavaScript Date objects and objects that pass the {@link module:sap/base/util/isPlainObject isPlainObject}
|
11
|
+
* check will be cloned. For other object types, a <code>TypeError</code> will be thrown as there's no standard way
|
12
|
+
* to clone them. Primitive values (boolean, number, string) as well as <code>null</code> and <code>undefined</code>
|
13
|
+
* will be copied, they have value semantics anyhow.
|
14
|
+
*
|
15
|
+
* <code>deepClone</code> is designed to match the semantics of {@link module:sap/base/util/deepEqual deepEqual}.
|
16
|
+
* Any deeply cloned object should be deep-equal to the source. However, not every object that can be handled
|
17
|
+
* by <code>deepEqual</code> can also be deeply cloned (e.g. <code>deepClone</code> fails on non-plain objects).
|
18
|
+
*
|
19
|
+
* To limit the time needed for a deep clone and to avoid endless recursion in case of cyclic structures, the
|
20
|
+
* recursion depth is limited by the parameter <code>maxDepth</code>, which defaults to 10. When the recursion
|
21
|
+
* depth exceeds the given limit, a <code>TypeError</code> is thrown.
|
22
|
+
*
|
23
|
+
* Note that object identities are not honored by the clone operation. If the original source contained multiple
|
24
|
+
* references to the same plain object instance, the clone will contain a different clone for each reference.
|
25
|
+
*
|
26
|
+
* @example <caption>Simple operation</caption>
|
27
|
+
* var oSource = { a: 1, b: { x: "test", y : 5.0 }, c: new Date(), d: null };
|
28
|
+
* var oClone = deepClone(oValue);
|
29
|
+
*
|
30
|
+
* deepEqual(oClone, oSource); // true
|
31
|
+
* oClone !== oSource; // true
|
32
|
+
* oClone.b !== oSource.b; // true
|
33
|
+
* oClone.c !== oSource.c; // true
|
34
|
+
*
|
35
|
+
* @example <caption>Object Identities</caption>
|
36
|
+
* var oCommon = { me: "unique" };
|
37
|
+
* var oValue = { a: oCommon, b: oCommon };
|
38
|
+
* var oClone = deepClone(oValue);
|
39
|
+
*
|
40
|
+
* deepEqual(oClone, oSource); // true
|
41
|
+
* oSource.a === oSource.b; // true
|
42
|
+
* oClone.a === oClone.b; // false
|
43
|
+
* deepEqual(oClone.a, oClone.b); // true
|
44
|
+
*
|
45
|
+
* @since 1.63
|
46
|
+
* @public
|
47
|
+
* @alias module:sap/base/util/deepClone
|
48
|
+
* @param {any} src Source value that shall be cloned
|
49
|
+
* @param {int} [maxDepth=10] Maximum recursion depth for the clone operation, deeper structures will throw an error
|
50
|
+
* @returns {any} A clone of the source value
|
51
|
+
* @throws {TypeError} When a non-plain object is encountered or when the max structure depth is exceeded
|
52
|
+
*/
|
53
|
+
var fnDeepClone = function (src, maxDepth) {
|
54
|
+
if (!maxDepth) {
|
55
|
+
maxDepth = 10;
|
56
|
+
}
|
57
|
+
return clone(src, 0, maxDepth);
|
58
|
+
};
|
59
|
+
function clone(src, depth, maxDepth) {
|
60
|
+
// avoid endless recursion due to cyclic structures
|
61
|
+
if (depth > maxDepth) {
|
62
|
+
throw new TypeError("The structure depth of the source exceeds the maximum depth (" + maxDepth + ")");
|
63
|
+
}
|
64
|
+
if (src == null) {
|
65
|
+
return src;
|
66
|
+
} else if (src instanceof Date) {
|
67
|
+
if (src.clone) {
|
68
|
+
// sap.ui.core.date.UI5Date
|
69
|
+
return src.clone();
|
70
|
+
}
|
71
|
+
|
72
|
+
// clone date object using #getTime(). Officially the date constructor does not support parameter Date.
|
73
|
+
return new Date(src.getTime());
|
74
|
+
} else if (Array.isArray(src)) {
|
75
|
+
return cloneArray(src, depth, maxDepth);
|
76
|
+
} else if (typeof src === "object") {
|
77
|
+
return cloneObject(src, depth, maxDepth);
|
78
|
+
} else {
|
79
|
+
return src;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
function cloneArray(src, depth, maxDepth) {
|
83
|
+
var aClone = [];
|
84
|
+
for (var i = 0; i < src.length; i++) {
|
85
|
+
aClone.push(clone(src[i], depth + 1, maxDepth));
|
86
|
+
}
|
87
|
+
return aClone;
|
88
|
+
}
|
89
|
+
function cloneObject(src, depth, maxDepth) {
|
90
|
+
if (!isPlainObject(src)) {
|
91
|
+
throw new TypeError("Cloning is only supported for plain objects");
|
92
|
+
}
|
93
|
+
var oClone = {};
|
94
|
+
for (var key in src) {
|
95
|
+
if (key === "__proto__") {
|
96
|
+
continue;
|
97
|
+
}
|
98
|
+
oClone[key] = clone(src[key], depth + 1, maxDepth);
|
99
|
+
}
|
100
|
+
return oClone;
|
101
|
+
}
|
102
|
+
export default fnDeepClone;
|