@ui5/webcomponents-base 0.0.0-d9b978d1d → 0.0.0-da0d3eb88

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 (251) hide show
  1. package/CHANGELOG.md +653 -0
  2. package/README.md +0 -8
  3. package/config/wdio.conf.cjs +0 -8
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/Boot.d.ts +3 -2
  6. package/dist/Boot.js +8 -6
  7. package/dist/Boot.js.map +1 -1
  8. package/dist/Device.d.ts +1 -2
  9. package/dist/Device.js +5 -12
  10. package/dist/Device.js.map +1 -1
  11. package/dist/IgnoreCustomElements.d.ts +3 -5
  12. package/dist/IgnoreCustomElements.js +3 -5
  13. package/dist/IgnoreCustomElements.js.map +1 -1
  14. package/dist/InitialConfiguration.d.ts +1 -2
  15. package/dist/InitialConfiguration.js +1 -5
  16. package/dist/InitialConfiguration.js.map +1 -1
  17. package/dist/Keys.d.ts +3 -1
  18. package/dist/Keys.js +5 -1
  19. package/dist/Keys.js.map +1 -1
  20. package/dist/ManagedStyles.js +24 -98
  21. package/dist/ManagedStyles.js.map +1 -1
  22. package/dist/MediaRange.d.ts +6 -12
  23. package/dist/MediaRange.js +21 -31
  24. package/dist/MediaRange.js.map +1 -1
  25. package/dist/UI5Element.d.ts +36 -54
  26. package/dist/UI5Element.js +152 -101
  27. package/dist/UI5Element.js.map +1 -1
  28. package/dist/UI5ElementMetadata.d.ts +12 -13
  29. package/dist/UI5ElementMetadata.js +24 -13
  30. package/dist/UI5ElementMetadata.js.map +1 -1
  31. package/dist/asset-registries/Icons.js +1 -1
  32. package/dist/asset-registries/Icons.js.map +1 -1
  33. package/dist/asset-registries/Illustrations.d.ts +1 -0
  34. package/dist/asset-registries/Illustrations.js +12 -19
  35. package/dist/asset-registries/Illustrations.js.map +1 -1
  36. package/dist/asset-registries/LocaleData.js +1 -1
  37. package/dist/asset-registries/LocaleData.js.map +1 -1
  38. package/dist/asset-registries/i18n.d.ts +2 -2
  39. package/dist/asset-registries/i18n.js +2 -2
  40. package/dist/asset-registries/i18n.js.map +1 -1
  41. package/dist/asset-registries/util/IconCollectionsByTheme.d.ts +1 -1
  42. package/dist/asset-registries/util/IconCollectionsByTheme.js +1 -1
  43. package/dist/asset-registries/util/IconCollectionsByTheme.js.map +1 -1
  44. package/dist/asset-registries/util/getIconCollectionByTheme.d.ts +3 -3
  45. package/dist/asset-registries/util/getIconCollectionByTheme.js +3 -3
  46. package/dist/asset-registries/util/getIconCollectionByTheme.js.map +1 -1
  47. package/dist/config/AnimationMode.js +2 -1
  48. package/dist/config/AnimationMode.js.map +1 -1
  49. package/dist/config/Icons.d.ts +7 -7
  50. package/dist/config/Icons.js +7 -7
  51. package/dist/config/Icons.js.map +1 -1
  52. package/dist/config/Language.d.ts +1 -1
  53. package/dist/config/Language.js +6 -3
  54. package/dist/config/Language.js.map +1 -1
  55. package/dist/config/Theme.d.ts +4 -3
  56. package/dist/config/Theme.js +13 -6
  57. package/dist/config/Theme.js.map +1 -1
  58. package/dist/config/ThemeRoot.d.ts +2 -4
  59. package/dist/config/ThemeRoot.js +2 -4
  60. package/dist/config/ThemeRoot.js.map +1 -1
  61. package/dist/config/Timezone.d.ts +1 -1
  62. package/dist/config/Timezone.js +1 -1
  63. package/dist/config/Timezone.js.map +1 -1
  64. package/dist/css/SystemCSSVars.css +0 -8
  65. package/dist/decorators/customElement.d.ts +3 -3
  66. package/dist/decorators/customElement.js +11 -6
  67. package/dist/decorators/customElement.js.map +1 -1
  68. package/dist/decorators/event.d.ts +5 -2
  69. package/dist/decorators/event.js.map +1 -1
  70. package/dist/decorators.d.ts +5 -0
  71. package/dist/decorators.js +6 -0
  72. package/dist/decorators.js.map +1 -0
  73. package/dist/delegate/ItemNavigation.d.ts +8 -8
  74. package/dist/delegate/ItemNavigation.js +9 -9
  75. package/dist/delegate/ItemNavigation.js.map +1 -1
  76. package/dist/delegate/ResizeHandler.d.ts +4 -6
  77. package/dist/delegate/ResizeHandler.js +4 -6
  78. package/dist/delegate/ResizeHandler.js.map +1 -1
  79. package/dist/features/InputElementsFormSupport.d.ts +18 -0
  80. package/dist/features/InputElementsFormSupport.js +40 -0
  81. package/dist/features/InputElementsFormSupport.js.map +1 -0
  82. package/dist/features/OpenUI5Support.d.ts +0 -2
  83. package/dist/features/OpenUI5Support.js +6 -21
  84. package/dist/features/OpenUI5Support.js.map +1 -1
  85. package/dist/features/patchPatcher.d.ts +11 -0
  86. package/dist/features/patchPatcher.js +11 -0
  87. package/dist/features/patchPatcher.js.map +1 -0
  88. package/dist/features/patchPopup.d.ts +14 -0
  89. package/dist/features/patchPopup.js +50 -0
  90. package/dist/features/patchPopup.js.map +1 -0
  91. package/dist/generated/AssetParameters.js +1 -1
  92. package/dist/generated/AssetParameters.js.map +1 -1
  93. package/dist/generated/VersionInfo.js +5 -5
  94. package/dist/generated/VersionInfo.js.map +1 -1
  95. package/dist/generated/css/SystemCSSVars.css.js +1 -1
  96. package/dist/generated/css/SystemCSSVars.css.js.map +1 -1
  97. package/dist/i18nBundle.d.ts +1 -3
  98. package/dist/i18nBundle.js +1 -4
  99. package/dist/i18nBundle.js.map +1 -1
  100. package/dist/locale/applyDirection.d.ts +3 -2
  101. package/dist/locale/applyDirection.js +3 -2
  102. package/dist/locale/applyDirection.js.map +1 -1
  103. package/dist/locale/getEffectiveDir.d.ts +1 -1
  104. package/dist/locale/getEffectiveDir.js +3 -19
  105. package/dist/locale/getEffectiveDir.js.map +1 -1
  106. package/dist/renderer/LitRenderer.js +2 -8
  107. package/dist/renderer/LitRenderer.js.map +1 -1
  108. package/dist/renderer/directives/style-map.d.ts +13 -0
  109. package/dist/renderer/directives/style-map.js +59 -59
  110. package/dist/renderer/directives/style-map.js.map +1 -0
  111. package/dist/renderer/executeTemplate.d.ts +8 -0
  112. package/dist/renderer/executeTemplate.js +1 -0
  113. package/dist/renderer/executeTemplate.js.map +1 -1
  114. package/dist/sap/base/Log.js +698 -188
  115. package/dist/sap/base/assert.js +28 -1
  116. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  117. package/dist/sap/base/security/URLListValidator.js +253 -6
  118. package/dist/sap/base/security/encodeCSS.js +34 -8
  119. package/dist/sap/base/security/encodeXML.js +47 -17
  120. package/dist/sap/base/security/sanitizeHTML.js +35 -13
  121. package/dist/sap/base/strings/toHex.js +27 -2
  122. package/dist/sap/base/util/now.js +24 -3
  123. package/dist/sap/base/util/uid.js +27 -0
  124. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +1 -1
  125. package/dist/ssr-dom-shim.d.ts +1 -0
  126. package/dist/ssr-dom-shim.js +12 -0
  127. package/dist/ssr-dom-shim.js.map +1 -0
  128. package/dist/ssr-dom.d.ts +0 -0
  129. package/dist/ssr-dom.js +0 -0
  130. package/dist/theming/getConstructableStyle.d.ts +1 -1
  131. package/dist/theming/getConstructableStyle.js +3 -3
  132. package/dist/theming/getConstructableStyle.js.map +1 -1
  133. package/dist/theming/getEffectiveStyle.d.ts +1 -1
  134. package/dist/theming/getEffectiveStyle.js +5 -12
  135. package/dist/theming/getEffectiveStyle.js.map +1 -1
  136. package/dist/types/AnimationMode.d.ts +0 -8
  137. package/dist/types/AnimationMode.js +0 -8
  138. package/dist/types/AnimationMode.js.map +1 -1
  139. package/dist/types/AriaHasPopup.d.ts +32 -0
  140. package/dist/types/AriaHasPopup.js +34 -0
  141. package/dist/types/AriaHasPopup.js.map +1 -0
  142. package/dist/types/AriaLandmarkRole.d.ts +79 -0
  143. package/dist/types/AriaLandmarkRole.js +81 -0
  144. package/dist/types/AriaLandmarkRole.js.map +1 -0
  145. package/dist/types/AriaRole.d.ts +27 -0
  146. package/dist/types/AriaRole.js +29 -0
  147. package/dist/types/AriaRole.js.map +1 -0
  148. package/dist/types/CSSColor.d.ts +0 -4
  149. package/dist/types/CSSColor.js +0 -4
  150. package/dist/types/CSSColor.js.map +1 -1
  151. package/dist/types/CSSSize.d.ts +0 -4
  152. package/dist/types/CSSSize.js +0 -4
  153. package/dist/types/CSSSize.js.map +1 -1
  154. package/dist/types/CalendarType.d.ts +0 -9
  155. package/dist/types/CalendarType.js +0 -9
  156. package/dist/types/CalendarType.js.map +1 -1
  157. package/dist/types/DOMReference.d.ts +1 -5
  158. package/dist/types/DOMReference.js +1 -5
  159. package/dist/types/DOMReference.js.map +1 -1
  160. package/dist/types/DataType.d.ts +1 -6
  161. package/dist/types/DataType.js +1 -6
  162. package/dist/types/DataType.js.map +1 -1
  163. package/dist/types/Float.d.ts +0 -3
  164. package/dist/types/Float.js +0 -3
  165. package/dist/types/Float.js.map +1 -1
  166. package/dist/types/Integer.d.ts +0 -3
  167. package/dist/types/Integer.js +0 -3
  168. package/dist/types/Integer.js.map +1 -1
  169. package/dist/types/InvisibleMessageMode.d.ts +0 -6
  170. package/dist/types/InvisibleMessageMode.js +0 -6
  171. package/dist/types/InvisibleMessageMode.js.map +1 -1
  172. package/dist/types/ItemNavigationBehavior.d.ts +0 -6
  173. package/dist/types/ItemNavigationBehavior.js +0 -6
  174. package/dist/types/ItemNavigationBehavior.js.map +1 -1
  175. package/dist/types/MovePlacement.d.ts +20 -0
  176. package/dist/types/MovePlacement.js +22 -0
  177. package/dist/types/MovePlacement.js.map +1 -0
  178. package/dist/types/NavigationMode.d.ts +0 -8
  179. package/dist/types/NavigationMode.js +0 -8
  180. package/dist/types/NavigationMode.js.map +1 -1
  181. package/dist/types/Orientation.d.ts +16 -0
  182. package/dist/types/Orientation.js +18 -0
  183. package/dist/types/Orientation.js.map +1 -0
  184. package/dist/types/ValueState.d.ts +3 -17
  185. package/dist/types/ValueState.js +3 -17
  186. package/dist/types/ValueState.js.map +1 -1
  187. package/dist/types.d.ts +24 -1
  188. package/dist/types.js.map +1 -1
  189. package/dist/updateShadowRoot.d.ts +1 -2
  190. package/dist/updateShadowRoot.js +5 -29
  191. package/dist/updateShadowRoot.js.map +1 -1
  192. package/dist/util/InvisibleMessage.js +2 -2
  193. package/dist/util/InvisibleMessage.js.map +1 -1
  194. package/dist/util/PopupUtils.d.ts +1 -3
  195. package/dist/util/PopupUtils.js +1 -15
  196. package/dist/util/PopupUtils.js.map +1 -1
  197. package/dist/util/clamp.js +2 -1
  198. package/dist/util/clamp.js.map +1 -1
  199. package/dist/util/createLinkInHead.d.ts +1 -1
  200. package/dist/util/createLinkInHead.js +1 -1
  201. package/dist/util/createLinkInHead.js.map +1 -1
  202. package/dist/util/detectNavigatorLanguage.d.ts +2 -2
  203. package/dist/util/detectNavigatorLanguage.js +6 -1
  204. package/dist/util/detectNavigatorLanguage.js.map +1 -1
  205. package/dist/util/dragAndDrop/DragRegistry.d.ts +12 -0
  206. package/dist/util/dragAndDrop/DragRegistry.js +68 -0
  207. package/dist/util/dragAndDrop/DragRegistry.js.map +1 -0
  208. package/dist/util/dragAndDrop/findClosestPosition.d.ts +7 -0
  209. package/dist/util/dragAndDrop/findClosestPosition.js +59 -0
  210. package/dist/util/dragAndDrop/findClosestPosition.js.map +1 -0
  211. package/dist/util/dragAndDrop/longDragOverHandler.d.ts +2 -0
  212. package/dist/util/dragAndDrop/longDragOverHandler.js +25 -0
  213. package/dist/util/dragAndDrop/longDragOverHandler.js.map +1 -0
  214. package/dist/util/getClassCopy.d.ts +17 -12
  215. package/dist/util/getDesigntimePropertyAsArray.d.ts +2 -2
  216. package/dist/util/getDesigntimePropertyAsArray.js +2 -1
  217. package/dist/util/getDesigntimePropertyAsArray.js.map +1 -1
  218. package/index.js +1 -17
  219. package/package-scripts.cjs +18 -14
  220. package/package.json +20 -8
  221. package/src/css/SystemCSSVars.css +0 -8
  222. package/tsconfig.json +3 -0
  223. package/.eslintignore +0 -16
  224. package/.eslintrc.cjs +0 -3
  225. package/bundle.esm.js +0 -67
  226. package/dist/CSP.d.ts +0 -30
  227. package/dist/CSP.js +0 -51
  228. package/dist/CSP.js.map +0 -1
  229. package/dist/StaticArea.js +0 -7
  230. package/dist/StaticArea.js.map +0 -1
  231. package/dist/StaticAreaItem.d.ts +0 -37
  232. package/dist/StaticAreaItem.js +0 -102
  233. package/dist/StaticAreaItem.js.map +0 -1
  234. package/dist/api.json +0 -1
  235. package/dist/config/RTL.d.ts +0 -7
  236. package/dist/config/RTL.js +0 -37
  237. package/dist/config/RTL.js.map +0 -1
  238. package/dist/theming/getEffectiveLinksHrefs.d.ts +0 -3
  239. package/dist/theming/getEffectiveLinksHrefs.js +0 -17
  240. package/dist/theming/getEffectiveLinksHrefs.js.map +0 -1
  241. package/dist/theming/preloadLinks.d.ts +0 -3
  242. package/dist/theming/preloadLinks.js +0 -19
  243. package/dist/theming/preloadLinks.js.map +0 -1
  244. package/dist/util/createStyleInHead.d.ts +0 -8
  245. package/dist/util/createStyleInHead.js +0 -18
  246. package/dist/util/createStyleInHead.js.map +0 -1
  247. package/lib/generate-asset-parameters/index.js +0 -27
  248. package/lib/generate-styles/index.js +0 -31
  249. package/lib/generate-version-info/index.js +0 -32
  250. package/src/renderer/directives/style-map.js +0 -72
  251. package/used-modules.txt +0 -10
