@db-ux/wc-core-components 4.13.1-angular-signal-forms13-577b861 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/bundle/db-badge.js +1 -1
  3. package/bundle/db-brand.js +1 -1
  4. package/bundle/db-checkbox.js +1 -1
  5. package/bundle/db-custom-select.js +1 -1
  6. package/bundle/db-drawer.js +1 -1
  7. package/bundle/db-header.js +1 -1
  8. package/bundle/db-input.js +1 -1
  9. package/bundle/db-navigation-item.js +1 -1
  10. package/bundle/db-notification.js +1 -1
  11. package/bundle/db-popover.js +1 -1
  12. package/bundle/db-select.js +1 -1
  13. package/bundle/db-switch.js +1 -1
  14. package/bundle/db-tabs.js +1 -1
  15. package/bundle/db-tag.js +1 -1
  16. package/bundle/db-textarea.js +1 -1
  17. package/bundle/db-tooltip.js +1 -1
  18. package/bundle/index.js +1 -1
  19. package/bundle/p-BXHP_qH1.js +1 -0
  20. package/bundle/{p-Be1wVxvg.js → p-Bl3Nkowh.js} +1 -1
  21. package/bundle/p-Bsv9xU74.js +1 -0
  22. package/bundle/p-C3D_kjdU.js +1 -0
  23. package/bundle/p-Cm3dPtkD.js +1 -0
  24. package/bundle/{p-By8B0zRG.js → p-Cmc3AFmy.js} +1 -1
  25. package/bundle/{p-C_qYW0Kh.js → p-DmKfvZy3.js} +1 -1
  26. package/bundle/p-DzJeNSBs.js +1 -0
  27. package/bundle/{p-Dd85RhMq.js → p-OXsRLHzG.js} +1 -1
  28. package/dist/cjs/{constants-bMY2_d8A.js → constants-Dy7QIUQi.js} +5 -1
  29. package/dist/cjs/db-badge.cjs.entry.js +1 -1
  30. package/dist/cjs/db-brand.cjs.entry.js +1 -1
  31. package/dist/cjs/db-checkbox.cjs.entry.js +1 -1
  32. package/dist/cjs/db-custom-select-dropdown_5.cjs.entry.js +1 -1
  33. package/dist/cjs/db-custom-select.cjs.entry.js +40 -25
  34. package/dist/cjs/db-drawer.cjs.entry.js +1 -1
  35. package/dist/cjs/db-header.cjs.entry.js +3 -3
  36. package/dist/cjs/db-navigation-item.cjs.entry.js +3 -3
  37. package/dist/cjs/db-notification.cjs.entry.js +1 -1
  38. package/dist/cjs/db-popover.cjs.entry.js +50 -23
  39. package/dist/cjs/db-select.cjs.entry.js +1 -1
  40. package/dist/cjs/db-switch.cjs.entry.js +1 -1
  41. package/dist/cjs/db-tabs.cjs.entry.js +22 -17
  42. package/dist/cjs/db-textarea.cjs.entry.js +1 -1
  43. package/dist/cjs/db-tooltip.cjs.entry.js +40 -28
  44. package/dist/cjs/db-ux.cjs.js +1 -1
  45. package/dist/cjs/{document-click-listener-Bt1Iysz5.js → document-click-listener-DyO00UZC.js} +5 -9
  46. package/dist/cjs/{floating-components-SpHkZuLA.js → floating-components-Ns3Jt7dw.js} +161 -106
  47. package/dist/cjs/index.cjs.js +9 -6
  48. package/dist/cjs/intersection-observer-listener-BBUA6END.js +101 -0
  49. package/dist/cjs/loader.cjs.js +1 -1
  50. package/dist/cjs/{navigation-DUTSDY4q.js → navigation-fsWSnlKn.js} +1 -1
  51. package/dist/cjs/resize-observer-listener-B1uhHzqv.js +103 -0
  52. package/dist/collection/components/custom-select/custom-select.js +37 -20
  53. package/dist/collection/components/popover/popover.js +75 -46
  54. package/dist/collection/components/tabs/tabs.js +75 -18
  55. package/dist/collection/components/tooltip/tooltip.js +63 -49
  56. package/dist/collection/shared/constants.js +3 -1
  57. package/dist/collection/utils/abstract-document-listener.js +23 -0
  58. package/dist/collection/utils/abstract-observer-listener.js +61 -0
  59. package/dist/collection/utils/document-click-listener.js +5 -9
  60. package/dist/collection/utils/document-scroll-listener.js +5 -9
  61. package/dist/collection/utils/floating-components.js +161 -106
  62. package/dist/collection/utils/intersection-observer-listener.js +36 -0
  63. package/dist/collection/utils/resize-observer-listener.js +36 -0
  64. package/dist/custom-elements.json +232 -257
  65. package/dist/db-ux/db-ux.esm.js +1 -1
  66. package/dist/db-ux/index.esm.js +1 -1
  67. package/dist/db-ux/{p-d40a44ca.entry.js → p-1006233c.entry.js} +1 -1
  68. package/dist/db-ux/p-24767117.entry.js +1 -0
  69. package/dist/db-ux/{p-c83a359f.entry.js → p-40e78127.entry.js} +1 -1
  70. package/dist/db-ux/p-4a1282b9.entry.js +1 -0
  71. package/dist/db-ux/p-5b4ad0fd.entry.js +1 -0
  72. package/dist/db-ux/{p-dfc9ad26.entry.js → p-6a77f198.entry.js} +1 -1
  73. package/dist/db-ux/{p-1f740a3b.entry.js → p-6dfb57d0.entry.js} +1 -1
  74. package/dist/db-ux/p-775ef2b5.entry.js +1 -0
  75. package/dist/db-ux/p-78b4f191.entry.js +1 -0
  76. package/dist/db-ux/{p-2e66b25f.entry.js → p-7c26be27.entry.js} +1 -1
  77. package/dist/db-ux/{p-f4eb1ad4.entry.js → p-7fb6bf32.entry.js} +1 -1
  78. package/dist/db-ux/p-Bn4tE1v7.js +1 -0
  79. package/dist/db-ux/p-C3D_kjdU.js +1 -0
  80. package/dist/db-ux/p-Cm3dPtkD.js +1 -0
  81. package/dist/db-ux/{p-C_qYW0Kh.js → p-DmKfvZy3.js} +1 -1
  82. package/dist/db-ux/p-MhMqbaAW.js +1 -0
  83. package/dist/db-ux/p-aClGBxfA.js +1 -0
  84. package/dist/db-ux/{p-3649de37.entry.js → p-bfaec517.entry.js} +1 -1
  85. package/dist/db-ux/{p-3b9d4cc3.entry.js → p-c9b6ae8f.entry.js} +1 -1
  86. package/dist/db-ux/{p-c33fe9e0.entry.js → p-e8d5f721.entry.js} +1 -1
  87. package/dist/db-ux/{p-e35b2f5d.entry.js → p-fbb85f89.entry.js} +1 -1
  88. package/dist/esm/{constants-BdL-nI5y.js → constants-Cm3dPtkD.js} +4 -2
  89. package/dist/esm/db-badge.entry.js +1 -1
  90. package/dist/esm/db-brand.entry.js +1 -1
  91. package/dist/esm/db-checkbox.entry.js +1 -1
  92. package/dist/esm/db-custom-select-dropdown_5.entry.js +1 -1
  93. package/dist/esm/db-custom-select.entry.js +38 -23
  94. package/dist/esm/db-drawer.entry.js +1 -1
  95. package/dist/esm/db-header.entry.js +3 -3
  96. package/dist/esm/db-navigation-item.entry.js +3 -3
  97. package/dist/esm/db-notification.entry.js +1 -1
  98. package/dist/esm/db-popover.entry.js +48 -21
  99. package/dist/esm/db-select.entry.js +1 -1
  100. package/dist/esm/db-switch.entry.js +1 -1
  101. package/dist/esm/db-tabs.entry.js +22 -17
  102. package/dist/esm/db-textarea.entry.js +1 -1
  103. package/dist/esm/db-tooltip.entry.js +37 -25
  104. package/dist/esm/db-ux.js +1 -1
  105. package/dist/esm/{document-click-listener-B9qg-hEl.js → document-click-listener-Cqaqu5Jn.js} +5 -9
  106. package/dist/esm/{floating-components-C0q9XJSc.js → floating-components-C3D_kjdU.js} +162 -107
  107. package/dist/esm/index.js +6 -5
  108. package/dist/esm/intersection-observer-listener-DNd-fDFa.js +97 -0
  109. package/dist/esm/loader.js +1 -1
  110. package/dist/esm/{navigation-Cd7KZ6E2.js → navigation-BET7zThU.js} +1 -1
  111. package/dist/esm/resize-observer-listener-ed-nCkCj.js +100 -0
  112. package/dist/types/components/custom-select/custom-select.d.ts +3 -2
  113. package/dist/types/components/custom-select/model.d.ts +5 -1
  114. package/dist/types/components/popover/popover.d.ts +3 -2
  115. package/dist/types/components/tabs/model.d.ts +4 -12
  116. package/dist/types/components/tabs/tabs.d.ts +3 -1
  117. package/dist/types/components/tooltip/tooltip.d.ts +3 -2
  118. package/dist/types/components.d.ts +8 -2
  119. package/dist/types/shared/constants.d.ts +2 -0
  120. package/dist/types/shared/model.d.ts +27 -4
  121. package/dist/types/utils/abstract-document-listener.d.ts +18 -0
  122. package/dist/types/utils/abstract-observer-listener.d.ts +39 -0
  123. package/dist/types/utils/document-click-listener.d.ts +3 -3
  124. package/dist/types/utils/document-scroll-listener.d.ts +3 -3
  125. package/dist/types/utils/floating-components.d.ts +29 -6
  126. package/dist/types/utils/intersection-observer-listener.d.ts +15 -0
  127. package/dist/types/utils/resize-observer-listener.d.ts +15 -0
  128. package/dist/vscode.html-custom-data.json +29 -19
  129. package/dist/web-types.json +82 -75
  130. package/package.json +3 -3
  131. package/bundle/p-BdL-nI5y.js +0 -1
  132. package/bundle/p-C0q9XJSc.js +0 -1
  133. package/bundle/p-CTkfdjBp.js +0 -1
  134. package/bundle/p-LpyedXhR.js +0 -1
  135. package/dist/cjs/document-scroll-listener-Dd_hGebZ.js +0 -43
  136. package/dist/db-ux/p-177f3aeb.entry.js +0 -1
  137. package/dist/db-ux/p-2aee37e2.entry.js +0 -1
  138. package/dist/db-ux/p-550bd66a.entry.js +0 -1
  139. package/dist/db-ux/p-91d7fcc4.entry.js +0 -1
  140. package/dist/db-ux/p-B-HK8lhm.js +0 -1
  141. package/dist/db-ux/p-BdL-nI5y.js +0 -1
  142. package/dist/db-ux/p-C0q9XJSc.js +0 -1
  143. package/dist/db-ux/p-Z7eYHp_l.js +0 -1
  144. package/dist/db-ux/p-bc835df4.entry.js +0 -1
  145. package/dist/esm/document-scroll-listener-ewGU9bif.js +0 -41
