@react-native-aria/overlays 0.3.10 → 0.3.11

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 (100) hide show
  1. package/lib/commonjs/Portal.js +17 -37
  2. package/lib/commonjs/Portal.js.map +1 -1
  3. package/lib/commonjs/index.js +0 -10
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/index.web.js +0 -10
  6. package/lib/commonjs/index.web.js.map +1 -1
  7. package/lib/commonjs/useOverlay.js +0 -1
  8. package/lib/commonjs/useOverlay.js.map +1 -1
  9. package/lib/commonjs/useOverlay.web.js +9 -11
  10. package/lib/commonjs/useOverlay.web.js.map +1 -1
  11. package/lib/commonjs/useOverlayPosition.js +54 -69
  12. package/lib/commonjs/useOverlayPosition.js.map +1 -1
  13. package/lib/commonjs/useOverlayPosition.web.js +0 -1
  14. package/lib/commonjs/useOverlayPosition.web.js.map +1 -1
  15. package/lib/commonjs/useOverlayTrigger.js +0 -1
  16. package/lib/commonjs/useOverlayTrigger.js.map +1 -1
  17. package/lib/commonjs/useOverlayTrigger.web.js +0 -1
  18. package/lib/commonjs/useOverlayTrigger.web.js.map +1 -1
  19. package/lib/commonjs/usePreventScroll.js +0 -2
  20. package/lib/commonjs/usePreventScroll.js.map +1 -1
  21. package/lib/commonjs/usePreventScroll.web.js +0 -1
  22. package/lib/commonjs/usePreventScroll.web.js.map +1 -1
  23. package/lib/commonjs/utils.js +8 -8
  24. package/lib/commonjs/utils.js.map +1 -1
  25. package/lib/commonjs/web/overlays/index.js +0 -2
  26. package/lib/commonjs/web/overlays/index.js.map +1 -1
  27. package/lib/commonjs/web/overlays/src/calculatePosition.js +35 -68
  28. package/lib/commonjs/web/overlays/src/calculatePosition.js.map +1 -1
  29. package/lib/commonjs/web/overlays/src/index.js +0 -2
  30. package/lib/commonjs/web/overlays/src/index.js.map +1 -1
  31. package/lib/commonjs/web/overlays/src/useCloseOnScroll.js +3 -12
  32. package/lib/commonjs/web/overlays/src/useCloseOnScroll.js.map +1 -1
  33. package/lib/commonjs/web/overlays/src/useOverlayPosition.js +19 -23
  34. package/lib/commonjs/web/overlays/src/useOverlayPosition.js.map +1 -1
  35. package/lib/module/Portal.js +13 -20
  36. package/lib/module/Portal.js.map +1 -1
  37. package/lib/module/index.js.map +1 -1
  38. package/lib/module/index.web.js.map +1 -1
  39. package/lib/module/useOverlay.js.map +1 -1
  40. package/lib/module/useOverlay.web.js +9 -8
  41. package/lib/module/useOverlay.web.js.map +1 -1
  42. package/lib/module/useOverlayPosition.js +55 -60
  43. package/lib/module/useOverlayPosition.js.map +1 -1
  44. package/lib/module/useOverlayPosition.web.js.map +1 -1
  45. package/lib/module/useOverlayTrigger.js.map +1 -1
  46. package/lib/module/useOverlayTrigger.web.js.map +1 -1
  47. package/lib/module/usePreventScroll.js.map +1 -1
  48. package/lib/module/usePreventScroll.web.js.map +1 -1
  49. package/lib/module/utils.js +8 -4
  50. package/lib/module/utils.js.map +1 -1
  51. package/lib/module/web/overlays/index.js +1 -0
  52. package/lib/module/web/overlays/index.js.map +1 -1
  53. package/lib/module/web/overlays/src/calculatePosition.js +34 -57
  54. package/lib/module/web/overlays/src/calculatePosition.js.map +1 -1
  55. package/lib/module/web/overlays/src/index.js +1 -0
  56. package/lib/module/web/overlays/src/index.js.map +1 -1
  57. package/lib/module/web/overlays/src/useCloseOnScroll.js +4 -9
  58. package/lib/module/web/overlays/src/useCloseOnScroll.js.map +1 -1
  59. package/lib/module/web/overlays/src/useOverlayPosition.js +19 -18
  60. package/lib/module/web/overlays/src/useOverlayPosition.js.map +1 -1
  61. package/lib/typescript/Portal.d.ts +4 -2
  62. package/lib/typescript/Portal.d.ts.map +1 -0
  63. package/lib/typescript/index.d.ts +1 -0
  64. package/lib/typescript/index.d.ts.map +1 -0
  65. package/lib/typescript/index.web.d.ts +1 -0
  66. package/lib/typescript/index.web.d.ts.map +1 -0
  67. package/lib/typescript/useOverlay.d.ts +1 -0
  68. package/lib/typescript/useOverlay.d.ts.map +1 -0
  69. package/lib/typescript/useOverlay.web.d.ts +1 -0
  70. package/lib/typescript/useOverlay.web.d.ts.map +1 -0
  71. package/lib/typescript/useOverlayPosition.d.ts +1 -0
  72. package/lib/typescript/useOverlayPosition.d.ts.map +1 -0
  73. package/lib/typescript/useOverlayPosition.web.d.ts +1 -0
  74. package/lib/typescript/useOverlayPosition.web.d.ts.map +1 -0
  75. package/lib/typescript/useOverlayTrigger.d.ts +1 -0
  76. package/lib/typescript/useOverlayTrigger.d.ts.map +1 -0
  77. package/lib/typescript/useOverlayTrigger.web.d.ts +1 -0
  78. package/lib/typescript/useOverlayTrigger.web.d.ts.map +1 -0
  79. package/lib/typescript/usePreventScroll.d.ts +1 -0
  80. package/lib/typescript/usePreventScroll.d.ts.map +1 -0
  81. package/lib/typescript/usePreventScroll.web.d.ts +1 -0
  82. package/lib/typescript/usePreventScroll.web.d.ts.map +1 -0
  83. package/lib/typescript/utils.d.ts +1 -0
  84. package/lib/typescript/utils.d.ts.map +1 -0
  85. package/lib/typescript/web/overlays/index.d.ts +1 -0
  86. package/lib/typescript/web/overlays/index.d.ts.map +1 -0
  87. package/lib/typescript/web/overlays/src/calculatePosition.d.ts +1 -0
  88. package/lib/typescript/web/overlays/src/calculatePosition.d.ts.map +1 -0
  89. package/lib/typescript/web/overlays/src/index.d.ts +1 -0
  90. package/lib/typescript/web/overlays/src/index.d.ts.map +1 -0
  91. package/lib/typescript/web/overlays/src/useCloseOnScroll.d.ts +1 -0
  92. package/lib/typescript/web/overlays/src/useCloseOnScroll.d.ts.map +1 -0
  93. package/lib/typescript/web/overlays/src/useOverlayPosition.d.ts +1 -0
  94. package/lib/typescript/web/overlays/src/useOverlayPosition.d.ts.map +1 -0
  95. package/package.json +2 -1
  96. package/src/useOverlayPosition.ts +37 -17
  97. package/src/utils.ts +1 -0
  98. package/babel.config.js +0 -3
  99. package/scripts/bootstrap.js +0 -24
  100. package/tsconfig.build.json +0 -5