@@ -1,12 +1,12 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import "@ui5/webcomponents-base/dist/ssr-dom.js";
1
3
  import merge from "./thirdparty/merge.js";
2
4
  import { boot } from "./Boot.js";
3
5
  import UI5ElementMetadata from "./UI5ElementMetadata.js";
4
6
  import EventProvider from "./EventProvider.js";
5
- import getSingletonElementInstance from "./util/getSingletonElementInstance.js";
6
- import StaticAreaItem from "./StaticAreaItem.js";
7
7
  import updateShadowRoot from "./updateShadowRoot.js";
8
8
  import { shouldIgnoreCustomElement } from "./IgnoreCustomElements.js";
9
- import { renderDeferred, renderImmediately, cancelRender } from "./Render.js";
9
+ import { renderDeferred, renderImmediately, cancelRender, } from "./Render.js";
10
10
  import { registerTag, isTagRegistered, recordTagRegistrationFailure } from "./CustomElementsRegistry.js";
11
11
  import { observeDOMNode, unobserveDOMNode } from "./DOMObserver.js";
12
12
  import { skipOriginalEvent } from "./config/NoConflict.js";
@@ -16,8 +16,9 @@ import isValidPropertyName from "./util/isValidPropertyName.js";
16
16
  import { getSlotName, getSlottedNodesList } from "./util/SlotsHelper.js";
