@unabridged/midwest 0.18.0 → 0.19.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 (32) hide show
  1. package/README.md +4 -2
  2. package/app/assets/javascript/midwest/index.ts +6 -0
  3. package/app/assets/javascript/midwest.js +327 -571
  4. package/app/assets/javascript/midwest.js.map +1 -1
  5. package/app/assets/stylesheets/midwest/form-group.css +4 -0
  6. package/app/assets/stylesheets/midwest.css +1 -1
  7. package/app/assets/stylesheets/midwest.tailwind.css +4 -1
  8. package/dist/css/midwest.css +1 -1
  9. package/dist/javascript/collection/app/assets/javascript/midwest/index.js +7 -5
  10. package/dist/javascript/collection/app/assets/javascript/midwest/index.js.map +1 -1
  11. package/dist/javascript/collection/app/components/midwest/carousel_component/carousel_component_controller.js +106 -6
  12. package/dist/javascript/collection/app/components/midwest/carousel_component/carousel_component_controller.js.map +1 -1
  13. package/dist/javascript/collection/app/components/midwest/dropdown_component/dropdown_component_controller.js +1 -1
  14. package/dist/javascript/collection/app/components/midwest/form/input_component/input_component_controller.js +116 -1
  15. package/dist/javascript/collection/app/components/midwest/form/input_component/input_component_controller.js.map +1 -1
  16. package/dist/javascript/collection/app/components/midwest/horizontal_scroll_component/horizontal_scroll_component_controller.js +24 -0
  17. package/dist/javascript/collection/app/components/midwest/horizontal_scroll_component/horizontal_scroll_component_controller.js.map +1 -0
  18. package/dist/javascript/collection/app/components/midwest/table_component/load_more_controller.js +60 -0
  19. package/dist/javascript/collection/app/components/midwest/table_component/load_more_controller.js.map +1 -0
  20. package/dist/javascript/collection/app/components/midwest/table_component/table_component_controller.js +30 -0
  21. package/dist/javascript/collection/app/components/midwest/table_component/table_component_controller.js.map +1 -0
  22. package/dist/javascript/collection/node_modules/@floating-ui/core/dist/floating-ui.core.js +561 -0
  23. package/dist/javascript/collection/node_modules/@floating-ui/core/dist/floating-ui.core.js.map +1 -0
  24. package/dist/javascript/collection/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +736 -0
  25. package/dist/javascript/collection/node_modules/@floating-ui/dom/dist/floating-ui.dom.js.map +1 -0
  26. package/dist/javascript/collection/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +166 -0
  27. package/dist/javascript/collection/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -0
  28. package/dist/javascript/collection/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +105 -0
  29. package/dist/javascript/collection/node_modules/@floating-ui/utils/dist/floating-ui.utils.js.map +1 -0
  30. package/dist/javascript/midwest.js +327 -571
  31. package/dist/javascript/midwest.js.map +1 -1
  32. package/package.json +3 -4