@@ -3,27 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.calculatePositionInternal = calculatePositionInternal;
7
6
  exports.calculatePosition = calculatePosition;
8
-
7
+ exports.calculatePositionInternal = calculatePositionInternal;
9
8
  var _css = _interopRequireDefault(require("dom-helpers/css"));
10
-
11
9
  var _offset = _interopRequireDefault(require("dom-helpers/offset"));
12
-
13
10
  var _position = _interopRequireDefault(require("dom-helpers/position"));
14
-
15
11
  var _scrollLeft = _interopRequireDefault(require("dom-helpers/scrollLeft"));
16
-
17
12
  var _scrollTop = _interopRequireDefault(require("dom-helpers/scrollTop"));
18
-
19
13
  var _ownerDocument = _interopRequireDefault(require("dom-helpers/ownerDocument"));
20
-
21
14
  var _getComputedStyle = _interopRequireDefault(require("dom-helpers/getComputedStyle"));
22
-
23
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
-
25
16
  // @ts-nocheck
26
-
27
17
  /*
28
18
  * Copyright 2020 Adobe. All rights reserved.
29
19
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -35,6 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
35
25
  * OF ANY KIND, either express or implied. See the License for the specific language
36
26
  * governing permissions and limitations under the License.
37
27
  */
28
+
38
29
  const AXIS = {
39
30
  top: 'top',
40
31
  bottom: 'top',
@@ -55,22 +46,19 @@ const AXIS_SIZE = {
55
46
  top: 'height',
56
47
  left: 'width'
57
48
  };
58
- const PARSED_PLACEMENT_CACHE = {}; // @ts-ignore
49
+ const PARSED_PLACEMENT_CACHE = {};
59
50
 
51
+ // @ts-ignore
60
52
  let visualViewport = typeof window !== 'undefined' && window.visualViewport;
61
-
62
53
  function getContainerDimensions(containerNode) {
63
54
  let width = 0,
64
- height = 0,
65
- top = 0,
66
- left = 0;
55
+ height = 0,
56
+ top = 0,
57
+ left = 0;
67
58
  let scroll = {};
68
-
69
59
  if (containerNode.tagName === 'BODY') {
70
- var _visualViewport$width, _visualViewport$heigh;
71
-
72
- width = (_visualViewport$width = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.width) !== null && _visualViewport$width !== void 0 ? _visualViewport$width : document.documentElement.clientWidth;
73
- height = (_visualViewport$heigh = visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.height) !== null && _visualViewport$heigh !== void 0 ? _visualViewport$heigh : document.documentElement.clientHeight;
60
+ width = (visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.width) ?? document.documentElement.clientWidth;
61
+ height = (visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.height) ?? document.documentElement.clientHeight;
74
62
  scroll.top = (0, _scrollTop.default)((0, _ownerDocument.default)(containerNode).documentElement) || (0, _scrollTop.default)(containerNode);
75
63
  scroll.left = (0, _scrollLeft.default)((0, _ownerDocument.default)(containerNode).documentElement) || (0, _scrollLeft.default)(containerNode);
76
64
  } else {
@@ -83,7 +71,6 @@ function getContainerDimensions(containerNode) {
83
71
  scroll.top = (0, _scrollTop.default)(containerNode);
84
72
  scroll.left = (0, _scrollLeft.default)(containerNode);
85
73
  }
86
-
87
74
  return {
88
75
  width,
89
76
  height,
@@ -92,7 +79,6 @@ function getContainerDimensions(containerNode) {
92
79
  left
93
80
  };
94
81
  }
95
-
96
82
  function getScroll(node) {
97
83
  return {
98
84
  top: node.scrollTop,
@@ -101,13 +87,11 @@ function getScroll(node) {
101
87
  height: node.scrollHeight
102
88
  };
103
89
  }
104
-
105
90
  function getDelta(axis, offset, size, containerDimensions, padding) {
106
91
  let containerScroll = containerDimensions.scroll[axis];
107
92
  let containerHeight = containerDimensions[AXIS_SIZE[axis]];
108
93
  let startEdgeOffset = offset - padding - containerScroll;
109
94
  let endEdgeOffset = offset + padding - containerScroll + size;
110
-
111
95
  if (startEdgeOffset < 0) {
112
96
  return -startEdgeOffset;
113
97
  } else if (endEdgeOffset > containerHeight) {
@@ -116,7 +100,6 @@ function getDelta(axis, offset, size, containerDimensions, padding) {
116
100
  return 0;
117
101
  }
118
102
  }
119
-
120
103
  function getMargins(node) {
121
104
  let style = window.getComputedStyle(node);
122
105
  return {
@@ -126,20 +109,16 @@ function getMargins(node) {
126
109
  right: parseInt(style.marginRight, 10) || 0
127
110
  };
128
111
  }
129
-
130
112
  function parsePlacement(input) {
131
113
  if (PARSED_PLACEMENT_CACHE[input]) {
132
114
  return PARSED_PLACEMENT_CACHE[input];
133
115
  }
134
-
135
116
  let [placement, crossPlacement] = input.split(' ');
136
117
  let axis = AXIS[placement] || 'right';
137
118
  let crossAxis = CROSS_AXIS[axis];
138
-
139
119
  if (!AXIS[crossPlacement]) {
140
120
  crossPlacement = 'center';
141
121
  }
142
-
143
122
  let size = AXIS_SIZE[axis];
144
123
  let crossSize = AXIS_SIZE[crossAxis];
145
124
  PARSED_PLACEMENT_CACHE[input] = {
@@ -152,7 +131,6 @@ function parsePlacement(input) {
152
131
  };
153
132
  return PARSED_PLACEMENT_CACHE[input];
154
133
  }
155
-
156
134
  function computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned) {
157
135
  let {
158
136
  placement,
@@ -162,10 +140,10 @@ function computePosition(childOffset, boundaryDimensions, overlaySize, placement
162
140
  size,
163
141
  crossSize
164
142
  } = placementInfo;
165
- let position = {}; // button position
143
+ let position = {};
166
144
 
145
+ // button position
167
146
  position[crossAxis] = childOffset[crossAxis];
168
-
169
147
  if (crossPlacement === 'center') {
170
148
  // + (button size / 2) - (overlay size / 2)
171
149
  // at this point the overlay center should match the button center
@@ -174,27 +152,27 @@ function computePosition(childOffset, boundaryDimensions, overlaySize, placement
174
152
  // + (button size) - (overlay size)
175
153
  // at this point the overlay bottom should match the button bottom
176
154
  position[crossAxis] += childOffset[crossSize] - overlaySize[crossSize];
177
- }
178
- /* else {
179
- the overlay top should match the button top
180
- } */
155
+ } /* else {
156
+ the overlay top should match the button top
157
+ } */
181
158
  // add the crossOffset from props
159
+ position[crossAxis] += crossOffset;
182
160
 
183
-
184
- position[crossAxis] += crossOffset; // // this is button center position - the overlay size + half of the button to align bottom of overlay with button center
161
+ // // this is button center position - the overlay size + half of the button to align bottom of overlay with button center
185
162
  // let minViablePosition =
186
163
  // childOffset[crossAxis] +
187
164
  // childOffset[crossSize] / 2 -
188
165
  // overlaySize[crossSize];
189
166
  // // this is button position of center, aligns top of overlay with button center
190
167
  // let maxViablePosition = childOffset[crossAxis] + childOffset[crossSize] / 2;
168
+
191
169
  // // clamp it into the range of the min/max positions
192
170
  // position[crossAxis] = Math.min(
193
171
  // Math.max(minViablePosition, position[crossAxis]),
194
172
  // maxViablePosition
195
173
  // );
196
- // Floor these so the position isn't placed on a partial pixel, only whole pixels. Shouldn't matter if it was floored or ceiled, so chose one.
197
174
 
175
+ // Floor these so the position isn't placed on a partial pixel, only whole pixels. Shouldn't matter if it was floored or ceiled, so chose one.
198
176
  if (placement === axis) {
199
177
  // If the container is positioned (non-static), then we use the container's actual
200
178
  // height, as `bottom` will be relative to this height. But if the container is static,
@@ -205,36 +183,36 @@ function computePosition(childOffset, boundaryDimensions, overlaySize, placement
205
183
  } else {
206
184
  position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);
207
185
  }
208
-
209
186
  return position;
210
187
  }
211
-
212
188
  function getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding) {
213
- return position.top != null ? // We want the distance between the top of the overlay to the bottom of the boundary
214
- Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top - ( // this is the bottom of the boundary
215
- containerOffsetWithBoundary.top + position.top) - ( // this is the top of the overlay
189
+ return position.top != null ?
190
+ // We want the distance between the top of the overlay to the bottom of the boundary
191
+ Math.max(0, boundaryDimensions.height + boundaryDimensions.top + boundaryDimensions.scroll.top - (
192
+ // this is the bottom of the boundary
193
+ containerOffsetWithBoundary.top + position.top) - (
194
+ // this is the top of the overlay
216
195
  margins.top + margins.bottom + padding) // save additional space for margin and padding
217
- ) : // We want the distance between the top of the trigger to the top of the boundary
218
- Math.max(0, childOffset.top + containerOffsetWithBoundary.top - ( // this is the top of the trigger
219
- boundaryDimensions.top + boundaryDimensions.scroll.top) - ( // this is the top of the boundary
196
+ ) :
197
+ // We want the distance between the top of the trigger to the top of the boundary
198
+ Math.max(0, childOffset.top + containerOffsetWithBoundary.top - (
199
+ // this is the top of the trigger
200
+ boundaryDimensions.top + boundaryDimensions.scroll.top) - (
201
+ // this is the top of the boundary
220
202
  margins.top + margins.bottom + padding) // save additional space for margin and padding
221
203
  );
222
204
  }
223
-
224
205
  function getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding, placementInfo) {
225
206
  let {
226
207
  placement,
227
208
  axis,
228
209
  size
229
210
  } = placementInfo;
230
-
231
211
  if (placement === axis) {
232
212
  return Math.max(0, childOffset[axis] - boundaryDimensions[axis] - boundaryDimensions.scroll[axis] + containerOffsetWithBoundary[axis] - margins[axis] - margins[FLIPPED_DIRECTION[axis]] - padding);
233
213
  }
234
-
235
214
  return Math.max(0, boundaryDimensions[size] + boundaryDimensions[axis] + boundaryDimensions.scroll[axis] - containerOffsetWithBoundary[axis] - childOffset[axis] - childOffset[size] - margins[axis] - margins[FLIPPED_DIRECTION[axis]] - padding);
236
215
  }
237
-
238
216
  function calculatePositionInternal(placementInput, childOffset, overlaySize, scrollSize, margins, padding, flip, boundaryDimensions, containerOffsetWithBoundary, offset, crossOffset, isContainerPositioned, shouldOverlapWithTrigger) {
239
217
  let placementInfo = parsePlacement(placementInput);
240
218
  let {
@@ -247,20 +225,21 @@ function calculatePositionInternal(placementInput, childOffset, overlaySize, scr
247
225
  } = placementInfo;
248
226
  let position = computePosition(childOffset, boundaryDimensions, overlaySize, placementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned);
249
227
  let normalizedOffset = offset;
250
- let space = getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo); // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip
228
+ let space = getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, placementInfo);
251
229
 
230
+ // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip
252
231
  if (flip && scrollSize[size] > space) {
253
232
  let flippedPlacementInfo = parsePlacement(`${FLIPPED_DIRECTION[placement]} ${crossPlacement}`);
254
233
  let flippedPosition = computePosition(childOffset, boundaryDimensions, overlaySize, flippedPlacementInfo, offset, crossOffset, containerOffsetWithBoundary, isContainerPositioned);
255
- let flippedSpace = getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo); // If the available space for the flipped position is greater than the original available space, flip.
234
+ let flippedSpace = getAvailableSpace(boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding + offset, flippedPlacementInfo);
256
235
 
236
+ // If the available space for the flipped position is greater than the original available space, flip.
257
237
  if (flippedSpace > space) {
258
238
  placementInfo = flippedPlacementInfo;
259
239
  position = flippedPosition;
260
240
  normalizedOffset = offset;
261
241
  }
262
242
  }
263
-
264
243
  let delta = getDelta(crossAxis, position[crossAxis], overlaySize[crossSize], boundaryDimensions, padding);
265
244
  position[crossAxis] += delta;
266
245
  let maxHeight = getMaxHeight(position, boundaryDimensions, containerOffsetWithBoundary, childOffset, margins, padding);
@@ -270,11 +249,9 @@ function calculatePositionInternal(placementInput, childOffset, overlaySize, scr
270
249
  position[crossAxis] += delta;
271
250
  let arrowPosition = {};
272
251
  arrowPosition[crossAxis] = childOffset[crossAxis] - position[crossAxis] + childOffset[crossSize] / 2;
273
-
274
252
  if (shouldOverlapWithTrigger) {
275
253
  position[FLIPPED_DIRECTION[placementInfo.placement]] = position[FLIPPED_DIRECTION[placementInfo.placement]] - childOffset[size];
276
254
  }
277
-
278
255
  return {
279
256
  position,
280
257
  maxHeight: maxHeight,
@@ -283,11 +260,10 @@ function calculatePositionInternal(placementInput, childOffset, overlaySize, scr
283
260
  placement: placementInfo.placement
284
261
  };
285
262
  }
263
+
286
264
  /**
287
265
  * Determines where to place the overlay with regards to the target and the position of an optional indicator.
288
266
  */
289
-
290
-
291
267
  function calculatePosition(opts) {
292
268
  let {
293
269
  placement,
@@ -306,12 +282,10 @@ function calculatePosition(opts) {
306
282
  const containerPositionStyle = window.getComputedStyle(container).position;
307
283
  let isContainerPositioned = !!containerPositionStyle && containerPositionStyle !== 'static';
308
284
  let childOffset = isBodyContainer ? (0, _offset.default)(targetNode) : (0, _position.default)(targetNode, container);
309
-
310
285
  if (!isBodyContainer) {
311
286
  childOffset.top += parseInt((0, _css.default)(targetNode, 'marginTop'), 10) || 0;
312
287
  childOffset.left += parseInt((0, _css.default)(targetNode, 'marginLeft'), 10) || 0;
313
288
  }
314
-
315
289
  let overlaySize = (0, _offset.default)(overlayNode);
316
290
  const matrix = (0, _getComputedStyle.default)(overlayNode).getPropertyValue('transform');
317
291
  const transform = matrix;
@@ -319,32 +293,25 @@ function calculatePosition(opts) {
319
293
  const matches = transform.match(regex);
320
294
  let scaleX = 1;
321
295
  let scaleY = 1;
322
-
323
296
  if (matches) {
324
297
  scaleX = parseFloat(matches[1]);
325
298
  scaleY = parseFloat(matches[4]);
326
-
327
299
  if (!scaleX || !Number.isFinite(scaleX)) {
328
300
  scaleX = 1;
329
301
  }
330
-
331
302
  if (!scaleY || !Number.isFinite(scaleY)) {
332
303
  scaleY = 1;
333
304
  }
334
305
  }
335
-
336
306
  let margins = getMargins(overlayNode);
337
307
  overlaySize.width += margins.left + margins.right;
338
308
  overlaySize.height += margins.top + margins.bottom;
339
-
340
309
  if (scaleX) {
341
310
  overlaySize.width = overlaySize.width / scaleX;
342
311
  }
343
-
344
312
  if (scaleY) {
345
313
  overlaySize.height = overlaySize.height / scaleY;
346
314
  }
347
-
348
315
  let scrollSize = getScroll(scrollNode);
349
316
  let boundaryDimensions = getContainerDimensions(boundaryElement);
350
317
  let containerOffsetWithBoundary = boundaryElement.tagName === 'BODY' ? (0, _offset.default)(container) : (0, _position.default)(container, boundaryElement);
@@ -1 +1 @@
1
- {"version":3,"sources":["calculatePosition.ts"],"names":["AXIS","top","bottom","left","right","FLIPPED_DIRECTION","CROSS_AXIS","AXIS_SIZE","PARSED_PLACEMENT_CACHE","visualViewport","window","getContainerDimensions","containerNode","width","height","scroll","tagName","document","documentElement","clientWidth","clientHeight","getScroll","node","scrollTop","scrollLeft","scrollWidth","scrollHeight","getDelta","axis","offset","size","containerDimensions","padding","containerScroll","containerHeight","startEdgeOffset","endEdgeOffset","Math","max","getMargins","style","getComputedStyle","parseInt","marginTop","marginBottom","marginLeft","marginRight","parsePlacement","input","placement","crossPlacement","split","crossAxis","crossSize","computePosition","childOffset","boundaryDimensions","overlaySize","placementInfo","crossOffset","containerOffsetWithBoundary","isContainerPositioned","position","floor","getMaxHeight","margins","getAvailableSpace","calculatePositionInternal","placementInput","scrollSize","flip","shouldOverlapWithTrigger","normalizedOffset","space","flippedPlacementInfo","flippedPosition","flippedSpace","delta","maxHeight","min","arrowPosition","arrowOffsetLeft","arrowOffsetTop","calculatePosition","opts","targetNode","overlayNode","scrollNode","shouldFlip","boundaryElement","container","offsetParent","body","isBodyContainer","containerPositionStyle","matrix","getPropertyValue","transform","regex","matches","match","scaleX","scaleY","parseFloat","Number","isFinite"],"mappings":";;;;;;;;AAmBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAzBA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoEA,MAAMA,IAAI,GAAG;AACXC,EAAAA,GAAG,EAAE,KADM;AAEXC,EAAAA,MAAM,EAAE,KAFG;AAGXC,EAAAA,IAAI,EAAE,MAHK;AAIXC,EAAAA,KAAK,EAAE;AAJI,CAAb;AAOA,MAAMC,iBAAiB,GAAG;AACxBJ,EAAAA,GAAG,EAAE,QADmB;AAExBC,EAAAA,MAAM,EAAE,KAFgB;AAGxBC,EAAAA,IAAI,EAAE,OAHkB;AAIxBC,EAAAA,KAAK,EAAE;AAJiB,CAA1B;AA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,kBAR8B,EAS9BI,2BAT8B,EAU9B/B,MAV8B,EAW9B8B,WAX8B,EAY9BE,qBAZ8B,EAa9BU,wBAb8B,CAAhC;AAeD","sourcesContent":["// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n Axis,\n Placement,\n PlacementAxis,\n SizeAxis,\n} from '@react-types/overlays';\nimport getCss from 'dom-helpers/css';\nimport getOffset from 'dom-helpers/offset';\nimport getPosition from 'dom-helpers/position';\nimport getScrollLeft from 'dom-helpers/scrollLeft';\nimport getScrollTop from 'dom-helpers/scrollTop';\nimport ownerDocument from 'dom-helpers/ownerDocument';\nimport getComputedStyle from 'dom-helpers/getComputedStyle';\n\ninterface Position {\n top?: number;\n left?: number;\n bottom?: number;\n right?: number;\n}\n\ninterface Dimensions {\n width: number;\n height: number;\n top: number;\n left: number;\n scroll: Position;\n}\n\ninterface ParsedPlacement {\n placement: PlacementAxis;\n crossPlacement: PlacementAxis;\n axis: Axis;\n crossAxis: Axis;\n size: SizeAxis;\n crossSize: SizeAxis;\n}\n\ninterface Offset {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\ninterface PositionOpts {\n placement: Placement;\n targetNode: HTMLElement;\n overlayNode: HTMLElement;\n scrollNode: HTMLElement;\n padding: number;\n shouldFlip: boolean;\n boundaryElement: HTMLElement;\n offset: number;\n crossOffset: number;\n shouldOverlapWithTrigger: boolean;\n}\n\nexport interface PositionResult {\n position?: Position;\n arrowOffsetLeft?: number;\n arrowOffsetTop?: number;\n maxHeight?: number;\n placement: PlacementAxis;\n}\n\nconst AXIS = {\n top: 'top',\n bottom: 'top',\n left: 'left',\n right: 'left',\n};\n\nconst FLIPPED_DIRECTION = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n};\n\nconst CROSS_AXIS = {\n top: 'left',\n left: 'top',\n};\n\nconst AXIS_SIZE = {\n top: 'height',\n left: 'width',\n};\n\nconst PARSED_PLACEMENT_CACHE = {};\n\n// @ts-ignore\nlet visualViewport = typeof window !== 'undefined' && window.visualViewport;\n\nfunction getContainerDimensions(containerNode: Element): Dimensions {\n let width = 0,\n height = 0,\n top = 0,\n left = 0;\n let scroll: Position = {};\n\n if (containerNode.tagName === 'BODY') {\n width = visualViewport?.width ?? document.documentElement.clientWidth;\n height = visualViewport?.height ?? document.documentElement.clientHeight;\n\n scroll.top =\n getScrollTop(ownerDocument(containerNode).documentElement) ||\n getScrollTop(containerNode);\n scroll.left =\n getScrollLeft(ownerDocument(containerNode).documentElement) ||\n getScrollLeft(containerNode);\n } else {\n ({ width, height, top, left } = getOffset(containerNode));\n scroll.top = getScrollTop(containerNode);\n scroll.left = getScrollLeft(containerNode);\n }\n\n return { width, height, scroll, top, left };\n}\n\nfunction getScroll(node: HTMLElement): Offset {\n return {\n top: node.scrollTop,\n left: node.scrollLeft,\n width: node.scrollWidth,\n height: node.scrollHeight,\n };\n}\n\nfunction getDelta(\n axis: Axis,\n offset: number,\n size: number,\n containerDimensions: Dimensions,\n padding: number\n) {\n let containerScroll = containerDimensions.scroll[axis];\n let containerHeight = containerDimensions[AXIS_SIZE[axis]];\n\n let startEdgeOffset = offset - padding - containerScroll;\n let endEdgeOffset = offset + padding - containerScroll + size;\n\n if (startEdgeOffset < 0) {\n return -startEdgeOffset;\n } else if (endEdgeOffset > containerHeight) {\n return Math.max(containerHeight - endEdgeOffset, -startEdgeOffset);\n } else {\n return 0;\n }\n}\n\nfunction getMargins(node: HTMLElement): Position {\n let style = window.getComputedStyle(node);\n return {\n top: parseInt(style.marginTop, 10) || 0,\n bottom: parseInt(style.marginBottom, 10) || 0,\n left: parseInt(style.marginLeft, 10) || 0,\n right: parseInt(style.marginRight, 10) || 0,\n };\n}\n\nfunction parsePlacement(input: Placement): ParsedPlacement {\n if (PARSED_PLACEMENT_CACHE[input]) {\n return PARSED_PLACEMENT_CACHE[input];\n }\n\n let [placement, crossPlacement] = input.split(' ');\n let axis: Axis = AXIS[placement] || 'right';\n let crossAxis: Axis = CROSS_AXIS[axis];\n\n if (!AXIS[crossPlacement]) {\n crossPlacement = 'center';\n }\n\n let size = AXIS_SIZE[axis];\n let crossSize = AXIS_SIZE[crossAxis];\n PARSED_PLACEMENT_CACHE[input] = {\n placement,\n crossPlacement,\n axis,\n crossAxis,\n size,\n crossSize,\n };\n return PARSED_PLACEMENT_CACHE[input];\n}\n\nfunction computePosition(\n childOffset: Offset,\n boundaryDimensions: Dimensions,\n overlaySize: Offset,\n placementInfo: ParsedPlacement,\n offset: number,\n crossOffset: number,\n containerOffsetWithBoundary: Offset,\n isContainerPositioned: boolean\n) {\n let {\n placement,\n crossPlacement,\n axis,\n crossAxis,\n size,\n crossSize,\n } = placementInfo;\n let position: Position = {};\n\n // button position\n position[crossAxis] = childOffset[crossAxis];\n\n if (crossPlacement === 'center') {\n // + (button size / 2) - (overlay size / 2)\n // at this point the overlay center should match the button center\n position[crossAxis] +=\n (childOffset[crossSize] - overlaySize[crossSize]) / 2;\n } else if (crossPlacement !== crossAxis) {\n // + (button size) - (overlay size)\n // at this point the overlay bottom should match the button bottom\n position[crossAxis] += childOffset[crossSize] - overlaySize[crossSize];\n } /* else {\n the overlay top should match the button top\n } */\n // add the crossOffset from props\n position[crossAxis] += crossOffset;\n\n // // this is button center position - the overlay size + half of the button to align bottom of overlay with button center\n // let minViablePosition =\n // childOffset[crossAxis] +\n // childOffset[crossSize] / 2 -\n // overlaySize[crossSize];\n // // this is button position of center, aligns top of overlay with button center\n // let maxViablePosition = childOffset[crossAxis] + childOffset[crossSize] / 2;\n\n // // clamp it into the range of the min/max positions\n // position[crossAxis] = Math.min(\n // Math.max(minViablePosition, position[crossAxis]),\n // maxViablePosition\n // );\n\n // Floor these so the position isn't placed on a partial pixel, only whole pixels. Shouldn't matter if it was floored or ceiled, so chose one.\n if (placement === axis) {\n // If the container is positioned (non-static), then we use the container's actual\n // height, as `bottom` will be relative to this height. But if the container is static,\n // then it can only be the `document.body`, and `bottom` will be relative to _its_\n // container, which should be as large as boundaryDimensions.\n const containerHeight = isContainerPositioned\n ? containerOffsetWithBoundary[size]\n : boundaryDimensions[size];\n position[FLIPPED_DIRECTION[axis]] = Math.floor(\n containerHeight - childOffset[axis] + offset\n );\n } else {\n position[axis] = Math.floor(childOffset[axis] + childOffset[size] + offset);\n }\n\n return position;\n}\n\nfunction getMaxHeight(\n position: Position,\n boundaryDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n childOffset: Offset,\n margins: Position,\n padding: number\n) {\n return position.top != null\n ? // We want the distance between the top of the overlay to the bottom of the boundary\n Math.max(\n 0,\n boundaryDimensions.height +\n boundaryDimensions.top +\n boundaryDimensions.scroll.top - // this is the bottom of the boundary\n (containerOffsetWithBoundary.top + position.top) - // this is the top of the overlay\n (margins.top + margins.bottom + padding) // save additional space for margin and padding\n )\n : // We want the distance between the top of the trigger to the top of the boundary\n Math.max(\n 0,\n childOffset.top +\n containerOffsetWithBoundary.top - // this is the top of the trigger\n (boundaryDimensions.top + boundaryDimensions.scroll.top) - // this is the top of the boundary\n (margins.top + margins.bottom + padding) // save additional space for margin and padding\n );\n}\n\nfunction getAvailableSpace(\n boundaryDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n childOffset: Offset,\n margins: Position,\n padding: number,\n placementInfo: ParsedPlacement\n) {\n let { placement, axis, size } = placementInfo;\n if (placement === axis) {\n return Math.max(\n 0,\n childOffset[axis] -\n boundaryDimensions[axis] -\n boundaryDimensions.scroll[axis] +\n containerOffsetWithBoundary[axis] -\n margins[axis] -\n margins[FLIPPED_DIRECTION[axis]] -\n padding\n );\n }\n\n return Math.max(\n 0,\n boundaryDimensions[size] +\n boundaryDimensions[axis] +\n boundaryDimensions.scroll[axis] -\n containerOffsetWithBoundary[axis] -\n childOffset[axis] -\n childOffset[size] -\n margins[axis] -\n margins[FLIPPED_DIRECTION[axis]] -\n padding\n );\n}\n\nexport function calculatePositionInternal(\n placementInput: Placement,\n childOffset: Offset,\n overlaySize: Offset,\n scrollSize: Offset,\n margins: Position,\n padding: number,\n flip: boolean,\n boundaryDimensions: Dimensions,\n containerOffsetWithBoundary: Offset,\n offset: number,\n crossOffset: number,\n isContainerPositioned: boolean,\n shouldOverlapWithTrigger: boolean\n): PositionResult {\n let placementInfo = parsePlacement(placementInput);\n let {\n size,\n crossAxis,\n crossSize,\n placement,\n crossPlacement,\n axis,\n } = placementInfo;\n let position = computePosition(\n childOffset,\n boundaryDimensions,\n overlaySize,\n placementInfo,\n offset,\n crossOffset,\n containerOffsetWithBoundary,\n isContainerPositioned\n );\n\n let normalizedOffset = offset;\n let space = getAvailableSpace(\n boundaryDimensions,\n containerOffsetWithBoundary,\n childOffset,\n margins,\n padding + offset,\n placementInfo\n );\n\n // Check if the scroll size of the overlay is greater than the available space to determine if we need to flip\n if (flip && scrollSize[size] > space) {\n let flippedPlacementInfo = parsePlacement(\n `${FLIPPED_DIRECTION[placement]} ${crossPlacement}` as Placement\n );\n let flippedPosition = computePosition(\n childOffset,\n boundaryDimensions,\n overlaySize,\n flippedPlacementInfo,\n offset,\n crossOffset,\n containerOffsetWithBoundary,\n isContainerPositioned\n );\n let flippedSpace = getAvailableSpace(\n boundaryDimensions,\n containerOffsetWithBoundary,\n childOffset,\n margins,\n padding + offset,\n flippedPlacementInfo\n );\n\n // If the available space for the flipped position is greater than the original available space, flip.\n if (flippedSpace > space) {\n placementInfo = flippedPlacementInfo;\n position = flippedPosition;\n normalizedOffset = offset;\n }\n }\n\n let delta = getDelta(\n crossAxis,\n position[crossAxis],\n overlaySize[crossSize],\n boundaryDimensions,\n padding\n );\n position[crossAxis] += delta;\n\n let maxHeight = getMaxHeight(\n position,\n boundaryDimensions,\n containerOffsetWithBoundary,\n childOffset,\n margins,\n padding\n );\n\n overlaySize.height = Math.min(overlaySize.height, maxHeight);\n\n position = computePosition(\n childOffset,\n boundaryDimensions,\n overlaySize,\n placementInfo,\n normalizedOffset,\n crossOffset,\n containerOffsetWithBoundary,\n isContainerPositioned\n );\n delta = getDelta(\n crossAxis,\n position[crossAxis],\n overlaySize[crossSize],\n boundaryDimensions,\n padding\n );\n position[crossAxis] += delta;\n\n let arrowPosition: Position = {};\n arrowPosition[crossAxis] =\n childOffset[crossAxis] - position[crossAxis] + childOffset[crossSize] / 2;\n\n if (shouldOverlapWithTrigger) {\n position[FLIPPED_DIRECTION[placementInfo.placement]] =\n position[FLIPPED_DIRECTION[placementInfo.placement]] - childOffset[size];\n }\n\n return {\n position,\n maxHeight: maxHeight,\n arrowOffsetLeft: arrowPosition.left,\n arrowOffsetTop: arrowPosition.top,\n placement: placementInfo.placement,\n };\n}\n\n/**\n * Determines where to place the overlay with regards to the target and the position of an optional indicator.\n */\nexport function calculatePosition(opts: PositionOpts): PositionResult {\n let {\n placement,\n targetNode,\n overlayNode,\n scrollNode,\n padding,\n shouldFlip,\n boundaryElement,\n offset,\n crossOffset,\n shouldOverlapWithTrigger,\n } = opts;\n\n let container = overlayNode.offsetParent || document.body;\n let isBodyContainer = container.tagName === 'BODY';\n const containerPositionStyle = window.getComputedStyle(container).position;\n let isContainerPositioned =\n !!containerPositionStyle && containerPositionStyle !== 'static';\n let childOffset: Offset = isBodyContainer\n ? getOffset(targetNode)\n : getPosition(targetNode, container);\n\n if (!isBodyContainer) {\n childOffset.top += parseInt(getCss(targetNode, 'marginTop'), 10) || 0;\n childOffset.left += parseInt(getCss(targetNode, 'marginLeft'), 10) || 0;\n }\n\n let overlaySize: Offset = getOffset(overlayNode);\n const matrix = getComputedStyle(overlayNode).getPropertyValue('transform');\n const transform = matrix;\n const regex = /matrix\\((-?\\d*\\.?\\d+),\\s*(-?\\d*\\.?\\d+),\\s*(-?\\d*\\.?\\d+),\\s*(-?\\d*\\.?\\d+),\\s*(-?\\d*\\.?\\d+),\\s*(-?\\d*\\.?\\d+)\\)/;\n const matches = transform.match(regex);\n let scaleX = 1;\n let scaleY = 1;\n\n if (matches) {\n scaleX = parseFloat(matches[1]);\n scaleY = parseFloat(matches[4]);\n if (!scaleX || !Number.isFinite(scaleX)) {\n scaleX = 1;\n }\n\n if (!scaleY || !Number.isFinite(scaleY)) {\n scaleY = 1;\n }\n }\n\n let margins = getMargins(overlayNode);\n overlaySize.width += margins.left + margins.right;\n overlaySize.height += margins.top + margins.bottom;\n\n if (scaleX) {\n overlaySize.width = overlaySize.width / scaleX;\n }\n if (scaleY) {\n overlaySize.height = overlaySize.height / scaleY;\n }\n\n let scrollSize = getScroll(scrollNode);\n let boundaryDimensions = getContainerDimensions(boundaryElement);\n let containerOffsetWithBoundary: Offset =\n boundaryElement.tagName === 'BODY'\n ? getOffset(container)\n : getPosition(container, boundaryElement);\n\n return calculatePositionInternal(\n placement,\n childOffset,\n overlaySize,\n scrollSize,\n margins,\n padding,\n shouldFlip,\n boundaryDimensions,\n containerOffsetWithBoundary,\n offset,\n crossOffset,\n isContainerPositioned,\n shouldOverlapWithTrigger\n );\n}\n"]}
1
+ {"version":3,"names":["_css","_interopRequireDefault","require","_offset","_position","_scrollLeft","_scrollTop","_ownerDocument","_getComputedStyle","obj","__esModule","default","AXIS","top","bottom","left","right","FLIPPED_DIRECTION","CROSS_AXIS","AXIS_SIZE","PARSED_PLACEMENT_CACHE","visualViewport","window","getContainerDimensions","containerNode","width","height","scroll","tagName","document","documentElement","clientWidth","clientHeight","getScrollTop","ownerDocument","getScrollLeft","getOffset","getScroll","node","scrollTop","scrollLeft","scrollWidth","scrollHeight","getDelta","axis","offset","size","containerDimensions","padding","containerScroll","containerHeight","startEdgeOffset","endEdgeOffset","Math","max","getMargins","style","getComputedStyle","parseInt","marginTop","marginBottom","marginLeft","marginRight","parsePlacement","input","placement","crossPlacement","split","crossAxis","crossSize","computePosition","childOffset","boundaryDimensions","overlaySize","placementInfo","crossOffset","containerOffsetWithBoundary","isContainerPositioned","position","floor","getMaxHeight","margins","getAvailableSpace","calculatePositionInternal","placementInput","scrollSize","flip","shouldOverlapWithTrigger","normalizedOffset","space","flippedPlacementInfo","flippedPosition","flippedSpace","delta","maxHeight","min","arrowPosition","arrowOffsetLeft","arrowOffsetTop","calculatePosition","opts","targetNode","overlayNode","scrollNode","shouldFlip","boundaryElement","container","offsetParent","body","isBodyContainer","containerPositionStyle","getPosition","getCss","matrix","getPropertyValue","transform","regex","matches","match","scaleX","scaleY","parseFloat","Number","isFinite"],"sourceRoot":"../../../../../src","sources":["web/overlays/src/calculatePosition.ts"],"mappings":";;;;;;;AAmBA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,cAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,iBAAA,GAAAP,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAQ,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAzB5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoEA,MAAMG,IAAI,GAAG;EACXC,GAAG,EAAE,KAAK;EACVC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAC;AAED,MAAMC,iBAAiB,GAAG;EACxBJ,GAAG,EAAE,QAAQ;EACbC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,OAAO;EACbC,KAAK,EAAE;AACT,CAAC;AAED,MAA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AAE;IACV/C,WAAW,CAAC/C,MAAM,GAAG+C,WAAW,CAAC/C,MAAM,GAAG8F,MAAM;EAClD;EAEA,IAAInC,UAAU,GAAGhD,SAAS,CAACkE,UAAU,CAAC;EACtC,IAAI/B,kBAAkB,GAAGjD,sBAAsB,CAACkF,eAAe,CAAC;EAChE,IAAI7B,2BAAmC,GACrC6B,eAAe,CAAC7E,OAAO,KAAK,MAAM,GAC9B,IAAAQ,eAAS,EAACsE,SAAS,CAAC,GACpB,IAAAK,iBAAW,EAACL,SAAS,EAAED,eAAe,CAAC;EAE7C,OAAOtB,yBAAyB,CAC9BlB,SAAS,EACTM,WAAW,EACXE,WAAW,EACXY,UAAU,EACVJ,OAAO,EACPjC,OAAO,EACPwD,UAAU,EACVhC,kBAAkB,EAClBI,2BAA2B,EAC3B/B,MAAM,EACN8B,WAAW,EACXE,qBAAqB,EACrBU,wBACF,CAAC;AACH"}
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _useOverlayPosition = require("./useOverlayPosition");
8
-
9
7
  Object.keys(_useOverlayPosition).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _useOverlayPosition[key]) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAYA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useOverlayPosition';\n"]}
1
+ {"version":3,"names":["_useOverlayPosition","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../../../src","sources":["web/overlays/src/index.ts"],"mappings":";;;;;AAYA,IAAAA,mBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,mBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,mBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,mBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
@@ -3,13 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useCloseOnScroll = useCloseOnScroll;
7
6
  exports.onCloseMap = void 0;
8
-
7
+ exports.useCloseOnScroll = useCloseOnScroll;
9
8
  var _react = require("react");
10
-
11
9
  //@ts-nocheck
12
-
13
10
  /*
14
11
  * Copyright 2020 Adobe. All rights reserved.
15
12
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -21,14 +18,13 @@ var _react = require("react");
21
18
  * OF ANY KIND, either express or implied. See the License for the specific language
22
19
  * governing permissions and limitations under the License.
23
20
  */
21
+
24
22
  // This behavior moved from useOverlayTrigger to useOverlayPosition.
25
23
  // For backward compatibility, where useOverlayTrigger handled hiding the popover on close,
26
24
  // it sets a close function here mapped from the trigger element. This way we can avoid
27
25
  // forcing users to pass an onClose function to useOverlayPosition which could be considered
28
26
  // a breaking change.
29
- const onCloseMap = new WeakMap();
30
- exports.onCloseMap = onCloseMap;
31
-
27
+ const onCloseMap = exports.onCloseMap = new WeakMap();
32
28
  /** @private */
33
29
  function useCloseOnScroll(opts) {
34
30
  let {
@@ -40,22 +36,17 @@ function useCloseOnScroll(opts) {
40
36
  if (!isOpen) {
41
37
  return;
42
38
  }
43
-
44
39
  let onScroll = e => {
45
40
  // Ignore if scrolling an scrollable region outside the trigger's tree.
46
41
  let target = e.target;
47
-
48
42
  if (!triggerRef.current || !target.contains(triggerRef.current)) {
49
43
  return;
50
44
  }
51
-
52
45
  let onCloseHandler = onClose || onCloseMap.get(triggerRef.current);
53
-
54
46
  if (onCloseHandler) {
55
47
  onCloseHandler();
56
48
  }
57
49
  };
58
-
59
50
  window.addEventListener('scroll', onScroll, true);
60
51
  return () => {
61
52
  window.removeEventListener('scroll', onScroll, true);
@@ -1 +1 @@
1
- {"version":3,"sources":["useCloseOnScroll.ts"],"names":["onCloseMap","WeakMap","useCloseOnScroll","opts","triggerRef","isOpen","onClose","onScroll","e","target","current","contains","onCloseHandler","get","window","addEventListener","removeEventListener"],"mappings":";;;;;;;;AAaA;;AAbA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAA4C,GAAG,IAAIC,OAAJ,EAArD;;;AAQP;AACO,SAASC,gBAAT,CAA0BC,IAA1B,EAAsD;AAC3D,MAAI;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,MAAd;AAAsBC,IAAAA;AAAtB,MAAkCH,IAAtC;AAEA,wBAAU,MAAM;AACd,QAAI,CAACE,MAAL,EAAa;AACX;AACD;;AAED,QAAIE,QAAQ,GAAIC,CAAD,IAAmB;AAChC;AACA,UAAIC,MAAM,GAAGD,CAAC,CAACC,MAAf;;AACA,UAAI,CAACL,UAAU,CAACM,OAAZ,IAAuB,CAACD,MAAM,CAACE,QAAP,CAAgBP,UAAU,CAACM,OAA3B,CAA5B,EAAiE;AAC/D;AACD;;AAED,UAAIE,cAAc,GAAGN,OAAO,IAAIN,UAAU,CAACa,GAAX,CAAeT,UAAU,CAACM,OAA1B,CAAhC;;AACA,UAAIE,cAAJ,EAAoB;AAClBA,QAAAA,cAAc;AACf;AACF,KAXD;;AAaAE,IAAAA,MAAM,CAACC,gBAAP,CAAwB,QAAxB,EAAkCR,QAAlC,EAA4C,IAA5C;AACA,WAAO,MAAM;AACXO,MAAAA,MAAM,CAACE,mBAAP,CAA2B,QAA3B,EAAqCT,QAArC,EAA+C,IAA/C;AACD,KAFD;AAGD,GAtBD,EAsBG,CAACF,MAAD,EAASC,OAAT,EAAkBF,UAAlB,CAtBH;AAuBD","sourcesContent":["//@ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { RefObject, useEffect } from 'react';\n\n// This behavior moved from useOverlayTrigger to useOverlayPosition.\n// For backward compatibility, where useOverlayTrigger handled hiding the popover on close,\n// it sets a close function here mapped from the trigger element. This way we can avoid\n// forcing users to pass an onClose function to useOverlayPosition which could be considered\n// a breaking change.\nexport const onCloseMap: WeakMap<HTMLElement, () => void> = new WeakMap();\n\ninterface CloseOnScrollOptions {\n triggerRef: RefObject<HTMLElement>;\n isOpen?: boolean;\n onClose?: () => void;\n}\n\n/** @private */\nexport function useCloseOnScroll(opts: CloseOnScrollOptions) {\n let { triggerRef, isOpen, onClose } = opts;\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n let onScroll = (e: MouseEvent) => {\n // Ignore if scrolling an scrollable region outside the trigger's tree.\n let target = e.target as HTMLElement;\n if (!triggerRef.current || !target.contains(triggerRef.current)) {\n return;\n }\n\n let onCloseHandler = onClose || onCloseMap.get(triggerRef.current);\n if (onCloseHandler) {\n onCloseHandler();\n }\n };\n\n window.addEventListener('scroll', onScroll, true);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n };\n }, [isOpen, onClose, triggerRef]);\n}\n"]}
1
+ {"version":3,"names":["_react","require","onCloseMap","exports","WeakMap","useCloseOnScroll","opts","triggerRef","isOpen","onClose","useEffect","onScroll","e","target","current","contains","onCloseHandler","get","window","addEventListener","removeEventListener"],"sourceRoot":"../../../../../src","sources":["web/overlays/src/useCloseOnScroll.ts"],"mappings":";;;;;;;AAaA,IAAAA,MAAA,GAAAC,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMC,UAA4C,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIE,OAAO,CAAC,CAAC;AAQzE;AACO,SAASC,gBAAgBA,CAACC,IAA0B,EAAE;EAC3D,IAAI;IAAEC,UAAU;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,IAAI;EAE1C,IAAAI,gBAAS,EAAC,MAAM;IACd,IAAI,CAACF,MAAM,EAAE;MACX;IACF;IAEA,IAAIG,QAAQ,GAAIC,CAAa,IAAK;MAChC;MACA,IAAIC,MAAM,GAAGD,CAAC,CAACC,MAAqB;MACpC,IAAI,CAACN,UAAU,CAACO,OAAO,IAAI,CAACD,MAAM,CAACE,QAAQ,CAACR,UAAU,CAACO,OAAO,CAAC,EAAE;QAC/D;MACF;MAEA,IAAIE,cAAc,GAAGP,OAAO,IAAIP,UAAU,CAACe,GAAG,CAACV,UAAU,CAACO,OAAO,CAAC;MAClE,IAAIE,cAAc,EAAE;QAClBA,cAAc,CAAC,CAAC;MAClB;IACF,CAAC;IAEDE,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAER,QAAQ,EAAE,IAAI,CAAC;IACjD,OAAO,MAAM;MACXO,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAET,QAAQ,EAAE,IAAI,CAAC;IACtD,CAAC;EACH,CAAC,EAAE,CAACH,MAAM,EAAEC,OAAO,EAAEF,UAAU,CAAC,CAAC;AACnC"}
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useOverlayPosition = useOverlayPosition;
7
-
8
7
  var _calculatePosition = require("./calculatePosition");
9
-
10
8
  var _react = require("react");
11
-
12
9
  var _useCloseOnScroll = require("./useCloseOnScroll");
13
-
14
10
  var _utils = require("@react-native-aria/utils");
15
-
16
11
  //@ts-nocheck
17
-
18
12
  /*
19
13
  * Copyright 2020 Adobe. All rights reserved.
20
14
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -26,16 +20,16 @@ var _utils = require("@react-native-aria/utils");
26
20
  * OF ANY KIND, either express or implied. See the License for the specific language
27
21
  * governing permissions and limitations under the License.
28
22
  */
23
+
29
24
  // @ts-ignore
30
25
  let visualViewport = typeof window !== 'undefined' && window.visualViewport;
26
+
31
27
  /**
32
28
  * Handles positioning overlays like popovers and menus relative to a trigger
33
29
  * element, and updating the position when the window resizes.
34
30
  */
35
-
36
31
  function useOverlayPosition(props) {
37
32
  var _targetRef$current, _targetRef$current2;
38
-
39
33
  const direction = (0, _utils.isRTL)() ? 'rtl' : undefined;
40
34
  let {
41
35
  targetRef,
@@ -64,7 +58,6 @@ function useOverlayPosition(props) {
64
58
  if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !scrollRef.current || !boundaryElement) {
65
59
  return;
66
60
  }
67
-
68
61
  setPosition((0, _calculatePosition.calculatePosition)({
69
62
  placement: translateRTL(placement, direction),
70
63
  overlayNode: overlayRef.current,
@@ -77,17 +70,19 @@ function useOverlayPosition(props) {
77
70
  crossOffset,
78
71
  shouldOverlapWithTrigger
79
72
  }));
80
- }, deps); // Update position when anything changes
73
+ }, deps);
81
74
 
82
- (0, _utils.useLayoutEffect)(updatePosition, deps); // Update position on window resize
75
+ // Update position when anything changes
76
+ (0, _utils.useLayoutEffect)(updatePosition, deps);
83
77
 
84
- useResize(updatePosition); // Reposition the overlay and do not close on scroll while the visual viewport is resizing.
85
- // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
78
+ // Update position on window resize
79
+ useResize(updatePosition);
86
80
 
81
+ // Reposition the overlay and do not close on scroll while the visual viewport is resizing.
82
+ // This will ensure that overlays adjust their positioning when the iOS virtual keyboard appears.
87
83
  let isResizing = (0, _react.useRef)(false);
88
84
  (0, _utils.useLayoutEffect)(() => {
89
85
  let timeout;
90
-
91
86
  let onResize = () => {
92
87
  isResizing.current = true;
93
88
  clearTimeout(timeout);
@@ -96,24 +91,26 @@ function useOverlayPosition(props) {
96
91
  }, 500);
97
92
  updatePosition();
98
93
  };
99
-
100
- visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.addEventListener('resize', onResize);
94
+ visualViewport === null || visualViewport === void 0 || visualViewport.addEventListener('resize', onResize);
101
95
  return () => {
102
- visualViewport === null || visualViewport === void 0 ? void 0 : visualViewport.removeEventListener('resize', onResize);
96
+ visualViewport === null || visualViewport === void 0 || visualViewport.removeEventListener('resize', onResize);
103
97
  };
104
98
  }, [updatePosition]);
105
99
  let close = (0, _react.useCallback)(() => {
106
100
  if (!isResizing.current) {
107
101
  onClose();
108
102
  }
109
- }, [onClose, isResizing]); // When scrolling a parent scrollable region of the trigger (other than the body),
110
- // we hide the popover. Otherwise, its position would be incorrect.
103
+ }, [onClose, isResizing]);
111
104
 
105
+ // When scrolling a parent scrollable region of the trigger (other than the body),
106
+ // we hide the popover. Otherwise, its position would be incorrect.
112
107
  (0, _useCloseOnScroll.useCloseOnScroll)({
113
108
  triggerRef: targetRef,
114
109
  isOpen,
115
110
  onClose: onClose ? close : undefined
116
- }); // useLayoutEffect(() => {
111
+ });
112
+
113
+ // useLayoutEffect(() => {
117
114
  // const mutationObserver = new MutationObserver((mutations) => {
118
115
  // updatePosition();
119
116
  // mutations.forEach((mutation) => {
@@ -130,7 +127,9 @@ function useOverlayPosition(props) {
130
127
  // // }
131
128
  // });
132
129
  // });
130
+
133
131
  // mutationObserver.observe(overlayRef?.current, { attributes: true });
132
+
134
133
  // return () => mutationObserver.disconnect();
135
134
  // }, [overlayRef, updatePosition]);
136
135
 
@@ -155,7 +154,6 @@ function useOverlayPosition(props) {
155
154
  updatePosition
156
155
  };
157
156
  }
158
-
159
157
  function useResize(onResize) {
160
158
  (0, _utils.useLayoutEffect)(() => {
161
159
  window.addEventListener('resize', onResize, false);
@@ -164,12 +162,10 @@ function useResize(onResize) {
164
162
  };
165
163
  }, [onResize]);
166
164
  }
167
-
168
165
  function translateRTL(position, direction) {
169
166
  if (direction === 'rtl') {
170
167
  return position.replace('start', 'right').replace('end', 'left');
171
168
  }
172
-
173
169
  return position.replace('start', 'left').replace('end', 'right');
174
170
  }
175
171
  //# sourceMappingURL=useOverlayPosition.js.map