17
17
  import arraysAreEqual from "./util/arraysAreEqual.js";
18
18
  import { markAsRtlAware } from "./locale/RTLAwareRegistry.js";
19
- import preloadLinks from "./theming/preloadLinks.js";
20
- import executeTemplate from "./renderer/executeTemplate.js";
19
+ import executeTemplate, { getTagsToScope } from "./renderer/executeTemplate.js";
20
+ import { attachFormElementInternals, setFormValue } from "./features/InputElementsFormSupport.js";
21
+ const DEV_MODE = true;
21
22
  let autoId = 0;
22
23
  const elementTimeouts = new Map();
23
24
  const uniqueDependenciesCache = new Map();
@@ -39,12 +40,25 @@ function _invalidate(changeInfo) {
39
40
  this._invalidationEventProvider.fireEvent("invalidate", { ...changeInfo, target: this });
40
41
  }
41
42
  /**
43
+ * looks up a property descsriptor including in the prototype chain
44
+ * @param proto the starting prototype
45
+ * @param name the property to look for
46
+ * @returns the property descriptor if found directly or in the prototype chaing, undefined if not found
47
+ */
48
+ function getPropertyDescriptor(proto, name) {
49
+ do {
50
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
51
+ if (descriptor) {
52
+ return descriptor;
53
+ }
54
+ // go up the prototype chain
55
+ proto = Object.getPrototypeOf(proto);
56
+ } while (proto && proto !== HTMLElement.prototype);
57
+ }
58
+ /**
59
+ * @class
42
60
  * Base class for all UI5 Web Components
43
61
  *
44
- * @class
45
- * @constructor
46
- * @author SAP SE
47
- * @alias sap.ui.webc.base.UI5Element
48
62
  * @extends HTMLElement
49
63
  * @public
50
64
  */
