@ui5/webcomponents-localization 0.0.0-0fcda382e → 0.0.0-10f3c0dc7

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.
Files changed (275) hide show
  1. package/.eslintignore +2 -0
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +2427 -0
  4. package/LICENSE.txt +201 -0
  5. package/README.md +38 -10
  6. package/dist/.tsbuildinfo +1 -0
  7. package/dist/Assets-fetch.d.ts +1 -0
  8. package/dist/Assets-fetch.js +3 -0
  9. package/dist/Assets-fetch.js.map +1 -0
  10. package/dist/Assets-node.d.ts +11 -0
  11. package/dist/Assets-node.js +12 -0
  12. package/dist/Assets-node.js.map +1 -0
  13. package/dist/Assets.d.ts +1 -0
  14. package/dist/Assets.js +1 -0
  15. package/dist/Assets.js.map +1 -0
  16. package/dist/CalendarUtils.d.ts +3 -0
  17. package/dist/CalendarUtils.js +6 -0
  18. package/dist/CalendarUtils.js.map +1 -0
  19. package/dist/DateFormat.d.ts +28 -0
  20. package/dist/DateFormat.js +22 -2
  21. package/dist/DateFormat.js.map +1 -0
  22. package/dist/Locale.d.ts +5 -0
  23. package/dist/Locale.js +7 -0
  24. package/dist/Locale.js.map +1 -0
  25. package/dist/LocaleData.d.ts +5 -0
  26. package/dist/LocaleData.js +6 -2
  27. package/dist/LocaleData.js.map +1 -0
  28. package/dist/NumberFormat.d.ts +5 -0
  29. package/dist/NumberFormat.js +7 -0
  30. package/dist/NumberFormat.js.map +1 -0
  31. package/dist/dates/CalendarDate.d.ts +42 -0
  32. package/dist/dates/CalendarDate.js +171 -181
  33. package/dist/dates/CalendarDate.js.map +1 -0
  34. package/dist/dates/ExtremeDates.d.ts +5 -0
  35. package/dist/dates/ExtremeDates.js +29 -0
  36. package/dist/dates/ExtremeDates.js.map +1 -0
  37. package/dist/dates/UI5Date.d.ts +5 -0
  38. package/dist/dates/UI5Date.js +7 -0
  39. package/dist/dates/UI5Date.js.map +1 -0
  40. package/dist/dates/UniversalDate.d.ts +47 -0
  41. package/dist/dates/UniversalDate.js +5 -0
  42. package/dist/dates/UniversalDate.js.map +1 -0
  43. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  44. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  45. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  46. package/dist/dates/getDaysInMonth.d.ts +3 -0
  47. package/dist/dates/getDaysInMonth.js +10 -0
  48. package/dist/dates/getDaysInMonth.js.map +1 -0
  49. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  50. package/dist/dates/getRoundedTimestamp.js +15 -0
  51. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  52. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  53. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  54. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  55. package/dist/dates/modifyDateBy.d.ts +14 -0
  56. package/dist/dates/modifyDateBy.js +55 -0
  57. package/dist/dates/modifyDateBy.js.map +1 -0
  58. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  59. package/dist/dates/transformDateToSecondaryType.js +18 -0
  60. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  61. package/dist/features/calendar/Buddhist.js +1 -0
  62. package/dist/features/calendar/Buddhist.js.map +1 -0
  63. package/dist/features/calendar/Gregorian.js +1 -0
  64. package/dist/features/calendar/Gregorian.js.map +1 -0
  65. package/dist/features/calendar/Islamic.js +1 -0
  66. package/dist/features/calendar/Islamic.js.map +1 -0
  67. package/dist/features/calendar/Japanese.js +1 -0
  68. package/dist/features/calendar/Japanese.js.map +1 -0
  69. package/dist/features/calendar/Persian.js +1 -0
  70. package/dist/features/calendar/Persian.js.map +1 -0
  71. package/dist/generated/assets/cldr/Unicode-Data-Files-LICENSE.txt +39 -0
  72. package/dist/generated/assets/cldr/ar.json +2179 -728
  73. package/dist/generated/assets/cldr/ar_EG.json +2179 -728
  74. package/dist/generated/assets/cldr/ar_SA.json +2275 -825
  75. package/dist/generated/assets/cldr/bg.json +1924 -798
  76. package/dist/generated/assets/cldr/ca.json +2027 -816
  77. package/dist/generated/assets/cldr/cnr.json +6476 -0
  78. package/dist/generated/assets/cldr/cs.json +1865 -842
  79. package/dist/generated/assets/cldr/cy.json +6566 -0
  80. package/dist/generated/assets/cldr/da.json +1844 -682
  81. package/dist/generated/assets/cldr/de.json +1806 -546
  82. package/dist/generated/assets/cldr/de_AT.json +1797 -537
  83. package/dist/generated/assets/cldr/de_CH.json +1879 -611
  84. package/dist/generated/assets/cldr/el.json +1497 -383
  85. package/dist/generated/assets/cldr/el_CY.json +1497 -383
  86. package/dist/generated/assets/cldr/en.json +1990 -563
  87. package/dist/generated/assets/cldr/en_AU.json +2339 -763
  88. package/dist/generated/assets/cldr/en_GB.json +2170 -621
  89. package/dist/generated/assets/cldr/en_HK.json +2076 -628
  90. package/dist/generated/assets/cldr/en_IE.json +2038 -593
  91. package/dist/generated/assets/cldr/en_IN.json +2336 -704
  92. package/dist/generated/assets/cldr/en_NZ.json +2056 -611
  93. package/dist/generated/assets/cldr/en_PG.json +2049 -604
  94. package/dist/generated/assets/cldr/en_SG.json +2041 -593
  95. package/dist/generated/assets/cldr/en_ZA.json +2046 -599
  96. package/dist/generated/assets/cldr/es.json +2197 -881
  97. package/dist/generated/assets/cldr/es_AR.json +2167 -819
  98. package/dist/generated/assets/cldr/es_BO.json +2210 -863
  99. package/dist/generated/assets/cldr/es_CL.json +2087 -848
  100. package/dist/generated/assets/cldr/es_CO.json +1947 -707
  101. package/dist/generated/assets/cldr/es_MX.json +2446 -1091
  102. package/dist/generated/assets/cldr/es_PE.json +1912 -773
  103. package/dist/generated/assets/cldr/es_UY.json +1926 -795
  104. package/dist/generated/assets/cldr/es_VE.json +1920 -789
  105. package/dist/generated/assets/cldr/et.json +1761 -544
  106. package/dist/generated/assets/cldr/fa.json +1872 -566
  107. package/dist/generated/assets/cldr/fi.json +1959 -526
  108. package/dist/generated/assets/cldr/fr.json +1711 -460
  109. package/dist/generated/assets/cldr/fr_BE.json +1710 -459
  110. package/dist/generated/assets/cldr/fr_CA.json +2087 -814
  111. package/dist/generated/assets/cldr/fr_CH.json +1669 -418
  112. package/dist/generated/assets/cldr/fr_LU.json +1711 -460
  113. package/dist/generated/assets/cldr/he.json +2018 -1033
  114. package/dist/generated/assets/cldr/hi.json +1619 -348
  115. package/dist/generated/assets/cldr/hr.json +1855 -569
  116. package/dist/generated/assets/cldr/hu.json +1764 -551
  117. package/dist/generated/assets/cldr/id.json +1924 -601
  118. package/dist/generated/assets/cldr/it.json +1821 -666
  119. package/dist/generated/assets/cldr/it_CH.json +1827 -672
  120. package/dist/generated/assets/cldr/ja.json +1426 -109
  121. package/dist/generated/assets/cldr/kk.json +2251 -737
  122. package/dist/generated/assets/cldr/ko.json +1484 -196
  123. package/dist/generated/assets/cldr/lt.json +1714 -734
  124. package/dist/generated/assets/cldr/lv.json +1686 -682
  125. package/dist/generated/assets/cldr/mk.json +6177 -0
  126. package/dist/generated/assets/cldr/ms.json +1903 -595
  127. package/dist/generated/assets/cldr/nb.json +1548 -369
  128. package/dist/generated/assets/cldr/nl.json +1935 -511
  129. package/dist/generated/assets/cldr/nl_BE.json +1955 -531
  130. package/dist/generated/assets/cldr/pl.json +1873 -586
  131. package/dist/generated/assets/cldr/pt.json +2184 -753
  132. package/dist/generated/assets/cldr/pt_PT.json +2149 -778
  133. package/dist/generated/assets/cldr/ro.json +1847 -765
  134. package/dist/generated/assets/cldr/ru.json +2082 -755
  135. package/dist/generated/assets/cldr/ru_UA.json +2076 -749
  136. package/dist/generated/assets/cldr/sk.json +1860 -972
  137. package/dist/generated/assets/cldr/sl.json +1861 -920
  138. package/dist/generated/assets/cldr/sr.json +1829 -767
  139. package/dist/generated/assets/cldr/sr_Latn.json +6173 -0
  140. package/dist/generated/assets/cldr/sv.json +1789 -587
  141. package/dist/generated/assets/cldr/th.json +1704 -373
  142. package/dist/generated/assets/cldr/tr.json +1855 -587
  143. package/dist/generated/assets/cldr/uk.json +2166 -711
  144. package/dist/generated/assets/cldr/vi.json +2054 -709
  145. package/dist/generated/assets/cldr/zh_CN.json +1736 -397
  146. package/dist/generated/assets/cldr/zh_HK.json +1713 -374
  147. package/dist/generated/assets/cldr/zh_SG.json +1723 -384
  148. package/dist/generated/assets/cldr/zh_TW.json +1678 -371
  149. package/dist/generated/json-imports/LocaleData-fetch.d.ts +1 -0
  150. package/dist/generated/json-imports/LocaleData-fetch.js +93 -0
  151. package/dist/generated/json-imports/LocaleData-fetch.js.map +1 -0
  152. package/dist/generated/json-imports/LocaleData-node.d.ts +1 -0
  153. package/dist/generated/json-imports/LocaleData-node.js +93 -0
  154. package/dist/generated/json-imports/LocaleData-node.js.map +1 -0
  155. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  156. package/dist/generated/json-imports/LocaleData.js +92 -95
  157. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  158. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  159. package/dist/getCachedLocaleDataInstance.js +12 -0
  160. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  161. package/dist/locale/getLocaleData.d.ts +11 -0
  162. package/dist/locale/getLocaleData.js +15 -17
  163. package/dist/locale/getLocaleData.js.map +1 -0
  164. package/dist/sap/base/Event.js +59 -0
  165. package/dist/sap/base/Eventing.js +147 -0
  166. package/dist/sap/base/Log.js +2 -248
  167. package/dist/sap/base/assert.js +31 -9
  168. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  169. package/dist/sap/base/config.js +17 -0
  170. package/dist/sap/base/future.js +12 -0
  171. package/dist/sap/base/i18n/Formatting.d.ts +13 -0
  172. package/dist/sap/base/i18n/Formatting.js +18 -0
  173. package/dist/sap/base/i18n/Formatting.js.map +1 -0
  174. package/dist/sap/base/i18n/LanguageTag.js +179 -0
  175. package/dist/sap/base/i18n/Localization.d.ts +7 -0
  176. package/dist/sap/base/i18n/Localization.js +17 -0
  177. package/dist/sap/base/i18n/Localization.js.map +1 -0
  178. package/dist/sap/base/i18n/ResourceBundle.js +20 -0
  179. package/dist/sap/base/i18n/date/CalendarType.js +44 -0
  180. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +106 -0
  181. package/dist/sap/base/i18n/date/TimezoneUtils.js +471 -0
  182. package/dist/sap/base/i18n/date/_EnumHelper.js +37 -0
  183. package/dist/sap/base/strings/camelize.js +30 -0
  184. package/dist/sap/base/strings/formatMessage.js +93 -15
  185. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  186. package/dist/sap/base/util/LoaderExtensions.js +11 -4
  187. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  188. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  189. package/dist/sap/base/util/ObjectPath.js +4 -33
  190. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  191. package/dist/sap/base/util/Properties.js +12 -0
  192. package/dist/sap/base/util/Version.js +163 -0
  193. package/dist/sap/base/util/_merge.js +83 -26
  194. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  195. package/dist/sap/base/util/deepClone.js +102 -0
  196. package/dist/sap/base/util/deepEqual.js +75 -55
  197. package/dist/sap/base/util/deepExtend.js +60 -0
  198. package/dist/sap/base/util/extend.js +58 -7
  199. package/dist/sap/base/util/fetch.js +8 -0
  200. package/dist/sap/base/util/isEmptyObject.js +34 -0
  201. package/dist/sap/base/util/isPlainObject.js +35 -1
  202. package/dist/sap/base/util/merge.js +57 -0
  203. package/dist/sap/base/util/mixedFetch.js +3 -0
  204. package/dist/sap/base/util/now.js +22 -7
  205. package/dist/sap/base/util/resolveReference.js +3 -0
  206. package/dist/sap/base/util/uid.js +27 -0
  207. package/dist/sap/ui/Device.js +25 -3
  208. package/dist/sap/ui/Global.js +1 -0
  209. package/dist/sap/ui/VersionInfo.js +14 -0
  210. package/dist/sap/ui/base/DataType.js +708 -0
  211. package/dist/sap/ui/base/DesignTime.js +11 -0
  212. package/dist/sap/ui/base/EventProvider.js +21 -0
  213. package/dist/sap/ui/base/Interface.js +50 -6
  214. package/dist/sap/ui/base/Metadata.js +470 -173
  215. package/dist/sap/ui/base/Object.js +287 -27
  216. package/dist/sap/ui/base/OwnStatics.js +6 -0
  217. package/dist/sap/ui/base/SyncPromise.js +98 -0
  218. package/dist/sap/ui/core/AnimationMode.js +42 -0
  219. package/dist/sap/ui/core/CalendarType.js +24 -8
  220. package/dist/sap/ui/core/Configuration.d.ts +17 -0
  221. package/dist/sap/ui/core/Configuration.js +23 -0
  222. package/dist/sap/ui/core/Configuration.js.map +1 -0
  223. package/dist/sap/ui/core/ControlBehavior.js +11 -0
  224. package/dist/sap/ui/core/Core.d.ts +25 -0
  225. package/dist/sap/ui/core/Core.js +7 -32
  226. package/dist/sap/ui/core/Core.js.map +1 -0
  227. package/dist/sap/ui/core/FormatSettings.d.ts +9 -0
  228. package/dist/sap/ui/core/FormatSettings.js +12 -0
  229. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  230. package/dist/sap/ui/core/Lib.js +41 -0
  231. package/dist/sap/ui/core/Locale.js +190 -116
  232. package/dist/sap/ui/core/LocaleData.js +2837 -2683
  233. package/dist/sap/ui/core/Supportability.js +5 -0
  234. package/dist/sap/ui/core/Theming.js +39 -0
  235. package/dist/sap/ui/core/_UrlResolver.js +11 -0
  236. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  237. package/dist/sap/ui/core/date/CalendarUtils.js +67 -0
  238. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  239. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  240. package/dist/sap/ui/core/date/Islamic.js +298 -185
  241. package/dist/sap/ui/core/date/Japanese.js +212 -117
  242. package/dist/sap/ui/core/date/Persian.js +324 -195
  243. package/dist/sap/ui/core/date/UI5Date.js +1039 -0
  244. package/dist/sap/ui/core/date/UniversalDate.js +1241 -217
  245. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  246. package/dist/sap/ui/core/format/DateFormat.js +3160 -1781
  247. package/dist/sap/ui/core/format/FormatUtils.js +30 -0
  248. package/dist/sap/ui/core/format/NumberFormat.js +3164 -0
  249. package/dist/sap/ui/core/format/TimezoneUtil.js +93 -0
  250. package/dist/sap/ui/core/getCompatibilityVersion.js +7 -0
  251. package/dist/sap/ui/core/theming/ThemeHelper.js +14 -0
  252. package/dist/sap/ui/security/Security.js +12 -0
  253. package/dist/sap/ui/util/XMLHelper.js +11 -0
  254. package/dist/sap/ui/util/_URL.js +1 -0
  255. package/dist/ui5loader-autoconfig.js +1 -0
  256. package/package-scripts.cjs +35 -0
  257. package/package.json +27 -21
  258. package/tsconfig.json +24 -0
  259. package/used-modules.txt +33 -1
  260. package/dist/dates/calculateWeekNumber.js +0 -51
  261. package/package-scripts.js +0 -31
  262. package/src/Assets.js +0 -2
  263. package/src/DateFormat.js +0 -3
  264. package/src/LocaleData.js +0 -3
  265. package/src/dates/CalendarDate.js +0 -203
  266. package/src/dates/calculateWeekNumber.js +0 -51
  267. package/src/locale/getLocaleData.js +0 -27
  268. package/src/sap/base/util/LoaderExtensions.js +0 -7
  269. package/src/sap/ui/core/Core.js +0 -38
  270. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  271. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  272. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  273. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  274. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  275. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -0,0 +1,708 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2026 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ /* global Set */
