PageSourceSearch

https://internationaldayofzerowaste.org/assets/@floating-ui--utils-874842bc.js

js internationaldayofzerowaste.org collected 2026-09-29 11:07:14 UTC 4,563 bytes, 138 lines download raw bytes

1// @floating-ui/[email protected] downloaded from https://cdn.jsdelivr.net/npm/@floating-ui/[email protected]/dist/floating-ui.utils.mjs
2
vendor: 4,435 bytes, lines 3-138
3/**
4 * Custom positioning reference element.
5 * @see https://floating-ui.com/docs/virtual-elements
6 */
7
8const sides = ['top', 'right', 'bottom', 'left'];
9const alignments = ['start', 'end'];
10const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
11const min = Math.min;
12const max = Math.max;
13const round = Math.round;
14const floor = Math.floor;
15const createCoords = v => ({
16  x: v,
17  y: v
18});
19const oppositeSideMap = {
20  left: 'right',
21  right: 'left',
22  bottom: 'top',
23  top: 'bottom'
24};
25function clamp(start, value, end) {
26  return max(start, min(value, end));
27}
28function evaluate(value, param) {
29  return typeof value === 'function' ? value(param) : value;
30}
31function getSide(placement) {
32  return placement.split('-')[0];
33}
34function getAlignment(placement) {
35  return placement.split('-')[1];
36}
37function getOppositeAxis(axis) {
38  return axis === 'x' ? 'y' : 'x';
39}
40function getAxisLength(axis) {
41  return axis === 'y' ? 'height' : 'width';
42}
43function getSideAxis(placement) {
44  const firstChar = placement[0];
45  return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
46}
47function getAlignmentAxis(placement) {
48  return getOppositeAxis(getSideAxis(placement));
49}
50function getAlignmentSides(placement, rects, rtl) {
51  if (rtl === void 0) {
52    rtl = false;
53  }
54  const alignment = getAlignment(placement);
55  const alignmentAxis = getAlignmentAxis(placement);
56  const length = getAxisLength(alignmentAxis);
57  let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
58  if (rects.reference[length] > rects.floating[length]) {
59    mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
60  }
61  return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
62}
63function getExpandedPlacements(placement) {
64  const oppositePlacement = getOppositePlacement(placement);
65  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
66}
67function getOppositeAlignmentPlacement(placement) {
68  return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
69}
70const lrPlacement = ['left', 'right'];
71const rlPlacement = ['right', 'left'];
72const tbPlacement = ['top', 'bottom'];
73const btPlacement = ['bottom', 'top'];
74function getSideList(side, isStart, rtl) {
75  switch (side) {
76    case 'top':
77    case 'bottom':
78      if (rtl) return isStart ? rlPlacement : lrPlacement;
79      return isStart ? lrPlacement : rlPlacement;
80    case 'left':
81    case 'right':
82      return isStart ? tbPlacement : btPlacement;
83    default:
84      return [];
85  }
86}
87function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
88  const alignment = getAlignment(placement);
89  let list = getSideList(getSide(placement), direction === 'start', rtl);
90  if (alignment) {
91    list = list.map(side => side + "-" + alignment);
92    if (flipAlignment) {
93      list = list.concat(list.map(getOppositeAlignmentPlacement));
94    }
95  }
96  return list;
97}
98function getOppositePlacement(placement) {
99  const side = getSide(placement);
100  return oppositeSideMap[side] + placement.slice(side.length);
101}
102function expandPaddingObject(padding) {
103  var _padding$top, _padding$right, _padding$bottom, _padding$left;
104  return {
105    top: (_padding$top = padding.top) != null ? _padding$top : 0,
106    right: (_padding$right = padding.right) != null ? _padding$right : 0,
107    bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
108    left: (_padding$left = padding.left) != null ? _padding$left : 0
109  };
110}
111function getPaddingObject(padding) {
112  return typeof padding !== 'number' ? expandPaddingObject(padding) : {
113    top: padding,
114    right: padding,
115    bottom: padding,
116    left: padding
117  };
118}
119function rectToClientRect(rect) {
120  const {
121    x,
122    y,
123    width,
124    height
125  } = rect;
126  return {
127    width,
128    height,
129    top: y,
130    left: x,
131    right: x + width,
132    bottom: y + height,
133    x,
134    y
135  };
136}
137
138export { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.