@@ -66,10 +80,12 @@ class UI5Element extends HTMLElement {
66
80
  });
67
81
  this._domRefReadyPromise._deferredResolve = deferredResolve;
68
82
  this._doNotSyncAttributes = new Set(); // attributes that are excluded from attributeChangedCallback synchronization
83
+ this._slotsAssignedNodes = new WeakMap(); // map of all nodes, slotted (directly or transitively) per component slot
69
84
  this._state = { ...ctor.getMetadata().getInitialState() };
70
85
  this._upgradeAllProperties();
71
86
  if (ctor._needsShadowDOM()) {
72
- this.attachShadow({ mode: "open" });
87
+ const defaultOptions = { mode: "open" };
88
+ this.attachShadow({ ...defaultOptions, ...ctor.getMetadata().getShadowRootOptions() });
73
89
  }
74
90
  }
75
91
  /**
@@ -88,15 +104,32 @@ class UI5Element extends HTMLElement {
88
104
  const template = this.constructor.template;
89
105
  return executeTemplate(template, this);
90
106
  }
91
- renderStatic() {
92
- const template = this.constructor.staticAreaTemplate;
93
- return executeTemplate(template, this);
94
- }
95
107
  /**
96
108
  * Do not call this method from derivatives of UI5Element, use "onEnterDOM" only
97
109
  * @private
98
110
  */
