@haiilo/catalyst 14.1.0 → 14.3.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.
@@ -189,6 +189,71 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
189
189
  return coords;
190
190
  }
191
191
 
192
+ /**
193
+ * Resolves with an object of overflow side offsets that determine how much the
194
+ * element is overflowing a given clipping boundary on each side.
195
+ * - positive = overflowing the boundary by that number of pixels
196
+ * - negative = how many pixels left before it will overflow
197
+ * - 0 = lies flush with the boundary
198
+ * @see https://floating-ui.com/docs/detectOverflow
199
+ */
200
+ async function detectOverflow(state, options) {
201
+ var _await$platform$isEle;
202
+ if (options === void 0) {
203
+ options = {};
204
+ }
205
+ const {
206
+ x,
207
+ y,
208
+ platform,
209
+ rects,
210
+ elements,
211
+ strategy
212
+ } = state;
213
+ const {
214
+ boundary = 'clippingAncestors',
215
+ rootBoundary = 'viewport',
216
+ elementContext = 'floating',
217
+ altBoundary = false,
218
+ padding = 0
219
+ } = evaluate(options, state);
220
+ const paddingObject = getPaddingObject(padding);
221
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
222
+ const element = elements[altBoundary ? altContext : elementContext];
223
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
224
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
225
+ boundary,
226
+ rootBoundary,
227
+ strategy
228
+ }));
229
+ const rect = elementContext === 'floating' ? {
230
+ x,
231
+ y,
232
+ width: rects.floating.width,
233
+ height: rects.floating.height
234
+ } : rects.reference;
235
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
236
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
237
+ x: 1,
238
+ y: 1
239
+ } : {
240
+ x: 1,
241
+ y: 1
242
+ };
243
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
244
+ elements,
245
+ rect,
246
+ offsetParent,
247
+ strategy
248
+ }) : rect);
249
+ return {
250
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
251
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
252
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
253
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
254
+ };
255
+ }
256
+
192
257
  /**
193
258
  * Computes the `x` and `y` coordinates that will place the floating element
194
259
  * next to a given reference element.
@@ -218,6 +283,7 @@ const computePosition$1 = async (reference, floating, config) => {
218
283
  let middlewareData = {};
219
284
  let resetCount = 0;
220
285
  for (let i = 0; i < validMiddleware.length; i++) {
286
+ var _platform$detectOverf;
221
287
  const {
222
288
  name,
223
289
  fn
@@ -235,7 +301,10 @@ const computePosition$1 = async (reference, floating, config) => {
235
301
  strategy,
236
302
  middlewareData,
237
303
  rects,
238
- platform,
304
+ platform: {
305
+ ...platform,
306
+ detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
307
+ },
239
308
  elements: {
240
309
  reference,
241
310
  floating
@@ -280,71 +349,6 @@ const computePosition$1 = async (reference, floating, config) => {
280
349
  };
281
350
  };
282
351
 
283
- /**
284
- * Resolves with an object of overflow side offsets that determine how much the
285
- * element is overflowing a given clipping boundary on each side.
286
- * - positive = overflowing the boundary by that number of pixels
287
- * - negative = how many pixels left before it will overflow
288
- * - 0 = lies flush with the boundary
289
- * @see https://floating-ui.com/docs/detectOverflow
290
- */
291
- async function detectOverflow(state, options) {
292
- var _await$platform$isEle;
293
- if (options === void 0) {
294
- options = {};
295
- }
296
- const {
297
- x,
298
- y,
299
- platform,
300
- rects,
301
- elements,
302
- strategy
303
- } = state;
304
- const {
305
- boundary = 'clippingAncestors',
306
- rootBoundary = 'viewport',
307
- elementContext = 'floating',
308
- altBoundary = false,
309
- padding = 0
310
- } = evaluate(options, state);
311
- const paddingObject = getPaddingObject(padding);
312
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
313
- const element = elements[altBoundary ? altContext : elementContext];
314
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
315
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
316
- boundary,
317
- rootBoundary,
318
- strategy
319
- }));
320
- const rect = elementContext === 'floating' ? {
321
- x,
322
- y,
323
- width: rects.floating.width,
324
- height: rects.floating.height
325
- } : rects.reference;
326
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
327
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
328
- x: 1,
329
- y: 1
330
- } : {
331
- x: 1,
332
- y: 1
333
- };
334
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
335
- elements,
336
- rect,
337
- offsetParent,
338
- strategy
339
- }) : rect);
340
- return {
341
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
342
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
343
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
344
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
345
- };
346
- }
347
-
348
352
  /**
349
353
  * Optimizes the visibility of the floating element by flipping the `placement`
350
354
  * in order to keep it in view when the preferred placement(s) will overflow the
@@ -395,7 +399,7 @@ const flip$1 = function (options) {
395
399
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
396
400
  }
397
401
  const placements = [initialPlacement, ...fallbackPlacements];
398
- const overflow = await detectOverflow(state, detectOverflowOptions);
402
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
399
403
  const overflows = [];
400
404
  let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
401
405
  if (checkMainAxis) {
@@ -579,7 +583,8 @@ const shift$1 = function (options) {
579
583
  const {
580
584
  x,
581
585
  y,
582
- placement
586
+ placement,
587
+ platform
583
588
  } = state;
584
589
  const {
585
590
  mainAxis: checkMainAxis = true,
@@ -602,7 +607,7 @@ const shift$1 = function (options) {
602
607
  x,
603
608
  y
604
609
  };
605
- const overflow = await detectOverflow(state, detectOverflowOptions);
610
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
606
611
  const crossAxis = getSideAxis(getSide(placement));
607
612
  const mainAxis = getOppositeAxis(crossAxis);
608
613
  let mainAxisCoord = coords[mainAxis];
@@ -666,7 +671,7 @@ const size$1 = function (options) {
666
671
  apply = () => {},
667
672
  ...detectOverflowOptions
668
673
  } = evaluate(options, state);
669
- const overflow = await detectOverflow(state, detectOverflowOptions);
674
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
670
675
  const side = getSide(placement);
671
676
  const alignment = getAlignment(placement);
672
677
  const isYAxis = getSideAxis(placement) === 'y';
@@ -1587,7 +1592,7 @@ const computePosition = (reference, floating, options) => {
1587
1592
  });
1588
1593
  };
1589
1594
 
1590
- export { autoUpdate as a, size as b, computePosition as c, flip as f, offset as o, shift as s };
1595
+ export { autoUpdate as a, shift as b, computePosition as c, flip as f, offset as o, size as s };
1591
1596
  //# sourceMappingURL=floating-ui.dom.js.map
1592
1597
 
1593
1598
  //# sourceMappingURL=floating-ui.dom.js.map