@@ -1,64 +1,4 @@
1
1
  // TODO: We should reevaluate this as soon as CSS Anchor Positioning is supported in all relevant browsers
2
- const isInView = (el) => {
3
- var _a;
4
- const { top, bottom, left, right } = el.getBoundingClientRect();
5
- const { innerHeight, innerWidth } = window;
6
- let outTop = top < 0;
7
- let outBottom = bottom > innerHeight;
8
- let outLeft = left < 0;
9
- let outRight = right > innerWidth;
10
- // We need to check if it was already outside
11
- const outsideY = el.dataset['outsideVy'];
12
- const outsideX = el.dataset['outsideVx'];
13
- const parentRect = (_a = el === null || el === void 0 ? void 0 : el.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
14
- if (parentRect) {
15
- if (outsideY) {
16
- const position = el.dataset['outsideVy'];
17
- if (position === 'top') {
18
- outTop = parentRect.top - (bottom - parentRect.bottom) < 0;
19
- }
20
- else {
21
- outBottom = parentRect.bottom + (parentRect.top - top) > innerHeight;
22
- }
23
- }
24
- if (outsideX) {
25
- const position = el.dataset['outsideVx'];
26
- if (position === 'left') {
27
- outLeft = parentRect.left - (right - parentRect.right) < 0;
28
- }
29
- else {
30
- outRight = parentRect.right + (parentRect.left - left) > innerWidth;
31
- }
32
- }
33
- }
34
- return {
35
- outTop,
36
- outBottom,
37
- outLeft,
38
- outRight
39
- };
40
- };
41
- export const handleDataOutside = (el) => {
42
- const { outTop, outBottom, outLeft, outRight } = isInView(el);
43
- let dataOutsidePair = {};
44
- if (outTop || outBottom) {
45
- dataOutsidePair = {
46
- vy: outTop ? 'top' : 'bottom'
47
- };
48
- el.dataset['outsideVy'] = dataOutsidePair.vy;
49
- }
50
- else {
51
- delete el.dataset['outsideVy'];
52
- }
53
- if (outLeft || outRight) {
54
- dataOutsidePair = Object.assign(Object.assign({}, dataOutsidePair), { vx: outRight ? 'right' : 'left' });
55
- el.dataset['outsideVx'] = dataOutsidePair.vx;
56
- }
57
- else {
58
- delete el.dataset['outsideVx'];
59
- }
60
- return dataOutsidePair;
61
- };
62
2
  export const handleFixedDropdown = (element, parent, placement) => {
63
3
  if (!element || !parent)
64
4
  return;
@@ -74,9 +14,11 @@ export const handleFixedDropdown = (element, parent, placement) => {
74
14
  // mobile max-inline-size guard and overflows the viewport.
75
15
  element.style.inlineSize = '';
76
16
  element.style.minInlineSize = '';
77
- // We skip the rest if we are in mobile, it's already fixed via CSS.
78
- if (getComputedStyle(element).zIndex === '9999')
17
+ // We skip this if we are in mobile it's already fixed or if we don't have a floating dropdown
18
+ const computedStyle = getComputedStyle(element);
19
+ if (computedStyle.zIndex === '9999' || computedStyle.position !== 'fixed' && computedStyle.position !== 'absolute') {
79
20
  return;
21
+ }
80
22
  const { top, bottom, childHeight, childWidth, width, right, left, correctedPlacement, innerWidth } = getFloatingProps(element, parent, placement);
81
23
  // For auto width the dropdown is forced to be at least as wide as the trigger,
82
24
  // but clamped to its own max-inline-size: CSS lets a min-inline-size override
@@ -151,27 +93,38 @@ export const getFloatingProps = (element, parent, placement) => {
151
93
  let childHeight = childRect.height;
152
94
  let childWidth = childRect.width;
153
95
  if (placement === 'bottom' || placement === 'top') {
154
- childWidth = childWidth / 2;
96
+ childWidth = width > childWidth ? 0 : childWidth / 2;
155
97
  }
156
98
  if (placement === 'left' || placement === 'right') {
157
- childHeight = childHeight / 2;
99
+ childHeight = height > childHeight ? 0 : childHeight / 2;
158
100
  }
159
- const outsideBottom = bottom + childHeight > innerHeight;
160
- const outsideTop = top - childHeight < 0;
161
- const outsideLeft = left - childWidth < 0;
162
- const outsideRight = right + childWidth > innerWidth;
101
+ const outsideBottom = Math.floor(bottom + childHeight) > innerHeight;
102
+ const outsideTop = Math.ceil(top - childHeight) < 0;
103
+ const outsideLeft = Math.ceil(left - childWidth) < 0;
104
+ const outsideRight = Math.floor(right + childWidth) > innerWidth;
163
105
  let correctedPlacement = placement;
164
106
  if (placement.startsWith('bottom')) {
165
107
  if (outsideBottom) {
166
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('bottom', 'top');
167
- if (outsideLeft && outsideRight) {
168
- correctedPlacement = 'top';
169
- }
170
- else if (outsideLeft) {
171
- correctedPlacement = 'top-start';
108
+ if (!outsideTop) {
109
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('bottom', 'top');
110
+ if (outsideLeft && outsideRight) {
111
+ correctedPlacement = 'top';
112
+ }
113
+ else if (outsideLeft) {
114
+ correctedPlacement = 'top-start';
115
+ }
116
+ else if (outsideRight) {
117
+ correctedPlacement = 'top-end';
118
+ }
172
119
  }
173
- else if (outsideRight) {
174
- correctedPlacement = 'top-end';
120
+ else {
121
+ // Both outsideBottom and outsideTop: keep bottom but still apply horizontal correction
122
+ if (outsideLeft) {
123
+ correctedPlacement = 'bottom-start';
124
+ }
125
+ else if (outsideRight) {
126
+ correctedPlacement = 'bottom-end';
127
+ }
175
128
  }
176
129
  }
177
130
  else {
@@ -188,15 +141,26 @@ export const getFloatingProps = (element, parent, placement) => {
188
141
  }
189
142
  else if (placement.startsWith('top')) {
190
143
  if (outsideTop) {
191
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('top', 'bottom');
192
- if (outsideLeft && outsideRight) {
193
- correctedPlacement = 'bottom';
144
+ if (!outsideBottom) {
145
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('top', 'bottom');
146
+ if (outsideLeft && outsideRight) {
147
+ correctedPlacement = 'bottom';
148
+ }
149
+ else if (outsideLeft) {
150
+ correctedPlacement = 'bottom-start';
151
+ }
152
+ else if (outsideRight) {
153
+ correctedPlacement = 'bottom-end';
154
+ }
194
155
  }
195
- else if (outsideLeft) {
196
- correctedPlacement = 'bottom-start';
197
- }
198
- else if (outsideRight) {
199
- correctedPlacement = 'bottom-end';
156
+ else {
157
+ // Both outsideTop and outsideBottom: keep top but still apply horizontal correction
158
+ if (outsideLeft) {
159
+ correctedPlacement = 'top-start';
160
+ }
161
+ else if (outsideRight) {
162
+ correctedPlacement = 'top-end';
163
+ }
200
164
  }
201
165
  }
202
166
  else {
@@ -213,15 +177,17 @@ export const getFloatingProps = (element, parent, placement) => {
213
177
  }
214
178
  else if (placement.startsWith('left')) {
215
179
  if (outsideLeft) {
216
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('left', 'right');
217
- if (outsideBottom && outsideTop) {
218
- correctedPlacement = 'right';
219
- }
220
- else if (outsideBottom) {
221
- correctedPlacement = 'right-end';
222
- }
223
- else if (outsideTop) {
224
- correctedPlacement = 'right-start';
180
+ if (!outsideRight) {
181
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('left', 'right');
182
+ if (outsideBottom && outsideTop) {
183
+ correctedPlacement = 'right';
184
+ }
185
+ else if (outsideBottom) {
186
+ correctedPlacement = 'right-end';
187
+ }
188
+ else if (outsideTop) {
189
+ correctedPlacement = 'right-start';
190
+ }
225
191
  }
226
192
  }
227
193
  else {
@@ -238,15 +204,17 @@ export const getFloatingProps = (element, parent, placement) => {
238
204
  }
239
205
  else if (correctedPlacement.startsWith('right')) {
240
206
  if (outsideRight) {
241
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('right', 'left');
242
- if (outsideBottom && outsideTop) {
243
- correctedPlacement = 'left';
244
- }
245
- else if (outsideBottom) {
246
- correctedPlacement = 'left-end';
247
- }
248
- else if (outsideTop) {
249
- correctedPlacement = 'left-start';
207
+ if (!outsideLeft) {
208
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('right', 'left');
209
+ if (outsideBottom && outsideTop) {
210
+ correctedPlacement = 'left';
211
+ }
212
+ else if (outsideBottom) {
213
+ correctedPlacement = 'left-end';
214
+ }
215
+ else if (outsideTop) {
216
+ correctedPlacement = 'left-start';
217
+ }
250
218
  }
251
219
  }
252
220
  else {
@@ -272,7 +240,8 @@ export const getFloatingProps = (element, parent, placement) => {
272
240
  childWidth: childRect.width,
273
241
  correctedPlacement,
274
242
  innerWidth,
275
- innerHeight
243
+ innerHeight,
244
+ outsideYBoth: outsideTop && outsideBottom
276
245
  };
277
246
  };
278
247
  const MAX_ANCESTOR_DEPTH = 10;
@@ -295,15 +264,24 @@ const getAncestorHasCorrectedPlacement = (element) => {
295
264
  return null;
296
265
  };
297
266
  export const handleFixedPopover = (element, parent, placement) => {
298
- var _a, _b;
267
+ var _a, _b, _c;
299
268
  if (!element || !parent)
300
269
  return;
301
270
  const parentComputedStyles = getComputedStyle(parent);
302
271
  const parentHasFloatingPosition = ['absolute', 'fixed'].includes(parentComputedStyles.position);
303
272
  const ancestorWithCorrectedPlacement = getAncestorHasCorrectedPlacement(element);
304
273
  const noFloatingAncestor = !ancestorWithCorrectedPlacement && !parentHasFloatingPosition;
305
- const distance = (_b = (_a = getComputedStyle(element)) === null || _a === void 0 ? void 0 : _a.getPropertyValue('--db-popover-distance')) !== null && _b !== void 0 ? _b : '0px';
306
- let { top, height, width, childHeight, childWidth, right, left, bottom, correctedPlacement, innerWidth, innerHeight } = getFloatingProps(element, parent, placement);
274
+ const computedStyle = getComputedStyle(element);
275
+ // We skip if we don't have a floating popover
276
+ if (computedStyle.position !== 'fixed' && computedStyle.position !== 'absolute') {
277
+ return;
278
+ }
279
+ let distance = computedStyle.getPropertyValue('--db-popover-distance');
280
+ if (!distance.length) {
281
+ distance = '0px';
282
+ }
283
+ const elementPlacement = (_c = (_b = (_a = element === null || element === void 0 ? void 0 : element.dataset) === null || _a === void 0 ? void 0 : _a['placement']) !== null && _b !== void 0 ? _b : placement) !== null && _c !== void 0 ? _c : 'bottom';
284
+ let { top, height, width, childHeight, childWidth, right, left, bottom, correctedPlacement, innerWidth, innerHeight, outsideYBoth } = getFloatingProps(element, parent, elementPlacement);
307
285
  if (ancestorWithCorrectedPlacement) {
308
286
  const ancestorRect = ancestorWithCorrectedPlacement.getBoundingClientRect();
309
287
  left = Math.abs(left - ancestorRect.left);
@@ -351,6 +329,10 @@ export const handleFixedPopover = (element, parent, placement) => {
351
329
  }
352
330
  }
353
331
  // Popover position
332
+ // Reset shorthand inset properties from previous calls (e.g. outsideYBoth)
333
+ // before writing new individual inset values
334
+ element.style.insetBlock = '';
335
+ element.style.insetInline = '';
354
336
  if (correctedPlacement === 'right' || correctedPlacement === 'left') {
355
337
  // center horizontally
356
338
  element.style.insetBlockStart = `${top + height / 2}px`;
@@ -399,6 +381,79 @@ export const handleFixedPopover = (element, parent, placement) => {
399
381
  element.style.insetBlockStart = `calc(${parentHasFloatingPosition ? end : bottom}px + ${distance})`;
400
382
  element.style.insetBlockEnd = `calc(${noFloatingAncestor && end > innerHeight ? innerHeight : end}px + ${distance})`;
401
383
  }
384
+ // In this case we are outside of top and bottom so we need to scroll
385
+ // We use the full height in this case
386
+ if (outsideYBoth) {
387
+ element.style.overflow = 'hidden auto';
388
+ element.style.insetBlock = distance;
389
+ element.style.maxBlockSize = `calc(${innerHeight}px - 2 * ${distance})`;
390
+ }
391
+ else {
392
+ element.style.overflow = '';
393
+ element.style.maxBlockSize = '';
394
+ }
402
395
  element.style.position = 'fixed';
403
396
  element.dataset['correctedPlacement'] = correctedPlacement;
397
+ // Set data-outside-vy / data-outside-vx for CSS-based flipping
398
+ handleDataOutside(element);
399
+ };
400
+ export const handleDataOutside = (el) => {
401
+ const { outTop, outBottom, outLeft, outRight } = isInView(el);
402
+ let dataOutsidePair = {};
403
+ if (outTop || outBottom) {
404
+ dataOutsidePair = {
405
+ vy: outTop ? 'top' : 'bottom'
406
+ };
407
+ el.dataset['outsideVy'] = dataOutsidePair.vy;
408
+ }
409
+ else {
410
+ delete el.dataset['outsideVy'];
411
+ }
412
+ if (outLeft || outRight) {
413
+ dataOutsidePair = Object.assign(Object.assign({}, dataOutsidePair), { vx: outRight ? 'right' : 'left' });
414
+ el.dataset['outsideVx'] = dataOutsidePair.vx;
415
+ }
416
+ else {
417
+ delete el.dataset['outsideVx'];
418
+ }
419
+ return dataOutsidePair;
420
+ };
421
+ const isInView = (el) => {
422
+ var _a;
423
+ const { top, bottom, left, right } = el.getBoundingClientRect();
424
+ const { innerHeight, innerWidth } = window;
425
+ let outTop = top < 0;
426
+ let outBottom = bottom > innerHeight;
427
+ let outLeft = left < 0;
428
+ let outRight = right > innerWidth;
429
+ // We need to check if it was already outside
430
+ const outsideY = el.dataset['outsideVy'];
431
+ const outsideX = el.dataset['outsideVx'];
432
+ const parentRect = (_a = el === null || el === void 0 ? void 0 : el.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
433
+ if (parentRect) {
434
+ if (outsideY) {
435
+ const position = el.dataset['outsideVy'];
436
+ if (position === 'top') {
437
+ outTop = parentRect.top - (bottom - parentRect.bottom) < 0;
438
+ }
439
+ else {
440
+ outBottom = parentRect.bottom + (parentRect.top - top) > innerHeight;
441
+ }
442
+ }
443
+ if (outsideX) {
444
+ const position = el.dataset['outsideVx'];
445
+ if (position === 'left') {
446
+ outLeft = parentRect.left - (right - parentRect.right) < 0;
447
+ }
448
+ else {
449
+ outRight = parentRect.right + (parentRect.left - left) > innerWidth;
450
+ }
451
+ }
452
+ }
453
+ return {
454
+ outTop,
455
+ outBottom,
456
+ outLeft,
457
+ outRight
458
+ };
404
459
  };
@@ -0,0 +1,36 @@
1
+ import { AbstractObserverListener } from "./abstract-observer-listener.js";
2
+ export class IntersectionObserverListener extends AbstractObserverListener {
3
+ constructor() {
4
+ super();
5
+ if (IntersectionObserverListener._instance) {
6
+ return IntersectionObserverListener._instance;
7
+ }
8
+ IntersectionObserverListener._instance = this;
9
+ if (typeof window !== 'undefined' && 'IntersectionObserver' in window) {
10
+ IntersectionObserverListener.observer = new IntersectionObserver(entries => {
11
+ for (const entry of entries) {
12
+ this.dispatchEntry(entry.target, entry);
13
+ }
14
+ });
15
+ }
16
+ }
17
+ getCallbacksByElement() {
18
+ return IntersectionObserverListener.callbacksByElement;
19
+ }
20
+ getIdToElement() {
21
+ return IntersectionObserverListener.idToElement;
22
+ }
23
+ getObserver() {
24
+ return IntersectionObserverListener.observer;
25
+ }
26
+ observeElement(observer, element) {
27
+ observer.observe(element);
28
+ }
29
+ unobserveElement(observer, element) {
30
+ observer.unobserve(element);
31
+ }
32
+ }
33
+ IntersectionObserverListener._instance = null;
34
+ IntersectionObserverListener.callbacksByElement = new Map();
35
+ IntersectionObserverListener.idToElement = new Map();
36
+ IntersectionObserverListener.observer = null;
@@ -0,0 +1,36 @@
1
+ import { AbstractObserverListener } from "./abstract-observer-listener.js";
2
+ export class ResizeObserverListener extends AbstractObserverListener {
3
+ constructor() {
4
+ super();
5
+ if (ResizeObserverListener._instance) {
6
+ return ResizeObserverListener._instance;
7
+ }
8
+ ResizeObserverListener._instance = this;
9
+ if (typeof window !== 'undefined' && 'ResizeObserver' in window) {
10
+ ResizeObserverListener.observer = new ResizeObserver(entries => {
11
+ for (const entry of entries) {
12
+ this.dispatchEntry(entry.target, entry);
13
+ }
14
+ });
15
+ }
16
+ }
17
+ getCallbacksByElement() {
18
+ return ResizeObserverListener.callbacksByElement;
19
+ }
20
+ getIdToElement() {
21
+ return ResizeObserverListener.idToElement;
22
+ }
23
+ getObserver() {
24
+ return ResizeObserverListener.observer;
25
+ }
26
+ observeElement(observer, element) {
27
+ observer.observe(element);
28
+ }
29
+ unobserveElement(observer, element) {
30
+ observer.unobserve(element);
31
+ }
32
+ }
33
+ ResizeObserverListener._instance = null;
34
+ ResizeObserverListener.callbacksByElement = new Map();
35
+ ResizeObserverListener.idToElement = new Map();
36
+ ResizeObserverListener.observer = null;