99
111
  async connectedCallback() {
112
+ if (DEV_MODE) {
113
+ const rootNode = this.getRootNode();
114
+ // when an element is connected, check if it exists in the `dependencies` of the parent
115
+ if (rootNode instanceof ShadowRoot && instanceOfUI5Element(rootNode.host)) {
116
+ const klass = rootNode.host.constructor;
117
+ const hasDependency = getTagsToScope(rootNode.host).includes(this.constructor.getMetadata().getPureTag());
118
+ if (!hasDependency) {
119
+ // eslint-disable-next-line no-console
120
+ console.error(`[UI5-FWK] ${this.constructor.getMetadata().getTag()} not found in dependencies of ${klass.getMetadata().getTag()}`);
121
+ }
122
+ }
123
+ }
124
+ if (DEV_MODE) {
125
+ const props = this.constructor.getMetadata().getProperties();
126
+ for (const [prop, propData] of Object.entries(props)) { // eslint-disable-line
127
+ if (Object.hasOwn(this, prop)) {
128
+ // eslint-disable-next-line no-console
129
+ console.error(`[UI5-FWK] ${this.constructor.getMetadata().getTag()} has a property [${prop}] that is shadowed by the instance. Updates to this property will not invalidate the component. Possible reason is TS target ES2022 or TS useDefineForClassFields`);
130
+ }
131
+ }
132
+ }
100
133
  const ctor = this.constructor;
101
134
  this.setAttribute(ctor.getMetadata().getPureTag(), "");
102
135
  if (ctor.getMetadata().supportsF6FastNavigation()) {
@@ -132,9 +165,7 @@ class UI5Element extends HTMLElement {
132
165
  this.onExitDOM();
133
166
  this._fullyConnected = false;
134
167
  }
135
- if (this.staticAreaItem && this.staticAreaItem.parentElement) {
136
- this.staticAreaItem.parentElement.removeChild(this.staticAreaItem);
137
- }
168
+ this._domRefReadyPromise._deferredResolve();
138
169
  cancelRender(this);
139
170
  }
140
171
  /**
@@ -234,9 +265,9 @@ class UI5Element extends HTMLElement {
234
265
  const localName = child.localName;
235
266
  const shouldWaitForCustomElement = localName.includes("-") && !shouldIgnoreCustomElement(localName);
236
267
  if (shouldWaitForCustomElement) {
237
- const isDefined = window.customElements.get(localName);
268
+ const isDefined = customElements.get(localName);
238
269
  if (!isDefined) {
239
- const whenDefinedPromise = window.customElements.whenDefined(localName); // Class registered, but instances not upgraded yet
270
+ const whenDefinedPromise = customElements.whenDefined(localName); // Class registered, but instances not upgraded yet
240
271
  let timeoutPromise = elementTimeouts.get(localName);
241
272
  if (!timeoutPromise) {
242
273
  timeoutPromise = new Promise(resolve => setTimeout(resolve, 1000));
@@ -244,20 +275,18 @@ class UI5Element extends HTMLElement {
244
275
  }
245
276
  await Promise.race([whenDefinedPromise, timeoutPromise]);
246
277
  }
247
- window.customElements.upgrade(child);
278
+ customElements.upgrade(child);
248
279
  }
249
280
  }
250
281
  child = ctor.getMetadata().constructor.validateSlotValue(child, slotData);
251
282
  // Listen for any invalidation on the child if invalidateOnChildChange is true or an object (ignore when false or not set)
252
283
  if (instanceOfUI5Element(child) && slotData.invalidateOnChildChange) {
253
284
  const childChangeListener = this._getChildChangeListener(slotName);
254
- if (childChangeListener) {
255
- child.attachInvalidate.call(child, childChangeListener);
256
- }
285
+ child.attachInvalidate.call(child, childChangeListener);
257
286
  }
258
287
  // Listen for the slotchange event if the child is a slot itself
259
288
  if (child instanceof HTMLSlotElement) {
260
- this._attachSlotChange(child, slotName);
289
+ this._attachSlotChange(child, slotName, !!slotData.invalidateOnChildChange);
261
290
  }
262
291
  const propertyName = slotData.propertyName || slotName;
263
292
  if (slottedChildrenMap.has(propertyName)) {
@@ -284,6 +313,9 @@ class UI5Element extends HTMLElement {
284
313
  reason: "children",
285
314
  });
286
315
  invalidated = true;
316
+ if (ctor.getMetadata().isFormAssociated()) {
317
+ setFormValue(this);
318
+ }
287
319
  }
288
320
  }
289
321
  // If none of the slots had an invalidation due to changes to immediate children,
@@ -306,9 +338,7 @@ class UI5Element extends HTMLElement {
306
338
  children.forEach(child => {
307
339
  if (instanceOfUI5Element(child)) {
308
340
  const childChangeListener = this._getChildChangeListener(slotName);
309
- if (childChangeListener) {
310
- child.detachInvalidate.call(child, childChangeListener);
311
- }
341
+ child.detachInvalidate.call(child, childChangeListener);
312
342
  }
313
343
  if (child instanceof HTMLSlotElement) {
314
344
  this._detachSlotChange(child, slotName);
@@ -319,7 +349,7 @@ class UI5Element extends HTMLElement {
319
349
  /**
320
350
  * Attach a callback that will be executed whenever the component is invalidated
321
351
  *
322
- * @param {InvalidationInfo} callback
352
+ * @param callback
323
353
  * @public
324
354
  */
325
355
  attachInvalidate(callback) {
@@ -328,7 +358,7 @@ class UI5Element extends HTMLElement {
328
358
  /**
329
359
  * Detach the callback that is executed whenever the component is invalidated
330
360
  *
331
- * @param {InvalidationInfo} callback
361
+ * @param callback
332
362
  * @public
333
363
  */
334
364
  detachInvalidate(callback) {
@@ -337,8 +367,8 @@ class UI5Element extends HTMLElement {
337
367
  /**
338
368
  * Callback that is executed whenever a monitored child changes its state
339
369
  *
340
- * @param {sting} slotName the slot in which a child was invalidated
341
- * @param { ChangeInfo } childChangeInfo the changeInfo object for the child in the given slot
370
+ * @param slotName the slot in which a child was invalidated
371
+ * @param childChangeInfo the changeInfo object for the child in the given slot
342
372
  * @private
343
373
  */
344
374
  _onChildChange(slotName, childChangeInfo) {
@@ -385,6 +415,16 @@ class UI5Element extends HTMLElement {
385
415
  this[nameInCamelCase] = newPropertyValue;
386
416
  }
387
417
  }
418
+ formAssociatedCallback() {
419
+ const ctor = this.constructor;
420
+ if (!ctor.getMetadata().isFormAssociated()) {
421
+ return;
422
+ }
423
+ attachFormElementInternals(this);
424
+ }
425
+ static get formAssociated() {
426
+ return this.getMetadata().isFormAssociated();
427
+ }
388
428
  /**
389
429
  * @private
390
430
  */
@@ -448,7 +488,6 @@ class UI5Element extends HTMLElement {
448
488
  * Returns a singleton event listener for the "change" event of a child in a given slot
449
489
  *
450
490
  * @param slotName the name of the slot, where the child is
451
- * @returns {ChildChangeListener}
452
491
  * @private
453
492
  */
454
493
  _getChildChangeListener(slotName) {
@@ -461,7 +500,6 @@ class UI5Element extends HTMLElement {
461
500
  * Returns a singleton slotchange event listener that invalidates the component due to changes in the given slot
462
501
  *
463
502
  * @param slotName the name of the slot, where the slot element (whose slotchange event we're listening to) is
464
- * @returns {SlotChangeListener}
465
503
  * @private
466
504
  */
467
505
  _getSlotChangeListener(slotName) {
@@ -473,11 +511,32 @@ class UI5Element extends HTMLElement {
473
511
  /**
474
512
  * @private
475
513
  */
476
- _attachSlotChange(child, slotName) {
514
+ _attachSlotChange(slot, slotName, invalidateOnChildChange) {
477
515
  const slotChangeListener = this._getSlotChangeListener(slotName);
478
- if (slotChangeListener) {
479
- child.addEventListener("slotchange", slotChangeListener);
480
- }
516
+ slot.addEventListener("slotchange", (e) => {
517
+ slotChangeListener.call(slot, e);
518
+ if (invalidateOnChildChange) {
519
+ // Detach listeners for UI5 Elements that used to be in this slot
520
+ const previousChildren = this._slotsAssignedNodes.get(slot);
521
+ if (previousChildren) {
522
+ previousChildren.forEach(child => {
523
+ if (instanceOfUI5Element(child)) {
524
+ const childChangeListener = this._getChildChangeListener(slotName);
525
+ child.detachInvalidate.call(child, childChangeListener);
526
+ }
527
+ });
528
+ }
529
+ // Attach listeners for UI5 Elements that are now in this slot
530
+ const newChildren = getSlottedNodesList([slot]);
531
+ this._slotsAssignedNodes.set(slot, newChildren);
532
+ newChildren.forEach(child => {
533
+ if (instanceOfUI5Element(child)) {
534
+ const childChangeListener = this._getChildChangeListener(slotName);
535
+ child.attachInvalidate.call(child, childChangeListener);
536
+ }
537
+ });
538
+ }
539
+ });
481
540
  }
482
541
  /**
483
542
  * @private
@@ -513,9 +572,9 @@ class UI5Element extends HTMLElement {
513
572
  * 1) children: immediate children (HTML elements or text nodes) were added, removed or reordered in the slot
514
573
  * 2) textcontent: text nodes in the slot changed value (or nested text nodes were added or changed value). Can only trigger for slots of "type: Node"
515
574
  * 3) slotchange: a slot element, slotted inside that slot had its "slotchange" event listener called. This practically means that transitively slotted children changed.
516
- * Can only trigger if the child of a slot is a slot element itself.
575
+ * Can only trigger if the child of a slot is a slot element itself.
517
576
  * 4) childchange: indicates that a UI5Element child in that slot was invalidated and in turn invalidated the component.
518
- * Can only trigger for slots with "invalidateOnChildChange" metadata descriptor
577
+ * Can only trigger for slots with "invalidateOnChildChange" metadata descriptor
519
578
  *
520
579
  * - newValue: the new value of the property (for type="property" only)
521
580
  *
@@ -566,9 +625,6 @@ class UI5Element extends HTMLElement {
566
625
  if (ctor._needsShadowDOM()) {
567
626
  updateShadowRoot(this);
568
627
  }
569
- if (this.staticAreaItem) {
570
- this.staticAreaItem.update();
571
- }
572
628
  // Safari requires that children get the slot attribute only after the slot tags have been rendered in the shadow DOM
573
629
  if (hasIndividualSlots) {
574
630
  this._assignIndividualSlotsToChildren();
@@ -608,11 +664,7 @@ class UI5Element extends HTMLElement {
608
664
  if (!this.shadowRoot || this.shadowRoot.children.length === 0) {
609
665
  return;
610
666
  }
611
- const children = [...this.shadowRoot.children].filter(child => !["link", "style"].includes(child.localName));
612
- if (children.length !== 1) {
613
- console.warn(`The shadow DOM for ${this.constructor.getMetadata().getTag()} does not have a top level element, the getDomRef() method might not work as expected`); // eslint-disable-line
614
- }
615
- return children[0];
667
+ return this.shadowRoot.children[0];
616
668
  }
617
669
  /**
618
670
  * Returns the DOM Element marked with "data-sap-focus-ref" inside the template.
@@ -637,7 +689,7 @@ class UI5Element extends HTMLElement {
637
689
  }
638
690
  /**
639
691
  * Set the focus to the element, returned by "getFocusDomRef()" (marked by "data-sap-focus-ref")
640
- * @param {FocusOptions} focusOptions additional options for the focus
692
+ * @param focusOptions additional options for the focus
641
693
  * @public
642
694
  */
643
695
  async focus(focusOptions) {
@@ -654,7 +706,7 @@ class UI5Element extends HTMLElement {
654
706
  * @param data - additional data for the event
655
707
  * @param cancelable - true, if the user can call preventDefault on the event object
656
708
  * @param bubbles - true, if the event bubbles
657
- * @returns {boolean} false, if the event was cancelled (preventDefault called), true otherwise
709
+ * @returns false, if the event was cancelled (preventDefault called), true otherwise
658
710
  */
659
711
  fireEvent(name, data, cancelable = false, bubbles = true) {
660
712
  const eventResult = this._fireEvent(name, data, cancelable, bubbles);
@@ -698,7 +750,7 @@ class UI5Element extends HTMLElement {
698
750
  /**
699
751
  * Attach a callback that will be executed whenever the component's state is finalized
700
752
  *
701
- * @param {} callback
753
+ * @param callback
702
754
  * @public
703
755
  */
704
756
  attachComponentStateFinalized(callback) {
@@ -707,7 +759,7 @@ class UI5Element extends HTMLElement {
707
759
  /**
708
760
  * Detach the callback that is executed whenever the component's state is finalized
709
761
  *
710
- * @param {} callback
762
+ * @param callback
711
763
  * @public
712
764
  */
713
765
  detachComponentStateFinalized(callback) {
@@ -718,7 +770,7 @@ class UI5Element extends HTMLElement {
718
770
  * Returns: "rtl", "ltr" or undefined
719
771
  *
720
772
  * @public
721
- * @returns {String|undefined}
773
+ * @default undefined
722
774
  */
723
775
  get effectiveDir() {
724
776
  markAsRtlAware(this.constructor); // if a UI5 Element calls this method, it's considered to be rtl-aware
@@ -726,8 +778,8 @@ class UI5Element extends HTMLElement {
726
778
  }
727
779
  /**
728
780
  * Used to duck-type UI5 elements without using instanceof
729
- * @returns {boolean}
730
781
  * @public
782
+ * @default true
731
783
  */
732
784
  get isUI5Element() {
733
785
  return true;
@@ -735,6 +787,13 @@ class UI5Element extends HTMLElement {
735
787
  get classes() {
736
788
  return {};
737
789
  }
790
+ /**
791
+ * Returns the component accessibility info.
792
+ * @private
793
+ */
794
+ get accessibilityInfo() {
795
+ return {};
796
+ }
738
797
  /**
739
798
  * Do not override this method in derivatives of UI5Element, use metadata properties instead
740
799
  * @private
@@ -748,28 +807,6 @@ class UI5Element extends HTMLElement {
748
807
  static _needsShadowDOM() {
749
808
  return !!this.template || Object.prototype.hasOwnProperty.call(this.prototype, "render");
750
809
  }
751
- /**
752
- * @private
753
- */
754
- static _needsStaticArea() {
755
- return !!this.staticAreaTemplate || Object.prototype.hasOwnProperty.call(this.prototype, "renderStatic");
756
- }
757
- /**
758
- * @public
759
- */
760
- getStaticAreaItemDomRef() {
761
- if (!this.constructor._needsStaticArea()) {
762
- throw new Error("This component does not use the static area");
763
- }
764
- if (!this.staticAreaItem) {
765
- this.staticAreaItem = StaticAreaItem.createInstance();
766
- this.staticAreaItem.setOwnerElement(this);
767
- }
768
- if (!this.staticAreaItem.parentElement) {
769
- getSingletonElementInstance("ui5-static-area").appendChild(this.staticAreaItem);
770
- }
771
- return this.staticAreaItem.getDomRef();
772
- }
773
810
  /**
774
811
  * @private
775
812
  */
@@ -794,8 +831,25 @@ class UI5Element extends HTMLElement {
794
831
  if (propData.multiple && propData.defaultValue) {
795
832
  throw new Error(`Cannot set a default value for property "${prop}". All multiple properties are empty arrays by default.`);
796
833
  }
834
+ const descriptor = getPropertyDescriptor(proto, prop);
835
+ // if the decorator is on a setter, proxy the new setter to it
836
+ let origSet;
837
+ if (descriptor?.set) {
838
+ // eslint-disable-next-line @typescript-eslint/unbound-method
839
+ origSet = descriptor.set;
840
+ }
841
+ // if the decorator is on a setter, there will be a corresponding getter - proxy the new getter to it
842
+ let origGet;
843
+ if (descriptor?.get) {
844
+ // eslint-disable-next-line @typescript-eslint/unbound-method
845
+ origGet = descriptor.get;
846
+ }
797
847
  Object.defineProperty(proto, prop, {
798
848
  get() {
849
+ // proxy the getter to the original accessor if there was one
850
+ if (origGet) {
851
+ return origGet.call(this);
852
+ }
799
853
  if (this._state[prop] !== undefined) {
800
854
  return this._state[prop];
801
855
  }
@@ -820,7 +874,7 @@ class UI5Element extends HTMLElement {
820
874
  value = metadataCtor.validatePropertyValue(value, propData);
821
875
  const propertyType = propData.type;
822
876
  let propertyValidator = propData.validator;
823
- const oldState = this._state[prop];
877
+ const oldState = origGet ? origGet.call(this) : this._state[prop];
824
878
  if (propertyType && propertyType.isDataTypeClass) {
825
879
  propertyValidator = propertyType;
826
880
  }
@@ -834,13 +888,22 @@ class UI5Element extends HTMLElement {
834
888
  isDifferent = oldState !== value;
835
889
  }
836
890
  if (isDifferent) {
837
- this._state[prop] = value;
891
+ // if the decorator is on a setter, use it for storage
892
+ if (origSet) {
893
+ origSet.call(this, value);
894
+ }
895
+ else {
896
+ this._state[prop] = value;
897
+ }
838
898
  _invalidate.call(this, {
839
899
  type: "property",
840
900
  name: prop,
841
901
  newValue: value,
842
902
  oldValue: oldState,
843
903
  });
904
+ if (ctor.getMetadata().isFormAssociated()) {
905
+ setFormValue(this);
906
+ }
844
907
  this._updateAttribute(prop, value);
845
908
  }
846
909
  },
@@ -868,20 +931,6 @@ class UI5Element extends HTMLElement {
868
931
  }
869
932
  }
870
933
  }
871
- /**
872
- * Returns the CSS for this UI5 Web Component Class
873
- * @protected
874
- */
875
- static get styles() {
876
- return "";
877
- }
878
- /**
879
- * Returns the Static Area CSS for this UI5 Web Component Class
880
- * @protected
881
- */
882
- static get staticAreaStyles() {
883
- return "";
884
- }
885
934
  /**
886
935
  * Returns an array with the dependencies for this UI5 Web Component, which could be:
887
936
  * - composed components (used in its shadow root or static area item)
@@ -906,8 +955,6 @@ class UI5Element extends HTMLElement {
906
955
  }
907
956
  /**
908
957
  * Returns a promise that resolves whenever all dependencies for this UI5 Web Component have resolved
909
- *
910
- * @returns {Promise}
911
958
  */
912
959
  static whenDependenciesDefined() {
913
960
  return Promise.all(this.getUniqueDependencies().map(dep => dep.define()));
@@ -916,7 +963,6 @@ class UI5Element extends HTMLElement {
916
963
  * Hook that will be called upon custom element definition
917
964
  *
918
965
  * @protected
919
- * @returns {Promise<void>}
920
966
  */
921
967
  static async onDefine() {
922
968
  return Promise.resolve();
@@ -924,7 +970,6 @@ class UI5Element extends HTMLElement {
924
970
  /**
925
971
  * Registers a UI5 Web Component in the browser window object
926
972
  * @public
927
- * @returns {Promise<UI5Element>}
928
973
  */
929
974
  static async define() {
930
975
  await boot();
@@ -934,15 +979,14 @@ class UI5Element extends HTMLElement {
934
979
  ]);
935
980
  const tag = this.getMetadata().getTag();
936
981
  const definedLocally = isTagRegistered(tag);
937
- const definedGlobally = window.customElements.get(tag);
982
+ const definedGlobally = customElements.get(tag);
938
983
  if (definedGlobally && !definedLocally) {
939
984
  recordTagRegistrationFailure(tag);
940
985
  }
941
986
  else if (!definedGlobally) {
942
987
  this._generateAccessors();
943
988
  registerTag(tag);
944
- window.customElements.define(tag, this);
945
- preloadLinks(this);
989
+ customElements.define(tag, this);
946
990
  }
947
991
  return this;
948
992
  }
@@ -950,7 +994,6 @@ class UI5Element extends HTMLElement {
950
994
  * Returns an instance of UI5ElementMetadata.js representing this UI5 Web Component's full metadata (its and its parents')
951
995
  * Note: not to be confused with the "get metadata()" method, which returns an object for this class's metadata only
952
996
  * @public
953
- * @returns {UI5ElementMetadata}
954
997
  */
955
998
  static getMetadata() {
956
999
  if (this.hasOwnProperty("_metadata")) { // eslint-disable-line
@@ -966,19 +1009,27 @@ class UI5Element extends HTMLElement {
966
1009
  this._metadata = new UI5ElementMetadata(mergedMetadata);
967
1010
  return this._metadata;
968
1011
  }
1012
+ get validity() { return this._internals?.validity; }
1013
+ get validationMessage() { return this._internals?.validationMessage; }
1014
+ checkValidity() { return this._internals?.checkValidity(); }
1015
+ reportValidity() { return this._internals?.reportValidity(); }
969
1016
  }
970
1017
  /**
971
1018
  * Returns the metadata object for this UI5 Web Component Class
972
1019
  * @protected
973
1020
  */
974
1021
  UI5Element.metadata = {};
1022
+ /**
1023
+ * Returns the CSS for this UI5 Web Component Class
1024
+ * @protected
1025
+ */
1026
+ UI5Element.styles = "";
975
1027
  /**
976
1028
  * Always use duck-typing to cover all runtimes on the page.
977
- * @returns {boolean}
978
1029
  */
979
1030
  const instanceOfUI5Element = (object) => {
980
1031
  return "isUI5Element" in object;
981
1032
  };
982
1033
  export default UI5Element;
983
- export { instanceOfUI5Element };
1034
+ export { instanceOfUI5Element, };
984
1035
  //# sourceMappingURL=UI5Element.js.map