@@ -0,0 +1,736 @@
1
+ import { offset as offset$1, autoPlacement as autoPlacement$1, shift as shift$1, hide as hide$1, computePosition as computePosition$1 } from '../../core/dist/floating-ui.core.js';
2
+ import { createCoords, rectToClientRect, round, max, min, floor } from '../../utils/dist/floating-ui.utils.js';
3
+ import { getOverflowAncestors, isElement, getWindow, getFrameElement, getComputedStyle as getComputedStyle$1, getDocumentElement, isHTMLElement, isWebKit, isTopLayer, getNodeName, isOverflowElement, getNodeScroll, getParentNode, isLastTraversableNode, isTableElement, isContainingBlock, getContainingBlock } from '../../utils/dist/floating-ui.utils.dom.js';
4
+
5
+ function getCssDimensions(element) {
6
+ const css = getComputedStyle$1(element);
7
+ // In testing environments, the `width` and `height` properties are empty
8
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
9
+ let width = parseFloat(css.width) || 0;
10
+ let height = parseFloat(css.height) || 0;
11
+ const hasOffset = isHTMLElement(element);
12
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
13
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
14
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
15
+ if (shouldFallback) {
16
+ width = offsetWidth;
17
+ height = offsetHeight;
18
+ }
19
+ return {
20
+ width,
21
+ height,
22
+ $: shouldFallback
23
+ };
24
+ }
25
+
26
+ function unwrapElement(element) {
27
+ return !isElement(element) ? element.contextElement : element;
28
+ }
29
+
30
+ function getScale(element) {
31
+ const domElement = unwrapElement(element);
32
+ if (!isHTMLElement(domElement)) {
33
+ return createCoords(1);
34
+ }
35
+ const rect = domElement.getBoundingClientRect();
36
+ const {
37
+ width,
38
+ height,
39
+ $
40
+ } = getCssDimensions(domElement);
41
+ let x = ($ ? round(rect.width) : rect.width) / width;
42
+ let y = ($ ? round(rect.height) : rect.height) / height;
43
+
44
+ // 0, NaN, or Infinity should always fallback to 1.
45
+
46
+ if (!x || !Number.isFinite(x)) {
47
+ x = 1;
48
+ }
49
+ if (!y || !Number.isFinite(y)) {
50
+ y = 1;
51
+ }
52
+ return {
53
+ x,
54
+ y
55
+ };
56
+ }
57
+
58
+ const noOffsets = /*#__PURE__*/createCoords(0);
59
+ function getVisualOffsets(element) {
60
+ const win = getWindow(element);
61
+ if (!isWebKit() || !win.visualViewport) {
62
+ return noOffsets;
63
+ }
64
+ return {
65
+ x: win.visualViewport.offsetLeft,
66
+ y: win.visualViewport.offsetTop
67
+ };
68
+ }
69
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
70
+ if (isFixed === void 0) {
71
+ isFixed = false;
72
+ }
73
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
74
+ return false;
75
+ }
76
+ return isFixed;
77
+ }
78
+
79
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
80
+ if (includeScale === void 0) {
81
+ includeScale = false;
82
+ }
83
+ if (isFixedStrategy === void 0) {
84
+ isFixedStrategy = false;
85
+ }
86
+ const clientRect = element.getBoundingClientRect();
87
+ const domElement = unwrapElement(element);
88
+ let scale = createCoords(1);
89
+ if (includeScale) {
90
+ if (offsetParent) {
91
+ if (isElement(offsetParent)) {
92
+ scale = getScale(offsetParent);
93
+ }
94
+ } else {
95
+ scale = getScale(element);
96
+ }
97
+ }
98
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
99
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
100
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
101
+ let width = clientRect.width / scale.x;
102
+ let height = clientRect.height / scale.y;
103
+ if (domElement) {
104
+ const win = getWindow(domElement);
105
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
106
+ let currentWin = win;
107
+ let currentIFrame = getFrameElement(currentWin);
108
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
109
+ const iframeScale = getScale(currentIFrame);
110
+ const iframeRect = currentIFrame.getBoundingClientRect();
111
+ const css = getComputedStyle$1(currentIFrame);
112
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
113
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
114
+ x *= iframeScale.x;
115
+ y *= iframeScale.y;
116
+ width *= iframeScale.x;
117
+ height *= iframeScale.y;
118
+ x += left;
119
+ y += top;
120
+ currentWin = getWindow(currentIFrame);
121
+ currentIFrame = getFrameElement(currentWin);
122
+ }
123
+ }
124
+ return rectToClientRect({
125
+ width,
126
+ height,
127
+ x,
128
+ y
129
+ });
130
+ }
131
+
132
+ // If <html> has a CSS width greater than the viewport, then this will be
133
+ // incorrect for RTL.
134
+ function getWindowScrollBarX(element, rect) {
135
+ const leftScroll = getNodeScroll(element).scrollLeft;
136
+ if (!rect) {
137
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
138
+ }
139
+ return rect.left + leftScroll;
140
+ }
141
+
142
+ function getHTMLOffset(documentElement, scroll) {
143
+ const htmlRect = documentElement.getBoundingClientRect();
144
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
145
+ const y = htmlRect.top + scroll.scrollTop;
146
+ return {
147
+ x,
148
+ y
149
+ };
150
+ }
151
+
152
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
153
+ let {
154
+ elements,
155
+ rect,
156
+ offsetParent,
157
+ strategy
158
+ } = _ref;
159
+ const isFixed = strategy === 'fixed';
160
+ const documentElement = getDocumentElement(offsetParent);
161
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
162
+ if (offsetParent === documentElement || topLayer && isFixed) {
163
+ return rect;
164
+ }
165
+ let scroll = {
166
+ scrollLeft: 0,
167
+ scrollTop: 0
168
+ };
169
+ let scale = createCoords(1);
170
+ const offsets = createCoords(0);
171
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
172
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
173
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
174
+ scroll = getNodeScroll(offsetParent);
175
+ }
176
+ if (isOffsetParentAnElement) {
177
+ const offsetRect = getBoundingClientRect(offsetParent);
178
+ scale = getScale(offsetParent);
179
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
180
+ offsets.y = offsetRect.y + offsetParent.clientTop;
181
+ }
182
+ }
183
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
184
+ return {
185
+ width: rect.width * scale.x,
186
+ height: rect.height * scale.y,
187
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
188
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
189
+ };
190
+ }
191
+
192
+ function getClientRects(element) {
193
+ return Array.from(element.getClientRects());
194
+ }
195
+
196
+ // Gets the entire size of the scrollable document area, even extending outside
197
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
198
+ function getDocumentRect(element) {
199
+ const html = getDocumentElement(element);
200
+ const scroll = getNodeScroll(element);
201
+ const body = element.ownerDocument.body;
202
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
203
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
204
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
205
+ const y = -scroll.scrollTop;
206
+ if (getComputedStyle$1(body).direction === 'rtl') {
207
+ x += max(html.clientWidth, body.clientWidth) - width;
208
+ }
209
+ return {
210
+ width,
211
+ height,
212
+ x,
213
+ y
214
+ };
215
+ }
216
+
217
+ // Safety check: ensure the scrollbar space is reasonable in case this
218
+ // calculation is affected by unusual styles.
219
+ // Most scrollbars leave 15-18px of space.
220
+ const SCROLLBAR_MAX = 25;
221
+ function getViewportRect(element, strategy) {
222
+ const win = getWindow(element);
223
+ const html = getDocumentElement(element);
224
+ const visualViewport = win.visualViewport;
225
+ let width = html.clientWidth;
226
+ let height = html.clientHeight;
227
+ let x = 0;
228
+ let y = 0;
229
+ if (visualViewport) {
230
+ width = visualViewport.width;
231
+ height = visualViewport.height;
232
+ const visualViewportBased = isWebKit();
233
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
234
+ x = visualViewport.offsetLeft;
235
+ y = visualViewport.offsetTop;
236
+ }
237
+ }
238
+ const windowScrollbarX = getWindowScrollBarX(html);
239
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
240
+ // visual width of the <html> but this is not considered in the size
241
+ // of `html.clientWidth`.
242
+ if (windowScrollbarX <= 0) {
243
+ const doc = html.ownerDocument;
244
+ const body = doc.body;
245
+ const bodyStyles = getComputedStyle(body);
246
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
247
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
248
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
249
+ width -= clippingStableScrollbarWidth;
250
+ }
251
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
252
+ // If the <body> scrollbar is on the left, the width needs to be extended
253
+ // by the scrollbar amount so there isn't extra space on the right.
254
+ width += windowScrollbarX;
255
+ }
256
+ return {
257
+ width,
258
+ height,
259
+ x,
260
+ y
261
+ };
262
+ }
263
+
264
+ // Returns the inner client rect, subtracting scrollbars if present.
265
+ function getInnerBoundingClientRect(element, strategy) {
266
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
267
+ const top = clientRect.top + element.clientTop;
268
+ const left = clientRect.left + element.clientLeft;
269
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
270
+ const width = element.clientWidth * scale.x;
271
+ const height = element.clientHeight * scale.y;
272
+ const x = left * scale.x;
273
+ const y = top * scale.y;
274
+ return {
275
+ width,
276
+ height,
277
+ x,
278
+ y
279
+ };
280
+ }
281
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
282
+ let rect;
283
+ if (clippingAncestor === 'viewport') {
284
+ rect = getViewportRect(element, strategy);
285
+ } else if (clippingAncestor === 'document') {
286
+ rect = getDocumentRect(getDocumentElement(element));
287
+ } else if (isElement(clippingAncestor)) {
288
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
289
+ } else {
290
+ const visualOffsets = getVisualOffsets(element);
291
+ rect = {
292
+ x: clippingAncestor.x - visualOffsets.x,
293
+ y: clippingAncestor.y - visualOffsets.y,
294
+ width: clippingAncestor.width,
295
+ height: clippingAncestor.height
296
+ };
297
+ }
298
+ return rectToClientRect(rect);
299
+ }
300
+ function hasFixedPositionAncestor(element, stopNode) {
301
+ const parentNode = getParentNode(element);
302
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
303
+ return false;
304
+ }
305
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
306
+ }
307
+
308
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
309
+ // clipping (or hiding) child elements. This returns all clipping ancestors
310
+ // of the given element up the tree.
311
+ function getClippingElementAncestors(element, cache) {
312
+ const cachedResult = cache.get(element);
313
+ if (cachedResult) {
314
+ return cachedResult;
315
+ }
316
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
317
+ let currentContainingBlockComputedStyle = null;
318
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
319
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
320
+
321
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
322
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
323
+ const computedStyle = getComputedStyle$1(currentNode);
324
+ const currentNodeIsContaining = isContainingBlock(currentNode);
325
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
326
+ currentContainingBlockComputedStyle = null;
327
+ }
328
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
329
+ if (shouldDropCurrentNode) {
330
+ // Drop non-containing blocks.
331
+ result = result.filter(ancestor => ancestor !== currentNode);
332
+ } else {
333
+ // Record last containing block for next iteration.
334
+ currentContainingBlockComputedStyle = computedStyle;
335
+ }
336
+ currentNode = getParentNode(currentNode);
337
+ }
338
+ cache.set(element, result);
339
+ return result;
340
+ }
341
+
342
+ // Gets the maximum area that the element is visible in due to any number of
343
+ // clipping ancestors.
344
+ function getClippingRect(_ref) {
345
+ let {
346
+ element,
347
+ boundary,
348
+ rootBoundary,
349
+ strategy
350
+ } = _ref;
351
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
352
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
353
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
354
+ let top = firstRect.top;
355
+ let right = firstRect.right;
356
+ let bottom = firstRect.bottom;
357
+ let left = firstRect.left;
358
+ for (let i = 1; i < clippingAncestors.length; i++) {
359
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
360
+ top = max(rect.top, top);
361
+ right = min(rect.right, right);
362
+ bottom = min(rect.bottom, bottom);
363
+ left = max(rect.left, left);
364
+ }
365
+ return {
366
+ width: right - left,
367
+ height: bottom - top,
368
+ x: left,
369
+ y: top
370
+ };
371
+ }
372
+
373
+ function getDimensions(element) {
374
+ const {
375
+ width,
376
+ height
377
+ } = getCssDimensions(element);
378
+ return {
379
+ width,
380
+ height
381
+ };
382
+ }
383
+
384
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
385
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
386
+ const documentElement = getDocumentElement(offsetParent);
387
+ const isFixed = strategy === 'fixed';
388
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
389
+ let scroll = {
390
+ scrollLeft: 0,
391
+ scrollTop: 0
392
+ };
393
+ const offsets = createCoords(0);
394
+
395
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
396
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
397
+ function setLeftRTLScrollbarOffset() {
398
+ offsets.x = getWindowScrollBarX(documentElement);
399
+ }
400
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
401
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
402
+ scroll = getNodeScroll(offsetParent);
403
+ }
404
+ if (isOffsetParentAnElement) {
405
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
406
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
407
+ offsets.y = offsetRect.y + offsetParent.clientTop;
408
+ } else if (documentElement) {
409
+ setLeftRTLScrollbarOffset();
410
+ }
411
+ }
412
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
413
+ setLeftRTLScrollbarOffset();
414
+ }
415
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
416
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
417
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
418
+ return {
419
+ x,
420
+ y,
421
+ width: rect.width,
422
+ height: rect.height
423
+ };
424
+ }
425
+
426
+ function isStaticPositioned(element) {
427
+ return getComputedStyle$1(element).position === 'static';
428
+ }
429
+
430
+ function getTrueOffsetParent(element, polyfill) {
431
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
432
+ return null;
433
+ }
434
+ if (polyfill) {
435
+ return polyfill(element);
436
+ }
437
+ let rawOffsetParent = element.offsetParent;
438
+
439
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
440
+ // while Chrome and Safari return the <body> element. The <body> element must
441
+ // be used to perform the correct calculations even if the <html> element is
442
+ // non-static.
443
+ if (getDocumentElement(element) === rawOffsetParent) {
444
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
445
+ }
446
+ return rawOffsetParent;
447
+ }
448
+
449
+ // Gets the closest ancestor positioned element. Handles some edge cases,
450
+ // such as table ancestors and cross browser bugs.
451
+ function getOffsetParent(element, polyfill) {
452
+ const win = getWindow(element);
453
+ if (isTopLayer(element)) {
454
+ return win;
455
+ }
456
+ if (!isHTMLElement(element)) {
457
+ let svgOffsetParent = getParentNode(element);
458
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
459
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
460
+ return svgOffsetParent;
461
+ }
462
+ svgOffsetParent = getParentNode(svgOffsetParent);
463
+ }
464
+ return win;
465
+ }
466
+ let offsetParent = getTrueOffsetParent(element, polyfill);
467
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
468
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
469
+ }
470
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
471
+ return win;
472
+ }
473
+ return offsetParent || getContainingBlock(element) || win;
474
+ }
475
+
476
+ const getElementRects = async function (data) {
477
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
478
+ const getDimensionsFn = this.getDimensions;
479
+ const floatingDimensions = await getDimensionsFn(data.floating);
480
+ return {
481
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
482
+ floating: {
483
+ x: 0,
484
+ y: 0,
485
+ width: floatingDimensions.width,
486
+ height: floatingDimensions.height
487
+ }
488
+ };
489
+ };
490
+
491
+ function isRTL(element) {
492
+ return getComputedStyle$1(element).direction === 'rtl';
493
+ }
494
+
495
+ const platform = {
496
+ convertOffsetParentRelativeRectToViewportRelativeRect,
497
+ getDocumentElement,
498
+ getClippingRect,
499
+ getOffsetParent,
500
+ getElementRects,
501
+ getClientRects,
502
+ getDimensions,
503
+ getScale,
504
+ isElement,
505
+ isRTL
506
+ };
507
+
508
+ function rectsAreEqual(a, b) {
509
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
510
+ }
511
+
512
+ // https://samthor.au/2021/observing-dom/
513
+ function observeMove(element, onMove) {
514
+ let io = null;
515
+ let timeoutId;
516
+ const root = getDocumentElement(element);
517
+ function cleanup() {
518
+ var _io;
519
+ clearTimeout(timeoutId);
520
+ (_io = io) == null || _io.disconnect();
521
+ io = null;
522
+ }
523
+ function refresh(skip, threshold) {
524
+ if (skip === void 0) {
525
+ skip = false;
526
+ }
527
+ if (threshold === void 0) {
528
+ threshold = 1;
529
+ }
530
+ cleanup();
531
+ const elementRectForRootMargin = element.getBoundingClientRect();
532
+ const {
533
+ left,
534
+ top,
535
+ width,
536
+ height
537
+ } = elementRectForRootMargin;
538
+ if (!skip) {
539
+ onMove();
540
+ }
541
+ if (!width || !height) {
542
+ return;
543
+ }
544
+ const insetTop = floor(top);
545
+ const insetRight = floor(root.clientWidth - (left + width));
546
+ const insetBottom = floor(root.clientHeight - (top + height));
547
+ const insetLeft = floor(left);
548
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
549
+ const options = {
550
+ rootMargin,
551
+ threshold: max(0, min(1, threshold)) || 1
552
+ };
553
+ let isFirstUpdate = true;
554
+ function handleObserve(entries) {
555
+ const ratio = entries[0].intersectionRatio;
556
+ if (ratio !== threshold) {
557
+ if (!isFirstUpdate) {
558
+ return refresh();
559
+ }
560
+ if (!ratio) {
561
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
562
+ // to prevent an infinite loop of updates.
563
+ timeoutId = setTimeout(() => {
564
+ refresh(false, 1e-7);
565
+ }, 1000);
566
+ } else {
567
+ refresh(false, ratio);
568
+ }
569
+ }
570
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
571
+ // It's possible that even though the ratio is reported as 1, the
572
+ // element is not actually fully within the IntersectionObserver's root
573
+ // area anymore. This can happen under performance constraints. This may
574
+ // be a bug in the browser's IntersectionObserver implementation. To
575
+ // work around this, we compare the element's bounding rect now with
576
+ // what it was at the time we created the IntersectionObserver. If they
577
+ // are not equal then the element moved, so we refresh.
578
+ refresh();
579
+ }
580
+ isFirstUpdate = false;
581
+ }
582
+
583
+ // Older browsers don't support a `document` as the root and will throw an
584
+ // error.
585
+ try {
586
+ io = new IntersectionObserver(handleObserve, {
587
+ ...options,
588
+ // Handle <iframe>s
589
+ root: root.ownerDocument
590
+ });
591
+ } catch (_e) {
592
+ io = new IntersectionObserver(handleObserve, options);
593
+ }
594
+ io.observe(element);
595
+ }
596
+ refresh(true);
597
+ return cleanup;
598
+ }
599
+
600
+ /**
601
+ * Automatically updates the position of the floating element when necessary.
602
+ * Should only be called when the floating element is mounted on the DOM or
603
+ * visible on the screen.
604
+ * @returns cleanup function that should be invoked when the floating element is
605
+ * removed from the DOM or hidden from the screen.
606
+ * @see https://floating-ui.com/docs/autoUpdate
607
+ */
608
+ function autoUpdate(reference, floating, update, options) {
609
+ if (options === void 0) {
610
+ options = {};
611
+ }
612
+ const {
613
+ ancestorScroll = true,
614
+ ancestorResize = true,
615
+ elementResize = typeof ResizeObserver === 'function',
616
+ layoutShift = typeof IntersectionObserver === 'function',
617
+ animationFrame = false
618
+ } = options;
619
+ const referenceEl = unwrapElement(reference);
620
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
621
+ ancestors.forEach(ancestor => {
622
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
623
+ passive: true
624
+ });
625
+ ancestorResize && ancestor.addEventListener('resize', update);
626
+ });
627
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
628
+ let reobserveFrame = -1;
629
+ let resizeObserver = null;
630
+ if (elementResize) {
631
+ resizeObserver = new ResizeObserver(_ref => {
632
+ let [firstEntry] = _ref;
633
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
634
+ // Prevent update loops when using the `size` middleware.
635
+ // https://github.com/floating-ui/floating-ui/issues/1740
636
+ resizeObserver.unobserve(floating);
637
+ cancelAnimationFrame(reobserveFrame);
638
+ reobserveFrame = requestAnimationFrame(() => {
639
+ var _resizeObserver;
640
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
641
+ });
642
+ }
643
+ update();
644
+ });
645
+ if (referenceEl && !animationFrame) {
646
+ resizeObserver.observe(referenceEl);
647
+ }
648
+ if (floating) {
649
+ resizeObserver.observe(floating);
650
+ }
651
+ }
652
+ let frameId;
653
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
654
+ if (animationFrame) {
655
+ frameLoop();
656
+ }
657
+ function frameLoop() {
658
+ const nextRefRect = getBoundingClientRect(reference);
659
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
660
+ update();
661
+ }
662
+ prevRefRect = nextRefRect;
663
+ frameId = requestAnimationFrame(frameLoop);
664
+ }
665
+ update();
666
+ return () => {
667
+ var _resizeObserver2;
668
+ ancestors.forEach(ancestor => {
669
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
670
+ ancestorResize && ancestor.removeEventListener('resize', update);
671
+ });
672
+ cleanupIo == null || cleanupIo();
673
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
674
+ resizeObserver = null;
675
+ if (animationFrame) {
676
+ cancelAnimationFrame(frameId);
677
+ }
678
+ };
679
+ }
680
+
681
+ /**
682
+ * Modifies the placement by translating the floating element along the
683
+ * specified axes.
684
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
685
+ * object may be passed.
686
+ * @see https://floating-ui.com/docs/offset
687
+ */
688
+ const offset = offset$1;
689
+
690
+ /**
691
+ * Optimizes the visibility of the floating element by choosing the placement
692
+ * that has the most space available automatically, without needing to specify a
693
+ * preferred placement. Alternative to `flip`.
694
+ * @see https://floating-ui.com/docs/autoPlacement
695
+ */
696
+ const autoPlacement = autoPlacement$1;
697
+
698
+ /**
699
+ * Optimizes the visibility of the floating element by shifting it in order to
700
+ * keep it in view when it will overflow the clipping boundary.
701
+ * @see https://floating-ui.com/docs/shift
702
+ */
703
+ const shift = shift$1;
704
+
705
+ /**
706
+ * Provides data to hide the floating element in applicable situations, such as
707
+ * when it is not in the same clipping context as the reference element.
708
+ * @see https://floating-ui.com/docs/hide
709
+ */
710
+ const hide = hide$1;
711
+
712
+ /**
713
+ * Computes the `x` and `y` coordinates that will place the floating element
714
+ * next to a given reference element.
715
+ */
716
+ const computePosition = (reference, floating, options) => {
717
+ // This caches the expensive `getClippingElementAncestors` function so that
718
+ // multiple lifecycle resets re-use the same result. It only lives for a
719
+ // single call. If other functions become expensive, we can add them as well.
720
+ const cache = new Map();
721
+ const mergedOptions = {
722
+ platform,
723
+ ...options
724
+ };
725
+ const platformWithCache = {
726
+ ...mergedOptions.platform,
727
+ _c: cache
728
+ };
729
+ return computePosition$1(reference, floating, {
730
+ ...mergedOptions,
731
+ platform: platformWithCache
732
+ });
733
+ };
734
+
735
+ export { autoPlacement, autoUpdate, computePosition, getOverflowAncestors, hide, offset, platform, shift };
736
+ //# sourceMappingURL=floating-ui.dom.js.map