@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,66 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  // TODO: We should reevaluate this as soon as CSS Anchor Positioning is supported in all relevant browsers
4
- const isInView = (el) => {
5
- var _a;
6
- const { top, bottom, left, right } = el.getBoundingClientRect();
7
- const { innerHeight, innerWidth } = window;
8
- let outTop = top < 0;
9
- let outBottom = bottom > innerHeight;
10
- let outLeft = left < 0;
11
- let outRight = right > innerWidth;
12
- // We need to check if it was already outside
13
- const outsideY = el.dataset['outsideVy'];
14
- const outsideX = el.dataset['outsideVx'];
15
- const parentRect = (_a = el === null || el === void 0 ? void 0 : el.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
16
- if (parentRect) {
17
- if (outsideY) {
18
- const position = el.dataset['outsideVy'];
19
- if (position === 'top') {
20
- outTop = parentRect.top - (bottom - parentRect.bottom) < 0;
21
- }
22
- else {
23
- outBottom = parentRect.bottom + (parentRect.top - top) > innerHeight;
24
- }
25
- }
26
- if (outsideX) {
27
- const position = el.dataset['outsideVx'];
28
- if (position === 'left') {
29
- outLeft = parentRect.left - (right - parentRect.right) < 0;
30
- }
31
- else {
32
- outRight = parentRect.right + (parentRect.left - left) > innerWidth;
33
- }
34
- }
35
- }
36
- return {
37
- outTop,
38
- outBottom,
39
- outLeft,
40
- outRight
41
- };
42
- };
43
- const handleDataOutside = (el) => {
44
- const { outTop, outBottom, outLeft, outRight } = isInView(el);
45
- let dataOutsidePair = {};
46
- if (outTop || outBottom) {
47
- dataOutsidePair = {
48
- vy: outTop ? 'top' : 'bottom'
49
- };
50
- el.dataset['outsideVy'] = dataOutsidePair.vy;
51
- }
52
- else {
53
- delete el.dataset['outsideVy'];
54
- }
55
- if (outLeft || outRight) {
56
- dataOutsidePair = Object.assign(Object.assign({}, dataOutsidePair), { vx: outRight ? 'right' : 'left' });
57
- el.dataset['outsideVx'] = dataOutsidePair.vx;
58
- }
59
- else {
60
- delete el.dataset['outsideVx'];
61
- }
62
- return dataOutsidePair;
63
- };
64
4
  const handleFixedDropdown = (element, parent, placement) => {
65
5
  if (!element || !parent)
66
6
  return;
@@ -76,9 +16,11 @@ const handleFixedDropdown = (element, parent, placement) => {
76
16
  // mobile max-inline-size guard and overflows the viewport.
77
17
  element.style.inlineSize = '';
78
18
  element.style.minInlineSize = '';
79
- // We skip the rest if we are in mobile, it's already fixed via CSS.
80
- if (getComputedStyle(element).zIndex === '9999')
19
+ // We skip this if we are in mobile it's already fixed or if we don't have a floating dropdown
20
+ const computedStyle = getComputedStyle(element);
21
+ if (computedStyle.zIndex === '9999' || computedStyle.position !== 'fixed' && computedStyle.position !== 'absolute') {
81
22
  return;
23
+ }
82
24
  const { top, bottom, childHeight, childWidth, width, right, left, correctedPlacement, innerWidth } = getFloatingProps(element, parent, placement);
83
25
  // For auto width the dropdown is forced to be at least as wide as the trigger,
84
26
  // but clamped to its own max-inline-size: CSS lets a min-inline-size override
@@ -153,27 +95,38 @@ const getFloatingProps = (element, parent, placement) => {
153
95
  let childHeight = childRect.height;
154
96
  let childWidth = childRect.width;
155
97
  if (placement === 'bottom' || placement === 'top') {
156
- childWidth = childWidth / 2;
98
+ childWidth = width > childWidth ? 0 : childWidth / 2;
157
99
  }
158
100
  if (placement === 'left' || placement === 'right') {
159
- childHeight = childHeight / 2;
101
+ childHeight = height > childHeight ? 0 : childHeight / 2;
160
102
  }
161
- const outsideBottom = bottom + childHeight > innerHeight;
162
- const outsideTop = top - childHeight < 0;
163
- const outsideLeft = left - childWidth < 0;
164
- const outsideRight = right + childWidth > innerWidth;
103
+ const outsideBottom = Math.floor(bottom + childHeight) > innerHeight;
104
+ const outsideTop = Math.ceil(top - childHeight) < 0;
105
+ const outsideLeft = Math.ceil(left - childWidth) < 0;
106
+ const outsideRight = Math.floor(right + childWidth) > innerWidth;
165
107
  let correctedPlacement = placement;
166
108
  if (placement.startsWith('bottom')) {
167
109
  if (outsideBottom) {
168
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('bottom', 'top');
169
- if (outsideLeft && outsideRight) {
170
- correctedPlacement = 'top';
171
- }
172
- else if (outsideLeft) {
173
- correctedPlacement = 'top-start';
110
+ if (!outsideTop) {
111
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('bottom', 'top');
112
+ if (outsideLeft && outsideRight) {
113
+ correctedPlacement = 'top';
114
+ }
115
+ else if (outsideLeft) {
116
+ correctedPlacement = 'top-start';
117
+ }
118
+ else if (outsideRight) {
119
+ correctedPlacement = 'top-end';
120
+ }
174
121
  }
175
- else if (outsideRight) {
176
- correctedPlacement = 'top-end';
122
+ else {
123
+ // Both outsideBottom and outsideTop: keep bottom but still apply horizontal correction
124
+ if (outsideLeft) {
125
+ correctedPlacement = 'bottom-start';
126
+ }
127
+ else if (outsideRight) {
128
+ correctedPlacement = 'bottom-end';
129
+ }
177
130
  }
178
131
  }
179
132
  else {
@@ -190,15 +143,26 @@ const getFloatingProps = (element, parent, placement) => {
190
143
  }
191
144
  else if (placement.startsWith('top')) {
192
145
  if (outsideTop) {
193
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('top', 'bottom');
194
- if (outsideLeft && outsideRight) {
195
- correctedPlacement = 'bottom';
146
+ if (!outsideBottom) {
147
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('top', 'bottom');
148
+ if (outsideLeft && outsideRight) {
149
+ correctedPlacement = 'bottom';
150
+ }
151
+ else if (outsideLeft) {
152
+ correctedPlacement = 'bottom-start';
153
+ }
154
+ else if (outsideRight) {
155
+ correctedPlacement = 'bottom-end';
156
+ }
196
157
  }
197
- else if (outsideLeft) {
198
- correctedPlacement = 'bottom-start';
199
- }
200
- else if (outsideRight) {
201
- correctedPlacement = 'bottom-end';
158
+ else {
159
+ // Both outsideTop and outsideBottom: keep top but still apply horizontal correction
160
+ if (outsideLeft) {
161
+ correctedPlacement = 'top-start';
162
+ }
163
+ else if (outsideRight) {
164
+ correctedPlacement = 'top-end';
165
+ }
202
166
  }
203
167
  }
204
168
  else {
@@ -215,15 +179,17 @@ const getFloatingProps = (element, parent, placement) => {
215
179
  }
216
180
  else if (placement.startsWith('left')) {
217
181
  if (outsideLeft) {
218
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('left', 'right');
219
- if (outsideBottom && outsideTop) {
220
- correctedPlacement = 'right';
221
- }
222
- else if (outsideBottom) {
223
- correctedPlacement = 'right-end';
224
- }
225
- else if (outsideTop) {
226
- correctedPlacement = 'right-start';
182
+ if (!outsideRight) {
183
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('left', 'right');
184
+ if (outsideBottom && outsideTop) {
185
+ correctedPlacement = 'right';
186
+ }
187
+ else if (outsideBottom) {
188
+ correctedPlacement = 'right-end';
189
+ }
190
+ else if (outsideTop) {
191
+ correctedPlacement = 'right-start';
192
+ }
227
193
  }
228
194
  }
229
195
  else {
@@ -240,15 +206,17 @@ const getFloatingProps = (element, parent, placement) => {
240
206
  }
241
207
  else if (correctedPlacement.startsWith('right')) {
242
208
  if (outsideRight) {
243
- correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('right', 'left');
244
- if (outsideBottom && outsideTop) {
245
- correctedPlacement = 'left';
246
- }
247
- else if (outsideBottom) {
248
- correctedPlacement = 'left-end';
249
- }
250
- else if (outsideTop) {
251
- correctedPlacement = 'left-start';
209
+ if (!outsideLeft) {
210
+ correctedPlacement = placement === null || placement === void 0 ? void 0 : placement.replace('right', 'left');
211
+ if (outsideBottom && outsideTop) {
212
+ correctedPlacement = 'left';
213
+ }
214
+ else if (outsideBottom) {
215
+ correctedPlacement = 'left-end';
216
+ }
217
+ else if (outsideTop) {
218
+ correctedPlacement = 'left-start';
219
+ }
252
220
  }
253
221
  }
254
222
  else {
@@ -274,7 +242,8 @@ const getFloatingProps = (element, parent, placement) => {
274
242
  childWidth: childRect.width,
275
243
  correctedPlacement,
276
244
  innerWidth,
277
- innerHeight
245
+ innerHeight,
246
+ outsideYBoth: outsideTop && outsideBottom
278
247
  };
279
248
  };
280
249
  const MAX_ANCESTOR_DEPTH = 10;
@@ -297,15 +266,24 @@ const getAncestorHasCorrectedPlacement = (element) => {
297
266
  return null;
298
267
  };
299
268
  const handleFixedPopover = (element, parent, placement) => {
300
- var _a, _b;
269
+ var _a, _b, _c;
301
270
  if (!element || !parent)
302
271
  return;
303
272
  const parentComputedStyles = getComputedStyle(parent);
304
273
  const parentHasFloatingPosition = ['absolute', 'fixed'].includes(parentComputedStyles.position);
305
274
  const ancestorWithCorrectedPlacement = getAncestorHasCorrectedPlacement(element);
306
275
  const noFloatingAncestor = !ancestorWithCorrectedPlacement && !parentHasFloatingPosition;
307
- const distance = (_b = (_a = getComputedStyle(element)) === null || _a === void 0 ? void 0 : _a.getPropertyValue('--db-popover-distance')) !== null && _b !== void 0 ? _b : '0px';
308
- let { top, height, width, childHeight, childWidth, right, left, bottom, correctedPlacement, innerWidth, innerHeight } = getFloatingProps(element, parent, placement);
276
+ const computedStyle = getComputedStyle(element);
277
+ // We skip if we don't have a floating popover
278
+ if (computedStyle.position !== 'fixed' && computedStyle.position !== 'absolute') {
279
+ return;
280
+ }
281
+ let distance = computedStyle.getPropertyValue('--db-popover-distance');
282
+ if (!distance.length) {
283
+ distance = '0px';
284
+ }
285
+ 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';
286
+ let { top, height, width, childHeight, childWidth, right, left, bottom, correctedPlacement, innerWidth, innerHeight, outsideYBoth } = getFloatingProps(element, parent, elementPlacement);
309
287
  if (ancestorWithCorrectedPlacement) {
310
288
  const ancestorRect = ancestorWithCorrectedPlacement.getBoundingClientRect();
311
289
  left = Math.abs(left - ancestorRect.left);
@@ -353,6 +331,10 @@ const handleFixedPopover = (element, parent, placement) => {
353
331
  }
354
332
  }
355
333
  // Popover position
334
+ // Reset shorthand inset properties from previous calls (e.g. outsideYBoth)
335
+ // before writing new individual inset values
336
+ element.style.insetBlock = '';
337
+ element.style.insetInline = '';
356
338
  if (correctedPlacement === 'right' || correctedPlacement === 'left') {
357
339
  // center horizontally
358
340
  element.style.insetBlockStart = `${top + height / 2}px`;
@@ -401,8 +383,81 @@ const handleFixedPopover = (element, parent, placement) => {
401
383
  element.style.insetBlockStart = `calc(${parentHasFloatingPosition ? end : bottom}px + ${distance})`;
402
384
  element.style.insetBlockEnd = `calc(${noFloatingAncestor && end > innerHeight ? innerHeight : end}px + ${distance})`;
403
385
  }
386
+ // In this case we are outside of top and bottom so we need to scroll
387
+ // We use the full height in this case
388
+ if (outsideYBoth) {
389
+ element.style.overflow = 'hidden auto';
390
+ element.style.insetBlock = distance;
391
+ element.style.maxBlockSize = `calc(${innerHeight}px - 2 * ${distance})`;
392
+ }
393
+ else {
394
+ element.style.overflow = '';
395
+ element.style.maxBlockSize = '';
396
+ }
404
397
  element.style.position = 'fixed';
405
398
  element.dataset['correctedPlacement'] = correctedPlacement;
399
+ // Set data-outside-vy / data-outside-vx for CSS-based flipping
400
+ handleDataOutside(element);
401
+ };
402
+ const handleDataOutside = (el) => {
403
+ const { outTop, outBottom, outLeft, outRight } = isInView(el);
404
+ let dataOutsidePair = {};
405
+ if (outTop || outBottom) {
406
+ dataOutsidePair = {
407
+ vy: outTop ? 'top' : 'bottom'
408
+ };
409
+ el.dataset['outsideVy'] = dataOutsidePair.vy;
410
+ }
411
+ else {
412
+ delete el.dataset['outsideVy'];
413
+ }
414
+ if (outLeft || outRight) {
415
+ dataOutsidePair = Object.assign(Object.assign({}, dataOutsidePair), { vx: outRight ? 'right' : 'left' });
416
+ el.dataset['outsideVx'] = dataOutsidePair.vx;
417
+ }
418
+ else {
419
+ delete el.dataset['outsideVx'];
420
+ }
421
+ return dataOutsidePair;
422
+ };
423
+ const isInView = (el) => {
424
+ var _a;
425
+ const { top, bottom, left, right } = el.getBoundingClientRect();
426
+ const { innerHeight, innerWidth } = window;
427
+ let outTop = top < 0;
428
+ let outBottom = bottom > innerHeight;
429
+ let outLeft = left < 0;
430
+ let outRight = right > innerWidth;
431
+ // We need to check if it was already outside
432
+ const outsideY = el.dataset['outsideVy'];
433
+ const outsideX = el.dataset['outsideVx'];
434
+ const parentRect = (_a = el === null || el === void 0 ? void 0 : el.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
435
+ if (parentRect) {
436
+ if (outsideY) {
437
+ const position = el.dataset['outsideVy'];
438
+ if (position === 'top') {
439
+ outTop = parentRect.top - (bottom - parentRect.bottom) < 0;
440
+ }
441
+ else {
442
+ outBottom = parentRect.bottom + (parentRect.top - top) > innerHeight;
443
+ }
444
+ }
445
+ if (outsideX) {
446
+ const position = el.dataset['outsideVx'];
447
+ if (position === 'left') {
448
+ outLeft = parentRect.left - (right - parentRect.right) < 0;
449
+ }
450
+ else {
451
+ outRight = parentRect.right + (parentRect.left - left) > innerWidth;
452
+ }
453
+ }
454
+ }
455
+ return {
456
+ outTop,
457
+ outBottom,
458
+ outLeft,
459
+ outRight
460
+ };
406
461
  };
407
462
 
408
463
  exports.getFloatingProps = getFloatingProps;
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-BmNxQ4GI.js');
4
- var constants = require('./constants-bMY2_d8A.js');
5
- var documentClickListener = require('./document-click-listener-Bt1Iysz5.js');
6
- var documentScrollListener = require('./document-scroll-listener-Dd_hGebZ.js');
7
- var floatingComponents = require('./floating-components-SpHkZuLA.js');
8
- var navigation = require('./navigation-DUTSDY4q.js');
4
+ var constants = require('./constants-Dy7QIUQi.js');
5
+ var documentClickListener = require('./document-click-listener-DyO00UZC.js');
6
+ var intersectionObserverListener = require('./intersection-observer-listener-BBUA6END.js');
7
+ var floatingComponents = require('./floating-components-Ns3Jt7dw.js');
8
+ require('./resize-observer-listener-B1uhHzqv.js');
9
+ var navigation = require('./navigation-fsWSnlKn.js');
9
10
 
10
11
  const AccordionVariantList = ['divider', 'card'];
11
12
  const AccordionBehaviorList = ['multiple', 'single'];
@@ -148,6 +149,8 @@ exports.DEFAULT_PLACEHOLDER = constants.DEFAULT_PLACEHOLDER;
148
149
  exports.DEFAULT_PLACEHOLDER_ID_SUFFIX = constants.DEFAULT_PLACEHOLDER_ID_SUFFIX;
149
150
  exports.DEFAULT_REMOVE = constants.DEFAULT_REMOVE;
150
151
  exports.DEFAULT_ROWS = constants.DEFAULT_ROWS;
152
+ exports.DEFAULT_SCROLL_LEFT = constants.DEFAULT_SCROLL_LEFT;
153
+ exports.DEFAULT_SCROLL_RIGHT = constants.DEFAULT_SCROLL_RIGHT;
151
154
  exports.DEFAULT_SELECTED = constants.DEFAULT_SELECTED;
152
155
  exports.DEFAULT_SELECT_ID_SUFFIX = constants.DEFAULT_SELECT_ID_SUFFIX;
153
156
  exports.DEFAULT_VALID_MESSAGE = constants.DEFAULT_VALID_MESSAGE;
@@ -167,7 +170,7 @@ Object.defineProperty(exports, "SEMANTIC", {
167
170
  exports.SEMANTICS = constants.SEMANTICS;
168
171
  exports.TESTING_VIEWPORTS = constants.TESTING_VIEWPORTS;
169
172
  exports.DocumentClickListener = documentClickListener.DocumentClickListener;
170
- exports.DocumentScrollListener = documentScrollListener.DocumentScrollListener;
173
+ exports.DocumentScrollListener = intersectionObserverListener.DocumentScrollListener;
171
174
  exports.getFloatingProps = floatingComponents.getFloatingProps;
172
175
  exports.handleDataOutside = floatingComponents.handleDataOutside;
173
176
  exports.handleFixedDropdown = floatingComponents.handleFixedDropdown;
@@ -0,0 +1,101 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-BmNxQ4GI.js');
4
+ var resizeObserverListener = require('./resize-observer-listener-B1uhHzqv.js');
5
+
6
+ /**
7
+ * Generic base class for singleton document event listeners.
8
+ * Manages a shared set of callbacks dispatched when a document-level
9
+ * event fires.
10
+ *
11
+ * Subclasses own their static state (callbacks, instance) and expose
12
+ * it via the abstract accessor methods below.
13
+ *
14
+ * @template TEvent - The event type passed to callbacks (Event, MouseEvent, etc.)
15
+ */
16
+ class AbstractDocumentListener {
17
+ addCallback(callback) {
18
+ const id = index.uuid();
19
+ const callbacks = this.getCallbacks();
20
+ callbacks[id] = callback;
21
+ return id;
22
+ }
23
+ removeCallback(id) {
24
+ const callbacks = this.getCallbacks();
25
+ delete callbacks[id];
26
+ }
27
+ }
28
+
29
+ class DocumentScrollListener extends AbstractDocumentListener {
30
+ static runCallbacks(event) {
31
+ for (const callback of Object.values(DocumentScrollListener.callbacks)) {
32
+ if (typeof callback === 'function') {
33
+ callback(event);
34
+ }
35
+ }
36
+ }
37
+ constructor() {
38
+ super();
39
+ this.ticking = false;
40
+ if (DocumentScrollListener._instance) {
41
+ return DocumentScrollListener._instance;
42
+ }
43
+ DocumentScrollListener._instance = this;
44
+ if (self.document) {
45
+ self.document.addEventListener('scroll', event => {
46
+ if (!this.ticking) {
47
+ window.requestAnimationFrame(() => {
48
+ DocumentScrollListener.runCallbacks(event);
49
+ this.ticking = false;
50
+ });
51
+ this.ticking = true;
52
+ }
53
+ }, true);
54
+ }
55
+ }
56
+ getCallbacks() {
57
+ return DocumentScrollListener.callbacks;
58
+ }
59
+ }
60
+ DocumentScrollListener.callbacks = {};
61
+ DocumentScrollListener._instance = null;
62
+
63
+ class IntersectionObserverListener extends resizeObserverListener.AbstractObserverListener {
64
+ constructor() {
65
+ super();
66
+ if (IntersectionObserverListener._instance) {
67
+ return IntersectionObserverListener._instance;
68
+ }
69
+ IntersectionObserverListener._instance = this;
70
+ if (typeof window !== 'undefined' && 'IntersectionObserver' in window) {
71
+ IntersectionObserverListener.observer = new IntersectionObserver(entries => {
72
+ for (const entry of entries) {
73
+ this.dispatchEntry(entry.target, entry);
74
+ }
75
+ });
76
+ }
77
+ }
78
+ getCallbacksByElement() {
79
+ return IntersectionObserverListener.callbacksByElement;
80
+ }
81
+ getIdToElement() {
82
+ return IntersectionObserverListener.idToElement;
83
+ }
84
+ getObserver() {
85
+ return IntersectionObserverListener.observer;
86
+ }
87
+ observeElement(observer, element) {
88
+ observer.observe(element);
89
+ }
90
+ unobserveElement(observer, element) {
91
+ observer.unobserve(element);
92
+ }
93
+ }
94
+ IntersectionObserverListener._instance = null;
95
+ IntersectionObserverListener.callbacksByElement = new Map();
96
+ IntersectionObserverListener.idToElement = new Map();
97
+ IntersectionObserverListener.observer = null;
98
+
99
+ exports.AbstractDocumentListener = AbstractDocumentListener;
100
+ exports.DocumentScrollListener = DocumentScrollListener;
101
+ exports.IntersectionObserverListener = IntersectionObserverListener;