7
+ // Provides class sap.ui.base.DataType
8
+ import future from "../../base/future.js";
9
+ import ObjectPath from "../../base/util/ObjectPath.js";
10
+ import assert from "../../base/assert.js";
11
+ import Log from "../../base/Log.js";
12
+ import isPlainObject from "../../base/util/isPlainObject.js";
13
+ import resolveReference from "../../base/util/resolveReference.js";
14
+ import _EnumHelper from "../../base/i18n/date/_EnumHelper.js";
15
+ /**
16
+ * Pseudo-Constructor for class <code>DataType</code>, never to be used.
17
+ *
18
+ * @class Represents the type of properties in a <code>ManagedObject</code> class.
19
+ *
20
+ * Each type provides some metadata like its {@link #getName qualified name} or its
21
+ * {@link #getBaseType base type} in case of a derived type. Array types provide information
22
+ * about the allowed {@link #getComponentType type of components} in an array, enumeration types
23
+ * inform about the set of their allowed {@link #getEnumValues keys and values}.
24
+ *
25
+ * Each type has a method to {@link #isValid check whether a value is valid} for a property
26
+ * of that type.
27
+ *
28
+ * Already defined types can be looked up by calling {@link #.getType DataType.getType}, new
29
+ * types can only be created by calling the factory method {@link #.createType DataType.createType},
30
+ * calling the constructor will throw an error.
31
+ *
32
+ * @author SAP SE
33
+ * @since 0.9.0
34
+ * @alias sap.ui.base.DataType
35
+ * @public
36
+ * @hideconstructor
37
+ * @throws {Error} Constructor must not be called, use {@link #.createType DataType.createType} instead
38
+ */
39
+ var DataType = function () {
40
+ // Avoid construction of a DataType.
41
+ // DataType is only a function to support the "instanceof" operator.
42
+ throw new Error();
43
+ };
44
+
45
+ /**
46
+ * The qualified name of the data type.
47
+ *
48
+ * @returns {string} Name of the data type
49
+ * @public
50
+ */
51
+ DataType.prototype.getName = function () {
52
+ return undefined;
53
+ };
54
+
55
+ /**
56
+ * The base type of this type or undefined if this is a primitive type.
57
+ * @returns {sap.ui.base.DataType|undefined} Base type or <code>undefined</code>
58
+ * @public
59
+ */
60
+ DataType.prototype.getBaseType = function () {
61
+ return undefined;
62
+ };
63
+
64
+ /**
65
+ * Returns the most basic (primitive) type that this type has been derived from.
66
+ *
67
+ * If the type is a primitive type by itself, <code>this</code> is returned.
68
+ *
69
+ * @returns {sap.ui.base.DataType} Primitive type of this type
70
+ * @public
71
+ */
72
+ DataType.prototype.getPrimitiveType = function () {
73
+ /*eslint-disable consistent-this*/
74
+ var oType = this;
75
+ /*eslint-enable consistent-this*/
76
+ while (oType.getBaseType()) {
77
+ oType = oType.getBaseType();
78
+ }
79
+ return oType;
80
+ };
81
+
82
+ /**
83
+ * Returns the component type of this type or <code>undefined</code> if this is not an array type.
84
+ *
85
+ * @returns {sap.ui.base.DataType|undefined} Component type or <code>undefined</code>
86
+ * @public
87
+ */
88
+ DataType.prototype.getComponentType = function () {
89
+ return undefined;
90
+ };
91
+
92
+ /**
93
+ * The default value for this type. Each type must define a default value.
94
+ * @returns {any} Default value of the data type. The type of the returned value
95
+ * must match the JavaScript type of the data type (a string for string types etc.)
96
+ * @public
97
+ */
98
+ DataType.prototype.getDefaultValue = function () {
99
+ return undefined;
100
+ };
101
+
102
+ /**
103
+ * Whether this type is an array type.
104
+ * @returns {boolean} Whether this type is an array type
105
+ * @public
106
+ */
107
+ DataType.prototype.isArrayType = function () {
108
+ return false;
109
+ };
110
+
111
+ /**
112
+ * Whether this type is an enumeration type.
113
+ * @returns {boolean} Whether this type is an enum type
114
+ * @public
115
+ */
116
+ DataType.prototype.isEnumType = function () {
117
+ return false;
118
+ };
119
+
120
+ /**
121
+ * Returns the object with keys and values from which this enum type was created
122
+ * or <code>undefined</code> if this is not an enum type.
123
+ *
124
+ * @returns {Object<string,string>|undefined} Object with enum keys and values or <code>undefined</code>
125
+ * @public
126
+ */
127
+ DataType.prototype.getEnumValues = function () {
128
+ return undefined;
129
+ };
130
+
131
+ /**
132
+ * Parses the given string value and converts it into the specific data type.
133
+ * @param {string} sValue String representation for a value of this type
134
+ * @returns {any} Value in the correct internal format
135
+ * @public
136
+ */
137
+ DataType.prototype.parseValue = function (sValue) {
138
+ return sValue;
139
+ };
140
+
141
+ /**
142
+ * Checks whether the given value is valid for this type.
143
+ *
144
+ * To be implemented by concrete types.
145
+ * @param {any} vValue Value to be checked
146
+ * @returns {boolean} Whether the given value is valid for this data type (without conversion)
147
+ * @public
148
+ * @function
149
+ */
150
+ DataType.prototype.isValid = undefined;
151
+ // Note that <code>isValid</code> must be assigned a falsy value here as it otherwise
152
+ // would be called in addition to any <code>isValid</code> implementation in subtypes.
153
+ // See <code>createType</code> for details.
154
+
155
+ /**
156
+ * Set or unset a normalizer function to be used for values of this data type.
157
+ *
158
+ * When a normalizer function has been set, it will be applied to values of this type
159
+ * whenever {@link #normalize} is called. <code>ManagedObject.prototype.setProperty</code>
160
+ * calls the <code>normalize</code> method before setting a new value to a property
161
+ * (normalization is applied on-write, not on-read).
162
+ *
163
+ * The <code>fnNormalize</code> function has the signature
164
+ * <pre>
165
+ * fnNormalize(value:any) : any
166
+ * </pre>
167
+ * It will be called with a value for this type and should return a normalized
168
+ * value (which also must be valid for the this type). There's no mean to reject a value.
169
+ * The <code>this</code> context of the function will be this type.
170
+ *
171
+ * This method allows applications or application frameworks to plug-in a generic value
172
+ * normalization for a type, e.g. to convert all URLs in some app-specific way before
173
+ * they are applied to controls. It is not intended to break-out of the value range
174
+ * defined by a type.
175
+ *
176
+ * @param {function(any):any} fnNormalizer Function to apply for normalizing
177
+ * @public
178
+ */
179
+ DataType.prototype.setNormalizer = function (fnNormalizer) {
180
+ assert(typeof fnNormalizer === "function", "DataType.setNormalizer: fnNormalizer must be a function");
181
+ this._fnNormalizer = typeof fnNormalizer === "function" ? fnNormalizer : undefined;
182
+ };
183
+
184
+ /**
185
+ * Normalizes the given value using the specified normalizer for this data type.
186
+ *
187
+ * If no normalizer has been set, the original value is returned.
188
+ *
189
+ * @param {any} oValue Value to be normalized
190
+ * @returns {any} Normalized value
191
+ * @public
192
+ */
193
+ DataType.prototype.normalize = function (oValue) {
194
+ return this._fnNormalizer ? this._fnNormalizer(oValue) : oValue;
195
+ };
196
+ function createType(sName, mSettings, oBase) {
197
+ mSettings = mSettings || {};
198
+
199
+ // create a new type object with the base type as prototype
200
+ var oBaseObject = oBase || DataType.prototype;
201
+ var oType = Object.create(oBaseObject);
202
+
203
+ // getter for the name
204
+ oType.getName = function () {
205
+ return sName;
206
+ };
207
+
208
+ // if a default value is specified, create a getter for it
209
+ if (mSettings.hasOwnProperty("defaultValue")) {
210
+ var vDefault = mSettings.defaultValue;
211
+ oType.getDefaultValue = function () {
212
+ return vDefault;
213
+ };
214
+ }
215
+
216
+ // if a validator is specified either chain it with the base type validator
217
+ // or set it if no base validator exists
218
+ if (mSettings.isValid) {
219
+ var fnIsValid = mSettings.isValid;
220
+ oType.isValid = oBaseObject.isValid ? function (vValue) {
221
+ if (!oBaseObject.isValid(vValue)) {
222
+ return false;
223
+ }
224
+ return fnIsValid(vValue);
225
+ } : fnIsValid;
226
+ }
227
+ if (mSettings.parseValue) {
228
+ oType.parseValue = mSettings.parseValue;
229
+ }
230
+
231
+ // return the base type
232
+ oType.getBaseType = function () {
233
+ return oBase;
234
+ };
235
+ return oType;
236
+ }
237
+ var mTypes = {
238
+ "any": createType("any", {
239
+ defaultValue: null,
240
+ isValid: function (vValue) {
241
+ return true;
242
+ }
243
+ }),
244
+ "boolean": createType("boolean", {
245
+ defaultValue: false,
246
+ isValid: function (vValue) {
247
+ return typeof vValue === "boolean";
248
+ },
249
+ parseValue: function (sValue) {
250
+ return sValue == "true";
251
+ }
252
+ }),
253
+ "int": createType("int", {
254
+ defaultValue: 0,
255
+ isValid: function (vValue) {
256
+ return typeof vValue === "number" && (isNaN(vValue) || Math.floor(vValue) == vValue);
257
+ },
258
+ parseValue: function (sValue) {
259
+ return parseInt(sValue);
260
+ }
261
+ }),
262
+ "float": createType("float", {
263
+ defaultValue: 0.0,
264
+ isValid: function (vValue) {
265
+ return typeof vValue === "number";
266
+ },
267
+ parseValue: function (sValue) {
268
+ return parseFloat(sValue);
269
+ }
270
+ }),
271
+ "string": createType("string", {
272
+ defaultValue: "",
273
+ isValid: function (vValue) {
274
+ return typeof vValue === "string" || vValue instanceof String;
275
+ },
276
+ parseValue: function (sValue) {
277
+ return sValue;
278
+ }
279
+ }),
280
+ "object": createType("object", {
281
+ defaultValue: null,
282
+ isValid: function (vValue) {
283
+ return typeof vValue === "object" || typeof vValue === "function";
284
+ },
285
+ parseValue: function (sValue) {
286
+ return sValue ? JSON.parse(sValue) : null;
287
+ }
288
+ }),
289
+ "function": createType("function", {
290
+ defaultValue: null,
291
+ isValid: function (vValue) {
292
+ return vValue == null || typeof vValue === 'function';
293
+ },
294
+ /*
295
+ * Note: the second parameter <code>_oOptions</code> is a hidden feature for internal use only.
296
+ * Its structure is subject to change. No code other than the XMLTemplateProcessor must use it.
297
+ */
298
+ parseValue: function (sValue, _oOptions) {
299
+ if (sValue === "") {
300
+ return undefined;
301
+ }
302
+ if (!/^\.?[A-Z_\$][A-Z0-9_\$]*(\.[A-Z_\$][A-Z0-9_\$]*)*$/i.test(sValue)) {
303
+ throw new Error("Function references must consist of dot separated " + "simple identifiers (A-Z, 0-9, _ or $) only, but was '" + sValue + "'");
304
+ }
305
+ var fnResult,
306
+ oContext = _oOptions && _oOptions.context,
307
+ oLocals = _oOptions && _oOptions.locals;
308
+ fnResult = resolveReference(sValue, Object.assign({
309
+ ".": oContext
310
+ }, oLocals));
311
+ if (fnResult && this.isValid(fnResult)) {
312
+ return fnResult;
313
+ }
314
+ throw new TypeError("The string '" + sValue + "' couldn't be resolved to a function");
315
+ }
316
+ })
317
+ };
318
+
319
+ // The generic "array" type must not be exposed by DataType.getType to avoid direct usage
320
+ // as type of a managed property. It is therefore not stored in the mTypes map
321
+ var arrayType = createType("array", {
322
+ defaultValue: []
323
+ });
324
+ function createArrayType(componentType) {
325
+ assert(componentType instanceof DataType, "DataType.<createArrayType>: componentType must be a DataType");
326
+
327
+ // create a new type object with the base type as prototype
328
+ var oType = Object.create(DataType.prototype);
329
+
330
+ // getter for the name
331
+ oType.getName = function () {
332
+ return componentType.getName() + "[]";
333
+ };
334
+
335
+ // getter for component type
336
+ oType.getComponentType = function () {
337
+ return componentType;
338
+ };
339
+
340
+ // array validator
341
+ oType.isValid = function (aValues) {
342
+ if (aValues === null) {
343
+ return true;
344
+ }
345
+ if (Array.isArray(aValues)) {
346
+ for (var i = 0; i < aValues.length; i++) {
347
+ if (!componentType.isValid(aValues[i])) {
348
+ return false;
349
+ }
350
+ }
351
+ return true;
352
+ }
353
+ return false;
354
+ };
355
+
356
+ // array parser
357
+ oType.parseValue = function (sValue) {
358
+ var aValues = sValue.split(",");
359
+ for (var i = 0; i < aValues.length; i++) {
360
+ aValues[i] = componentType.parseValue(aValues[i]);
361
+ }
362
+ return aValues;
363
+ };
364
+
365
+ // is an array type
366
+ oType.isArrayType = function () {
367
+ return true;
368
+ };
369
+
370
+ // return the base type
371
+ oType.getBaseType = function () {
372
+ return arrayType;
373
+ };
374
+ return oType;
375
+ }
376
+ const mEnumRegistry = Object.create(null);
377
+ function createEnumType(sTypeName, oEnum) {
378
+ var mValues = {},
379
+ sDefaultValue;
380
+ for (var sName in oEnum) {
381
+ var sValue = oEnum[sName];
382
+ // the first entry will become the default value
383
+ if (!sDefaultValue) {
384
+ sDefaultValue = sValue;
385
+ }
386
+ if (typeof sValue !== "string") {
387
+ throw new Error("Value " + sValue + " for enum type " + sTypeName + " is not a string");
388
+ }
389
+ // if there are multiple entries with the same value, the one where name
390
+ // and value are matching is taken
391
+ if (!mValues.hasOwnProperty(sValue) || sName == sValue) {
392
+ mValues[sValue] = sName;
393
+ }
394
+ }
395
+ var oType = Object.create(DataType.prototype);
396
+
397
+ // getter for the name
398
+ oType.getName = function () {
399
+ return sTypeName;
400
+ };
401
+
402
+ // enum validator
403
+ oType.isValid = function (v) {
404
+ return typeof v === "string" && mValues.hasOwnProperty(v);
405
+ };
406
+
407
+ // enum parser
408
+ oType.parseValue = function (sValue) {
409
+ return oEnum[sValue];
410
+ };
411
+
412
+ // default value
413
+ oType.getDefaultValue = function () {
414
+ return sDefaultValue;
415
+ };
416
+
417
+ // return the base type
418
+ oType.getBaseType = function () {
419
+ return mTypes.string;
420
+ };
421
+
422
+ // is an enum type
423
+ oType.isEnumType = function () {
424
+ return true;
425
+ };
426
+
427
+ // enum values are best represented by the existing global object
428
+ oType.getEnumValues = function () {
429
+ return oEnum;
430
+ };
431
+ return oType;
432
+ }
433
+ const oLoggedErrors = new Set();
434
+
435
+ /**
436
+ * Logs an error only once per class name and property name combination.
437
+ *
438
+ * If the class name and property name are not given, the message is logged.
439
+ *
440
+ * @param {string} sClassName - The name of the class where the error occurred.
441
+ * @param {string} sPropertyName - The name of the property causing the error.
442
+ * @param {string} sMessage - Additional message to log.
443
+ */
444
+ function logErrorOnce(sClassName, sPropertyName, sMessage) {
445
+ if (sClassName && sPropertyName) {
446
+ const sKey = `${sClassName}::${sPropertyName}`;
447
+ if (!oLoggedErrors.has(sKey)) {
448
+ oLoggedErrors.add(sKey);
449
+ Log.error(`Property "${sPropertyName}" of "${sClassName}": ${sMessage}`);
450
+ }
451
+ } else {
452
+ Log.error(sMessage);
453
+ }
454
+ }
455
+
456
+ /**
457
+ * Looks up the type with the given name and returns it.
458
+ *
459
+ * See {@link topic:ac56d92162ed47ff858fdf1ce26c18c4 Defining Control Properties} for
460
+ * a list of the built-in primitive types and their semantics.
461
+ *
462
+ * The lookup consists of the following steps:
463
+ * <ul>
464
+ * <li>When a type with the given name is already known, it will be returned</li>
465
+ * <li>When the name ends with a pair of brackets (<code>[]</code>), a type with the name
466
+ * in front of the brackets (<code>name.slice(0,-2)</code>) will be looked up and an
467
+ * array type will be created with the looked-up type as its component type. If the
468
+ * component type is <code>undefined</code>, <code>undefined</code> will be returned</li>
469
+ * <li>When a global property exists with the same name as the type and when the value of that
470
+ * property is an instance of <code>DataType</code>, that instance will be returned</li>
471
+ * <li>When a global property exists with the same name as the type and when the value of that
472
+ * property is a plain object (its prototype is <code>Object</code>), then an enum type will
473
+ * be created, based on the keys and values in that object. The <code>parseValue</code> method
474
+ * of the type will accept any of the keys in the plain object and convert them to the
475
+ * corresponding value; <code>isValid</code> will accept any of the values from the plain
476
+ * object's keys. The <code>defaultValue</code> will be the value of the first key found in
477
+ * the plain object</li>
478
+ * <li>When a global property exist with any other, non-falsy value, a warning is logged and the
479
+ * primitive type 'any' is returned</li>
480
+ * <li>If no such global property exist, an error is logged and <code>undefined</code>
481
+ * is returned</li>
482
+ * </ul>
483
+ *
484
+ * <b<Note:</b> UI Libraries and even components can introduce additional types. This method
485
+ * only checks for types that either have been defined already, or that describe arrays of
486
+ * values of an already defined type or types whose name matches the global name of a plain
487
+ * object (containing enum keys and values). This method doesn't try to load modules that
488
+ * might contain type definitions. So before being able to lookup and use a specific type,
489
+ * the module containing its definition has to be loaded. For that reason it is suggested that
490
+ * controls (or <code>ManagedObject</code> classes in general) declare a dependency to all
491
+ * modules (typically <code>some/lib/library.js</code> modules) that contain the type definitions
492
+ * needed by the specific control or class definition.
493
+ *
494
+ * @param {string} sTypeName Qualified name of the type to retrieve
495
+ * @param {sap.ui.base.ManagedObject.MetadataOptions.Property} [oProperty] Metadata of the property
496
+ * @returns {sap.ui.base.DataType|undefined} Type object or <code>undefined</code> when
497
+ * no such type has been defined yet
498
+ * @public
499
+ */
500
+ DataType.getType = function (sTypeName, oProperty) {
501
+ assert(sTypeName && typeof sTypeName === 'string', "sTypeName must be a non-empty string");
502
+ var oType = mTypes[sTypeName];
503
+ if (!(oType instanceof DataType)) {
504
+ // check for array types
505
+ if (sTypeName.indexOf("[]", sTypeName.length - 2) > 0) {
506
+ var sComponentTypeName = sTypeName.slice(0, -2),
507
+ oComponentType = this.getType(sComponentTypeName);
508
+ oType = oComponentType && createArrayType(oComponentType);
509
+ if (oType) {
510
+ mTypes[sTypeName] = oType;
511
+ }
512
+ } else if (sTypeName !== 'array') {
513
+ // check if we have a valid pre-registered enum
514
+ oType = mEnumRegistry[sTypeName];
515
+
516
+ /**
517
+ * If an enum was not registered beforehand (either explicitly via registerEnum or
518
+ * via a Proxy in the library namespace), we have to look it up in the global object.
519
+ * @deprecated since 1.120
520
+ */
521
+ if (oType == null) {
522
+ oType = ObjectPath.get(sTypeName);
523
+ if (oType != null) {
524
+ logErrorOnce(oProperty?._oParent.getName(), oProperty?.name, `[DEPRECATED] The type '${sTypeName}' was accessed via globals. Defining types via globals is deprecated. ` + `In case the referenced type is an enum: require the module 'sap/ui/base/DataType' and call the static 'DataType.registerEnum' API. ` + `In case the referenced type is non-primitive, please note that only primitive types (and those derived from them) are supported for ManagedObject properties. ` + `If the given type is an interface or a subclass of ManagedObject, you can define a "0..1" aggregation instead of a property`);
525
+ }
526
+ }
527
+ if (oType instanceof DataType) {
528
+ mTypes[sTypeName] = oType;
529
+ } else if (isPlainObject(oType)) {
530
+ oType = mTypes[sTypeName] = createEnumType(sTypeName, oType);
531
+ delete mEnumRegistry[sTypeName];
532
+ } else if (oType) {
533
+ future.warningThrows("'" + sTypeName + "' is not a valid data type. Falling back to type 'any'.");
534
+ oType = mTypes.any;
535
+ } else {
536
+ future.errorThrows("data type '" + sTypeName + "' could not be found.");
537
+ oType = undefined;
538
+ }
539
+ }
540
+ }
541
+ return oType;
542
+ };
543
+
544
+ /**
545
+ * Derives a new type from a given base type.
546
+ *
547
+ * Example:<br>
548
+ * <pre>
549
+ *
550
+ * var fooType = DataType.createType('foo', {
551
+ * isValid : function(vValue) {
552
+ * return /^(foo(bar)?)$/.test(vValue);
553
+ * }
554
+ * }, DataType.getType('string'));
555
+ *
556
+ * fooType.isValid('foo'); // true
557
+ * fooType.isValid('foobar'); // true
558
+ * fooType.isValid('==foobar=='); // false
559
+ *
560
+ * </pre>
561
+ *
562
+ * If <code>mSettings</code> contains an implementation for <code>isValid</code>,
563
+ * then the validity check of the newly created type will first execute the check of the
564
+ * base type and then call the given <code>isValid</code> function.
565
+ *
566
+ * Array types and enumeration types cannot be created with this method. They're created
567
+ * on-the-fly by {@link #.getType DataType.getType} when such a type is looked up.
568
+ *
569
+ * <b>Note:</b> The creation of new primitive types is not supported. When a type is created
570
+ * without a base type, it is automatically derived from the primitive type <code>any</code>.
571
+ *
572
+ * <b>Note:</b> If a type has to be used in classes, then the implementation of
573
+ * <code>isValid</code> must exactly have the structure shown in the example above (single
574
+ * return statement, regular expression literal of the form <code>/^(...)$/</code>, calling
575
+ * <code>/regex/.test()</code> on the given value).
576
+ * Only the inner part of the regular expression literal can be different.
577
+ *
578
+ * @param {string} sName Unique qualified name of the new type
579
+ * @param {object} [mSettings] Settings for the new type
580
+ * @param {any} [mSettings.defaultValue] Default value for the type (inherited if not given)
581
+ * @param {function} [mSettings.isValid] Additional validity check function for values of the
582
+ * type (inherited if not given)
583
+ * @param {function} [mSettings.parseValue] Parse function that converts a locale independent
584
+ * string into a value of the type (inherited if not given)
585
+ * @param {sap.ui.base.DataType|string} [vBase='any'] Base type for the new type
586
+ * @returns {sap.ui.base.DataType} The newly created type object
587
+ * @public
588
+ */
589
+ DataType.createType = function (sName, mSettings, vBase) {
590
+ assert(typeof sName === "string" && sName, "DataType.createType: type name must be a non-empty string");
591
+ assert(vBase == null || vBase instanceof DataType || typeof vBase === "string" && vBase, "DataType.createType: base type must be empty or a DataType or a non-empty string");
592
+ if (/[\[\]]/.test(sName)) {
593
+ future.errorThrows("DataType.createType: array types ('something[]') must not be created with createType, " + "they're created on-the-fly by DataType.getType");
594
+ }
595
+ if (typeof vBase === "string") {
596
+ vBase = DataType.getType(vBase);
597
+ }
598
+ vBase = vBase || mTypes.any;
599
+ if (vBase.isArrayType() || vBase.isEnumType()) {
600
+ future.errorThrows("DataType.createType: base type must not be an array- or enum-type");
601
+ }
602
+ if (sName === 'array' || mTypes[sName] instanceof DataType) {
603
+ if (sName === 'array' || mTypes[sName].getBaseType() == null) {
604
+ throw new Error("DataType.createType: primitive or hidden type " + sName + " can't be re-defined");
605
+ }
606
+ future.warningThrows("DataTypes.createType: type " + sName + " is redefined. " + "This is an unsupported usage of DataType and might cause issues.");
607
+ }
608
+ var oType = mTypes[sName] = createType(sName, mSettings, vBase);
609
+ return oType;
610
+ };
611
+
612
+ // ---- minimal support for interface types -------------------------------------------------------------------
613
+
614
+ var oInterfaces = new Set();
615
+
616
+ /**
617
+ * Registers the given array of type names as known interface types.
618
+ * Only purpose is to enable the {@link #isInterfaceType} check.
619
+ * @param {string[]} aTypes interface types to be registered
620
+ * @private
621
+ * @ui5-restricted sap.ui.core.Core
622
+ */
623
+ DataType.registerInterfaceTypes = function (aTypes) {
624
+ aTypes.forEach(function (sType) {
625
+ oInterfaces.add(sType);
626
+
627
+ /**
628
+ * @deprecated
629
+ */
630
+ (() => {
631
+ // Defining the interface on global namespace for compatibility reasons.
632
+ // This has never been a public feature and it is strongly discouraged it be relied upon.
633
+ // An interface must always be referenced by a string literal, not via the global namespace.
634
+ ObjectPath.set(sType, sType);
635
+ })();
636
+ });
637
+ };
638
+
639
+ /**
640
+ * Registers an enum under the given name.
641
+ * With version 2.0, registering an enum becomes mandatory when said enum is to be used in
642
+ * properties of a {@link sap.ui.base.ManagedObject ManagedObject} subclass.
643
+ *
644
+ * Example:<br>
645
+ * <pre>
646
+ * DataType.registerEnum("my.enums.Sample", {
647
+ * "A": "A",
648
+ * "B": "B",
649
+ * ...
650
+ * });
651
+ * </pre>
652
+ *
653
+ * @param {string} sTypeName the type name in dot syntax, e.g. sap.ui.my.EnumType
654
+ * @param {object} mContent the enum content
655
+ * @public
656
+ * @since 1.120.0
657
+ */
658
+ DataType.registerEnum = function (sTypeName, mContent) {
659
+ mEnumRegistry[sTypeName] = mContent;
660
+ };
661
+
662
+ /**
663
+ * Checks if the given object contains only static content
664
+ * and can be regarded as an enum candidate.
665
+ *
666
+ * @param {object} oObject the enum candidate
667
+ * @returns {boolean} whether the given object can be regarded as an enum candidate
668
+ * @private
669
+ * @ui5-restricted sap.ui.core.Lib
670
+ */
671
+ DataType._isEnumCandidate = function (oObject) {
672
+ return !Object.keys(oObject).some(key => {
673
+ const propertyType = typeof oObject[key];
674
+ return propertyType === "object" || propertyType === "function";
675
+ });
676
+ };
677
+
678
+ /**
679
+ * @param {string} sType name of type to check
680
+ * @returns {boolean} whether the given type is known to be an interface type
681
+ * @private
682
+ * @ui5-restricted sap.ui.base.ManagedObject
683
+ */
684
+ DataType.isInterfaceType = function (sType) {
685
+ return oInterfaces.has(sType);
686
+ };
687
+
688
+ /**
689
+ * A string type representing an ID or a name.
690
+ *
691
+ * Allowed is a sequence of characters (capital/lowercase), digits, underscores, hyphens, dots and/or colons.
692
+ * It may start with a character or underscore only.
693
+ *
694
+ * @typedef {string} sap.ui.core.ID
695
+ * @final
696
+ * @public
697
+ * @ui5-module-override sap/ui/core/library ID
698
+ */
699
+ DataType.createType('sap.ui.core.ID', {
700
+ isValid: function (vValue) {
701
+ return /^([A-Za-z_][-A-Za-z0-9_.:]*)$/.test(vValue);
702
+ }
703
+ }, DataType.getType('string'));
704
+
705
+ // The enum helper receives the final registerEnum function and ensures
706
+ // that all early collected enums are correctly registered
707
+ _EnumHelper.inject(DataType.registerEnum);
708
+ export default DataType;