@xhsreds/reds-rn-next 0.0.1-beta-3
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.
- package/cjs/_chunks/DOz-p6oh.js +467 -0
- package/cjs/_chunks/DOz-p6oh.js.map +1 -0
- package/cjs/_chunks/Dx-JjEWA.js +115 -0
- package/cjs/_chunks/Dx-JjEWA.js.map +1 -0
- package/cjs/components/Button/common/index.js +12 -0
- package/cjs/components/Button/common/index.js.map +1 -0
- package/cjs/components/Button/interface/index.js +3 -0
- package/cjs/components/Button/interface/index.js.map +1 -0
- package/cjs/components/Button/rn/index.js +25 -0
- package/cjs/components/Button/rn/index.js.map +1 -0
- package/cjs/components/Popover/common/index.js +12 -0
- package/cjs/components/Popover/common/index.js.map +1 -0
- package/cjs/components/Popover/interface/index.js +3 -0
- package/cjs/components/Popover/interface/index.js.map +1 -0
- package/cjs/components/Popover/rn/component.js +59 -0
- package/cjs/components/Popover/rn/component.js.map +1 -0
- package/cjs/components/Popover/rn/hook.js +1414 -0
- package/cjs/components/Popover/rn/hook.js.map +1 -0
- package/cjs/components/Popover/rn/index.js +114 -0
- package/cjs/components/Popover/rn/index.js.map +1 -0
- package/cjs/index.rn.js +17 -0
- package/cjs/index.rn.js.map +1 -0
- package/cjs/utils/hook.js +7 -0
- package/cjs/utils/hook.js.map +1 -0
- package/esm/_chunks/BdytNqoo.js +458 -0
- package/esm/_chunks/BdytNqoo.js.map +1 -0
- package/esm/_chunks/C8kshcql.js +111 -0
- package/esm/_chunks/C8kshcql.js.map +1 -0
- package/esm/components/Button/common/index.js +10 -0
- package/esm/components/Button/common/index.js.map +1 -0
- package/esm/components/Button/interface/index.js +2 -0
- package/esm/components/Button/interface/index.js.map +1 -0
- package/esm/components/Button/rn/index.js +21 -0
- package/esm/components/Button/rn/index.js.map +1 -0
- package/esm/components/Popover/common/index.js +10 -0
- package/esm/components/Popover/common/index.js.map +1 -0
- package/esm/components/Popover/interface/index.js +2 -0
- package/esm/components/Popover/interface/index.js.map +1 -0
- package/esm/components/Popover/rn/component.js +56 -0
- package/esm/components/Popover/rn/component.js.map +1 -0
- package/esm/components/Popover/rn/hook.js +1394 -0
- package/esm/components/Popover/rn/hook.js.map +1 -0
- package/esm/components/Popover/rn/index.js +110 -0
- package/esm/components/Popover/rn/index.js.map +1 -0
- package/esm/index.rn.js +10 -0
- package/esm/index.rn.js.map +1 -0
- package/esm/utils/hook.js +5 -0
- package/esm/utils/hook.js.map +1 -0
- package/package.json +34 -0
- package/types/index.rn.d.ts +3 -0
- package/types/src/components/Button/common/index.d.ts +1 -0
- package/types/src/components/Button/interface/index.d.ts +31 -0
- package/types/src/components/Button/rn/index.d.ts +4 -0
- package/types/src/components/Popover/common/index.d.ts +1 -0
- package/types/src/components/Popover/interface/index.d.ts +12 -0
- package/types/src/components/Popover/rn/component.d.ts +13 -0
- package/types/src/components/Popover/rn/hook.d.ts +51 -0
- package/types/src/components/Popover/rn/index.d.ts +4 -0
- package/types/src/utils/hook.d.ts +1 -0
|
@@ -0,0 +1,1414 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _rollupPluginBabelHelpers = require('../../../_chunks/DOz-p6oh.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
26
|
+
var min = Math.min;
|
|
27
|
+
var max = Math.max;
|
|
28
|
+
var oppositeSideMap = {
|
|
29
|
+
left: 'right',
|
|
30
|
+
right: 'left',
|
|
31
|
+
bottom: 'top',
|
|
32
|
+
top: 'bottom'
|
|
33
|
+
};
|
|
34
|
+
var oppositeAlignmentMap = {
|
|
35
|
+
start: 'end',
|
|
36
|
+
end: 'start'
|
|
37
|
+
};
|
|
38
|
+
function clamp(start, value, end) {
|
|
39
|
+
return max(start, min(value, end));
|
|
40
|
+
}
|
|
41
|
+
function evaluate(value, param) {
|
|
42
|
+
return typeof value === 'function' ? value(param) : value;
|
|
43
|
+
}
|
|
44
|
+
function getSide(placement) {
|
|
45
|
+
return placement.split('-')[0];
|
|
46
|
+
}
|
|
47
|
+
function getAlignment(placement) {
|
|
48
|
+
return placement.split('-')[1];
|
|
49
|
+
}
|
|
50
|
+
function getOppositeAxis(axis) {
|
|
51
|
+
return axis === 'x' ? 'y' : 'x';
|
|
52
|
+
}
|
|
53
|
+
function getAxisLength(axis) {
|
|
54
|
+
return axis === 'y' ? 'height' : 'width';
|
|
55
|
+
}
|
|
56
|
+
function getSideAxis(placement) {
|
|
57
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
|
|
58
|
+
}
|
|
59
|
+
function getAlignmentAxis(placement) {
|
|
60
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
61
|
+
}
|
|
62
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
63
|
+
if (rtl === void 0) {
|
|
64
|
+
rtl = false;
|
|
65
|
+
}
|
|
66
|
+
var alignment = getAlignment(placement);
|
|
67
|
+
var alignmentAxis = getAlignmentAxis(placement);
|
|
68
|
+
var length = getAxisLength(alignmentAxis);
|
|
69
|
+
var mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
70
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
71
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
72
|
+
}
|
|
73
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
74
|
+
}
|
|
75
|
+
function getExpandedPlacements(placement) {
|
|
76
|
+
var oppositePlacement = getOppositePlacement(placement);
|
|
77
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
78
|
+
}
|
|
79
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
80
|
+
return placement.replace(/start|end/g, function (alignment) {
|
|
81
|
+
return oppositeAlignmentMap[alignment];
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function getSideList(side, isStart, rtl) {
|
|
85
|
+
var lr = ['left', 'right'];
|
|
86
|
+
var rl = ['right', 'left'];
|
|
87
|
+
var tb = ['top', 'bottom'];
|
|
88
|
+
var bt = ['bottom', 'top'];
|
|
89
|
+
switch (side) {
|
|
90
|
+
case 'top':
|
|
91
|
+
case 'bottom':
|
|
92
|
+
if (rtl) return isStart ? rl : lr;
|
|
93
|
+
return isStart ? lr : rl;
|
|
94
|
+
case 'left':
|
|
95
|
+
case 'right':
|
|
96
|
+
return isStart ? tb : bt;
|
|
97
|
+
default:
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
102
|
+
var alignment = getAlignment(placement);
|
|
103
|
+
var list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
104
|
+
if (alignment) {
|
|
105
|
+
list = list.map(function (side) {
|
|
106
|
+
return side + "-" + alignment;
|
|
107
|
+
});
|
|
108
|
+
if (flipAlignment) {
|
|
109
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return list;
|
|
113
|
+
}
|
|
114
|
+
function getOppositePlacement(placement) {
|
|
115
|
+
return placement.replace(/left|right|bottom|top/g, function (side) {
|
|
116
|
+
return oppositeSideMap[side];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function expandPaddingObject(padding) {
|
|
120
|
+
return _rollupPluginBabelHelpers._objectSpread2({
|
|
121
|
+
top: 0,
|
|
122
|
+
right: 0,
|
|
123
|
+
bottom: 0,
|
|
124
|
+
left: 0
|
|
125
|
+
}, padding);
|
|
126
|
+
}
|
|
127
|
+
function getPaddingObject(padding) {
|
|
128
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
129
|
+
top: padding,
|
|
130
|
+
right: padding,
|
|
131
|
+
bottom: padding,
|
|
132
|
+
left: padding
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function rectToClientRect(rect) {
|
|
136
|
+
var x = rect.x,
|
|
137
|
+
y = rect.y,
|
|
138
|
+
width = rect.width,
|
|
139
|
+
height = rect.height;
|
|
140
|
+
return {
|
|
141
|
+
width: width,
|
|
142
|
+
height: height,
|
|
143
|
+
top: y,
|
|
144
|
+
left: x,
|
|
145
|
+
right: x + width,
|
|
146
|
+
bottom: y + height,
|
|
147
|
+
x: x,
|
|
148
|
+
y: y
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var _excluded2 = ["mainAxis", "crossAxis", "fallbackPlacements", "fallbackStrategy", "fallbackAxisSideDirection", "flipAlignment"],
|
|
153
|
+
_excluded4 = ["mainAxis", "crossAxis", "limiter"];
|
|
154
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
155
|
+
var reference = _ref.reference,
|
|
156
|
+
floating = _ref.floating;
|
|
157
|
+
var sideAxis = getSideAxis(placement);
|
|
158
|
+
var alignmentAxis = getAlignmentAxis(placement);
|
|
159
|
+
var alignLength = getAxisLength(alignmentAxis);
|
|
160
|
+
var side = getSide(placement);
|
|
161
|
+
var isVertical = sideAxis === 'y';
|
|
162
|
+
var commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
163
|
+
var commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
164
|
+
var commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
165
|
+
var coords;
|
|
166
|
+
switch (side) {
|
|
167
|
+
case 'top':
|
|
168
|
+
coords = {
|
|
169
|
+
x: commonX,
|
|
170
|
+
y: reference.y - floating.height
|
|
171
|
+
};
|
|
172
|
+
break;
|
|
173
|
+
case 'bottom':
|
|
174
|
+
coords = {
|
|
175
|
+
x: commonX,
|
|
176
|
+
y: reference.y + reference.height
|
|
177
|
+
};
|
|
178
|
+
break;
|
|
179
|
+
case 'right':
|
|
180
|
+
coords = {
|
|
181
|
+
x: reference.x + reference.width,
|
|
182
|
+
y: commonY
|
|
183
|
+
};
|
|
184
|
+
break;
|
|
185
|
+
case 'left':
|
|
186
|
+
coords = {
|
|
187
|
+
x: reference.x - floating.width,
|
|
188
|
+
y: commonY
|
|
189
|
+
};
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
coords = {
|
|
193
|
+
x: reference.x,
|
|
194
|
+
y: reference.y
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
switch (getAlignment(placement)) {
|
|
198
|
+
case 'start':
|
|
199
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
200
|
+
break;
|
|
201
|
+
case 'end':
|
|
202
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
return coords;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
210
|
+
* next to a given reference element.
|
|
211
|
+
*
|
|
212
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
213
|
+
* write one for the platform you are using Floating UI with.
|
|
214
|
+
*/
|
|
215
|
+
var computePosition = /*#__PURE__*/function () {
|
|
216
|
+
var _ref2 = _rollupPluginBabelHelpers._asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers._regeneratorRuntime().mark(function _callee(reference, floating, config) {
|
|
217
|
+
var _config$placement, placement, _config$strategy, strategy, _config$middleware, middleware, platform, validMiddleware, rtl, rects, _computeCoordsFromPla, x, y, statefulPlacement, middlewareData, resetCount, i, _validMiddleware$i, name, fn, _yield$fn, nextX, nextY, data, reset, _computeCoordsFromPla2;
|
|
218
|
+
return _rollupPluginBabelHelpers._regeneratorRuntime().wrap(function _callee$(_context) {
|
|
219
|
+
while (1) switch (_context.prev = _context.next) {
|
|
220
|
+
case 0:
|
|
221
|
+
_config$placement = config.placement, placement = _config$placement === void 0 ? 'bottom' : _config$placement, _config$strategy = config.strategy, strategy = _config$strategy === void 0 ? 'absolute' : _config$strategy, _config$middleware = config.middleware, middleware = _config$middleware === void 0 ? [] : _config$middleware, platform = config.platform;
|
|
222
|
+
validMiddleware = middleware.filter(Boolean);
|
|
223
|
+
_context.next = 4;
|
|
224
|
+
return platform.isRTL == null ? void 0 : platform.isRTL(floating);
|
|
225
|
+
case 4:
|
|
226
|
+
rtl = _context.sent;
|
|
227
|
+
_context.next = 7;
|
|
228
|
+
return platform.getElementRects({
|
|
229
|
+
reference: reference,
|
|
230
|
+
floating: floating,
|
|
231
|
+
strategy: strategy
|
|
232
|
+
});
|
|
233
|
+
case 7:
|
|
234
|
+
rects = _context.sent;
|
|
235
|
+
_computeCoordsFromPla = computeCoordsFromPlacement(rects, placement, rtl), x = _computeCoordsFromPla.x, y = _computeCoordsFromPla.y;
|
|
236
|
+
statefulPlacement = placement;
|
|
237
|
+
middlewareData = {};
|
|
238
|
+
resetCount = 0;
|
|
239
|
+
i = 0;
|
|
240
|
+
case 13:
|
|
241
|
+
if (!(i < validMiddleware.length)) {
|
|
242
|
+
_context.next = 45;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
_validMiddleware$i = validMiddleware[i], name = _validMiddleware$i.name, fn = _validMiddleware$i.fn;
|
|
246
|
+
_context.next = 17;
|
|
247
|
+
return fn({
|
|
248
|
+
x: x,
|
|
249
|
+
y: y,
|
|
250
|
+
initialPlacement: placement,
|
|
251
|
+
placement: statefulPlacement,
|
|
252
|
+
strategy: strategy,
|
|
253
|
+
middlewareData: middlewareData,
|
|
254
|
+
rects: rects,
|
|
255
|
+
platform: platform,
|
|
256
|
+
elements: {
|
|
257
|
+
reference: reference,
|
|
258
|
+
floating: floating
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
case 17:
|
|
262
|
+
_yield$fn = _context.sent;
|
|
263
|
+
nextX = _yield$fn.x;
|
|
264
|
+
nextY = _yield$fn.y;
|
|
265
|
+
data = _yield$fn.data;
|
|
266
|
+
reset = _yield$fn.reset;
|
|
267
|
+
x = nextX != null ? nextX : x;
|
|
268
|
+
y = nextY != null ? nextY : y;
|
|
269
|
+
middlewareData = _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, middlewareData), {}, _rollupPluginBabelHelpers._defineProperty({}, name, _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, middlewareData[name]), data)));
|
|
270
|
+
if (!(reset && resetCount <= 50)) {
|
|
271
|
+
_context.next = 42;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
resetCount++;
|
|
275
|
+
if (!(_rollupPluginBabelHelpers._typeof(reset) === 'object')) {
|
|
276
|
+
_context.next = 41;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
if (reset.placement) {
|
|
280
|
+
statefulPlacement = reset.placement;
|
|
281
|
+
}
|
|
282
|
+
if (!reset.rects) {
|
|
283
|
+
_context.next = 38;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
if (!(reset.rects === true)) {
|
|
287
|
+
_context.next = 36;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
_context.next = 33;
|
|
291
|
+
return platform.getElementRects({
|
|
292
|
+
reference: reference,
|
|
293
|
+
floating: floating,
|
|
294
|
+
strategy: strategy
|
|
295
|
+
});
|
|
296
|
+
case 33:
|
|
297
|
+
_context.t0 = _context.sent;
|
|
298
|
+
_context.next = 37;
|
|
299
|
+
break;
|
|
300
|
+
case 36:
|
|
301
|
+
_context.t0 = reset.rects;
|
|
302
|
+
case 37:
|
|
303
|
+
rects = _context.t0;
|
|
304
|
+
case 38:
|
|
305
|
+
_computeCoordsFromPla2 = computeCoordsFromPlacement(rects, statefulPlacement, rtl);
|
|
306
|
+
x = _computeCoordsFromPla2.x;
|
|
307
|
+
y = _computeCoordsFromPla2.y;
|
|
308
|
+
case 41:
|
|
309
|
+
i = -1;
|
|
310
|
+
case 42:
|
|
311
|
+
i++;
|
|
312
|
+
_context.next = 13;
|
|
313
|
+
break;
|
|
314
|
+
case 45:
|
|
315
|
+
return _context.abrupt("return", {
|
|
316
|
+
x: x,
|
|
317
|
+
y: y,
|
|
318
|
+
placement: statefulPlacement,
|
|
319
|
+
strategy: strategy,
|
|
320
|
+
middlewareData: middlewareData
|
|
321
|
+
});
|
|
322
|
+
case 46:
|
|
323
|
+
case "end":
|
|
324
|
+
return _context.stop();
|
|
325
|
+
}
|
|
326
|
+
}, _callee);
|
|
327
|
+
}));
|
|
328
|
+
return function computePosition(_x, _x2, _x3) {
|
|
329
|
+
return _ref2.apply(this, arguments);
|
|
330
|
+
};
|
|
331
|
+
}();
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
335
|
+
* element is overflowing a given clipping boundary on each side.
|
|
336
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
337
|
+
* - negative = how many pixels left before it will overflow
|
|
338
|
+
* - 0 = lies flush with the boundary
|
|
339
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
340
|
+
*/
|
|
341
|
+
function detectOverflow(_x4, _x5) {
|
|
342
|
+
return _detectOverflow.apply(this, arguments);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Provides data to position an inner element of the floating element so that it
|
|
346
|
+
* appears centered to the reference element.
|
|
347
|
+
* @see https://floating-ui.com/docs/arrow
|
|
348
|
+
*/
|
|
349
|
+
function _detectOverflow() {
|
|
350
|
+
_detectOverflow = _rollupPluginBabelHelpers._asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers._regeneratorRuntime().mark(function _callee10(state, options) {
|
|
351
|
+
var _await$platform$isEle, x, y, platform, rects, elements, strategy, _evaluate8, _evaluate8$boundary, boundary, _evaluate8$rootBounda, rootBoundary, _evaluate8$elementCon, elementContext, _evaluate8$altBoundar, altBoundary, _evaluate8$padding, padding, paddingObject, altContext, element, clippingClientRect, rect, offsetParent, offsetScale, elementClientRect;
|
|
352
|
+
return _rollupPluginBabelHelpers._regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
353
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
354
|
+
case 0:
|
|
355
|
+
if (options === void 0) {
|
|
356
|
+
options = {};
|
|
357
|
+
}
|
|
358
|
+
x = state.x, y = state.y, platform = state.platform, rects = state.rects, elements = state.elements, strategy = state.strategy;
|
|
359
|
+
_evaluate8 = evaluate(options, state), _evaluate8$boundary = _evaluate8.boundary, boundary = _evaluate8$boundary === void 0 ? 'clippingAncestors' : _evaluate8$boundary, _evaluate8$rootBounda = _evaluate8.rootBoundary, rootBoundary = _evaluate8$rootBounda === void 0 ? 'viewport' : _evaluate8$rootBounda, _evaluate8$elementCon = _evaluate8.elementContext, elementContext = _evaluate8$elementCon === void 0 ? 'floating' : _evaluate8$elementCon, _evaluate8$altBoundar = _evaluate8.altBoundary, altBoundary = _evaluate8$altBoundar === void 0 ? false : _evaluate8$altBoundar, _evaluate8$padding = _evaluate8.padding, padding = _evaluate8$padding === void 0 ? 0 : _evaluate8$padding;
|
|
360
|
+
paddingObject = getPaddingObject(padding);
|
|
361
|
+
altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
362
|
+
element = elements[altBoundary ? altContext : elementContext];
|
|
363
|
+
_context10.t0 = rectToClientRect;
|
|
364
|
+
_context10.t1 = platform;
|
|
365
|
+
_context10.next = 10;
|
|
366
|
+
return platform.isElement == null ? void 0 : platform.isElement(element);
|
|
367
|
+
case 10:
|
|
368
|
+
_context10.t2 = _await$platform$isEle = _context10.sent;
|
|
369
|
+
if (!(_context10.t2 != null)) {
|
|
370
|
+
_context10.next = 15;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
_context10.t3 = _await$platform$isEle;
|
|
374
|
+
_context10.next = 16;
|
|
375
|
+
break;
|
|
376
|
+
case 15:
|
|
377
|
+
_context10.t3 = true;
|
|
378
|
+
case 16:
|
|
379
|
+
if (!_context10.t3) {
|
|
380
|
+
_context10.next = 20;
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
_context10.t4 = element;
|
|
384
|
+
_context10.next = 26;
|
|
385
|
+
break;
|
|
386
|
+
case 20:
|
|
387
|
+
_context10.t5 = element.contextElement;
|
|
388
|
+
if (_context10.t5) {
|
|
389
|
+
_context10.next = 25;
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
_context10.next = 24;
|
|
393
|
+
return platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating);
|
|
394
|
+
case 24:
|
|
395
|
+
_context10.t5 = _context10.sent;
|
|
396
|
+
case 25:
|
|
397
|
+
_context10.t4 = _context10.t5;
|
|
398
|
+
case 26:
|
|
399
|
+
_context10.t6 = _context10.t4;
|
|
400
|
+
_context10.t7 = boundary;
|
|
401
|
+
_context10.t8 = rootBoundary;
|
|
402
|
+
_context10.t9 = strategy;
|
|
403
|
+
_context10.t10 = {
|
|
404
|
+
element: _context10.t6,
|
|
405
|
+
boundary: _context10.t7,
|
|
406
|
+
rootBoundary: _context10.t8,
|
|
407
|
+
strategy: _context10.t9
|
|
408
|
+
};
|
|
409
|
+
_context10.next = 33;
|
|
410
|
+
return _context10.t1.getClippingRect.call(_context10.t1, _context10.t10);
|
|
411
|
+
case 33:
|
|
412
|
+
_context10.t11 = _context10.sent;
|
|
413
|
+
clippingClientRect = (0, _context10.t0)(_context10.t11);
|
|
414
|
+
rect = elementContext === 'floating' ? {
|
|
415
|
+
x: x,
|
|
416
|
+
y: y,
|
|
417
|
+
width: rects.floating.width,
|
|
418
|
+
height: rects.floating.height
|
|
419
|
+
} : rects.reference;
|
|
420
|
+
_context10.next = 38;
|
|
421
|
+
return platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating);
|
|
422
|
+
case 38:
|
|
423
|
+
offsetParent = _context10.sent;
|
|
424
|
+
_context10.next = 41;
|
|
425
|
+
return platform.isElement == null ? void 0 : platform.isElement(offsetParent);
|
|
426
|
+
case 41:
|
|
427
|
+
if (!_context10.sent) {
|
|
428
|
+
_context10.next = 50;
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
_context10.next = 44;
|
|
432
|
+
return platform.getScale == null ? void 0 : platform.getScale(offsetParent);
|
|
433
|
+
case 44:
|
|
434
|
+
_context10.t13 = _context10.sent;
|
|
435
|
+
if (_context10.t13) {
|
|
436
|
+
_context10.next = 47;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
_context10.t13 = {
|
|
440
|
+
x: 1,
|
|
441
|
+
y: 1
|
|
442
|
+
};
|
|
443
|
+
case 47:
|
|
444
|
+
_context10.t12 = _context10.t13;
|
|
445
|
+
_context10.next = 51;
|
|
446
|
+
break;
|
|
447
|
+
case 50:
|
|
448
|
+
_context10.t12 = {
|
|
449
|
+
x: 1,
|
|
450
|
+
y: 1
|
|
451
|
+
};
|
|
452
|
+
case 51:
|
|
453
|
+
offsetScale = _context10.t12;
|
|
454
|
+
_context10.t14 = rectToClientRect;
|
|
455
|
+
if (!platform.convertOffsetParentRelativeRectToViewportRelativeRect) {
|
|
456
|
+
_context10.next = 59;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
_context10.next = 56;
|
|
460
|
+
return platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
461
|
+
elements: elements,
|
|
462
|
+
rect: rect,
|
|
463
|
+
offsetParent: offsetParent,
|
|
464
|
+
strategy: strategy
|
|
465
|
+
});
|
|
466
|
+
case 56:
|
|
467
|
+
_context10.t15 = _context10.sent;
|
|
468
|
+
_context10.next = 60;
|
|
469
|
+
break;
|
|
470
|
+
case 59:
|
|
471
|
+
_context10.t15 = rect;
|
|
472
|
+
case 60:
|
|
473
|
+
_context10.t16 = _context10.t15;
|
|
474
|
+
elementClientRect = (0, _context10.t14)(_context10.t16);
|
|
475
|
+
return _context10.abrupt("return", {
|
|
476
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
477
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
478
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
479
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
480
|
+
});
|
|
481
|
+
case 63:
|
|
482
|
+
case "end":
|
|
483
|
+
return _context10.stop();
|
|
484
|
+
}
|
|
485
|
+
}, _callee10);
|
|
486
|
+
}));
|
|
487
|
+
return _detectOverflow.apply(this, arguments);
|
|
488
|
+
}
|
|
489
|
+
var arrow$2 = function arrow(options) {
|
|
490
|
+
return {
|
|
491
|
+
name: 'arrow',
|
|
492
|
+
options: options,
|
|
493
|
+
fn: function fn(state) {
|
|
494
|
+
return _rollupPluginBabelHelpers._asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers._regeneratorRuntime().mark(function _callee2() {
|
|
495
|
+
var x, y, placement, rects, platform, elements, middlewareData, _ref3, element, _ref3$padding, padding, paddingObject, coords, axis, length, arrowDimensions, isYAxis, minProp, maxProp, clientProp, endDiff, startDiff, arrowOffsetParent, clientSize, centerToReference, largestPossiblePadding, minPadding, maxPadding, min$1, max, center, offset, shouldAddOffset, alignmentOffset;
|
|
496
|
+
return _rollupPluginBabelHelpers._regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
497
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
498
|
+
case 0:
|
|
499
|
+
x = state.x, y = state.y, placement = state.placement, rects = state.rects, platform = state.platform, elements = state.elements, middlewareData = state.middlewareData; // Since `element` is required, we don't Partial<> the type.
|
|
500
|
+
_ref3 = evaluate(options, state) || {}, element = _ref3.element, _ref3$padding = _ref3.padding, padding = _ref3$padding === void 0 ? 0 : _ref3$padding;
|
|
501
|
+
if (!(element == null)) {
|
|
502
|
+
_context2.next = 4;
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
return _context2.abrupt("return", {});
|
|
506
|
+
case 4:
|
|
507
|
+
paddingObject = getPaddingObject(padding);
|
|
508
|
+
coords = {
|
|
509
|
+
x: x,
|
|
510
|
+
y: y
|
|
511
|
+
};
|
|
512
|
+
axis = getAlignmentAxis(placement);
|
|
513
|
+
length = getAxisLength(axis);
|
|
514
|
+
_context2.next = 10;
|
|
515
|
+
return platform.getDimensions(element);
|
|
516
|
+
case 10:
|
|
517
|
+
arrowDimensions = _context2.sent;
|
|
518
|
+
isYAxis = axis === 'y';
|
|
519
|
+
minProp = isYAxis ? 'top' : 'left';
|
|
520
|
+
maxProp = isYAxis ? 'bottom' : 'right';
|
|
521
|
+
clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
522
|
+
endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
523
|
+
startDiff = coords[axis] - rects.reference[axis];
|
|
524
|
+
_context2.next = 19;
|
|
525
|
+
return platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element);
|
|
526
|
+
case 19:
|
|
527
|
+
arrowOffsetParent = _context2.sent;
|
|
528
|
+
clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; // DOM platform can return `window` as the `offsetParent`.
|
|
529
|
+
_context2.t0 = !clientSize;
|
|
530
|
+
if (_context2.t0) {
|
|
531
|
+
_context2.next = 26;
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
_context2.next = 25;
|
|
535
|
+
return platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent);
|
|
536
|
+
case 25:
|
|
537
|
+
_context2.t0 = !_context2.sent;
|
|
538
|
+
case 26:
|
|
539
|
+
if (!_context2.t0) {
|
|
540
|
+
_context2.next = 28;
|
|
541
|
+
break;
|
|
542
|
+
}
|
|
543
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
544
|
+
case 28:
|
|
545
|
+
centerToReference = endDiff / 2 - startDiff / 2; // If the padding is large enough that it causes the arrow to no longer be
|
|
546
|
+
// centered, modify the padding so that it is centered.
|
|
547
|
+
largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
548
|
+
minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
549
|
+
maxPadding = min(paddingObject[maxProp], largestPossiblePadding); // Make sure the arrow doesn't overflow the floating element if the center
|
|
550
|
+
// point is outside the floating element's bounds.
|
|
551
|
+
min$1 = minPadding;
|
|
552
|
+
max = clientSize - arrowDimensions[length] - maxPadding;
|
|
553
|
+
center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
554
|
+
offset = clamp(min$1, center, max); // If the reference is small enough that the arrow's padding causes it to
|
|
555
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
556
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
557
|
+
// a single reset is performed when this is true.
|
|
558
|
+
shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
559
|
+
alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
560
|
+
return _context2.abrupt("return", _rollupPluginBabelHelpers._defineProperty(_rollupPluginBabelHelpers._defineProperty(_rollupPluginBabelHelpers._defineProperty({}, axis, coords[axis] + alignmentOffset), "data", _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._defineProperty(_rollupPluginBabelHelpers._defineProperty({}, axis, offset), "centerOffset", center - offset - alignmentOffset), shouldAddOffset && {
|
|
561
|
+
alignmentOffset: alignmentOffset
|
|
562
|
+
})), "reset", shouldAddOffset));
|
|
563
|
+
case 39:
|
|
564
|
+
case "end":
|
|
565
|
+
return _context2.stop();
|
|
566
|
+
}
|
|
567
|
+
}, _callee2);
|
|
568
|
+
}))();
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
575
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
576
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
577
|
+
* @see https://floating-ui.com/docs/flip
|
|
578
|
+
*/
|
|
579
|
+
var flip$1 = function flip(options) {
|
|
580
|
+
if (options === void 0) {
|
|
581
|
+
options = {};
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
name: 'flip',
|
|
585
|
+
options: options,
|
|
586
|
+
fn: function fn(state) {
|
|
587
|
+
return _rollupPluginBabelHelpers._asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers._regeneratorRuntime().mark(function _callee4() {
|
|
588
|
+
var _middlewareData$arrow, _middlewareData$flip, placement, middlewareData, rects, initialPlacement, platform, elements, _evaluate2, _evaluate2$mainAxis, checkMainAxis, _evaluate2$crossAxis, checkCrossAxis, specifiedFallbackPlacements, _evaluate2$fallbackSt, fallbackStrategy, _evaluate2$fallbackAx, fallbackAxisSideDirection, _evaluate2$flipAlignm, flipAlignment, detectOverflowOptions, side, isBasePlacement, rtl, fallbackPlacements, placements, overflow, overflows, overflowsData, _sides, _middlewareData$flip2, _overflowsData$filter, nextIndex, nextPlacement, resetPlacement, _overflowsData$map$so, _placement;
|
|
589
|
+
return _rollupPluginBabelHelpers._regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
590
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
591
|
+
case 0:
|
|
592
|
+
placement = state.placement, middlewareData = state.middlewareData, rects = state.rects, initialPlacement = state.initialPlacement, platform = state.platform, elements = state.elements;
|
|
593
|
+
_evaluate2 = evaluate(options, state), _evaluate2$mainAxis = _evaluate2.mainAxis, checkMainAxis = _evaluate2$mainAxis === void 0 ? true : _evaluate2$mainAxis, _evaluate2$crossAxis = _evaluate2.crossAxis, checkCrossAxis = _evaluate2$crossAxis === void 0 ? true : _evaluate2$crossAxis, specifiedFallbackPlacements = _evaluate2.fallbackPlacements, _evaluate2$fallbackSt = _evaluate2.fallbackStrategy, fallbackStrategy = _evaluate2$fallbackSt === void 0 ? 'bestFit' : _evaluate2$fallbackSt, _evaluate2$fallbackAx = _evaluate2.fallbackAxisSideDirection, fallbackAxisSideDirection = _evaluate2$fallbackAx === void 0 ? 'none' : _evaluate2$fallbackAx, _evaluate2$flipAlignm = _evaluate2.flipAlignment, flipAlignment = _evaluate2$flipAlignm === void 0 ? true : _evaluate2$flipAlignm, detectOverflowOptions = _rollupPluginBabelHelpers._objectWithoutProperties(_evaluate2, _excluded2); // If a reset by the arrow was caused due to an alignment offset being
|
|
594
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
595
|
+
// work.
|
|
596
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
597
|
+
if (!((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset)) {
|
|
598
|
+
_context4.next = 4;
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
return _context4.abrupt("return", {});
|
|
602
|
+
case 4:
|
|
603
|
+
side = getSide(placement);
|
|
604
|
+
isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
605
|
+
_context4.next = 8;
|
|
606
|
+
return platform.isRTL == null ? void 0 : platform.isRTL(elements.floating);
|
|
607
|
+
case 8:
|
|
608
|
+
rtl = _context4.sent;
|
|
609
|
+
fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
610
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
611
|
+
fallbackPlacements.push.apply(fallbackPlacements, _rollupPluginBabelHelpers._toConsumableArray(getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)));
|
|
612
|
+
}
|
|
613
|
+
placements = [initialPlacement].concat(_rollupPluginBabelHelpers._toConsumableArray(fallbackPlacements));
|
|
614
|
+
_context4.next = 14;
|
|
615
|
+
return detectOverflow(state, detectOverflowOptions);
|
|
616
|
+
case 14:
|
|
617
|
+
overflow = _context4.sent;
|
|
618
|
+
overflows = [];
|
|
619
|
+
overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
620
|
+
if (checkMainAxis) {
|
|
621
|
+
overflows.push(overflow[side]);
|
|
622
|
+
}
|
|
623
|
+
if (checkCrossAxis) {
|
|
624
|
+
_sides = getAlignmentSides(placement, rects, rtl);
|
|
625
|
+
overflows.push(overflow[_sides[0]], overflow[_sides[1]]);
|
|
626
|
+
}
|
|
627
|
+
overflowsData = [].concat(_rollupPluginBabelHelpers._toConsumableArray(overflowsData), [{
|
|
628
|
+
placement: placement,
|
|
629
|
+
overflows: overflows
|
|
630
|
+
}]);
|
|
631
|
+
|
|
632
|
+
// One or more sides is overflowing.
|
|
633
|
+
if (overflows.every(function (side) {
|
|
634
|
+
return side <= 0;
|
|
635
|
+
})) {
|
|
636
|
+
_context4.next = 37;
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
640
|
+
nextPlacement = placements[nextIndex];
|
|
641
|
+
if (!nextPlacement) {
|
|
642
|
+
_context4.next = 25;
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
return _context4.abrupt("return", {
|
|
646
|
+
data: {
|
|
647
|
+
index: nextIndex,
|
|
648
|
+
overflows: overflowsData
|
|
649
|
+
},
|
|
650
|
+
reset: {
|
|
651
|
+
placement: nextPlacement
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
case 25:
|
|
655
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
656
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
657
|
+
resetPlacement = (_overflowsData$filter = overflowsData.filter(function (d) {
|
|
658
|
+
return d.overflows[0] <= 0;
|
|
659
|
+
}).sort(function (a, b) {
|
|
660
|
+
return a.overflows[1] - b.overflows[1];
|
|
661
|
+
})[0]) == null ? void 0 : _overflowsData$filter.placement; // Otherwise fallback.
|
|
662
|
+
if (resetPlacement) {
|
|
663
|
+
_context4.next = 35;
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
_context4.t0 = fallbackStrategy;
|
|
667
|
+
_context4.next = _context4.t0 === 'bestFit' ? 30 : _context4.t0 === 'initialPlacement' ? 33 : 35;
|
|
668
|
+
break;
|
|
669
|
+
case 30:
|
|
670
|
+
_placement = (_overflowsData$map$so = overflowsData.map(function (d) {
|
|
671
|
+
return [d.placement, d.overflows.filter(function (overflow) {
|
|
672
|
+
return overflow > 0;
|
|
673
|
+
}).reduce(function (acc, overflow) {
|
|
674
|
+
return acc + overflow;
|
|
675
|
+
}, 0)];
|
|
676
|
+
}).sort(function (a, b) {
|
|
677
|
+
return a[1] - b[1];
|
|
678
|
+
})[0]) == null ? void 0 : _overflowsData$map$so[0];
|
|
679
|
+
if (_placement) {
|
|
680
|
+
resetPlacement = _placement;
|
|
681
|
+
}
|
|
682
|
+
return _context4.abrupt("break", 35);
|
|
683
|
+
case 33:
|
|
684
|
+
resetPlacement = initialPlacement;
|
|
685
|
+
return _context4.abrupt("break", 35);
|
|
686
|
+
case 35:
|
|
687
|
+
if (!(placement !== resetPlacement)) {
|
|
688
|
+
_context4.next = 37;
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
return _context4.abrupt("return", {
|
|
692
|
+
reset: {
|
|
693
|
+
placement: resetPlacement
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
case 37:
|
|
697
|
+
return _context4.abrupt("return", {});
|
|
698
|
+
case 38:
|
|
699
|
+
case "end":
|
|
700
|
+
return _context4.stop();
|
|
701
|
+
}
|
|
702
|
+
}, _callee4);
|
|
703
|
+
}))();
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
709
|
+
// Derivable.
|
|
710
|
+
function convertValueToCoords(_x6, _x7) {
|
|
711
|
+
return _convertValueToCoords.apply(this, arguments);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Modifies the placement by translating the floating element along the
|
|
715
|
+
* specified axes.
|
|
716
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
717
|
+
* object may be passed.
|
|
718
|
+
* @see https://floating-ui.com/docs/offset
|
|
719
|
+
*/
|
|
720
|
+
function _convertValueToCoords() {
|
|
721
|
+
_convertValueToCoords = _rollupPluginBabelHelpers._asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers._regeneratorRuntime().mark(function _callee11(state, options) {
|
|
722
|
+
var placement, platform, elements, rtl, side, alignment, isVertical, mainAxisMulti, crossAxisMulti, rawValue, _ref6, mainAxis, crossAxis, alignmentAxis;
|
|
723
|
+
return _rollupPluginBabelHelpers._regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
724
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
725
|
+
case 0:
|
|
726
|
+
placement = state.placement, platform = state.platform, elements = state.elements;
|
|
727
|
+
_context11.next = 3;
|
|
728
|
+
return platform.isRTL == null ? void 0 : platform.isRTL(elements.floating);
|
|
729
|
+
case 3:
|
|
730
|
+
rtl = _context11.sent;
|
|
731
|
+
side = getSide(placement);
|
|
732
|
+
alignment = getAlignment(placement);
|
|
733
|
+
isVertical = getSideAxis(placement) === 'y';
|
|
734
|
+
mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
735
|
+
crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
736
|
+
rawValue = evaluate(options, state); // eslint-disable-next-line prefer-const
|
|
737
|
+
_ref6 = typeof rawValue === 'number' ? {
|
|
738
|
+
mainAxis: rawValue,
|
|
739
|
+
crossAxis: 0,
|
|
740
|
+
alignmentAxis: null
|
|
741
|
+
} : _rollupPluginBabelHelpers._objectSpread2({
|
|
742
|
+
mainAxis: 0,
|
|
743
|
+
crossAxis: 0,
|
|
744
|
+
alignmentAxis: null
|
|
745
|
+
}, rawValue), mainAxis = _ref6.mainAxis, crossAxis = _ref6.crossAxis, alignmentAxis = _ref6.alignmentAxis;
|
|
746
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
747
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
748
|
+
}
|
|
749
|
+
return _context11.abrupt("return", isVertical ? {
|
|
750
|
+
x: crossAxis * crossAxisMulti,
|
|
751
|
+
y: mainAxis * mainAxisMulti
|
|
752
|
+
} : {
|
|
753
|
+
x: mainAxis * mainAxisMulti,
|
|
754
|
+
y: crossAxis * crossAxisMulti
|
|
755
|
+
});
|
|
756
|
+
case 13:
|
|
757
|
+
case "end":
|
|
758
|
+
return _context11.stop();
|
|
759
|
+
}
|
|
760
|
+
}, _callee11);
|
|
761
|
+
}));
|
|
762
|
+
return _convertValueToCoords.apply(this, arguments);
|
|
763
|
+
}
|
|
764
|
+
var offset$1 = function offset(options) {
|
|
765
|
+
return {
|
|
766
|
+
name: 'offset',
|
|
767
|
+
options: options,
|
|
768
|
+
fn: function fn(state) {
|
|
769
|
+
return _rollupPluginBabelHelpers._asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers._regeneratorRuntime().mark(function _callee7() {
|
|
770
|
+
var _middlewareData$offse, _middlewareData$arrow, x, y, placement, middlewareData, diffCoords;
|
|
771
|
+
return _rollupPluginBabelHelpers._regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
772
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
773
|
+
case 0:
|
|
774
|
+
x = state.x, y = state.y, placement = state.placement, middlewareData = state.middlewareData;
|
|
775
|
+
_context7.next = 3;
|
|
776
|
+
return convertValueToCoords(state, options);
|
|
777
|
+
case 3:
|
|
778
|
+
diffCoords = _context7.sent;
|
|
779
|
+
if (!(placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset)) {
|
|
780
|
+
_context7.next = 6;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
return _context7.abrupt("return", {});
|
|
784
|
+
case 6:
|
|
785
|
+
return _context7.abrupt("return", {
|
|
786
|
+
x: x + diffCoords.x,
|
|
787
|
+
y: y + diffCoords.y,
|
|
788
|
+
data: _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, diffCoords), {}, {
|
|
789
|
+
placement: placement
|
|
790
|
+
})
|
|
791
|
+
});
|
|
792
|
+
case 7:
|
|
793
|
+
case "end":
|
|
794
|
+
return _context7.stop();
|
|
795
|
+
}
|
|
796
|
+
}, _callee7);
|
|
797
|
+
}))();
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
804
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
805
|
+
* @see https://floating-ui.com/docs/shift
|
|
806
|
+
*/
|
|
807
|
+
var shift$1 = function shift(options) {
|
|
808
|
+
if (options === void 0) {
|
|
809
|
+
options = {};
|
|
810
|
+
}
|
|
811
|
+
return {
|
|
812
|
+
name: 'shift',
|
|
813
|
+
options: options,
|
|
814
|
+
fn: function fn(state) {
|
|
815
|
+
return _rollupPluginBabelHelpers._asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers._regeneratorRuntime().mark(function _callee8() {
|
|
816
|
+
var x, y, placement, _evaluate5, _evaluate5$mainAxis, checkMainAxis, _evaluate5$crossAxis, checkCrossAxis, _evaluate5$limiter, limiter, detectOverflowOptions, coords, overflow, crossAxis, mainAxis, mainAxisCoord, crossAxisCoord, minSide, maxSide, _min, _max, _minSide, _maxSide, _min2, _max2, limitedCoords;
|
|
817
|
+
return _rollupPluginBabelHelpers._regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
818
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
819
|
+
case 0:
|
|
820
|
+
x = state.x, y = state.y, placement = state.placement;
|
|
821
|
+
_evaluate5 = evaluate(options, state), _evaluate5$mainAxis = _evaluate5.mainAxis, checkMainAxis = _evaluate5$mainAxis === void 0 ? true : _evaluate5$mainAxis, _evaluate5$crossAxis = _evaluate5.crossAxis, checkCrossAxis = _evaluate5$crossAxis === void 0 ? false : _evaluate5$crossAxis, _evaluate5$limiter = _evaluate5.limiter, limiter = _evaluate5$limiter === void 0 ? {
|
|
822
|
+
fn: function fn(_ref) {
|
|
823
|
+
var x = _ref.x,
|
|
824
|
+
y = _ref.y;
|
|
825
|
+
return {
|
|
826
|
+
x: x,
|
|
827
|
+
y: y
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
} : _evaluate5$limiter, detectOverflowOptions = _rollupPluginBabelHelpers._objectWithoutProperties(_evaluate5, _excluded4);
|
|
831
|
+
coords = {
|
|
832
|
+
x: x,
|
|
833
|
+
y: y
|
|
834
|
+
};
|
|
835
|
+
_context8.next = 5;
|
|
836
|
+
return detectOverflow(state, detectOverflowOptions);
|
|
837
|
+
case 5:
|
|
838
|
+
overflow = _context8.sent;
|
|
839
|
+
crossAxis = getSideAxis(getSide(placement));
|
|
840
|
+
mainAxis = getOppositeAxis(crossAxis);
|
|
841
|
+
mainAxisCoord = coords[mainAxis];
|
|
842
|
+
crossAxisCoord = coords[crossAxis];
|
|
843
|
+
if (checkMainAxis) {
|
|
844
|
+
minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
845
|
+
maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
846
|
+
_min = mainAxisCoord + overflow[minSide];
|
|
847
|
+
_max = mainAxisCoord - overflow[maxSide];
|
|
848
|
+
mainAxisCoord = clamp(_min, mainAxisCoord, _max);
|
|
849
|
+
}
|
|
850
|
+
if (checkCrossAxis) {
|
|
851
|
+
_minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
852
|
+
_maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
853
|
+
_min2 = crossAxisCoord + overflow[_minSide];
|
|
854
|
+
_max2 = crossAxisCoord - overflow[_maxSide];
|
|
855
|
+
crossAxisCoord = clamp(_min2, crossAxisCoord, _max2);
|
|
856
|
+
}
|
|
857
|
+
limitedCoords = limiter.fn(_rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, state), {}, _rollupPluginBabelHelpers._defineProperty(_rollupPluginBabelHelpers._defineProperty({}, mainAxis, mainAxisCoord), crossAxis, crossAxisCoord)));
|
|
858
|
+
return _context8.abrupt("return", _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, limitedCoords), {}, {
|
|
859
|
+
data: {
|
|
860
|
+
x: limitedCoords.x - x,
|
|
861
|
+
y: limitedCoords.y - y
|
|
862
|
+
}
|
|
863
|
+
}));
|
|
864
|
+
case 14:
|
|
865
|
+
case "end":
|
|
866
|
+
return _context8.stop();
|
|
867
|
+
}
|
|
868
|
+
}, _callee8);
|
|
869
|
+
}))();
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
};
|
|
873
|
+
/**
|
|
874
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
875
|
+
*/
|
|
876
|
+
var limitShift$1 = function limitShift(options) {
|
|
877
|
+
if (options === void 0) {
|
|
878
|
+
options = {};
|
|
879
|
+
}
|
|
880
|
+
return {
|
|
881
|
+
options: options,
|
|
882
|
+
fn: function fn(state) {
|
|
883
|
+
var x = state.x,
|
|
884
|
+
y = state.y,
|
|
885
|
+
placement = state.placement,
|
|
886
|
+
rects = state.rects,
|
|
887
|
+
middlewareData = state.middlewareData;
|
|
888
|
+
var _evaluate6 = evaluate(options, state),
|
|
889
|
+
_evaluate6$offset = _evaluate6.offset,
|
|
890
|
+
offset = _evaluate6$offset === void 0 ? 0 : _evaluate6$offset,
|
|
891
|
+
_evaluate6$mainAxis = _evaluate6.mainAxis,
|
|
892
|
+
checkMainAxis = _evaluate6$mainAxis === void 0 ? true : _evaluate6$mainAxis,
|
|
893
|
+
_evaluate6$crossAxis = _evaluate6.crossAxis,
|
|
894
|
+
checkCrossAxis = _evaluate6$crossAxis === void 0 ? true : _evaluate6$crossAxis;
|
|
895
|
+
var coords = {
|
|
896
|
+
x: x,
|
|
897
|
+
y: y
|
|
898
|
+
};
|
|
899
|
+
var crossAxis = getSideAxis(placement);
|
|
900
|
+
var mainAxis = getOppositeAxis(crossAxis);
|
|
901
|
+
var mainAxisCoord = coords[mainAxis];
|
|
902
|
+
var crossAxisCoord = coords[crossAxis];
|
|
903
|
+
var rawOffset = evaluate(offset, state);
|
|
904
|
+
var computedOffset = typeof rawOffset === 'number' ? {
|
|
905
|
+
mainAxis: rawOffset,
|
|
906
|
+
crossAxis: 0
|
|
907
|
+
} : _rollupPluginBabelHelpers._objectSpread2({
|
|
908
|
+
mainAxis: 0,
|
|
909
|
+
crossAxis: 0
|
|
910
|
+
}, rawOffset);
|
|
911
|
+
if (checkMainAxis) {
|
|
912
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
913
|
+
var limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
914
|
+
var limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
915
|
+
if (mainAxisCoord < limitMin) {
|
|
916
|
+
mainAxisCoord = limitMin;
|
|
917
|
+
} else if (mainAxisCoord > limitMax) {
|
|
918
|
+
mainAxisCoord = limitMax;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
if (checkCrossAxis) {
|
|
922
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
923
|
+
var _len = mainAxis === 'y' ? 'width' : 'height';
|
|
924
|
+
var isOriginSide = ['top', 'left'].includes(getSide(placement));
|
|
925
|
+
var _limitMin = rects.reference[crossAxis] - rects.floating[_len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
926
|
+
var _limitMax = rects.reference[crossAxis] + rects.reference[_len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
927
|
+
if (crossAxisCoord < _limitMin) {
|
|
928
|
+
crossAxisCoord = _limitMin;
|
|
929
|
+
} else if (crossAxisCoord > _limitMax) {
|
|
930
|
+
crossAxisCoord = _limitMax;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
return _rollupPluginBabelHelpers._defineProperty(_rollupPluginBabelHelpers._defineProperty({}, mainAxis, mainAxisCoord), crossAxis, crossAxisCoord);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
var ORIGIN$1 = {
|
|
939
|
+
x: 0,
|
|
940
|
+
y: 0
|
|
941
|
+
};
|
|
942
|
+
function isView(reference) {
|
|
943
|
+
return 'measure' in reference;
|
|
944
|
+
}
|
|
945
|
+
var createPlatform = function createPlatform(_ref) {
|
|
946
|
+
var offsetParent = _ref.offsetParent,
|
|
947
|
+
_ref$sameScrollView = _ref.sameScrollView,
|
|
948
|
+
sameScrollView = _ref$sameScrollView === void 0 ? true : _ref$sameScrollView,
|
|
949
|
+
_ref$scrollOffsets = _ref.scrollOffsets,
|
|
950
|
+
scrollOffsets = _ref$scrollOffsets === void 0 ? ORIGIN$1 : _ref$scrollOffsets;
|
|
951
|
+
return {
|
|
952
|
+
getElementRects: function getElementRects(_ref2) {
|
|
953
|
+
var reference = _ref2.reference,
|
|
954
|
+
floating = _ref2.floating;
|
|
955
|
+
return new Promise(function (resolve) {
|
|
956
|
+
var onMeasure = function onMeasure(offsetX, offsetY) {
|
|
957
|
+
if (offsetX === void 0) {
|
|
958
|
+
offsetX = 0;
|
|
959
|
+
}
|
|
960
|
+
if (offsetY === void 0) {
|
|
961
|
+
offsetY = 0;
|
|
962
|
+
}
|
|
963
|
+
floating.measure(function (x, y, width, height) {
|
|
964
|
+
var floatingRect = _rollupPluginBabelHelpers._objectSpread2({
|
|
965
|
+
width: width,
|
|
966
|
+
height: height
|
|
967
|
+
}, ORIGIN$1);
|
|
968
|
+
var method = sameScrollView ? 'measure' : 'measureInWindow';
|
|
969
|
+
if (isView(reference)) {
|
|
970
|
+
reference[method](function (x, y, width, height) {
|
|
971
|
+
var referenceRect = {
|
|
972
|
+
width: width,
|
|
973
|
+
height: height,
|
|
974
|
+
x: x - offsetX,
|
|
975
|
+
y: y - offsetY
|
|
976
|
+
};
|
|
977
|
+
resolve({
|
|
978
|
+
reference: referenceRect,
|
|
979
|
+
floating: floatingRect
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
} else {
|
|
983
|
+
var boundingRect = reference.getBoundingClientRect();
|
|
984
|
+
var referenceRect = {
|
|
985
|
+
width: boundingRect.width,
|
|
986
|
+
height: boundingRect.height,
|
|
987
|
+
x: boundingRect.x - offsetX,
|
|
988
|
+
y: boundingRect.y - offsetY
|
|
989
|
+
};
|
|
990
|
+
resolve({
|
|
991
|
+
reference: referenceRect,
|
|
992
|
+
floating: floatingRect
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
};
|
|
997
|
+
if (offsetParent) {
|
|
998
|
+
offsetParent.measure(onMeasure);
|
|
999
|
+
} else {
|
|
1000
|
+
onMeasure();
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
},
|
|
1004
|
+
getClippingRect: function getClippingRect() {
|
|
1005
|
+
var _Dimensions$get = reactNative.Dimensions.get('window'),
|
|
1006
|
+
width = _Dimensions$get.width,
|
|
1007
|
+
height = _Dimensions$get.height;
|
|
1008
|
+
return Promise.resolve(_rollupPluginBabelHelpers._objectSpread2({
|
|
1009
|
+
width: width,
|
|
1010
|
+
height: height
|
|
1011
|
+
}, sameScrollView ? scrollOffsets : ORIGIN$1));
|
|
1012
|
+
},
|
|
1013
|
+
convertOffsetParentRelativeRectToViewportRelativeRect: function convertOffsetParentRelativeRectToViewportRelativeRect(_ref3) {
|
|
1014
|
+
var rect = _ref3.rect;
|
|
1015
|
+
return new Promise(function (resolve) {
|
|
1016
|
+
var onMeasure = function onMeasure(offsetX, offsetY) {
|
|
1017
|
+
if (offsetX === void 0) {
|
|
1018
|
+
offsetX = 0;
|
|
1019
|
+
}
|
|
1020
|
+
if (offsetY === void 0) {
|
|
1021
|
+
offsetY = 0;
|
|
1022
|
+
}
|
|
1023
|
+
resolve(_rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, rect), {}, {
|
|
1024
|
+
x: rect.x + offsetX,
|
|
1025
|
+
y: rect.y + offsetY
|
|
1026
|
+
}));
|
|
1027
|
+
};
|
|
1028
|
+
if (offsetParent) {
|
|
1029
|
+
offsetParent.measure(onMeasure);
|
|
1030
|
+
} else {
|
|
1031
|
+
onMeasure();
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
},
|
|
1035
|
+
getDimensions: function getDimensions(element) {
|
|
1036
|
+
return new Promise(function (resolve) {
|
|
1037
|
+
return element.measure(function (x, y, width, height) {
|
|
1038
|
+
return resolve({
|
|
1039
|
+
width: width,
|
|
1040
|
+
height: height
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// Fork of `fast-deep-equal` that only does the comparisons we need and compares
|
|
1049
|
+
// functions
|
|
1050
|
+
function deepEqual(a, b) {
|
|
1051
|
+
if (a === b) {
|
|
1052
|
+
return true;
|
|
1053
|
+
}
|
|
1054
|
+
if (_rollupPluginBabelHelpers._typeof(a) !== _rollupPluginBabelHelpers._typeof(b)) {
|
|
1055
|
+
return false;
|
|
1056
|
+
}
|
|
1057
|
+
if (typeof a === 'function' && a.toString() === b.toString()) {
|
|
1058
|
+
return true;
|
|
1059
|
+
}
|
|
1060
|
+
var length;
|
|
1061
|
+
var i;
|
|
1062
|
+
var keys;
|
|
1063
|
+
if (a && b && _rollupPluginBabelHelpers._typeof(a) === 'object') {
|
|
1064
|
+
if (Array.isArray(a)) {
|
|
1065
|
+
length = a.length;
|
|
1066
|
+
if (length !== b.length) return false;
|
|
1067
|
+
for (i = length; i-- !== 0;) {
|
|
1068
|
+
if (!deepEqual(a[i], b[i])) {
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
return true;
|
|
1073
|
+
}
|
|
1074
|
+
keys = Object.keys(a);
|
|
1075
|
+
length = keys.length;
|
|
1076
|
+
if (length !== Object.keys(b).length) {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
for (i = length; i-- !== 0;) {
|
|
1080
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
for (i = length; i-- !== 0;) {
|
|
1085
|
+
var key = keys[i];
|
|
1086
|
+
if (key === '_owner' && a.$$typeof) {
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
if (!deepEqual(a[key], b[key])) {
|
|
1090
|
+
return false;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1095
|
+
return a !== a && b !== b;
|
|
1096
|
+
}
|
|
1097
|
+
var ORIGIN = {
|
|
1098
|
+
x: 0,
|
|
1099
|
+
y: 0
|
|
1100
|
+
};
|
|
1101
|
+
function useFloating$1(options) {
|
|
1102
|
+
if (options === void 0) {
|
|
1103
|
+
options = {};
|
|
1104
|
+
}
|
|
1105
|
+
var _options = options,
|
|
1106
|
+
_options$placement = _options.placement,
|
|
1107
|
+
placement = _options$placement === void 0 ? 'bottom' : _options$placement,
|
|
1108
|
+
_options$middleware = _options.middleware,
|
|
1109
|
+
middleware = _options$middleware === void 0 ? [] : _options$middleware,
|
|
1110
|
+
_options$sameScrollVi = _options.sameScrollView,
|
|
1111
|
+
sameScrollView = _options$sameScrollVi === void 0 ? true : _options$sameScrollVi,
|
|
1112
|
+
_options$elements = _options.elements,
|
|
1113
|
+
_options$elements2 = _options$elements === void 0 ? {} : _options$elements,
|
|
1114
|
+
externalReference = _options$elements2.reference,
|
|
1115
|
+
externalFloating = _options$elements2.floating,
|
|
1116
|
+
externalOffsetParent = _options$elements2.offsetParent;
|
|
1117
|
+
var _React$useState = React__namespace.useState(null),
|
|
1118
|
+
_React$useState2 = _rollupPluginBabelHelpers._slicedToArray(_React$useState, 2),
|
|
1119
|
+
_reference = _React$useState2[0],
|
|
1120
|
+
_setReference = _React$useState2[1];
|
|
1121
|
+
var _React$useState3 = React__namespace.useState(null),
|
|
1122
|
+
_React$useState4 = _rollupPluginBabelHelpers._slicedToArray(_React$useState3, 2),
|
|
1123
|
+
_floating = _React$useState4[0],
|
|
1124
|
+
_setFloating = _React$useState4[1];
|
|
1125
|
+
var _React$useState5 = React__namespace.useState(null),
|
|
1126
|
+
_React$useState6 = _rollupPluginBabelHelpers._slicedToArray(_React$useState5, 2),
|
|
1127
|
+
_offsetParent = _React$useState6[0],
|
|
1128
|
+
_setOffsetParent = _React$useState6[1];
|
|
1129
|
+
var referenceEl = externalReference || _reference;
|
|
1130
|
+
var floatingEl = externalFloating || _floating;
|
|
1131
|
+
var offsetParentEl = externalOffsetParent || _offsetParent;
|
|
1132
|
+
var setReference = React__namespace.useCallback(function (node) {
|
|
1133
|
+
if (node !== referenceRef.current) {
|
|
1134
|
+
referenceRef.current = node;
|
|
1135
|
+
_setReference(node);
|
|
1136
|
+
}
|
|
1137
|
+
}, []);
|
|
1138
|
+
var setFloating = React__namespace.useCallback(function (node) {
|
|
1139
|
+
if (node !== floatingRef.current) {
|
|
1140
|
+
floatingRef.current = node;
|
|
1141
|
+
_setFloating(node);
|
|
1142
|
+
}
|
|
1143
|
+
}, []);
|
|
1144
|
+
var setOffsetParent = React__namespace.useCallback(function (node) {
|
|
1145
|
+
if (node !== offsetParentRef.current) {
|
|
1146
|
+
offsetParentRef.current = node;
|
|
1147
|
+
_setOffsetParent(node);
|
|
1148
|
+
}
|
|
1149
|
+
}, []);
|
|
1150
|
+
var referenceRef = React__namespace.useRef(null);
|
|
1151
|
+
var floatingRef = React__namespace.useRef(null);
|
|
1152
|
+
var offsetParentRef = React__namespace.useRef(null);
|
|
1153
|
+
var _React$useState7 = React__namespace.useState({
|
|
1154
|
+
x: 0,
|
|
1155
|
+
y: 0,
|
|
1156
|
+
placement: placement,
|
|
1157
|
+
strategy: 'absolute',
|
|
1158
|
+
middlewareData: {}
|
|
1159
|
+
}),
|
|
1160
|
+
_React$useState8 = _rollupPluginBabelHelpers._slicedToArray(_React$useState7, 2),
|
|
1161
|
+
data = _React$useState8[0],
|
|
1162
|
+
setData = _React$useState8[1];
|
|
1163
|
+
var _React$useState9 = React__namespace.useState(ORIGIN),
|
|
1164
|
+
_React$useState10 = _rollupPluginBabelHelpers._slicedToArray(_React$useState9, 2),
|
|
1165
|
+
scrollOffsets = _React$useState10[0],
|
|
1166
|
+
setScrollOffsets = _React$useState10[1];
|
|
1167
|
+
var _React$useState11 = React__namespace.useState(middleware),
|
|
1168
|
+
_React$useState12 = _rollupPluginBabelHelpers._slicedToArray(_React$useState11, 2),
|
|
1169
|
+
latestMiddleware = _React$useState12[0],
|
|
1170
|
+
setLatestMiddleware = _React$useState12[1];
|
|
1171
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
1172
|
+
setLatestMiddleware(middleware);
|
|
1173
|
+
}
|
|
1174
|
+
var platform = React__namespace.useMemo(function () {
|
|
1175
|
+
return createPlatform({
|
|
1176
|
+
offsetParent: offsetParentEl,
|
|
1177
|
+
scrollOffsets: scrollOffsets,
|
|
1178
|
+
sameScrollView: sameScrollView
|
|
1179
|
+
});
|
|
1180
|
+
}, [offsetParentEl, scrollOffsets, sameScrollView]);
|
|
1181
|
+
var update = React__namespace.useCallback(function () {
|
|
1182
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
computePosition(referenceRef.current, floatingRef.current, {
|
|
1186
|
+
middleware: latestMiddleware,
|
|
1187
|
+
platform: platform,
|
|
1188
|
+
placement: placement
|
|
1189
|
+
}).then(function (data) {
|
|
1190
|
+
if (isMountedRef.current) {
|
|
1191
|
+
setData(data);
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
}, [latestMiddleware, platform, placement]);
|
|
1195
|
+
React__namespace.useLayoutEffect(function () {
|
|
1196
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
1197
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
1198
|
+
if (offsetParentEl) offsetParentRef.current = offsetParentEl;
|
|
1199
|
+
var frame = requestAnimationFrame(update);
|
|
1200
|
+
return function () {
|
|
1201
|
+
cancelAnimationFrame(frame);
|
|
1202
|
+
};
|
|
1203
|
+
}, [referenceEl, floatingEl, offsetParentEl, update]);
|
|
1204
|
+
var isMountedRef = React__namespace.useRef(true);
|
|
1205
|
+
React__namespace.useLayoutEffect(function () {
|
|
1206
|
+
isMountedRef.current = true;
|
|
1207
|
+
return function () {
|
|
1208
|
+
isMountedRef.current = false;
|
|
1209
|
+
};
|
|
1210
|
+
}, []);
|
|
1211
|
+
var refs = React__namespace.useMemo(function () {
|
|
1212
|
+
return {
|
|
1213
|
+
reference: referenceRef,
|
|
1214
|
+
floating: floatingRef,
|
|
1215
|
+
offsetParent: offsetParentRef,
|
|
1216
|
+
setReference: setReference,
|
|
1217
|
+
setFloating: setFloating,
|
|
1218
|
+
setOffsetParent: setOffsetParent
|
|
1219
|
+
};
|
|
1220
|
+
}, [setReference, setFloating, setOffsetParent]);
|
|
1221
|
+
var elements = React__namespace.useMemo(function () {
|
|
1222
|
+
return {
|
|
1223
|
+
reference: referenceEl,
|
|
1224
|
+
floating: floatingEl,
|
|
1225
|
+
offsetParent: offsetParentEl
|
|
1226
|
+
};
|
|
1227
|
+
}, [referenceEl, floatingEl, offsetParentEl]);
|
|
1228
|
+
var floatingStyles = React__namespace.useMemo(function () {
|
|
1229
|
+
if (!elements.floating) {
|
|
1230
|
+
return {
|
|
1231
|
+
position: 'absolute',
|
|
1232
|
+
left: 0,
|
|
1233
|
+
top: 0
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
return {
|
|
1237
|
+
position: 'absolute',
|
|
1238
|
+
left: data.x,
|
|
1239
|
+
top: data.y
|
|
1240
|
+
};
|
|
1241
|
+
}, [elements.floating, data.x, data.y]);
|
|
1242
|
+
return React__namespace.useMemo(function () {
|
|
1243
|
+
return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, data), {}, {
|
|
1244
|
+
update: update,
|
|
1245
|
+
refs: refs,
|
|
1246
|
+
elements: elements,
|
|
1247
|
+
floatingStyles: floatingStyles,
|
|
1248
|
+
offsetParent: setOffsetParent,
|
|
1249
|
+
reference: setReference,
|
|
1250
|
+
floating: setFloating,
|
|
1251
|
+
scrollProps: {
|
|
1252
|
+
onScroll: function onScroll(event) {
|
|
1253
|
+
return setScrollOffsets(event.nativeEvent.contentOffset);
|
|
1254
|
+
},
|
|
1255
|
+
scrollEventThrottle: 16
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
}, [data, refs, elements, floatingStyles, setReference, setFloating, setOffsetParent, update]);
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* A data provider that provides data to position an inner element of the
|
|
1263
|
+
* floating element (usually a triangle or caret) so that it is centered to the
|
|
1264
|
+
* reference element.
|
|
1265
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
1266
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1267
|
+
*/
|
|
1268
|
+
var arrow$1 = function arrow$1(options) {
|
|
1269
|
+
function isRef(value) {
|
|
1270
|
+
return {}.hasOwnProperty.call(value, 'current');
|
|
1271
|
+
}
|
|
1272
|
+
return {
|
|
1273
|
+
name: 'arrow',
|
|
1274
|
+
options: options,
|
|
1275
|
+
fn: function fn(state) {
|
|
1276
|
+
var _ref4 = typeof options === 'function' ? options(state) : options,
|
|
1277
|
+
element = _ref4.element,
|
|
1278
|
+
padding = _ref4.padding;
|
|
1279
|
+
if (element && isRef(element)) {
|
|
1280
|
+
if (element.current != null) {
|
|
1281
|
+
return arrow$2({
|
|
1282
|
+
element: element.current,
|
|
1283
|
+
padding: padding
|
|
1284
|
+
}).fn(state);
|
|
1285
|
+
}
|
|
1286
|
+
return {};
|
|
1287
|
+
}
|
|
1288
|
+
if (element) {
|
|
1289
|
+
return arrow$2({
|
|
1290
|
+
element: element,
|
|
1291
|
+
padding: padding
|
|
1292
|
+
}).fn(state);
|
|
1293
|
+
}
|
|
1294
|
+
return {};
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* Modifies the placement by translating the floating element along the
|
|
1301
|
+
* specified axes.
|
|
1302
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1303
|
+
* object may be passed.
|
|
1304
|
+
* @see https://floating-ui.com/docs/offset
|
|
1305
|
+
*/
|
|
1306
|
+
var offset = function offset(options, deps) {
|
|
1307
|
+
return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, offset$1(options)), {}, {
|
|
1308
|
+
options: [options, deps]
|
|
1309
|
+
});
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1314
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1315
|
+
* @see https://floating-ui.com/docs/shift
|
|
1316
|
+
*/
|
|
1317
|
+
var shift = function shift(options, deps) {
|
|
1318
|
+
return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, shift$1(options)), {}, {
|
|
1319
|
+
options: [options, deps]
|
|
1320
|
+
});
|
|
1321
|
+
};
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
1325
|
+
*/
|
|
1326
|
+
var limitShift = function limitShift(options, deps) {
|
|
1327
|
+
return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, limitShift$1(options)), {}, {
|
|
1328
|
+
options: [options, deps]
|
|
1329
|
+
});
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1334
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1335
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1336
|
+
* @see https://floating-ui.com/docs/flip
|
|
1337
|
+
*/
|
|
1338
|
+
var flip = function flip(options, deps) {
|
|
1339
|
+
return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, flip$1(options)), {}, {
|
|
1340
|
+
options: [options, deps]
|
|
1341
|
+
});
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Provides data to position an inner element of the floating element so that it
|
|
1346
|
+
* appears centered to the reference element.
|
|
1347
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
1348
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1349
|
+
*/
|
|
1350
|
+
var arrow = function arrow(options, deps) {
|
|
1351
|
+
return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, arrow$1(options)), {}, {
|
|
1352
|
+
options: [options, deps]
|
|
1353
|
+
});
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
var _excluded = ["refs", "floatingStyles", "middlewareData", "elements"];
|
|
1357
|
+
var useFloating = function useFloating(_ref) {
|
|
1358
|
+
var _middlewareData$arrow, _middlewareData$offse, _middlewareData$offse2;
|
|
1359
|
+
var placement = _ref.placement,
|
|
1360
|
+
needModal = _ref.needModal;
|
|
1361
|
+
var _useState = React.useState(0),
|
|
1362
|
+
_useState2 = _rollupPluginBabelHelpers._slicedToArray(_useState, 2),
|
|
1363
|
+
floatingHeight = _useState2[0],
|
|
1364
|
+
setfloatingHeight = _useState2[1];
|
|
1365
|
+
var arrowRef = React.useRef(null);
|
|
1366
|
+
var _useFloatingUI = useFloating$1({
|
|
1367
|
+
placement: placement,
|
|
1368
|
+
sameScrollView: !needModal,
|
|
1369
|
+
// offset 9,箭头加空隙的宽度
|
|
1370
|
+
middleware: [shift({
|
|
1371
|
+
limiter: limitShift({
|
|
1372
|
+
offset: 9
|
|
1373
|
+
}),
|
|
1374
|
+
padding: 8
|
|
1375
|
+
}), flip(), offset(9), arrow({
|
|
1376
|
+
element: arrowRef,
|
|
1377
|
+
padding: 8
|
|
1378
|
+
})]
|
|
1379
|
+
}),
|
|
1380
|
+
refs = _useFloatingUI.refs,
|
|
1381
|
+
floatingStyles = _useFloatingUI.floatingStyles,
|
|
1382
|
+
middlewareData = _useFloatingUI.middlewareData,
|
|
1383
|
+
elements = _useFloatingUI.elements,
|
|
1384
|
+
other = _rollupPluginBabelHelpers._objectWithoutProperties(_useFloatingUI, _excluded);
|
|
1385
|
+
React.useEffect(function () {
|
|
1386
|
+
var _elements$floating;
|
|
1387
|
+
(_elements$floating = elements.floating) === null || _elements$floating === void 0 || _elements$floating.measure(function (x, y, width, height, pageX, pageY) {
|
|
1388
|
+
setfloatingHeight(height);
|
|
1389
|
+
});
|
|
1390
|
+
});
|
|
1391
|
+
return _rollupPluginBabelHelpers._objectSpread2({
|
|
1392
|
+
setFloatingRef: function setFloatingRef(ref) {
|
|
1393
|
+
return refs.setFloating(ref);
|
|
1394
|
+
},
|
|
1395
|
+
setReferenceRef: function setReferenceRef(ref) {
|
|
1396
|
+
return refs.setReference(ref);
|
|
1397
|
+
},
|
|
1398
|
+
setOffsetParentRef: refs.offsetParent,
|
|
1399
|
+
setArrowRef: arrowRef,
|
|
1400
|
+
refs: refs,
|
|
1401
|
+
elements: elements,
|
|
1402
|
+
middlewareData: middlewareData,
|
|
1403
|
+
floatingStyles: floatingStyles,
|
|
1404
|
+
arrowStyles: {
|
|
1405
|
+
position: "absolute",
|
|
1406
|
+
left: ((_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x) != null ? middlewareData.arrow.x : null,
|
|
1407
|
+
top: (_middlewareData$offse = middlewareData.offset) !== null && _middlewareData$offse !== void 0 && _middlewareData$offse.placement.includes("top") ? floatingHeight : -12,
|
|
1408
|
+
transform: (_middlewareData$offse2 = middlewareData.offset) !== null && _middlewareData$offse2 !== void 0 && _middlewareData$offse2.placement.includes("top") ? "rotate(180deg)" : "rotate(0deg)"
|
|
1409
|
+
}
|
|
1410
|
+
}, other);
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
exports.useFloating = useFloating;
|
|
1414
|
+
//# sourceMappingURL=hook.js.map
|