@ballistix.digital/react-components 2.1.1 → 2.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.
- package/dist/index.d.ts +36 -13
- package/dist/index.esm.js +3801 -249
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3796 -224
- package/dist/index.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { ArrowPathIcon, ChevronDownIcon, EllipsisVerticalIcon, ExclamationCircleIcon, ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon, ChevronUpIcon, ChevronUpDownIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
|
|
3
3
|
import { isArray, map, set, get, noop as noop$1, indexOf, toSafeInteger, pick, isEmpty, some, compact as compact$1, forEach, assign, includes, intersection, trim, lastIndexOf } from 'lodash';
|
|
4
4
|
import get$1 from 'lodash/get';
|
|
5
|
-
import
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import React__default, { useState, useMemo, useLayoutEffect, useEffect, useRef, Children, Fragment as Fragment$1, useCallback, forwardRef, useImperativeHandle, useReducer, createElement, PureComponent, Component } from 'react';
|
|
6
7
|
import { library } from '@fortawesome/fontawesome-svg-core';
|
|
7
8
|
import { fab } from '@fortawesome/free-brands-svg-icons';
|
|
8
9
|
import { fal } from '@fortawesome/pro-light-svg-icons';
|
|
@@ -10,6 +11,7 @@ import { far } from '@fortawesome/pro-regular-svg-icons';
|
|
|
10
11
|
import { fas } from '@fortawesome/pro-solid-svg-icons';
|
|
11
12
|
import { fat } from '@fortawesome/pro-thin-svg-icons';
|
|
12
13
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
14
|
+
import * as ReactDOM from 'react-dom';
|
|
13
15
|
import { Menu, Transition, Dialog, Popover, Switch as Switch$1 } from '@headlessui/react';
|
|
14
16
|
import { useMask } from '@react-input/mask';
|
|
15
17
|
import { ViewColumnsIcon, ChevronDownIcon as ChevronDownIcon$1, TableCellsIcon, XMarkIcon, PlusIcon } from '@heroicons/react/24/outline';
|
|
@@ -155,10 +157,10 @@ var deepCopyObject = function (object) {
|
|
|
155
157
|
var AvatarElement = function (props) {
|
|
156
158
|
var src = props.src, placeholder = props.placeholder, children = props.children, url = props.url, _a = props.size, size = _a === void 0 ? 'md' : _a, _b = props.figure, figure = _b === void 0 ? 'block' : _b, status = props.status, isDisabled = props.isDisabled, isLoading = props.isLoading, stylesOverrides = props.styles;
|
|
157
159
|
var handleGenerateStyle = function () {
|
|
158
|
-
var result = deepCopyObject(styles$
|
|
159
|
-
var keys = calculateNestedKeys(styles$
|
|
160
|
+
var result = deepCopyObject(styles$w.base);
|
|
161
|
+
var keys = calculateNestedKeys(styles$w.base);
|
|
160
162
|
keys.forEach(function (key) {
|
|
161
|
-
set(result, key, toClassName(get(styles$
|
|
163
|
+
set(result, key, toClassName(get(styles$w.base, key), size && get(styles$w[size], key), figure && get(styles$w[figure], key), status && get(styles$w[status], key), isDisabled && get(styles$w.disabled, key), isLoading && get(styles$w.loading, key), get(stylesOverrides, key)));
|
|
162
164
|
});
|
|
163
165
|
return result;
|
|
164
166
|
};
|
|
@@ -176,7 +178,7 @@ var AvatarElement = function (props) {
|
|
|
176
178
|
return (jsx("a", { href: url, children: jsxs("div", { className: "flex items-center", children: [jsxs("span", { className: "flex items-center justify-center", children: [jsx("div", { className: styles.container, style: { backgroundImage: "url(".concat(src, ")") } }), status && jsx("span", { className: styles.indicator })] }), children && jsx("div", { className: "ml-3", children: children })] }) }));
|
|
177
179
|
};
|
|
178
180
|
|
|
179
|
-
var base$
|
|
181
|
+
var base$s = {
|
|
180
182
|
loading: 'inline-block relative overflow-hidden bg-gray-50 flex items-center justify-center',
|
|
181
183
|
spinner: 'w-5 h-5 animate-spin text-gray-400',
|
|
182
184
|
empty: 'inline-block relative overflow-hidden bg-gray-50 text-red-400',
|
|
@@ -254,8 +256,8 @@ var online = {
|
|
|
254
256
|
var blocked = {
|
|
255
257
|
indicator: 'bg-red-400',
|
|
256
258
|
};
|
|
257
|
-
var styles$
|
|
258
|
-
base: base$
|
|
259
|
+
var styles$w = {
|
|
260
|
+
base: base$s,
|
|
259
261
|
xs: xs$4,
|
|
260
262
|
sm: sm$5,
|
|
261
263
|
md: md$4,
|
|
@@ -305,233 +307,3783 @@ var IconElement = function (props) {
|
|
|
305
307
|
component = (jsx(FontAwesomeIcon, { icon: ['fat', accessor], className: className }));
|
|
306
308
|
break;
|
|
307
309
|
}
|
|
308
|
-
return component;
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
var BadgeElement$1 = function (props) {
|
|
312
|
-
var title = props.title, message = props.message, _a = props.type, type = _a === void 0 ? 'generic' : _a, _b = props.onClose, onClose = _b === void 0 ? noop$1 : _b, _c = props.onCollapse, onCollapse = _c === void 0 ? noop$1 : _c, _d = props.isCollapsible, isCollapsible = _d === void 0 ? false : _d, stylesOverrides = props.styles, iconAccessorOverride = props.iconAccessor;
|
|
313
|
-
var _e = useState(false), isCollapsed = _e[0], setIsCollapsed = _e[1];
|
|
314
|
-
var handleGenerateStyle = function () {
|
|
315
|
-
var result = deepCopyObject(styles$
|
|
316
|
-
var keys = calculateNestedKeys(styles$
|
|
317
|
-
keys.forEach(function (key) {
|
|
318
|
-
set(result, key, toClassName(get(styles$
|
|
319
|
-
});
|
|
320
|
-
return result;
|
|
310
|
+
return component;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
var BadgeElement$1 = function (props) {
|
|
314
|
+
var title = props.title, message = props.message, _a = props.type, type = _a === void 0 ? 'generic' : _a, _b = props.onClose, onClose = _b === void 0 ? noop$1 : _b, _c = props.onCollapse, onCollapse = _c === void 0 ? noop$1 : _c, _d = props.isCollapsible, isCollapsible = _d === void 0 ? false : _d, stylesOverrides = props.styles, iconAccessorOverride = props.iconAccessor;
|
|
315
|
+
var _e = useState(false), isCollapsed = _e[0], setIsCollapsed = _e[1];
|
|
316
|
+
var handleGenerateStyle = function () {
|
|
317
|
+
var result = deepCopyObject(styles$v.base);
|
|
318
|
+
var keys = calculateNestedKeys(styles$v.base);
|
|
319
|
+
keys.forEach(function (key) {
|
|
320
|
+
set(result, key, toClassName(get(styles$v.base, key), type && get(styles$v[type], key), get(stylesOverrides, key)));
|
|
321
|
+
});
|
|
322
|
+
return result;
|
|
323
|
+
};
|
|
324
|
+
var styles = handleGenerateStyle();
|
|
325
|
+
var iconAccessor = useMemo(function () {
|
|
326
|
+
if (iconAccessorOverride)
|
|
327
|
+
return iconAccessorOverride;
|
|
328
|
+
switch (type) {
|
|
329
|
+
case 'info':
|
|
330
|
+
return 'question-circle';
|
|
331
|
+
case 'error':
|
|
332
|
+
return 'exclamation-triangle';
|
|
333
|
+
case 'warn':
|
|
334
|
+
return 'exclamation-circle';
|
|
335
|
+
case 'success':
|
|
336
|
+
return 'sparkles';
|
|
337
|
+
case 'generic':
|
|
338
|
+
default:
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
}, [iconAccessorOverride, type]);
|
|
342
|
+
return (jsx("div", { className: toClassName(styles.container), children: jsxs("div", { className: "flex h-full items-center", children: [jsx("div", { className: "flex-shrink-0", children: iconAccessor && (jsx(IconElement, { accessor: iconAccessor, className: toClassName(styles.icon), "aria-hidden": "true" })) }), jsxs("div", { className: styles.content.container, children: [jsxs("div", { children: [jsx("h3", { className: toClassName(styles.content.title), children: title }), !isCollapsed && (jsx("p", { className: toClassName(styles.content.message), children: message }))] }), jsxs("div", { className: styles.content.actions, children: [isCollapsible && (jsx("div", { onClick: function () {
|
|
343
|
+
setIsCollapsed(!isCollapsed);
|
|
344
|
+
onCollapse();
|
|
345
|
+
}, children: jsx(IconElement, { className: toClassName(styles.content.action, isCollapsed && styles.content.inverted), accessor: "chevron-up" }) })), jsx("div", { onClick: onClose, children: jsx(IconElement, { className: styles.content.action, accessor: "times" }) })] })] })] }) }));
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
var base$r = {
|
|
349
|
+
container: 'rounded-sm p-4 border-l-4',
|
|
350
|
+
icon: 'h-5 w-5',
|
|
351
|
+
content: {
|
|
352
|
+
container: 'ml-3 flex-1 md:flex md:justify-between ease-in-out transition-transform',
|
|
353
|
+
title: 'text-md font-semibold',
|
|
354
|
+
message: 'text-sm',
|
|
355
|
+
actions: 'flex gap-2',
|
|
356
|
+
action: 'h-5 w-5 !p-0 hover:opacity-60 cursor-pointer',
|
|
357
|
+
inverted: 'rotate-180',
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
var generic = {
|
|
361
|
+
container: 'bg-gray-50 border-gray-400',
|
|
362
|
+
icon: 'text-gray-400',
|
|
363
|
+
content: {
|
|
364
|
+
actions: 'text-gray-500',
|
|
365
|
+
message: 'text-gray-500',
|
|
366
|
+
title: 'text-gray-500 rotate',
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
var error$2 = {
|
|
370
|
+
container: 'bg-red-50 border-red-400',
|
|
371
|
+
icon: 'text-red-400',
|
|
372
|
+
content: {
|
|
373
|
+
actions: 'text-red-500',
|
|
374
|
+
message: 'text-red-500',
|
|
375
|
+
title: 'text-red-500',
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
var warn$1 = {
|
|
379
|
+
container: 'bg-yellow-50 border-orange-400',
|
|
380
|
+
icon: 'text-orange-400',
|
|
381
|
+
content: {
|
|
382
|
+
actions: 'text-orange-500',
|
|
383
|
+
message: 'text-orange-500',
|
|
384
|
+
title: 'text-orange-500',
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
var success$1 = {
|
|
388
|
+
container: 'bg-green-50 border-green-400',
|
|
389
|
+
icon: 'text-green-400',
|
|
390
|
+
content: {
|
|
391
|
+
actions: 'text-green-500',
|
|
392
|
+
message: 'text-green-500',
|
|
393
|
+
title: 'text-green-500',
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
var info = {
|
|
397
|
+
container: 'bg-blue-50 border-blue-400',
|
|
398
|
+
icon: 'text-blue-400',
|
|
399
|
+
content: {
|
|
400
|
+
actions: 'text-blue-500',
|
|
401
|
+
message: 'text-blue-500',
|
|
402
|
+
title: 'text-blue-500',
|
|
403
|
+
},
|
|
404
|
+
};
|
|
405
|
+
var styles$v = {
|
|
406
|
+
base: base$r,
|
|
407
|
+
generic: generic,
|
|
408
|
+
error: error$2,
|
|
409
|
+
warn: warn$1,
|
|
410
|
+
success: success$1,
|
|
411
|
+
info: info,
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
var BadgeElement = function (props) {
|
|
415
|
+
var children = props.children, _a = props.color, color = _a === void 0 ? 'gray' : _a, _b = props.type, type = _b === void 0 ? 'normal' : _b, _c = props.size, size = _c === void 0 ? 'sm' : _c, _d = props.figure, figure = _d === void 0 ? 'block' : _d, isDisabled = props.isDisabled, isLoading = props.isLoading, onClose = props.onClose, stylesOverrides = props.styles, dataCy = props.dataCy;
|
|
416
|
+
var handleGenerateStyle = function () {
|
|
417
|
+
var result = deepCopyObject(styles$u.base);
|
|
418
|
+
var keys = calculateNestedKeys(styles$u.base);
|
|
419
|
+
keys.forEach(function (key) {
|
|
420
|
+
set(result, key, toClassName(get(styles$u.base, key), type && get(styles$u[type], key), color && get(styles$u[color], key), size && get(styles$u[size], key), figure && get(styles$u[figure], key), isDisabled && get(styles$u.disabled, key), isLoading && get(styles$u.loading, key), get(stylesOverrides, key)));
|
|
421
|
+
});
|
|
422
|
+
return result;
|
|
423
|
+
};
|
|
424
|
+
var styles = handleGenerateStyle();
|
|
425
|
+
var xIcon = (jsx("svg", { className: "h-2 w-2", stroke: "currentColor", fill: "none", viewBox: "0 0 8 8", children: jsx("path", { strokeLinecap: "round", strokeWidth: "1.5", d: "M1 1l6 6m0-6L1 7" }) }));
|
|
426
|
+
if (isLoading) {
|
|
427
|
+
return (jsx("span", { className: toClassName(styles.container, 'h-4 w-12 animate-pulse'), children: type === 'indicator' && (jsx("svg", { className: styles.indicator, fill: "currentColor", viewBox: "0 0 8 8", children: jsx("circle", { cx: 4, cy: 4, r: 3 }) })) }));
|
|
428
|
+
}
|
|
429
|
+
return (jsxs("span", { className: styles.container, "data-cy": dataCy, children: [type === 'indicator' && (jsx("svg", { className: styles.indicator, fill: "currentColor", viewBox: "0 0 8 8", children: jsx("circle", { cx: 4, cy: 4, r: 3 }) })), children, type === 'close' && (jsxs("button", { type: "button", className: styles.button, onClick: onClose, children: [jsx("span", { className: "sr-only", children: "Remove large option" }), xIcon] }))] }));
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
var base$q = {
|
|
433
|
+
container: 'inline-flex items-center font-medium py-0.5',
|
|
434
|
+
indicator: '',
|
|
435
|
+
button: 'flex-shrink-0 ml-0.5 h-4 w-4 rounded-full inline-flex items-center justify-center focus:text-white focus:outline-none',
|
|
436
|
+
};
|
|
437
|
+
var normal$8 = {
|
|
438
|
+
container: 'px-2.5',
|
|
439
|
+
};
|
|
440
|
+
var indicator = {
|
|
441
|
+
container: 'px-2.5',
|
|
442
|
+
};
|
|
443
|
+
var close = {
|
|
444
|
+
container: 'pl-2.5 pr-1',
|
|
445
|
+
};
|
|
446
|
+
var primary$1 = {
|
|
447
|
+
container: "shadow-sm text-white bg-primary-600 hover:bg-primary-700",
|
|
448
|
+
};
|
|
449
|
+
var secondary$1 = {
|
|
450
|
+
container: "shadow-none text-primary-700 bg-primary-100 hover:bg-primary-200",
|
|
451
|
+
};
|
|
452
|
+
var outline$1 = {
|
|
453
|
+
container: "border-gray-300 text-gray-700 bg-white hover:bg-gray-50",
|
|
454
|
+
};
|
|
455
|
+
var sm$4 = {
|
|
456
|
+
container: 'text-xs',
|
|
457
|
+
indicator: 'mr-1.5 h-2 w-2 ',
|
|
458
|
+
};
|
|
459
|
+
var lg$4 = {
|
|
460
|
+
container: 'text-sm',
|
|
461
|
+
indicator: '-ml-0.5 mr-1.5 h-2 w-2',
|
|
462
|
+
};
|
|
463
|
+
var block$1 = {
|
|
464
|
+
container: 'rounded-md',
|
|
465
|
+
};
|
|
466
|
+
var rounded$1 = {
|
|
467
|
+
container: 'rounded-full',
|
|
468
|
+
};
|
|
469
|
+
var gray = {
|
|
470
|
+
container: 'bg-gray-100 text-gray-800',
|
|
471
|
+
indicator: 'text-gray-400',
|
|
472
|
+
button: 'text-gray-400 hover:bg-gray-200 hover:text-gray-500 focus:bg-gray-500',
|
|
473
|
+
};
|
|
474
|
+
var red = {
|
|
475
|
+
container: 'bg-red-100 text-red-800',
|
|
476
|
+
indicator: 'text-red-400',
|
|
477
|
+
button: 'text-red-400 hover:bg-red-200 hover:text-red-500 focus:bg-red-500',
|
|
478
|
+
};
|
|
479
|
+
var yellow = {
|
|
480
|
+
container: 'bg-yellow-100 text-yellow-800',
|
|
481
|
+
indicator: 'text-yellow-400',
|
|
482
|
+
button: 'text-yellow-400 hover:bg-yellow-200 hover:text-yellow-500 focus:bg-yellow-500',
|
|
483
|
+
};
|
|
484
|
+
var green = {
|
|
485
|
+
container: 'bg-green-100 text-green-800',
|
|
486
|
+
indicator: 'text-green-400',
|
|
487
|
+
button: 'text-green-400 hover:bg-green-200 hover:text-green-500 focus:bg-green-500',
|
|
488
|
+
};
|
|
489
|
+
var blue = {
|
|
490
|
+
container: 'bg-blue-100 text-blue-800',
|
|
491
|
+
indicator: 'text-blue-400',
|
|
492
|
+
button: 'text-blue-400 hover:bg-blue-200 hover:text-blue-500 focus:bg-blue-500',
|
|
493
|
+
};
|
|
494
|
+
var indigo = {
|
|
495
|
+
container: 'bg-primary-100 text-primary-800',
|
|
496
|
+
indicator: 'text-primary-400',
|
|
497
|
+
button: 'text-primary-400 hover:bg-primary-200 hover:text-primary-500 focus:outline-none focus:bg-primary-500',
|
|
498
|
+
};
|
|
499
|
+
var purple = {
|
|
500
|
+
container: 'bg-purple-100 text-purple-800',
|
|
501
|
+
indicator: 'text-purple-400',
|
|
502
|
+
button: 'text-purple-400 hover:bg-purple-200 hover:text-purple-500 focus:bg-purple-500',
|
|
503
|
+
};
|
|
504
|
+
var pink = {
|
|
505
|
+
container: 'bg-pink-100 text-pink-800',
|
|
506
|
+
indicator: 'text-pink-400',
|
|
507
|
+
button: 'text-pink-400 hover:bg-pink-200 hover:text-pink-500 focus:bg-purple-500',
|
|
508
|
+
};
|
|
509
|
+
var disabled$9 = {
|
|
510
|
+
container: 'opacity-20 cursor-not-allowed',
|
|
511
|
+
};
|
|
512
|
+
var loading$1 = {
|
|
513
|
+
container: 'cursor-progress',
|
|
514
|
+
};
|
|
515
|
+
var styles$u = {
|
|
516
|
+
base: base$q,
|
|
517
|
+
normal: normal$8,
|
|
518
|
+
indicator: indicator,
|
|
519
|
+
close: close,
|
|
520
|
+
primary: primary$1,
|
|
521
|
+
secondary: secondary$1,
|
|
522
|
+
outline: outline$1,
|
|
523
|
+
sm: sm$4,
|
|
524
|
+
lg: lg$4,
|
|
525
|
+
block: block$1,
|
|
526
|
+
rounded: rounded$1,
|
|
527
|
+
gray: gray,
|
|
528
|
+
red: red,
|
|
529
|
+
yellow: yellow,
|
|
530
|
+
green: green,
|
|
531
|
+
blue: blue,
|
|
532
|
+
indigo: indigo,
|
|
533
|
+
purple: purple,
|
|
534
|
+
pink: pink,
|
|
535
|
+
disabled: disabled$9,
|
|
536
|
+
loading: loading$1,
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
function getNodeName(node) {
|
|
540
|
+
if (isNode(node)) {
|
|
541
|
+
return (node.nodeName || '').toLowerCase();
|
|
542
|
+
}
|
|
543
|
+
return '#document';
|
|
544
|
+
}
|
|
545
|
+
function getWindow(node) {
|
|
546
|
+
var _node$ownerDocument;
|
|
547
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
548
|
+
}
|
|
549
|
+
function getDocumentElement(node) {
|
|
550
|
+
var _ref;
|
|
551
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
552
|
+
}
|
|
553
|
+
function isNode(value) {
|
|
554
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
555
|
+
}
|
|
556
|
+
function isElement(value) {
|
|
557
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
558
|
+
}
|
|
559
|
+
function isHTMLElement(value) {
|
|
560
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
561
|
+
}
|
|
562
|
+
function isShadowRoot(value) {
|
|
563
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
567
|
+
}
|
|
568
|
+
function isOverflowElement(element) {
|
|
569
|
+
const {
|
|
570
|
+
overflow,
|
|
571
|
+
overflowX,
|
|
572
|
+
overflowY,
|
|
573
|
+
display
|
|
574
|
+
} = getComputedStyle(element);
|
|
575
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
576
|
+
}
|
|
577
|
+
function isTableElement(element) {
|
|
578
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
579
|
+
}
|
|
580
|
+
function isContainingBlock(element) {
|
|
581
|
+
const webkit = isWebKit();
|
|
582
|
+
const css = getComputedStyle(element);
|
|
583
|
+
return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
|
|
584
|
+
}
|
|
585
|
+
function getContainingBlock(element) {
|
|
586
|
+
let currentNode = getParentNode(element);
|
|
587
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
588
|
+
if (isContainingBlock(currentNode)) {
|
|
589
|
+
return currentNode;
|
|
590
|
+
}
|
|
591
|
+
currentNode = getParentNode(currentNode);
|
|
592
|
+
}
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
function isWebKit() {
|
|
596
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
597
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
598
|
+
}
|
|
599
|
+
function isLastTraversableNode(node) {
|
|
600
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
601
|
+
}
|
|
602
|
+
function getComputedStyle(element) {
|
|
603
|
+
return getWindow(element).getComputedStyle(element);
|
|
604
|
+
}
|
|
605
|
+
function getNodeScroll(element) {
|
|
606
|
+
if (isElement(element)) {
|
|
607
|
+
return {
|
|
608
|
+
scrollLeft: element.scrollLeft,
|
|
609
|
+
scrollTop: element.scrollTop
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
return {
|
|
613
|
+
scrollLeft: element.pageXOffset,
|
|
614
|
+
scrollTop: element.pageYOffset
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function getParentNode(node) {
|
|
618
|
+
if (getNodeName(node) === 'html') {
|
|
619
|
+
return node;
|
|
620
|
+
}
|
|
621
|
+
const result =
|
|
622
|
+
node.assignedSlot ||
|
|
623
|
+
node.parentNode ||
|
|
624
|
+
isShadowRoot(node) && node.host ||
|
|
625
|
+
getDocumentElement(node);
|
|
626
|
+
return isShadowRoot(result) ? result.host : result;
|
|
627
|
+
}
|
|
628
|
+
function getNearestOverflowAncestor(node) {
|
|
629
|
+
const parentNode = getParentNode(node);
|
|
630
|
+
if (isLastTraversableNode(parentNode)) {
|
|
631
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
632
|
+
}
|
|
633
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
634
|
+
return parentNode;
|
|
635
|
+
}
|
|
636
|
+
return getNearestOverflowAncestor(parentNode);
|
|
637
|
+
}
|
|
638
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
639
|
+
var _node$ownerDocument2;
|
|
640
|
+
if (list === void 0) {
|
|
641
|
+
list = [];
|
|
642
|
+
}
|
|
643
|
+
if (traverseIframes === void 0) {
|
|
644
|
+
traverseIframes = true;
|
|
645
|
+
}
|
|
646
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
647
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
648
|
+
const win = getWindow(scrollableAncestor);
|
|
649
|
+
if (isBody) {
|
|
650
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
|
|
651
|
+
}
|
|
652
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
function activeElement(doc) {
|
|
656
|
+
let activeElement = doc.activeElement;
|
|
657
|
+
while (((_activeElement = activeElement) == null || (_activeElement = _activeElement.shadowRoot) == null ? void 0 : _activeElement.activeElement) != null) {
|
|
658
|
+
var _activeElement;
|
|
659
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
660
|
+
}
|
|
661
|
+
return activeElement;
|
|
662
|
+
}
|
|
663
|
+
function contains(parent, child) {
|
|
664
|
+
if (!parent || !child) {
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
|
|
668
|
+
if (parent.contains(child)) {
|
|
669
|
+
return true;
|
|
670
|
+
}
|
|
671
|
+
if (rootNode && isShadowRoot(rootNode)) {
|
|
672
|
+
let next = child;
|
|
673
|
+
while (next) {
|
|
674
|
+
if (parent === next) {
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
next = next.parentNode || next.host;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
function getPlatform() {
|
|
683
|
+
const uaData = navigator.userAgentData;
|
|
684
|
+
if (uaData != null && uaData.platform) {
|
|
685
|
+
return uaData.platform;
|
|
686
|
+
}
|
|
687
|
+
return navigator.platform;
|
|
688
|
+
}
|
|
689
|
+
function getUserAgent() {
|
|
690
|
+
const uaData = navigator.userAgentData;
|
|
691
|
+
if (uaData && Array.isArray(uaData.brands)) {
|
|
692
|
+
return uaData.brands.map(_ref => {
|
|
693
|
+
let {
|
|
694
|
+
brand,
|
|
695
|
+
version
|
|
696
|
+
} = _ref;
|
|
697
|
+
return brand + "/" + version;
|
|
698
|
+
}).join(' ');
|
|
699
|
+
}
|
|
700
|
+
return navigator.userAgent;
|
|
701
|
+
}
|
|
702
|
+
function isVirtualPointerEvent(event) {
|
|
703
|
+
if (isJSDOM()) return false;
|
|
704
|
+
return !isAndroid() && event.width === 0 && event.height === 0 || isAndroid() && event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'mouse' ||
|
|
705
|
+
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'touch';
|
|
706
|
+
}
|
|
707
|
+
function isSafari() {
|
|
708
|
+
return /apple/i.test(navigator.vendor);
|
|
709
|
+
}
|
|
710
|
+
function isAndroid() {
|
|
711
|
+
const re = /android/i;
|
|
712
|
+
return re.test(getPlatform()) || re.test(getUserAgent());
|
|
713
|
+
}
|
|
714
|
+
function isMac() {
|
|
715
|
+
return getPlatform().toLowerCase().startsWith('mac') && !navigator.maxTouchPoints;
|
|
716
|
+
}
|
|
717
|
+
function isJSDOM() {
|
|
718
|
+
return getUserAgent().includes('jsdom/');
|
|
719
|
+
}
|
|
720
|
+
function isMouseLikePointerType(pointerType, strict) {
|
|
721
|
+
const values = ['mouse', 'pen'];
|
|
722
|
+
if (!strict) {
|
|
723
|
+
values.push('', undefined);
|
|
724
|
+
}
|
|
725
|
+
return values.includes(pointerType);
|
|
726
|
+
}
|
|
727
|
+
function isReactEvent(event) {
|
|
728
|
+
return 'nativeEvent' in event;
|
|
729
|
+
}
|
|
730
|
+
function isRootElement(element) {
|
|
731
|
+
return element.matches('html,body');
|
|
732
|
+
}
|
|
733
|
+
function getDocument(node) {
|
|
734
|
+
return (node == null ? void 0 : node.ownerDocument) || document;
|
|
735
|
+
}
|
|
736
|
+
function isEventTargetWithin(event, node) {
|
|
737
|
+
if (node == null) {
|
|
738
|
+
return false;
|
|
739
|
+
}
|
|
740
|
+
if ('composedPath' in event) {
|
|
741
|
+
return event.composedPath().includes(node);
|
|
742
|
+
}
|
|
743
|
+
const e = event;
|
|
744
|
+
return e.target != null && node.contains(e.target);
|
|
745
|
+
}
|
|
746
|
+
function getTarget(event) {
|
|
747
|
+
if ('composedPath' in event) {
|
|
748
|
+
return event.composedPath()[0];
|
|
749
|
+
}
|
|
750
|
+
return event.target;
|
|
751
|
+
}
|
|
752
|
+
const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled])," + "[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
753
|
+
function isTypeableElement(element) {
|
|
754
|
+
return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
|
|
755
|
+
}
|
|
756
|
+
function stopEvent(event) {
|
|
757
|
+
event.preventDefault();
|
|
758
|
+
event.stopPropagation();
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
762
|
+
const alignments = ['start', 'end'];
|
|
763
|
+
sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
764
|
+
const min = Math.min;
|
|
765
|
+
const max = Math.max;
|
|
766
|
+
const round = Math.round;
|
|
767
|
+
const floor = Math.floor;
|
|
768
|
+
const createCoords = v => ({
|
|
769
|
+
x: v,
|
|
770
|
+
y: v
|
|
771
|
+
});
|
|
772
|
+
const oppositeSideMap = {
|
|
773
|
+
left: 'right',
|
|
774
|
+
right: 'left',
|
|
775
|
+
bottom: 'top',
|
|
776
|
+
top: 'bottom'
|
|
777
|
+
};
|
|
778
|
+
const oppositeAlignmentMap = {
|
|
779
|
+
start: 'end',
|
|
780
|
+
end: 'start'
|
|
781
|
+
};
|
|
782
|
+
function clamp(start, value, end) {
|
|
783
|
+
return max(start, min(value, end));
|
|
784
|
+
}
|
|
785
|
+
function evaluate(value, param) {
|
|
786
|
+
return typeof value === 'function' ? value(param) : value;
|
|
787
|
+
}
|
|
788
|
+
function getSide(placement) {
|
|
789
|
+
return placement.split('-')[0];
|
|
790
|
+
}
|
|
791
|
+
function getAlignment(placement) {
|
|
792
|
+
return placement.split('-')[1];
|
|
793
|
+
}
|
|
794
|
+
function getOppositeAxis(axis) {
|
|
795
|
+
return axis === 'x' ? 'y' : 'x';
|
|
796
|
+
}
|
|
797
|
+
function getAxisLength(axis) {
|
|
798
|
+
return axis === 'y' ? 'height' : 'width';
|
|
799
|
+
}
|
|
800
|
+
function getSideAxis(placement) {
|
|
801
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
|
|
802
|
+
}
|
|
803
|
+
function getAlignmentAxis(placement) {
|
|
804
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
805
|
+
}
|
|
806
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
807
|
+
if (rtl === void 0) {
|
|
808
|
+
rtl = false;
|
|
809
|
+
}
|
|
810
|
+
const alignment = getAlignment(placement);
|
|
811
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
812
|
+
const length = getAxisLength(alignmentAxis);
|
|
813
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
814
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
815
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
816
|
+
}
|
|
817
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
818
|
+
}
|
|
819
|
+
function getExpandedPlacements(placement) {
|
|
820
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
821
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
822
|
+
}
|
|
823
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
824
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
825
|
+
}
|
|
826
|
+
function getSideList(side, isStart, rtl) {
|
|
827
|
+
const lr = ['left', 'right'];
|
|
828
|
+
const rl = ['right', 'left'];
|
|
829
|
+
const tb = ['top', 'bottom'];
|
|
830
|
+
const bt = ['bottom', 'top'];
|
|
831
|
+
switch (side) {
|
|
832
|
+
case 'top':
|
|
833
|
+
case 'bottom':
|
|
834
|
+
if (rtl) return isStart ? rl : lr;
|
|
835
|
+
return isStart ? lr : rl;
|
|
836
|
+
case 'left':
|
|
837
|
+
case 'right':
|
|
838
|
+
return isStart ? tb : bt;
|
|
839
|
+
default:
|
|
840
|
+
return [];
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
844
|
+
const alignment = getAlignment(placement);
|
|
845
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
846
|
+
if (alignment) {
|
|
847
|
+
list = list.map(side => side + "-" + alignment);
|
|
848
|
+
if (flipAlignment) {
|
|
849
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return list;
|
|
853
|
+
}
|
|
854
|
+
function getOppositePlacement(placement) {
|
|
855
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
856
|
+
}
|
|
857
|
+
function expandPaddingObject(padding) {
|
|
858
|
+
return {
|
|
859
|
+
top: 0,
|
|
860
|
+
right: 0,
|
|
861
|
+
bottom: 0,
|
|
862
|
+
left: 0,
|
|
863
|
+
...padding
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function getPaddingObject(padding) {
|
|
867
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
868
|
+
top: padding,
|
|
869
|
+
right: padding,
|
|
870
|
+
bottom: padding,
|
|
871
|
+
left: padding
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
function rectToClientRect(rect) {
|
|
875
|
+
const {
|
|
876
|
+
x,
|
|
877
|
+
y,
|
|
878
|
+
width,
|
|
879
|
+
height
|
|
880
|
+
} = rect;
|
|
881
|
+
return {
|
|
882
|
+
width,
|
|
883
|
+
height,
|
|
884
|
+
top: y,
|
|
885
|
+
left: x,
|
|
886
|
+
right: x + width,
|
|
887
|
+
bottom: y + height,
|
|
888
|
+
x,
|
|
889
|
+
y
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
894
|
+
let {
|
|
895
|
+
reference,
|
|
896
|
+
floating
|
|
897
|
+
} = _ref;
|
|
898
|
+
const sideAxis = getSideAxis(placement);
|
|
899
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
900
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
901
|
+
const side = getSide(placement);
|
|
902
|
+
const isVertical = sideAxis === 'y';
|
|
903
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
904
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
905
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
906
|
+
let coords;
|
|
907
|
+
switch (side) {
|
|
908
|
+
case 'top':
|
|
909
|
+
coords = {
|
|
910
|
+
x: commonX,
|
|
911
|
+
y: reference.y - floating.height
|
|
912
|
+
};
|
|
913
|
+
break;
|
|
914
|
+
case 'bottom':
|
|
915
|
+
coords = {
|
|
916
|
+
x: commonX,
|
|
917
|
+
y: reference.y + reference.height
|
|
918
|
+
};
|
|
919
|
+
break;
|
|
920
|
+
case 'right':
|
|
921
|
+
coords = {
|
|
922
|
+
x: reference.x + reference.width,
|
|
923
|
+
y: commonY
|
|
924
|
+
};
|
|
925
|
+
break;
|
|
926
|
+
case 'left':
|
|
927
|
+
coords = {
|
|
928
|
+
x: reference.x - floating.width,
|
|
929
|
+
y: commonY
|
|
930
|
+
};
|
|
931
|
+
break;
|
|
932
|
+
default:
|
|
933
|
+
coords = {
|
|
934
|
+
x: reference.x,
|
|
935
|
+
y: reference.y
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
switch (getAlignment(placement)) {
|
|
939
|
+
case 'start':
|
|
940
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
941
|
+
break;
|
|
942
|
+
case 'end':
|
|
943
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
944
|
+
break;
|
|
945
|
+
}
|
|
946
|
+
return coords;
|
|
947
|
+
}
|
|
948
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
949
|
+
const {
|
|
950
|
+
placement = 'bottom',
|
|
951
|
+
strategy = 'absolute',
|
|
952
|
+
middleware = [],
|
|
953
|
+
platform
|
|
954
|
+
} = config;
|
|
955
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
956
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
957
|
+
let rects = await platform.getElementRects({
|
|
958
|
+
reference,
|
|
959
|
+
floating,
|
|
960
|
+
strategy
|
|
961
|
+
});
|
|
962
|
+
let {
|
|
963
|
+
x,
|
|
964
|
+
y
|
|
965
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
966
|
+
let statefulPlacement = placement;
|
|
967
|
+
let middlewareData = {};
|
|
968
|
+
let resetCount = 0;
|
|
969
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
970
|
+
const {
|
|
971
|
+
name,
|
|
972
|
+
fn
|
|
973
|
+
} = validMiddleware[i];
|
|
974
|
+
const {
|
|
975
|
+
x: nextX,
|
|
976
|
+
y: nextY,
|
|
977
|
+
data,
|
|
978
|
+
reset
|
|
979
|
+
} = await fn({
|
|
980
|
+
x,
|
|
981
|
+
y,
|
|
982
|
+
initialPlacement: placement,
|
|
983
|
+
placement: statefulPlacement,
|
|
984
|
+
strategy,
|
|
985
|
+
middlewareData,
|
|
986
|
+
rects,
|
|
987
|
+
platform,
|
|
988
|
+
elements: {
|
|
989
|
+
reference,
|
|
990
|
+
floating
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
x = nextX != null ? nextX : x;
|
|
994
|
+
y = nextY != null ? nextY : y;
|
|
995
|
+
middlewareData = {
|
|
996
|
+
...middlewareData,
|
|
997
|
+
[name]: {
|
|
998
|
+
...middlewareData[name],
|
|
999
|
+
...data
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
if (reset && resetCount <= 50) {
|
|
1003
|
+
resetCount++;
|
|
1004
|
+
if (typeof reset === 'object') {
|
|
1005
|
+
if (reset.placement) {
|
|
1006
|
+
statefulPlacement = reset.placement;
|
|
1007
|
+
}
|
|
1008
|
+
if (reset.rects) {
|
|
1009
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
1010
|
+
reference,
|
|
1011
|
+
floating,
|
|
1012
|
+
strategy
|
|
1013
|
+
}) : reset.rects;
|
|
1014
|
+
}
|
|
1015
|
+
({
|
|
1016
|
+
x,
|
|
1017
|
+
y
|
|
1018
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
1019
|
+
}
|
|
1020
|
+
i = -1;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return {
|
|
1024
|
+
x,
|
|
1025
|
+
y,
|
|
1026
|
+
placement: statefulPlacement,
|
|
1027
|
+
strategy,
|
|
1028
|
+
middlewareData
|
|
1029
|
+
};
|
|
1030
|
+
};
|
|
1031
|
+
async function detectOverflow(state, options) {
|
|
1032
|
+
var _await$platform$isEle;
|
|
1033
|
+
if (options === void 0) {
|
|
1034
|
+
options = {};
|
|
1035
|
+
}
|
|
1036
|
+
const {
|
|
1037
|
+
x,
|
|
1038
|
+
y,
|
|
1039
|
+
platform,
|
|
1040
|
+
rects,
|
|
1041
|
+
elements,
|
|
1042
|
+
strategy
|
|
1043
|
+
} = state;
|
|
1044
|
+
const {
|
|
1045
|
+
boundary = 'clippingAncestors',
|
|
1046
|
+
rootBoundary = 'viewport',
|
|
1047
|
+
elementContext = 'floating',
|
|
1048
|
+
altBoundary = false,
|
|
1049
|
+
padding = 0
|
|
1050
|
+
} = evaluate(options, state);
|
|
1051
|
+
const paddingObject = getPaddingObject(padding);
|
|
1052
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
1053
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
1054
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
1055
|
+
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))),
|
|
1056
|
+
boundary,
|
|
1057
|
+
rootBoundary,
|
|
1058
|
+
strategy
|
|
1059
|
+
}));
|
|
1060
|
+
const rect = elementContext === 'floating' ? {
|
|
1061
|
+
x,
|
|
1062
|
+
y,
|
|
1063
|
+
width: rects.floating.width,
|
|
1064
|
+
height: rects.floating.height
|
|
1065
|
+
} : rects.reference;
|
|
1066
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
1067
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
1068
|
+
x: 1,
|
|
1069
|
+
y: 1
|
|
1070
|
+
} : {
|
|
1071
|
+
x: 1,
|
|
1072
|
+
y: 1
|
|
1073
|
+
};
|
|
1074
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
1075
|
+
elements,
|
|
1076
|
+
rect,
|
|
1077
|
+
offsetParent,
|
|
1078
|
+
strategy
|
|
1079
|
+
}) : rect);
|
|
1080
|
+
return {
|
|
1081
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
1082
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
1083
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
1084
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
const arrow$3 = options => ({
|
|
1088
|
+
name: 'arrow',
|
|
1089
|
+
options,
|
|
1090
|
+
async fn(state) {
|
|
1091
|
+
const {
|
|
1092
|
+
x,
|
|
1093
|
+
y,
|
|
1094
|
+
placement,
|
|
1095
|
+
rects,
|
|
1096
|
+
platform,
|
|
1097
|
+
elements,
|
|
1098
|
+
middlewareData
|
|
1099
|
+
} = state;
|
|
1100
|
+
const {
|
|
1101
|
+
element,
|
|
1102
|
+
padding = 0
|
|
1103
|
+
} = evaluate(options, state) || {};
|
|
1104
|
+
if (element == null) {
|
|
1105
|
+
return {};
|
|
1106
|
+
}
|
|
1107
|
+
const paddingObject = getPaddingObject(padding);
|
|
1108
|
+
const coords = {
|
|
1109
|
+
x,
|
|
1110
|
+
y
|
|
1111
|
+
};
|
|
1112
|
+
const axis = getAlignmentAxis(placement);
|
|
1113
|
+
const length = getAxisLength(axis);
|
|
1114
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
1115
|
+
const isYAxis = axis === 'y';
|
|
1116
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
1117
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
1118
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
1119
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1120
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
1121
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
1122
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
1123
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
1124
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1125
|
+
}
|
|
1126
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
1127
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
1128
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
1129
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
1130
|
+
const min$1 = minPadding;
|
|
1131
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
1132
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1133
|
+
const offset = clamp(min$1, center, max);
|
|
1134
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1135
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
1136
|
+
return {
|
|
1137
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
1138
|
+
data: {
|
|
1139
|
+
[axis]: offset,
|
|
1140
|
+
centerOffset: center - offset - alignmentOffset,
|
|
1141
|
+
...(shouldAddOffset && {
|
|
1142
|
+
alignmentOffset
|
|
1143
|
+
})
|
|
1144
|
+
},
|
|
1145
|
+
reset: shouldAddOffset
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
const flip$2 = function (options) {
|
|
1150
|
+
if (options === void 0) {
|
|
1151
|
+
options = {};
|
|
1152
|
+
}
|
|
1153
|
+
return {
|
|
1154
|
+
name: 'flip',
|
|
1155
|
+
options,
|
|
1156
|
+
async fn(state) {
|
|
1157
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
1158
|
+
const {
|
|
1159
|
+
placement,
|
|
1160
|
+
middlewareData,
|
|
1161
|
+
rects,
|
|
1162
|
+
initialPlacement,
|
|
1163
|
+
platform,
|
|
1164
|
+
elements
|
|
1165
|
+
} = state;
|
|
1166
|
+
const {
|
|
1167
|
+
mainAxis: checkMainAxis = true,
|
|
1168
|
+
crossAxis: checkCrossAxis = true,
|
|
1169
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
1170
|
+
fallbackStrategy = 'bestFit',
|
|
1171
|
+
fallbackAxisSideDirection = 'none',
|
|
1172
|
+
flipAlignment = true,
|
|
1173
|
+
...detectOverflowOptions
|
|
1174
|
+
} = evaluate(options, state);
|
|
1175
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1176
|
+
return {};
|
|
1177
|
+
}
|
|
1178
|
+
const side = getSide(placement);
|
|
1179
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1180
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1181
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1182
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
1183
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1184
|
+
}
|
|
1185
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1186
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1187
|
+
const overflows = [];
|
|
1188
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1189
|
+
if (checkMainAxis) {
|
|
1190
|
+
overflows.push(overflow[side]);
|
|
1191
|
+
}
|
|
1192
|
+
if (checkCrossAxis) {
|
|
1193
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
1194
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
1195
|
+
}
|
|
1196
|
+
overflowsData = [...overflowsData, {
|
|
1197
|
+
placement,
|
|
1198
|
+
overflows
|
|
1199
|
+
}];
|
|
1200
|
+
if (!overflows.every(side => side <= 0)) {
|
|
1201
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
1202
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1203
|
+
const nextPlacement = placements[nextIndex];
|
|
1204
|
+
if (nextPlacement) {
|
|
1205
|
+
return {
|
|
1206
|
+
data: {
|
|
1207
|
+
index: nextIndex,
|
|
1208
|
+
overflows: overflowsData
|
|
1209
|
+
},
|
|
1210
|
+
reset: {
|
|
1211
|
+
placement: nextPlacement
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
1216
|
+
if (!resetPlacement) {
|
|
1217
|
+
switch (fallbackStrategy) {
|
|
1218
|
+
case 'bestFit':
|
|
1219
|
+
{
|
|
1220
|
+
var _overflowsData$map$so;
|
|
1221
|
+
const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
|
|
1222
|
+
if (placement) {
|
|
1223
|
+
resetPlacement = placement;
|
|
1224
|
+
}
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
case 'initialPlacement':
|
|
1228
|
+
resetPlacement = initialPlacement;
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
if (placement !== resetPlacement) {
|
|
1233
|
+
return {
|
|
1234
|
+
reset: {
|
|
1235
|
+
placement: resetPlacement
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
return {};
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
};
|
|
1244
|
+
async function convertValueToCoords(state, options) {
|
|
1245
|
+
const {
|
|
1246
|
+
placement,
|
|
1247
|
+
platform,
|
|
1248
|
+
elements
|
|
1249
|
+
} = state;
|
|
1250
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1251
|
+
const side = getSide(placement);
|
|
1252
|
+
const alignment = getAlignment(placement);
|
|
1253
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
1254
|
+
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
1255
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1256
|
+
const rawValue = evaluate(options, state);
|
|
1257
|
+
let {
|
|
1258
|
+
mainAxis,
|
|
1259
|
+
crossAxis,
|
|
1260
|
+
alignmentAxis
|
|
1261
|
+
} = typeof rawValue === 'number' ? {
|
|
1262
|
+
mainAxis: rawValue,
|
|
1263
|
+
crossAxis: 0,
|
|
1264
|
+
alignmentAxis: null
|
|
1265
|
+
} : {
|
|
1266
|
+
mainAxis: 0,
|
|
1267
|
+
crossAxis: 0,
|
|
1268
|
+
alignmentAxis: null,
|
|
1269
|
+
...rawValue
|
|
1270
|
+
};
|
|
1271
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
1272
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
1273
|
+
}
|
|
1274
|
+
return isVertical ? {
|
|
1275
|
+
x: crossAxis * crossAxisMulti,
|
|
1276
|
+
y: mainAxis * mainAxisMulti
|
|
1277
|
+
} : {
|
|
1278
|
+
x: mainAxis * mainAxisMulti,
|
|
1279
|
+
y: crossAxis * crossAxisMulti
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
const offset$2 = function (options) {
|
|
1283
|
+
if (options === void 0) {
|
|
1284
|
+
options = 0;
|
|
1285
|
+
}
|
|
1286
|
+
return {
|
|
1287
|
+
name: 'offset',
|
|
1288
|
+
options,
|
|
1289
|
+
async fn(state) {
|
|
1290
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
1291
|
+
const {
|
|
1292
|
+
x,
|
|
1293
|
+
y,
|
|
1294
|
+
placement,
|
|
1295
|
+
middlewareData
|
|
1296
|
+
} = state;
|
|
1297
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
1298
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1299
|
+
return {};
|
|
1300
|
+
}
|
|
1301
|
+
return {
|
|
1302
|
+
x: x + diffCoords.x,
|
|
1303
|
+
y: y + diffCoords.y,
|
|
1304
|
+
data: {
|
|
1305
|
+
...diffCoords,
|
|
1306
|
+
placement
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
};
|
|
1312
|
+
const shift$2 = function (options) {
|
|
1313
|
+
if (options === void 0) {
|
|
1314
|
+
options = {};
|
|
1315
|
+
}
|
|
1316
|
+
return {
|
|
1317
|
+
name: 'shift',
|
|
1318
|
+
options,
|
|
1319
|
+
async fn(state) {
|
|
1320
|
+
const {
|
|
1321
|
+
x,
|
|
1322
|
+
y,
|
|
1323
|
+
placement
|
|
1324
|
+
} = state;
|
|
1325
|
+
const {
|
|
1326
|
+
mainAxis: checkMainAxis = true,
|
|
1327
|
+
crossAxis: checkCrossAxis = false,
|
|
1328
|
+
limiter = {
|
|
1329
|
+
fn: _ref => {
|
|
1330
|
+
let {
|
|
1331
|
+
x,
|
|
1332
|
+
y
|
|
1333
|
+
} = _ref;
|
|
1334
|
+
return {
|
|
1335
|
+
x,
|
|
1336
|
+
y
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
},
|
|
1340
|
+
...detectOverflowOptions
|
|
1341
|
+
} = evaluate(options, state);
|
|
1342
|
+
const coords = {
|
|
1343
|
+
x,
|
|
1344
|
+
y
|
|
1345
|
+
};
|
|
1346
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1347
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
1348
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1349
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1350
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1351
|
+
if (checkMainAxis) {
|
|
1352
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
1353
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
1354
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
1355
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
1356
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
1357
|
+
}
|
|
1358
|
+
if (checkCrossAxis) {
|
|
1359
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
1360
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
1361
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
1362
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
1363
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
1364
|
+
}
|
|
1365
|
+
const limitedCoords = limiter.fn({
|
|
1366
|
+
...state,
|
|
1367
|
+
[mainAxis]: mainAxisCoord,
|
|
1368
|
+
[crossAxis]: crossAxisCoord
|
|
1369
|
+
});
|
|
1370
|
+
return {
|
|
1371
|
+
...limitedCoords,
|
|
1372
|
+
data: {
|
|
1373
|
+
x: limitedCoords.x - x,
|
|
1374
|
+
y: limitedCoords.y - y
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
function getCssDimensions(element) {
|
|
1382
|
+
const css = getComputedStyle(element);
|
|
1383
|
+
let width = parseFloat(css.width) || 0;
|
|
1384
|
+
let height = parseFloat(css.height) || 0;
|
|
1385
|
+
const hasOffset = isHTMLElement(element);
|
|
1386
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1387
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1388
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1389
|
+
if (shouldFallback) {
|
|
1390
|
+
width = offsetWidth;
|
|
1391
|
+
height = offsetHeight;
|
|
1392
|
+
}
|
|
1393
|
+
return {
|
|
1394
|
+
width,
|
|
1395
|
+
height,
|
|
1396
|
+
$: shouldFallback
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
function unwrapElement(element) {
|
|
1400
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1401
|
+
}
|
|
1402
|
+
function getScale(element) {
|
|
1403
|
+
const domElement = unwrapElement(element);
|
|
1404
|
+
if (!isHTMLElement(domElement)) {
|
|
1405
|
+
return createCoords(1);
|
|
1406
|
+
}
|
|
1407
|
+
const rect = domElement.getBoundingClientRect();
|
|
1408
|
+
const {
|
|
1409
|
+
width,
|
|
1410
|
+
height,
|
|
1411
|
+
$
|
|
1412
|
+
} = getCssDimensions(domElement);
|
|
1413
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1414
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1415
|
+
if (!x || !Number.isFinite(x)) {
|
|
1416
|
+
x = 1;
|
|
1417
|
+
}
|
|
1418
|
+
if (!y || !Number.isFinite(y)) {
|
|
1419
|
+
y = 1;
|
|
1420
|
+
}
|
|
1421
|
+
return {
|
|
1422
|
+
x,
|
|
1423
|
+
y
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
const noOffsets = createCoords(0);
|
|
1427
|
+
function getVisualOffsets(element) {
|
|
1428
|
+
const win = getWindow(element);
|
|
1429
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1430
|
+
return noOffsets;
|
|
1431
|
+
}
|
|
1432
|
+
return {
|
|
1433
|
+
x: win.visualViewport.offsetLeft,
|
|
1434
|
+
y: win.visualViewport.offsetTop
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1438
|
+
if (isFixed === void 0) {
|
|
1439
|
+
isFixed = false;
|
|
1440
|
+
}
|
|
1441
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1442
|
+
return false;
|
|
1443
|
+
}
|
|
1444
|
+
return isFixed;
|
|
1445
|
+
}
|
|
1446
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1447
|
+
if (includeScale === void 0) {
|
|
1448
|
+
includeScale = false;
|
|
1449
|
+
}
|
|
1450
|
+
if (isFixedStrategy === void 0) {
|
|
1451
|
+
isFixedStrategy = false;
|
|
1452
|
+
}
|
|
1453
|
+
const clientRect = element.getBoundingClientRect();
|
|
1454
|
+
const domElement = unwrapElement(element);
|
|
1455
|
+
let scale = createCoords(1);
|
|
1456
|
+
if (includeScale) {
|
|
1457
|
+
if (offsetParent) {
|
|
1458
|
+
if (isElement(offsetParent)) {
|
|
1459
|
+
scale = getScale(offsetParent);
|
|
1460
|
+
}
|
|
1461
|
+
} else {
|
|
1462
|
+
scale = getScale(element);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1466
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1467
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1468
|
+
let width = clientRect.width / scale.x;
|
|
1469
|
+
let height = clientRect.height / scale.y;
|
|
1470
|
+
if (domElement) {
|
|
1471
|
+
const win = getWindow(domElement);
|
|
1472
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1473
|
+
let currentWin = win;
|
|
1474
|
+
let currentIFrame = currentWin.frameElement;
|
|
1475
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1476
|
+
const iframeScale = getScale(currentIFrame);
|
|
1477
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1478
|
+
const css = getComputedStyle(currentIFrame);
|
|
1479
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1480
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1481
|
+
x *= iframeScale.x;
|
|
1482
|
+
y *= iframeScale.y;
|
|
1483
|
+
width *= iframeScale.x;
|
|
1484
|
+
height *= iframeScale.y;
|
|
1485
|
+
x += left;
|
|
1486
|
+
y += top;
|
|
1487
|
+
currentWin = getWindow(currentIFrame);
|
|
1488
|
+
currentIFrame = currentWin.frameElement;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
return rectToClientRect({
|
|
1492
|
+
width,
|
|
1493
|
+
height,
|
|
1494
|
+
x,
|
|
1495
|
+
y
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
const topLayerSelectors = [':popover-open', ':modal'];
|
|
1499
|
+
function isTopLayer(element) {
|
|
1500
|
+
return topLayerSelectors.some(selector => {
|
|
1501
|
+
try {
|
|
1502
|
+
return element.matches(selector);
|
|
1503
|
+
} catch (e) {
|
|
1504
|
+
return false;
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1509
|
+
let {
|
|
1510
|
+
elements,
|
|
1511
|
+
rect,
|
|
1512
|
+
offsetParent,
|
|
1513
|
+
strategy
|
|
1514
|
+
} = _ref;
|
|
1515
|
+
const isFixed = strategy === 'fixed';
|
|
1516
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1517
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1518
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1519
|
+
return rect;
|
|
1520
|
+
}
|
|
1521
|
+
let scroll = {
|
|
1522
|
+
scrollLeft: 0,
|
|
1523
|
+
scrollTop: 0
|
|
1524
|
+
};
|
|
1525
|
+
let scale = createCoords(1);
|
|
1526
|
+
const offsets = createCoords(0);
|
|
1527
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1528
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1529
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1530
|
+
scroll = getNodeScroll(offsetParent);
|
|
1531
|
+
}
|
|
1532
|
+
if (isHTMLElement(offsetParent)) {
|
|
1533
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1534
|
+
scale = getScale(offsetParent);
|
|
1535
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1536
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return {
|
|
1540
|
+
width: rect.width * scale.x,
|
|
1541
|
+
height: rect.height * scale.y,
|
|
1542
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
1543
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
function getClientRects(element) {
|
|
1547
|
+
return Array.from(element.getClientRects());
|
|
1548
|
+
}
|
|
1549
|
+
function getWindowScrollBarX(element) {
|
|
1550
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
1551
|
+
}
|
|
1552
|
+
function getDocumentRect(element) {
|
|
1553
|
+
const html = getDocumentElement(element);
|
|
1554
|
+
const scroll = getNodeScroll(element);
|
|
1555
|
+
const body = element.ownerDocument.body;
|
|
1556
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1557
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1558
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1559
|
+
const y = -scroll.scrollTop;
|
|
1560
|
+
if (getComputedStyle(body).direction === 'rtl') {
|
|
1561
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1562
|
+
}
|
|
1563
|
+
return {
|
|
1564
|
+
width,
|
|
1565
|
+
height,
|
|
1566
|
+
x,
|
|
1567
|
+
y
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
function getViewportRect(element, strategy) {
|
|
1571
|
+
const win = getWindow(element);
|
|
1572
|
+
const html = getDocumentElement(element);
|
|
1573
|
+
const visualViewport = win.visualViewport;
|
|
1574
|
+
let width = html.clientWidth;
|
|
1575
|
+
let height = html.clientHeight;
|
|
1576
|
+
let x = 0;
|
|
1577
|
+
let y = 0;
|
|
1578
|
+
if (visualViewport) {
|
|
1579
|
+
width = visualViewport.width;
|
|
1580
|
+
height = visualViewport.height;
|
|
1581
|
+
const visualViewportBased = isWebKit();
|
|
1582
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1583
|
+
x = visualViewport.offsetLeft;
|
|
1584
|
+
y = visualViewport.offsetTop;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
return {
|
|
1588
|
+
width,
|
|
1589
|
+
height,
|
|
1590
|
+
x,
|
|
1591
|
+
y
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1595
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1596
|
+
const top = clientRect.top + element.clientTop;
|
|
1597
|
+
const left = clientRect.left + element.clientLeft;
|
|
1598
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1599
|
+
const width = element.clientWidth * scale.x;
|
|
1600
|
+
const height = element.clientHeight * scale.y;
|
|
1601
|
+
const x = left * scale.x;
|
|
1602
|
+
const y = top * scale.y;
|
|
1603
|
+
return {
|
|
1604
|
+
width,
|
|
1605
|
+
height,
|
|
1606
|
+
x,
|
|
1607
|
+
y
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1611
|
+
let rect;
|
|
1612
|
+
if (clippingAncestor === 'viewport') {
|
|
1613
|
+
rect = getViewportRect(element, strategy);
|
|
1614
|
+
} else if (clippingAncestor === 'document') {
|
|
1615
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1616
|
+
} else if (isElement(clippingAncestor)) {
|
|
1617
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1618
|
+
} else {
|
|
1619
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1620
|
+
rect = {
|
|
1621
|
+
...clippingAncestor,
|
|
1622
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1623
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
return rectToClientRect(rect);
|
|
1627
|
+
}
|
|
1628
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1629
|
+
const parentNode = getParentNode(element);
|
|
1630
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1631
|
+
return false;
|
|
1632
|
+
}
|
|
1633
|
+
return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1634
|
+
}
|
|
1635
|
+
function getClippingElementAncestors(element, cache) {
|
|
1636
|
+
const cachedResult = cache.get(element);
|
|
1637
|
+
if (cachedResult) {
|
|
1638
|
+
return cachedResult;
|
|
1639
|
+
}
|
|
1640
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1641
|
+
let currentContainingBlockComputedStyle = null;
|
|
1642
|
+
const elementIsFixed = getComputedStyle(element).position === 'fixed';
|
|
1643
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1644
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1645
|
+
const computedStyle = getComputedStyle(currentNode);
|
|
1646
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1647
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1648
|
+
currentContainingBlockComputedStyle = null;
|
|
1649
|
+
}
|
|
1650
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1651
|
+
if (shouldDropCurrentNode) {
|
|
1652
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1653
|
+
} else {
|
|
1654
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1655
|
+
}
|
|
1656
|
+
currentNode = getParentNode(currentNode);
|
|
1657
|
+
}
|
|
1658
|
+
cache.set(element, result);
|
|
1659
|
+
return result;
|
|
1660
|
+
}
|
|
1661
|
+
function getClippingRect(_ref) {
|
|
1662
|
+
let {
|
|
1663
|
+
element,
|
|
1664
|
+
boundary,
|
|
1665
|
+
rootBoundary,
|
|
1666
|
+
strategy
|
|
1667
|
+
} = _ref;
|
|
1668
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1669
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1670
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1671
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1672
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1673
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1674
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1675
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1676
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1677
|
+
return accRect;
|
|
1678
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1679
|
+
return {
|
|
1680
|
+
width: clippingRect.right - clippingRect.left,
|
|
1681
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1682
|
+
x: clippingRect.left,
|
|
1683
|
+
y: clippingRect.top
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function getDimensions(element) {
|
|
1687
|
+
const {
|
|
1688
|
+
width,
|
|
1689
|
+
height
|
|
1690
|
+
} = getCssDimensions(element);
|
|
1691
|
+
return {
|
|
1692
|
+
width,
|
|
1693
|
+
height
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1697
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1698
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1699
|
+
const isFixed = strategy === 'fixed';
|
|
1700
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1701
|
+
let scroll = {
|
|
1702
|
+
scrollLeft: 0,
|
|
1703
|
+
scrollTop: 0
|
|
1704
|
+
};
|
|
1705
|
+
const offsets = createCoords(0);
|
|
1706
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1707
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1708
|
+
scroll = getNodeScroll(offsetParent);
|
|
1709
|
+
}
|
|
1710
|
+
if (isOffsetParentAnElement) {
|
|
1711
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1712
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1713
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1714
|
+
} else if (documentElement) {
|
|
1715
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
const x = rect.left + scroll.scrollLeft - offsets.x;
|
|
1719
|
+
const y = rect.top + scroll.scrollTop - offsets.y;
|
|
1720
|
+
return {
|
|
1721
|
+
x,
|
|
1722
|
+
y,
|
|
1723
|
+
width: rect.width,
|
|
1724
|
+
height: rect.height
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
function isStaticPositioned(element) {
|
|
1728
|
+
return getComputedStyle(element).position === 'static';
|
|
1729
|
+
}
|
|
1730
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1731
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
1732
|
+
return null;
|
|
1733
|
+
}
|
|
1734
|
+
if (polyfill) {
|
|
1735
|
+
return polyfill(element);
|
|
1736
|
+
}
|
|
1737
|
+
return element.offsetParent;
|
|
1738
|
+
}
|
|
1739
|
+
function getOffsetParent(element, polyfill) {
|
|
1740
|
+
const win = getWindow(element);
|
|
1741
|
+
if (isTopLayer(element)) {
|
|
1742
|
+
return win;
|
|
1743
|
+
}
|
|
1744
|
+
if (!isHTMLElement(element)) {
|
|
1745
|
+
let svgOffsetParent = getParentNode(element);
|
|
1746
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1747
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1748
|
+
return svgOffsetParent;
|
|
1749
|
+
}
|
|
1750
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1751
|
+
}
|
|
1752
|
+
return win;
|
|
1753
|
+
}
|
|
1754
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1755
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1756
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1757
|
+
}
|
|
1758
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1759
|
+
return win;
|
|
1760
|
+
}
|
|
1761
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1762
|
+
}
|
|
1763
|
+
const getElementRects = async function (data) {
|
|
1764
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1765
|
+
const getDimensionsFn = this.getDimensions;
|
|
1766
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1767
|
+
return {
|
|
1768
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1769
|
+
floating: {
|
|
1770
|
+
x: 0,
|
|
1771
|
+
y: 0,
|
|
1772
|
+
width: floatingDimensions.width,
|
|
1773
|
+
height: floatingDimensions.height
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
};
|
|
1777
|
+
function isRTL(element) {
|
|
1778
|
+
return getComputedStyle(element).direction === 'rtl';
|
|
1779
|
+
}
|
|
1780
|
+
const platform = {
|
|
1781
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1782
|
+
getDocumentElement,
|
|
1783
|
+
getClippingRect,
|
|
1784
|
+
getOffsetParent,
|
|
1785
|
+
getElementRects,
|
|
1786
|
+
getClientRects,
|
|
1787
|
+
getDimensions,
|
|
1788
|
+
getScale,
|
|
1789
|
+
isElement,
|
|
1790
|
+
isRTL
|
|
1791
|
+
};
|
|
1792
|
+
function observeMove(element, onMove) {
|
|
1793
|
+
let io = null;
|
|
1794
|
+
let timeoutId;
|
|
1795
|
+
const root = getDocumentElement(element);
|
|
1796
|
+
function cleanup() {
|
|
1797
|
+
var _io;
|
|
1798
|
+
clearTimeout(timeoutId);
|
|
1799
|
+
(_io = io) == null || _io.disconnect();
|
|
1800
|
+
io = null;
|
|
1801
|
+
}
|
|
1802
|
+
function refresh(skip, threshold) {
|
|
1803
|
+
if (skip === void 0) {
|
|
1804
|
+
skip = false;
|
|
1805
|
+
}
|
|
1806
|
+
if (threshold === void 0) {
|
|
1807
|
+
threshold = 1;
|
|
1808
|
+
}
|
|
1809
|
+
cleanup();
|
|
1810
|
+
const {
|
|
1811
|
+
left,
|
|
1812
|
+
top,
|
|
1813
|
+
width,
|
|
1814
|
+
height
|
|
1815
|
+
} = element.getBoundingClientRect();
|
|
1816
|
+
if (!skip) {
|
|
1817
|
+
onMove();
|
|
1818
|
+
}
|
|
1819
|
+
if (!width || !height) {
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
const insetTop = floor(top);
|
|
1823
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1824
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1825
|
+
const insetLeft = floor(left);
|
|
1826
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1827
|
+
const options = {
|
|
1828
|
+
rootMargin,
|
|
1829
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1830
|
+
};
|
|
1831
|
+
let isFirstUpdate = true;
|
|
1832
|
+
function handleObserve(entries) {
|
|
1833
|
+
const ratio = entries[0].intersectionRatio;
|
|
1834
|
+
if (ratio !== threshold) {
|
|
1835
|
+
if (!isFirstUpdate) {
|
|
1836
|
+
return refresh();
|
|
1837
|
+
}
|
|
1838
|
+
if (!ratio) {
|
|
1839
|
+
timeoutId = setTimeout(() => {
|
|
1840
|
+
refresh(false, 1e-7);
|
|
1841
|
+
}, 1000);
|
|
1842
|
+
} else {
|
|
1843
|
+
refresh(false, ratio);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
isFirstUpdate = false;
|
|
1847
|
+
}
|
|
1848
|
+
try {
|
|
1849
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1850
|
+
...options,
|
|
1851
|
+
root: root.ownerDocument
|
|
1852
|
+
});
|
|
1853
|
+
} catch (e) {
|
|
1854
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1855
|
+
}
|
|
1856
|
+
io.observe(element);
|
|
1857
|
+
}
|
|
1858
|
+
refresh(true);
|
|
1859
|
+
return cleanup;
|
|
1860
|
+
}
|
|
1861
|
+
function autoUpdate(reference, floating, update, options) {
|
|
1862
|
+
if (options === void 0) {
|
|
1863
|
+
options = {};
|
|
1864
|
+
}
|
|
1865
|
+
const {
|
|
1866
|
+
ancestorScroll = true,
|
|
1867
|
+
ancestorResize = true,
|
|
1868
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
1869
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
1870
|
+
animationFrame = false
|
|
1871
|
+
} = options;
|
|
1872
|
+
const referenceEl = unwrapElement(reference);
|
|
1873
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
1874
|
+
ancestors.forEach(ancestor => {
|
|
1875
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1876
|
+
passive: true
|
|
1877
|
+
});
|
|
1878
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1879
|
+
});
|
|
1880
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1881
|
+
let reobserveFrame = -1;
|
|
1882
|
+
let resizeObserver = null;
|
|
1883
|
+
if (elementResize) {
|
|
1884
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
1885
|
+
let [firstEntry] = _ref;
|
|
1886
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1887
|
+
resizeObserver.unobserve(floating);
|
|
1888
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1889
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1890
|
+
var _resizeObserver;
|
|
1891
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
update();
|
|
1895
|
+
});
|
|
1896
|
+
if (referenceEl && !animationFrame) {
|
|
1897
|
+
resizeObserver.observe(referenceEl);
|
|
1898
|
+
}
|
|
1899
|
+
resizeObserver.observe(floating);
|
|
1900
|
+
}
|
|
1901
|
+
let frameId;
|
|
1902
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1903
|
+
if (animationFrame) {
|
|
1904
|
+
frameLoop();
|
|
1905
|
+
}
|
|
1906
|
+
function frameLoop() {
|
|
1907
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
1908
|
+
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1909
|
+
update();
|
|
1910
|
+
}
|
|
1911
|
+
prevRefRect = nextRefRect;
|
|
1912
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
1913
|
+
}
|
|
1914
|
+
update();
|
|
1915
|
+
return () => {
|
|
1916
|
+
var _resizeObserver2;
|
|
1917
|
+
ancestors.forEach(ancestor => {
|
|
1918
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1919
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1920
|
+
});
|
|
1921
|
+
cleanupIo == null || cleanupIo();
|
|
1922
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
1923
|
+
resizeObserver = null;
|
|
1924
|
+
if (animationFrame) {
|
|
1925
|
+
cancelAnimationFrame(frameId);
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
const offset$1 = offset$2;
|
|
1930
|
+
const shift$1 = shift$2;
|
|
1931
|
+
const flip$1 = flip$2;
|
|
1932
|
+
const arrow$2 = arrow$3;
|
|
1933
|
+
const computePosition = (reference, floating, options) => {
|
|
1934
|
+
const cache = new Map();
|
|
1935
|
+
const mergedOptions = {
|
|
1936
|
+
platform,
|
|
1937
|
+
...options
|
|
1938
|
+
};
|
|
1939
|
+
const platformWithCache = {
|
|
1940
|
+
...mergedOptions.platform,
|
|
1941
|
+
_c: cache
|
|
1942
|
+
};
|
|
1943
|
+
return computePosition$1(reference, floating, {
|
|
1944
|
+
...mergedOptions,
|
|
1945
|
+
platform: platformWithCache
|
|
1946
|
+
});
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
var index$1 = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
|
|
1950
|
+
function deepEqual(a, b) {
|
|
1951
|
+
if (a === b) {
|
|
1952
|
+
return true;
|
|
1953
|
+
}
|
|
1954
|
+
if (typeof a !== typeof b) {
|
|
1955
|
+
return false;
|
|
1956
|
+
}
|
|
1957
|
+
if (typeof a === 'function' && a.toString() === b.toString()) {
|
|
1958
|
+
return true;
|
|
1959
|
+
}
|
|
1960
|
+
let length;
|
|
1961
|
+
let i;
|
|
1962
|
+
let keys;
|
|
1963
|
+
if (a && b && typeof a === 'object') {
|
|
1964
|
+
if (Array.isArray(a)) {
|
|
1965
|
+
length = a.length;
|
|
1966
|
+
if (length !== b.length) return false;
|
|
1967
|
+
for (i = length; i-- !== 0;) {
|
|
1968
|
+
if (!deepEqual(a[i], b[i])) {
|
|
1969
|
+
return false;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
return true;
|
|
1973
|
+
}
|
|
1974
|
+
keys = Object.keys(a);
|
|
1975
|
+
length = keys.length;
|
|
1976
|
+
if (length !== Object.keys(b).length) {
|
|
1977
|
+
return false;
|
|
1978
|
+
}
|
|
1979
|
+
for (i = length; i-- !== 0;) {
|
|
1980
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
1981
|
+
return false;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
for (i = length; i-- !== 0;) {
|
|
1985
|
+
const key = keys[i];
|
|
1986
|
+
if (key === '_owner' && a.$$typeof) {
|
|
1987
|
+
continue;
|
|
1988
|
+
}
|
|
1989
|
+
if (!deepEqual(a[key], b[key])) {
|
|
1990
|
+
return false;
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
return true;
|
|
1994
|
+
}
|
|
1995
|
+
return a !== a && b !== b;
|
|
1996
|
+
}
|
|
1997
|
+
function getDPR(element) {
|
|
1998
|
+
if (typeof window === 'undefined') {
|
|
1999
|
+
return 1;
|
|
2000
|
+
}
|
|
2001
|
+
const win = element.ownerDocument.defaultView || window;
|
|
2002
|
+
return win.devicePixelRatio || 1;
|
|
2003
|
+
}
|
|
2004
|
+
function roundByDPR(element, value) {
|
|
2005
|
+
const dpr = getDPR(element);
|
|
2006
|
+
return Math.round(value * dpr) / dpr;
|
|
2007
|
+
}
|
|
2008
|
+
function useLatestRef$1(value) {
|
|
2009
|
+
const ref = React.useRef(value);
|
|
2010
|
+
index$1(() => {
|
|
2011
|
+
ref.current = value;
|
|
2012
|
+
});
|
|
2013
|
+
return ref;
|
|
2014
|
+
}
|
|
2015
|
+
function useFloating$1(options) {
|
|
2016
|
+
if (options === void 0) {
|
|
2017
|
+
options = {};
|
|
2018
|
+
}
|
|
2019
|
+
const {
|
|
2020
|
+
placement = 'bottom',
|
|
2021
|
+
strategy = 'absolute',
|
|
2022
|
+
middleware = [],
|
|
2023
|
+
platform,
|
|
2024
|
+
elements: {
|
|
2025
|
+
reference: externalReference,
|
|
2026
|
+
floating: externalFloating
|
|
2027
|
+
} = {},
|
|
2028
|
+
transform = true,
|
|
2029
|
+
whileElementsMounted,
|
|
2030
|
+
open
|
|
2031
|
+
} = options;
|
|
2032
|
+
const [data, setData] = React.useState({
|
|
2033
|
+
x: 0,
|
|
2034
|
+
y: 0,
|
|
2035
|
+
strategy,
|
|
2036
|
+
placement,
|
|
2037
|
+
middlewareData: {},
|
|
2038
|
+
isPositioned: false
|
|
2039
|
+
});
|
|
2040
|
+
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
|
|
2041
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
2042
|
+
setLatestMiddleware(middleware);
|
|
2043
|
+
}
|
|
2044
|
+
const [_reference, _setReference] = React.useState(null);
|
|
2045
|
+
const [_floating, _setFloating] = React.useState(null);
|
|
2046
|
+
const setReference = React.useCallback(node => {
|
|
2047
|
+
if (node !== referenceRef.current) {
|
|
2048
|
+
referenceRef.current = node;
|
|
2049
|
+
_setReference(node);
|
|
2050
|
+
}
|
|
2051
|
+
}, []);
|
|
2052
|
+
const setFloating = React.useCallback(node => {
|
|
2053
|
+
if (node !== floatingRef.current) {
|
|
2054
|
+
floatingRef.current = node;
|
|
2055
|
+
_setFloating(node);
|
|
2056
|
+
}
|
|
2057
|
+
}, []);
|
|
2058
|
+
const referenceEl = externalReference || _reference;
|
|
2059
|
+
const floatingEl = externalFloating || _floating;
|
|
2060
|
+
const referenceRef = React.useRef(null);
|
|
2061
|
+
const floatingRef = React.useRef(null);
|
|
2062
|
+
const dataRef = React.useRef(data);
|
|
2063
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
2064
|
+
const whileElementsMountedRef = useLatestRef$1(whileElementsMounted);
|
|
2065
|
+
const platformRef = useLatestRef$1(platform);
|
|
2066
|
+
const update = React.useCallback(() => {
|
|
2067
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
const config = {
|
|
2071
|
+
placement,
|
|
2072
|
+
strategy,
|
|
2073
|
+
middleware: latestMiddleware
|
|
2074
|
+
};
|
|
2075
|
+
if (platformRef.current) {
|
|
2076
|
+
config.platform = platformRef.current;
|
|
2077
|
+
}
|
|
2078
|
+
computePosition(referenceRef.current, floatingRef.current, config).then(data => {
|
|
2079
|
+
const fullData = {
|
|
2080
|
+
...data,
|
|
2081
|
+
isPositioned: true
|
|
2082
|
+
};
|
|
2083
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
2084
|
+
dataRef.current = fullData;
|
|
2085
|
+
ReactDOM.flushSync(() => {
|
|
2086
|
+
setData(fullData);
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
});
|
|
2090
|
+
}, [latestMiddleware, placement, strategy, platformRef]);
|
|
2091
|
+
index$1(() => {
|
|
2092
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
2093
|
+
dataRef.current.isPositioned = false;
|
|
2094
|
+
setData(data => ({
|
|
2095
|
+
...data,
|
|
2096
|
+
isPositioned: false
|
|
2097
|
+
}));
|
|
2098
|
+
}
|
|
2099
|
+
}, [open]);
|
|
2100
|
+
const isMountedRef = React.useRef(false);
|
|
2101
|
+
index$1(() => {
|
|
2102
|
+
isMountedRef.current = true;
|
|
2103
|
+
return () => {
|
|
2104
|
+
isMountedRef.current = false;
|
|
2105
|
+
};
|
|
2106
|
+
}, []);
|
|
2107
|
+
index$1(() => {
|
|
2108
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
2109
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
2110
|
+
if (referenceEl && floatingEl) {
|
|
2111
|
+
if (whileElementsMountedRef.current) {
|
|
2112
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
2113
|
+
}
|
|
2114
|
+
update();
|
|
2115
|
+
}
|
|
2116
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
2117
|
+
const refs = React.useMemo(() => ({
|
|
2118
|
+
reference: referenceRef,
|
|
2119
|
+
floating: floatingRef,
|
|
2120
|
+
setReference,
|
|
2121
|
+
setFloating
|
|
2122
|
+
}), [setReference, setFloating]);
|
|
2123
|
+
const elements = React.useMemo(() => ({
|
|
2124
|
+
reference: referenceEl,
|
|
2125
|
+
floating: floatingEl
|
|
2126
|
+
}), [referenceEl, floatingEl]);
|
|
2127
|
+
const floatingStyles = React.useMemo(() => {
|
|
2128
|
+
const initialStyles = {
|
|
2129
|
+
position: strategy,
|
|
2130
|
+
left: 0,
|
|
2131
|
+
top: 0
|
|
2132
|
+
};
|
|
2133
|
+
if (!elements.floating) {
|
|
2134
|
+
return initialStyles;
|
|
2135
|
+
}
|
|
2136
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
2137
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
2138
|
+
if (transform) {
|
|
2139
|
+
return {
|
|
2140
|
+
...initialStyles,
|
|
2141
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
2142
|
+
...(getDPR(elements.floating) >= 1.5 && {
|
|
2143
|
+
willChange: 'transform'
|
|
2144
|
+
})
|
|
2145
|
+
};
|
|
2146
|
+
}
|
|
2147
|
+
return {
|
|
2148
|
+
position: strategy,
|
|
2149
|
+
left: x,
|
|
2150
|
+
top: y
|
|
2151
|
+
};
|
|
2152
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
2153
|
+
return React.useMemo(() => ({
|
|
2154
|
+
...data,
|
|
2155
|
+
update,
|
|
2156
|
+
refs,
|
|
2157
|
+
elements,
|
|
2158
|
+
floatingStyles
|
|
2159
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
2160
|
+
}
|
|
2161
|
+
const arrow$1 = options => {
|
|
2162
|
+
function isRef(value) {
|
|
2163
|
+
return {}.hasOwnProperty.call(value, 'current');
|
|
2164
|
+
}
|
|
2165
|
+
return {
|
|
2166
|
+
name: 'arrow',
|
|
2167
|
+
options,
|
|
2168
|
+
fn(state) {
|
|
2169
|
+
const {
|
|
2170
|
+
element,
|
|
2171
|
+
padding
|
|
2172
|
+
} = typeof options === 'function' ? options(state) : options;
|
|
2173
|
+
if (element && isRef(element)) {
|
|
2174
|
+
if (element.current != null) {
|
|
2175
|
+
return arrow$2({
|
|
2176
|
+
element: element.current,
|
|
2177
|
+
padding
|
|
2178
|
+
}).fn(state);
|
|
2179
|
+
}
|
|
2180
|
+
return {};
|
|
2181
|
+
}
|
|
2182
|
+
if (element) {
|
|
2183
|
+
return arrow$2({
|
|
2184
|
+
element,
|
|
2185
|
+
padding
|
|
2186
|
+
}).fn(state);
|
|
2187
|
+
}
|
|
2188
|
+
return {};
|
|
2189
|
+
}
|
|
2190
|
+
};
|
|
2191
|
+
};
|
|
2192
|
+
const offset = (options, deps) => ({
|
|
2193
|
+
...offset$1(options),
|
|
2194
|
+
options: [options, deps]
|
|
2195
|
+
});
|
|
2196
|
+
const shift = (options, deps) => ({
|
|
2197
|
+
...shift$1(options),
|
|
2198
|
+
options: [options, deps]
|
|
2199
|
+
});
|
|
2200
|
+
const flip = (options, deps) => ({
|
|
2201
|
+
...flip$1(options),
|
|
2202
|
+
options: [options, deps]
|
|
2203
|
+
});
|
|
2204
|
+
const arrow = (options, deps) => ({
|
|
2205
|
+
...arrow$1(options),
|
|
2206
|
+
options: [options, deps]
|
|
2207
|
+
});
|
|
2208
|
+
|
|
2209
|
+
function useMergeRefs(refs) {
|
|
2210
|
+
return React.useMemo(() => {
|
|
2211
|
+
if (refs.every(ref => ref == null)) {
|
|
2212
|
+
return null;
|
|
2213
|
+
}
|
|
2214
|
+
return value => {
|
|
2215
|
+
refs.forEach(ref => {
|
|
2216
|
+
if (typeof ref === 'function') {
|
|
2217
|
+
ref(value);
|
|
2218
|
+
} else if (ref != null) {
|
|
2219
|
+
ref.current = value;
|
|
2220
|
+
}
|
|
2221
|
+
});
|
|
2222
|
+
};
|
|
2223
|
+
}, refs);
|
|
2224
|
+
}
|
|
2225
|
+
const SafeReact = {
|
|
2226
|
+
...React
|
|
2227
|
+
};
|
|
2228
|
+
const useInsertionEffect = SafeReact.useInsertionEffect;
|
|
2229
|
+
const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
|
|
2230
|
+
function useEffectEvent(callback) {
|
|
2231
|
+
const ref = React.useRef(() => {
|
|
2232
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2233
|
+
throw new Error('Cannot call an event handler while rendering.');
|
|
2234
|
+
}
|
|
2235
|
+
});
|
|
2236
|
+
useSafeInsertionEffect(() => {
|
|
2237
|
+
ref.current = callback;
|
|
2238
|
+
});
|
|
2239
|
+
return React.useCallback(function () {
|
|
2240
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2241
|
+
args[_key] = arguments[_key];
|
|
2242
|
+
}
|
|
2243
|
+
return ref.current == null ? void 0 : ref.current(...args);
|
|
2244
|
+
}, []);
|
|
2245
|
+
}
|
|
2246
|
+
const ARROW_UP = 'ArrowUp';
|
|
2247
|
+
const ARROW_DOWN = 'ArrowDown';
|
|
2248
|
+
const ARROW_LEFT = 'ArrowLeft';
|
|
2249
|
+
const ARROW_RIGHT = 'ArrowRight';
|
|
2250
|
+
function isDifferentRow(index, cols, prevRow) {
|
|
2251
|
+
return Math.floor(index / cols) !== prevRow;
|
|
2252
|
+
}
|
|
2253
|
+
function isIndexOutOfBounds(listRef, index) {
|
|
2254
|
+
return index < 0 || index >= listRef.current.length;
|
|
2255
|
+
}
|
|
2256
|
+
function getMinIndex(listRef, disabledIndices) {
|
|
2257
|
+
return findNonDisabledIndex(listRef, {
|
|
2258
|
+
disabledIndices
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
function getMaxIndex(listRef, disabledIndices) {
|
|
2262
|
+
return findNonDisabledIndex(listRef, {
|
|
2263
|
+
decrement: true,
|
|
2264
|
+
startingIndex: listRef.current.length,
|
|
2265
|
+
disabledIndices
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
function findNonDisabledIndex(listRef, _temp) {
|
|
2269
|
+
let {
|
|
2270
|
+
startingIndex = -1,
|
|
2271
|
+
decrement = false,
|
|
2272
|
+
disabledIndices,
|
|
2273
|
+
amount = 1
|
|
2274
|
+
} = _temp === void 0 ? {} : _temp;
|
|
2275
|
+
const list = listRef.current;
|
|
2276
|
+
let index = startingIndex;
|
|
2277
|
+
do {
|
|
2278
|
+
index += decrement ? -amount : amount;
|
|
2279
|
+
} while (index >= 0 && index <= list.length - 1 && isDisabled(list, index, disabledIndices));
|
|
2280
|
+
return index;
|
|
2281
|
+
}
|
|
2282
|
+
function getGridNavigatedIndex(elementsRef, _ref) {
|
|
2283
|
+
let {
|
|
2284
|
+
event,
|
|
2285
|
+
orientation,
|
|
2286
|
+
loop,
|
|
2287
|
+
cols,
|
|
2288
|
+
disabledIndices,
|
|
2289
|
+
minIndex,
|
|
2290
|
+
maxIndex,
|
|
2291
|
+
prevIndex,
|
|
2292
|
+
stopEvent: stop = false
|
|
2293
|
+
} = _ref;
|
|
2294
|
+
let nextIndex = prevIndex;
|
|
2295
|
+
if (event.key === ARROW_UP) {
|
|
2296
|
+
stop && stopEvent(event);
|
|
2297
|
+
if (prevIndex === -1) {
|
|
2298
|
+
nextIndex = maxIndex;
|
|
2299
|
+
} else {
|
|
2300
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2301
|
+
startingIndex: nextIndex,
|
|
2302
|
+
amount: cols,
|
|
2303
|
+
decrement: true,
|
|
2304
|
+
disabledIndices
|
|
2305
|
+
});
|
|
2306
|
+
if (loop && (prevIndex - cols < minIndex || nextIndex < 0)) {
|
|
2307
|
+
const col = prevIndex % cols;
|
|
2308
|
+
const maxCol = maxIndex % cols;
|
|
2309
|
+
const offset = maxIndex - (maxCol - col);
|
|
2310
|
+
if (maxCol === col) {
|
|
2311
|
+
nextIndex = maxIndex;
|
|
2312
|
+
} else {
|
|
2313
|
+
nextIndex = maxCol > col ? offset : offset - cols;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
if (isIndexOutOfBounds(elementsRef, nextIndex)) {
|
|
2318
|
+
nextIndex = prevIndex;
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
if (event.key === ARROW_DOWN) {
|
|
2322
|
+
stop && stopEvent(event);
|
|
2323
|
+
if (prevIndex === -1) {
|
|
2324
|
+
nextIndex = minIndex;
|
|
2325
|
+
} else {
|
|
2326
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2327
|
+
startingIndex: prevIndex,
|
|
2328
|
+
amount: cols,
|
|
2329
|
+
disabledIndices
|
|
2330
|
+
});
|
|
2331
|
+
if (loop && prevIndex + cols > maxIndex) {
|
|
2332
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2333
|
+
startingIndex: prevIndex % cols - cols,
|
|
2334
|
+
amount: cols,
|
|
2335
|
+
disabledIndices
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
if (isIndexOutOfBounds(elementsRef, nextIndex)) {
|
|
2340
|
+
nextIndex = prevIndex;
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
if (orientation === 'both') {
|
|
2344
|
+
const prevRow = floor(prevIndex / cols);
|
|
2345
|
+
if (event.key === ARROW_RIGHT) {
|
|
2346
|
+
stop && stopEvent(event);
|
|
2347
|
+
if (prevIndex % cols !== cols - 1) {
|
|
2348
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2349
|
+
startingIndex: prevIndex,
|
|
2350
|
+
disabledIndices
|
|
2351
|
+
});
|
|
2352
|
+
if (loop && isDifferentRow(nextIndex, cols, prevRow)) {
|
|
2353
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2354
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
2355
|
+
disabledIndices
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
} else if (loop) {
|
|
2359
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2360
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
2361
|
+
disabledIndices
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
if (isDifferentRow(nextIndex, cols, prevRow)) {
|
|
2365
|
+
nextIndex = prevIndex;
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
if (event.key === ARROW_LEFT) {
|
|
2369
|
+
stop && stopEvent(event);
|
|
2370
|
+
if (prevIndex % cols !== 0) {
|
|
2371
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2372
|
+
startingIndex: prevIndex,
|
|
2373
|
+
decrement: true,
|
|
2374
|
+
disabledIndices
|
|
2375
|
+
});
|
|
2376
|
+
if (loop && isDifferentRow(nextIndex, cols, prevRow)) {
|
|
2377
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2378
|
+
startingIndex: prevIndex + (cols - prevIndex % cols),
|
|
2379
|
+
decrement: true,
|
|
2380
|
+
disabledIndices
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2383
|
+
} else if (loop) {
|
|
2384
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2385
|
+
startingIndex: prevIndex + (cols - prevIndex % cols),
|
|
2386
|
+
decrement: true,
|
|
2387
|
+
disabledIndices
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
if (isDifferentRow(nextIndex, cols, prevRow)) {
|
|
2391
|
+
nextIndex = prevIndex;
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
const lastRow = floor(maxIndex / cols) === prevRow;
|
|
2395
|
+
if (isIndexOutOfBounds(elementsRef, nextIndex)) {
|
|
2396
|
+
if (loop && lastRow) {
|
|
2397
|
+
nextIndex = event.key === ARROW_LEFT ? maxIndex : findNonDisabledIndex(elementsRef, {
|
|
2398
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
2399
|
+
disabledIndices
|
|
2400
|
+
});
|
|
2401
|
+
} else {
|
|
2402
|
+
nextIndex = prevIndex;
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
return nextIndex;
|
|
2407
|
+
}
|
|
2408
|
+
function buildCellMap(sizes, cols, dense) {
|
|
2409
|
+
const cellMap = [];
|
|
2410
|
+
let startIndex = 0;
|
|
2411
|
+
sizes.forEach((_ref2, index) => {
|
|
2412
|
+
let {
|
|
2413
|
+
width,
|
|
2414
|
+
height
|
|
2415
|
+
} = _ref2;
|
|
2416
|
+
if (width > cols) {
|
|
2417
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2418
|
+
throw new Error("[Floating UI]: Invalid grid - item width at index " + index + " is greater than grid columns");
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
let itemPlaced = false;
|
|
2422
|
+
if (dense) {
|
|
2423
|
+
startIndex = 0;
|
|
2424
|
+
}
|
|
2425
|
+
while (!itemPlaced) {
|
|
2426
|
+
const targetCells = [];
|
|
2427
|
+
for (let i = 0; i < width; i++) {
|
|
2428
|
+
for (let j = 0; j < height; j++) {
|
|
2429
|
+
targetCells.push(startIndex + i + j * cols);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
if (startIndex % cols + width <= cols && targetCells.every(cell => cellMap[cell] == null)) {
|
|
2433
|
+
targetCells.forEach(cell => {
|
|
2434
|
+
cellMap[cell] = index;
|
|
2435
|
+
});
|
|
2436
|
+
itemPlaced = true;
|
|
2437
|
+
} else {
|
|
2438
|
+
startIndex++;
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
return [...cellMap];
|
|
2443
|
+
}
|
|
2444
|
+
function getCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
|
|
2445
|
+
if (index === -1) return -1;
|
|
2446
|
+
const firstCellIndex = cellMap.indexOf(index);
|
|
2447
|
+
const sizeItem = sizes[index];
|
|
2448
|
+
switch (corner) {
|
|
2449
|
+
case 'tl':
|
|
2450
|
+
return firstCellIndex;
|
|
2451
|
+
case 'tr':
|
|
2452
|
+
if (!sizeItem) {
|
|
2453
|
+
return firstCellIndex;
|
|
2454
|
+
}
|
|
2455
|
+
return firstCellIndex + sizeItem.width - 1;
|
|
2456
|
+
case 'bl':
|
|
2457
|
+
if (!sizeItem) {
|
|
2458
|
+
return firstCellIndex;
|
|
2459
|
+
}
|
|
2460
|
+
return firstCellIndex + (sizeItem.height - 1) * cols;
|
|
2461
|
+
case 'br':
|
|
2462
|
+
return cellMap.lastIndexOf(index);
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
function getCellIndices(indices, cellMap) {
|
|
2466
|
+
return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
|
|
2467
|
+
}
|
|
2468
|
+
function isDisabled(list, index, disabledIndices) {
|
|
2469
|
+
if (disabledIndices) {
|
|
2470
|
+
return disabledIndices.includes(index);
|
|
2471
|
+
}
|
|
2472
|
+
const element = list[index];
|
|
2473
|
+
return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
|
|
2474
|
+
}
|
|
2475
|
+
let rafId = 0;
|
|
2476
|
+
function enqueueFocus(el, options) {
|
|
2477
|
+
if (options === void 0) {
|
|
2478
|
+
options = {};
|
|
2479
|
+
}
|
|
2480
|
+
const {
|
|
2481
|
+
preventScroll = false,
|
|
2482
|
+
cancelPrevious = true,
|
|
2483
|
+
sync = false
|
|
2484
|
+
} = options;
|
|
2485
|
+
cancelPrevious && cancelAnimationFrame(rafId);
|
|
2486
|
+
const exec = () => el == null ? void 0 : el.focus({
|
|
2487
|
+
preventScroll
|
|
2488
|
+
});
|
|
2489
|
+
if (sync) {
|
|
2490
|
+
exec();
|
|
2491
|
+
} else {
|
|
2492
|
+
rafId = requestAnimationFrame(exec);
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
|
|
2496
|
+
function sortByDocumentPosition(a, b) {
|
|
2497
|
+
const position = a.compareDocumentPosition(b);
|
|
2498
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
2499
|
+
return -1;
|
|
2500
|
+
}
|
|
2501
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING || position & Node.DOCUMENT_POSITION_CONTAINS) {
|
|
2502
|
+
return 1;
|
|
2503
|
+
}
|
|
2504
|
+
return 0;
|
|
2505
|
+
}
|
|
2506
|
+
function areMapsEqual(map1, map2) {
|
|
2507
|
+
if (map1.size !== map2.size) {
|
|
2508
|
+
return false;
|
|
2509
|
+
}
|
|
2510
|
+
for (const [key, value] of map1.entries()) {
|
|
2511
|
+
if (value !== map2.get(key)) {
|
|
2512
|
+
return false;
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
return true;
|
|
2516
|
+
}
|
|
2517
|
+
const FloatingListContext = React.createContext({
|
|
2518
|
+
register: () => {},
|
|
2519
|
+
unregister: () => {},
|
|
2520
|
+
map: new Map(),
|
|
2521
|
+
elementsRef: {
|
|
2522
|
+
current: []
|
|
2523
|
+
}
|
|
2524
|
+
});
|
|
2525
|
+
function FloatingList(props) {
|
|
2526
|
+
const {
|
|
2527
|
+
children,
|
|
2528
|
+
elementsRef,
|
|
2529
|
+
labelsRef
|
|
2530
|
+
} = props;
|
|
2531
|
+
const [map, setMap] = React.useState(() => new Map());
|
|
2532
|
+
const register = React.useCallback(node => {
|
|
2533
|
+
setMap(prevMap => new Map(prevMap).set(node, null));
|
|
2534
|
+
}, []);
|
|
2535
|
+
const unregister = React.useCallback(node => {
|
|
2536
|
+
setMap(prevMap => {
|
|
2537
|
+
const map = new Map(prevMap);
|
|
2538
|
+
map.delete(node);
|
|
2539
|
+
return map;
|
|
2540
|
+
});
|
|
2541
|
+
}, []);
|
|
2542
|
+
index(() => {
|
|
2543
|
+
const newMap = new Map(map);
|
|
2544
|
+
const nodes = Array.from(newMap.keys()).sort(sortByDocumentPosition);
|
|
2545
|
+
nodes.forEach((node, index) => {
|
|
2546
|
+
newMap.set(node, index);
|
|
2547
|
+
});
|
|
2548
|
+
if (!areMapsEqual(map, newMap)) {
|
|
2549
|
+
setMap(newMap);
|
|
2550
|
+
}
|
|
2551
|
+
}, [map]);
|
|
2552
|
+
return React.createElement(FloatingListContext.Provider, {
|
|
2553
|
+
value: React.useMemo(() => ({
|
|
2554
|
+
register,
|
|
2555
|
+
unregister,
|
|
2556
|
+
map,
|
|
2557
|
+
elementsRef,
|
|
2558
|
+
labelsRef
|
|
2559
|
+
}), [register, unregister, map, elementsRef, labelsRef])
|
|
2560
|
+
}, children);
|
|
2561
|
+
}
|
|
2562
|
+
function useListItem(props) {
|
|
2563
|
+
if (props === void 0) {
|
|
2564
|
+
props = {};
|
|
2565
|
+
}
|
|
2566
|
+
const {
|
|
2567
|
+
label
|
|
2568
|
+
} = props;
|
|
2569
|
+
const {
|
|
2570
|
+
register,
|
|
2571
|
+
unregister,
|
|
2572
|
+
map,
|
|
2573
|
+
elementsRef,
|
|
2574
|
+
labelsRef
|
|
2575
|
+
} = React.useContext(FloatingListContext);
|
|
2576
|
+
const [index$1, setIndex] = React.useState(null);
|
|
2577
|
+
const componentRef = React.useRef(null);
|
|
2578
|
+
const ref = React.useCallback(node => {
|
|
2579
|
+
componentRef.current = node;
|
|
2580
|
+
if (index$1 !== null) {
|
|
2581
|
+
elementsRef.current[index$1] = node;
|
|
2582
|
+
if (labelsRef) {
|
|
2583
|
+
var _node$textContent;
|
|
2584
|
+
const isLabelDefined = label !== undefined;
|
|
2585
|
+
labelsRef.current[index$1] = isLabelDefined ? label : (_node$textContent = node == null ? void 0 : node.textContent) != null ? _node$textContent : null;
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
}, [index$1, elementsRef, labelsRef, label]);
|
|
2589
|
+
index(() => {
|
|
2590
|
+
const node = componentRef.current;
|
|
2591
|
+
if (node) {
|
|
2592
|
+
register(node);
|
|
2593
|
+
return () => {
|
|
2594
|
+
unregister(node);
|
|
2595
|
+
};
|
|
2596
|
+
}
|
|
2597
|
+
}, [register, unregister]);
|
|
2598
|
+
index(() => {
|
|
2599
|
+
const index = componentRef.current ? map.get(componentRef.current) : null;
|
|
2600
|
+
if (index != null) {
|
|
2601
|
+
setIndex(index);
|
|
2602
|
+
}
|
|
2603
|
+
}, [map]);
|
|
2604
|
+
return React.useMemo(() => ({
|
|
2605
|
+
ref,
|
|
2606
|
+
index: index$1 == null ? -1 : index$1
|
|
2607
|
+
}), [index$1, ref]);
|
|
2608
|
+
}
|
|
2609
|
+
function renderJsx(render, computedProps) {
|
|
2610
|
+
if (typeof render === 'function') {
|
|
2611
|
+
return render(computedProps);
|
|
2612
|
+
}
|
|
2613
|
+
if (render) {
|
|
2614
|
+
return React.cloneElement(render, computedProps);
|
|
2615
|
+
}
|
|
2616
|
+
return React.createElement("div", computedProps);
|
|
2617
|
+
}
|
|
2618
|
+
const CompositeContext = React.createContext({
|
|
2619
|
+
activeIndex: 0,
|
|
2620
|
+
onNavigate: () => {}
|
|
2621
|
+
});
|
|
2622
|
+
const horizontalKeys = [ARROW_LEFT, ARROW_RIGHT];
|
|
2623
|
+
const verticalKeys = [ARROW_UP, ARROW_DOWN];
|
|
2624
|
+
const allKeys = [...horizontalKeys, ...verticalKeys];
|
|
2625
|
+
React.forwardRef(function Composite(props, forwardedRef) {
|
|
2626
|
+
const {
|
|
2627
|
+
render,
|
|
2628
|
+
orientation = 'both',
|
|
2629
|
+
loop = true,
|
|
2630
|
+
cols = 1,
|
|
2631
|
+
disabledIndices,
|
|
2632
|
+
activeIndex: externalActiveIndex,
|
|
2633
|
+
onNavigate: externalSetActiveIndex,
|
|
2634
|
+
itemSizes,
|
|
2635
|
+
dense = false,
|
|
2636
|
+
...domProps
|
|
2637
|
+
} = props;
|
|
2638
|
+
const [internalActiveIndex, internalSetActiveIndex] = React.useState(0);
|
|
2639
|
+
const activeIndex = externalActiveIndex != null ? externalActiveIndex : internalActiveIndex;
|
|
2640
|
+
const onNavigate = useEffectEvent(externalSetActiveIndex != null ? externalSetActiveIndex : internalSetActiveIndex);
|
|
2641
|
+
const elementsRef = React.useRef([]);
|
|
2642
|
+
const renderElementProps = render && typeof render !== 'function' ? render.props : {};
|
|
2643
|
+
const contextValue = React.useMemo(() => ({
|
|
2644
|
+
activeIndex,
|
|
2645
|
+
onNavigate
|
|
2646
|
+
}), [activeIndex, onNavigate]);
|
|
2647
|
+
const isGrid = cols > 1;
|
|
2648
|
+
function handleKeyDown(event) {
|
|
2649
|
+
if (!allKeys.includes(event.key)) return;
|
|
2650
|
+
let nextIndex = activeIndex;
|
|
2651
|
+
const minIndex = getMinIndex(elementsRef, disabledIndices);
|
|
2652
|
+
const maxIndex = getMaxIndex(elementsRef, disabledIndices);
|
|
2653
|
+
if (isGrid) {
|
|
2654
|
+
const sizes = itemSizes || Array.from({
|
|
2655
|
+
length: elementsRef.current.length
|
|
2656
|
+
}, () => ({
|
|
2657
|
+
width: 1,
|
|
2658
|
+
height: 1
|
|
2659
|
+
}));
|
|
2660
|
+
const cellMap = buildCellMap(sizes, cols, dense);
|
|
2661
|
+
const minGridIndex = cellMap.findIndex(index => index != null && !isDisabled(elementsRef.current, index, disabledIndices));
|
|
2662
|
+
const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex) => index != null && !isDisabled(elementsRef.current, index, disabledIndices) ? cellIndex : foundIndex, -1);
|
|
2663
|
+
nextIndex = cellMap[getGridNavigatedIndex({
|
|
2664
|
+
current: cellMap.map(itemIndex => itemIndex ? elementsRef.current[itemIndex] : null)
|
|
2665
|
+
}, {
|
|
2666
|
+
event,
|
|
2667
|
+
orientation,
|
|
2668
|
+
loop,
|
|
2669
|
+
cols,
|
|
2670
|
+
disabledIndices: getCellIndices([...(disabledIndices || elementsRef.current.map((_, index) => isDisabled(elementsRef.current, index) ? index : undefined)), undefined], cellMap),
|
|
2671
|
+
minIndex: minGridIndex,
|
|
2672
|
+
maxIndex: maxGridIndex,
|
|
2673
|
+
prevIndex: getCellIndexOfCorner(activeIndex > maxIndex ? minIndex : activeIndex, sizes, cellMap, cols,
|
|
2674
|
+
event.key === ARROW_DOWN ? 'bl' : event.key === ARROW_RIGHT ? 'tr' : 'tl')
|
|
2675
|
+
})];
|
|
2676
|
+
}
|
|
2677
|
+
const toEndKeys = {
|
|
2678
|
+
horizontal: [ARROW_RIGHT],
|
|
2679
|
+
vertical: [ARROW_DOWN],
|
|
2680
|
+
both: [ARROW_RIGHT, ARROW_DOWN]
|
|
2681
|
+
}[orientation];
|
|
2682
|
+
const toStartKeys = {
|
|
2683
|
+
horizontal: [ARROW_LEFT],
|
|
2684
|
+
vertical: [ARROW_UP],
|
|
2685
|
+
both: [ARROW_LEFT, ARROW_UP]
|
|
2686
|
+
}[orientation];
|
|
2687
|
+
const preventedKeys = isGrid ? allKeys : {
|
|
2688
|
+
horizontal: horizontalKeys,
|
|
2689
|
+
vertical: verticalKeys,
|
|
2690
|
+
both: allKeys
|
|
2691
|
+
}[orientation];
|
|
2692
|
+
if (nextIndex === activeIndex && [...toEndKeys, ...toStartKeys].includes(event.key)) {
|
|
2693
|
+
if (loop && nextIndex === maxIndex && toEndKeys.includes(event.key)) {
|
|
2694
|
+
nextIndex = minIndex;
|
|
2695
|
+
} else if (loop && nextIndex === minIndex && toStartKeys.includes(event.key)) {
|
|
2696
|
+
nextIndex = maxIndex;
|
|
2697
|
+
} else {
|
|
2698
|
+
nextIndex = findNonDisabledIndex(elementsRef, {
|
|
2699
|
+
startingIndex: nextIndex,
|
|
2700
|
+
decrement: toStartKeys.includes(event.key),
|
|
2701
|
+
disabledIndices
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
if (nextIndex !== activeIndex && !isIndexOutOfBounds(elementsRef, nextIndex)) {
|
|
2706
|
+
event.stopPropagation();
|
|
2707
|
+
if (preventedKeys.includes(event.key)) {
|
|
2708
|
+
event.preventDefault();
|
|
2709
|
+
}
|
|
2710
|
+
onNavigate(nextIndex);
|
|
2711
|
+
queueMicrotask(() => {
|
|
2712
|
+
enqueueFocus(elementsRef.current[nextIndex]);
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
const computedProps = {
|
|
2717
|
+
...domProps,
|
|
2718
|
+
...renderElementProps,
|
|
2719
|
+
ref: forwardedRef,
|
|
2720
|
+
'aria-orientation': orientation === 'both' ? undefined : orientation,
|
|
2721
|
+
onKeyDown(e) {
|
|
2722
|
+
domProps.onKeyDown == null || domProps.onKeyDown(e);
|
|
2723
|
+
renderElementProps.onKeyDown == null || renderElementProps.onKeyDown(e);
|
|
2724
|
+
handleKeyDown(e);
|
|
2725
|
+
}
|
|
2726
|
+
};
|
|
2727
|
+
return React.createElement(CompositeContext.Provider, {
|
|
2728
|
+
value: contextValue
|
|
2729
|
+
}, React.createElement(FloatingList, {
|
|
2730
|
+
elementsRef: elementsRef
|
|
2731
|
+
}, renderJsx(render, computedProps)));
|
|
2732
|
+
});
|
|
2733
|
+
React.forwardRef(function CompositeItem(props, forwardedRef) {
|
|
2734
|
+
const {
|
|
2735
|
+
render,
|
|
2736
|
+
...domProps
|
|
2737
|
+
} = props;
|
|
2738
|
+
const renderElementProps = render && typeof render !== 'function' ? render.props : {};
|
|
2739
|
+
const {
|
|
2740
|
+
activeIndex,
|
|
2741
|
+
onNavigate
|
|
2742
|
+
} = React.useContext(CompositeContext);
|
|
2743
|
+
const {
|
|
2744
|
+
ref,
|
|
2745
|
+
index
|
|
2746
|
+
} = useListItem();
|
|
2747
|
+
const mergedRef = useMergeRefs([ref, forwardedRef, renderElementProps.ref]);
|
|
2748
|
+
const isActive = activeIndex === index;
|
|
2749
|
+
const computedProps = {
|
|
2750
|
+
...domProps,
|
|
2751
|
+
...renderElementProps,
|
|
2752
|
+
ref: mergedRef,
|
|
2753
|
+
tabIndex: isActive ? 0 : -1,
|
|
2754
|
+
'data-active': isActive ? '' : undefined,
|
|
2755
|
+
onFocus(e) {
|
|
2756
|
+
domProps.onFocus == null || domProps.onFocus(e);
|
|
2757
|
+
renderElementProps.onFocus == null || renderElementProps.onFocus(e);
|
|
2758
|
+
onNavigate(index);
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
return renderJsx(render, computedProps);
|
|
2762
|
+
});
|
|
2763
|
+
function _extends() {
|
|
2764
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
2765
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2766
|
+
var source = arguments[i];
|
|
2767
|
+
for (var key in source) {
|
|
2768
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2769
|
+
target[key] = source[key];
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
return target;
|
|
2774
|
+
};
|
|
2775
|
+
return _extends.apply(this, arguments);
|
|
2776
|
+
}
|
|
2777
|
+
let serverHandoffComplete = false;
|
|
2778
|
+
let count = 0;
|
|
2779
|
+
const genId = () =>
|
|
2780
|
+
"floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
|
|
2781
|
+
function useFloatingId() {
|
|
2782
|
+
const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : undefined);
|
|
2783
|
+
index(() => {
|
|
2784
|
+
if (id == null) {
|
|
2785
|
+
setId(genId());
|
|
2786
|
+
}
|
|
2787
|
+
}, []);
|
|
2788
|
+
React.useEffect(() => {
|
|
2789
|
+
serverHandoffComplete = true;
|
|
2790
|
+
}, []);
|
|
2791
|
+
return id;
|
|
2792
|
+
}
|
|
2793
|
+
const useReactId = SafeReact.useId;
|
|
2794
|
+
const useId = useReactId || useFloatingId;
|
|
2795
|
+
let devMessageSet;
|
|
2796
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2797
|
+
devMessageSet = new Set();
|
|
2798
|
+
}
|
|
2799
|
+
function warn() {
|
|
2800
|
+
var _devMessageSet;
|
|
2801
|
+
for (var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2802
|
+
messages[_key] = arguments[_key];
|
|
2803
|
+
}
|
|
2804
|
+
const message = "Floating UI: " + messages.join(' ');
|
|
2805
|
+
if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(message))) {
|
|
2806
|
+
var _devMessageSet2;
|
|
2807
|
+
(_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(message);
|
|
2808
|
+
console.warn(message);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
function error$1() {
|
|
2812
|
+
var _devMessageSet3;
|
|
2813
|
+
for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2814
|
+
messages[_key2] = arguments[_key2];
|
|
2815
|
+
}
|
|
2816
|
+
const message = "Floating UI: " + messages.join(' ');
|
|
2817
|
+
if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
|
|
2818
|
+
var _devMessageSet4;
|
|
2819
|
+
(_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
|
|
2820
|
+
console.error(message);
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
const FloatingArrow = React.forwardRef(function FloatingArrow(props, ref) {
|
|
2824
|
+
const {
|
|
2825
|
+
context: {
|
|
2826
|
+
placement,
|
|
2827
|
+
elements: {
|
|
2828
|
+
floating
|
|
2829
|
+
},
|
|
2830
|
+
middlewareData: {
|
|
2831
|
+
arrow
|
|
2832
|
+
}
|
|
2833
|
+
},
|
|
2834
|
+
width = 14,
|
|
2835
|
+
height = 7,
|
|
2836
|
+
tipRadius = 0,
|
|
2837
|
+
strokeWidth = 0,
|
|
2838
|
+
staticOffset,
|
|
2839
|
+
stroke,
|
|
2840
|
+
d,
|
|
2841
|
+
style: {
|
|
2842
|
+
transform,
|
|
2843
|
+
...restStyle
|
|
2844
|
+
} = {},
|
|
2845
|
+
...rest
|
|
2846
|
+
} = props;
|
|
2847
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2848
|
+
if (!ref) {
|
|
2849
|
+
warn('The `ref` prop is required for `FloatingArrow`.');
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
const clipPathId = useId();
|
|
2853
|
+
if (!floating) {
|
|
2854
|
+
return null;
|
|
2855
|
+
}
|
|
2856
|
+
const computedStrokeWidth = strokeWidth * 2;
|
|
2857
|
+
const halfStrokeWidth = computedStrokeWidth / 2;
|
|
2858
|
+
const svgX = width / 2 * (tipRadius / -8 + 1);
|
|
2859
|
+
const svgY = height / 2 * tipRadius / 4;
|
|
2860
|
+
const [side, alignment] = placement.split('-');
|
|
2861
|
+
const isRTL = platform.isRTL(floating);
|
|
2862
|
+
const isCustomShape = !!d;
|
|
2863
|
+
const isVerticalSide = side === 'top' || side === 'bottom';
|
|
2864
|
+
const yOffsetProp = staticOffset && alignment === 'end' ? 'bottom' : 'top';
|
|
2865
|
+
let xOffsetProp = staticOffset && alignment === 'end' ? 'right' : 'left';
|
|
2866
|
+
if (staticOffset && isRTL) {
|
|
2867
|
+
xOffsetProp = alignment === 'end' ? 'left' : 'right';
|
|
2868
|
+
}
|
|
2869
|
+
const arrowX = (arrow == null ? void 0 : arrow.x) != null ? staticOffset || arrow.x : '';
|
|
2870
|
+
const arrowY = (arrow == null ? void 0 : arrow.y) != null ? staticOffset || arrow.y : '';
|
|
2871
|
+
const dValue = d || 'M0,0' + (" H" + width) + (" L" + (width - svgX) + "," + (height - svgY)) + (" Q" + width / 2 + "," + height + " " + svgX + "," + (height - svgY)) + ' Z';
|
|
2872
|
+
const rotation = {
|
|
2873
|
+
top: isCustomShape ? 'rotate(180deg)' : '',
|
|
2874
|
+
left: isCustomShape ? 'rotate(90deg)' : 'rotate(-90deg)',
|
|
2875
|
+
bottom: isCustomShape ? '' : 'rotate(180deg)',
|
|
2876
|
+
right: isCustomShape ? 'rotate(-90deg)' : 'rotate(90deg)'
|
|
2877
|
+
}[side];
|
|
2878
|
+
return React.createElement("svg", _extends({}, rest, {
|
|
2879
|
+
"aria-hidden": true,
|
|
2880
|
+
ref: ref,
|
|
2881
|
+
width: isCustomShape ? width : width + computedStrokeWidth,
|
|
2882
|
+
height: width,
|
|
2883
|
+
viewBox: "0 0 " + width + " " + (height > width ? height : width),
|
|
2884
|
+
style: {
|
|
2885
|
+
position: 'absolute',
|
|
2886
|
+
pointerEvents: 'none',
|
|
2887
|
+
[xOffsetProp]: arrowX,
|
|
2888
|
+
[yOffsetProp]: arrowY,
|
|
2889
|
+
[side]: isVerticalSide || isCustomShape ? '100%' : "calc(100% - " + computedStrokeWidth / 2 + "px)",
|
|
2890
|
+
transform: "" + rotation + (transform != null ? transform : ''),
|
|
2891
|
+
...restStyle
|
|
2892
|
+
}
|
|
2893
|
+
}), computedStrokeWidth > 0 && React.createElement("path", {
|
|
2894
|
+
clipPath: "url(#" + clipPathId + ")",
|
|
2895
|
+
fill: "none",
|
|
2896
|
+
stroke: stroke
|
|
2897
|
+
,
|
|
2898
|
+
strokeWidth: computedStrokeWidth + (d ? 0 : 1),
|
|
2899
|
+
d: dValue
|
|
2900
|
+
}), React.createElement("path", {
|
|
2901
|
+
stroke: computedStrokeWidth && !d ? rest.fill : 'none',
|
|
2902
|
+
d: dValue
|
|
2903
|
+
}), React.createElement("clipPath", {
|
|
2904
|
+
id: clipPathId
|
|
2905
|
+
}, React.createElement("rect", {
|
|
2906
|
+
x: -halfStrokeWidth,
|
|
2907
|
+
y: halfStrokeWidth * (isCustomShape ? -1 : 1),
|
|
2908
|
+
width: width + computedStrokeWidth,
|
|
2909
|
+
height: width
|
|
2910
|
+
})));
|
|
2911
|
+
});
|
|
2912
|
+
function createPubSub() {
|
|
2913
|
+
const map = new Map();
|
|
2914
|
+
return {
|
|
2915
|
+
emit(event, data) {
|
|
2916
|
+
var _map$get;
|
|
2917
|
+
(_map$get = map.get(event)) == null || _map$get.forEach(handler => handler(data));
|
|
2918
|
+
},
|
|
2919
|
+
on(event, listener) {
|
|
2920
|
+
map.set(event, [...(map.get(event) || []), listener]);
|
|
2921
|
+
},
|
|
2922
|
+
off(event, listener) {
|
|
2923
|
+
var _map$get2;
|
|
2924
|
+
map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter(l => l !== listener)) || []);
|
|
2925
|
+
}
|
|
2926
|
+
};
|
|
2927
|
+
}
|
|
2928
|
+
const FloatingNodeContext = React.createContext(null);
|
|
2929
|
+
const FloatingTreeContext = React.createContext(null);
|
|
2930
|
+
const useFloatingParentNodeId = () => {
|
|
2931
|
+
var _React$useContext;
|
|
2932
|
+
return ((_React$useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
|
|
2933
|
+
};
|
|
2934
|
+
const useFloatingTree = () => React.useContext(FloatingTreeContext);
|
|
2935
|
+
function createAttribute(name) {
|
|
2936
|
+
return "data-floating-ui-" + name;
|
|
2937
|
+
}
|
|
2938
|
+
function useLatestRef(value) {
|
|
2939
|
+
const ref = useRef(value);
|
|
2940
|
+
index(() => {
|
|
2941
|
+
ref.current = value;
|
|
2942
|
+
});
|
|
2943
|
+
return ref;
|
|
2944
|
+
}
|
|
2945
|
+
const safePolygonIdentifier = createAttribute('safe-polygon');
|
|
2946
|
+
function getDelay(value, prop, pointerType) {
|
|
2947
|
+
if (pointerType && !isMouseLikePointerType(pointerType)) {
|
|
2948
|
+
return 0;
|
|
2949
|
+
}
|
|
2950
|
+
if (typeof value === 'number') {
|
|
2951
|
+
return value;
|
|
2952
|
+
}
|
|
2953
|
+
return value == null ? void 0 : value[prop];
|
|
2954
|
+
}
|
|
2955
|
+
function useHover(context, props) {
|
|
2956
|
+
if (props === void 0) {
|
|
2957
|
+
props = {};
|
|
2958
|
+
}
|
|
2959
|
+
const {
|
|
2960
|
+
open,
|
|
2961
|
+
onOpenChange,
|
|
2962
|
+
dataRef,
|
|
2963
|
+
events,
|
|
2964
|
+
elements: {
|
|
2965
|
+
domReference,
|
|
2966
|
+
floating
|
|
2967
|
+
}
|
|
2968
|
+
} = context;
|
|
2969
|
+
const {
|
|
2970
|
+
enabled = true,
|
|
2971
|
+
delay = 0,
|
|
2972
|
+
handleClose = null,
|
|
2973
|
+
mouseOnly = false,
|
|
2974
|
+
restMs = 0,
|
|
2975
|
+
move = true
|
|
2976
|
+
} = props;
|
|
2977
|
+
const tree = useFloatingTree();
|
|
2978
|
+
const parentId = useFloatingParentNodeId();
|
|
2979
|
+
const handleCloseRef = useLatestRef(handleClose);
|
|
2980
|
+
const delayRef = useLatestRef(delay);
|
|
2981
|
+
const pointerTypeRef = React.useRef();
|
|
2982
|
+
const timeoutRef = React.useRef(-1);
|
|
2983
|
+
const handlerRef = React.useRef();
|
|
2984
|
+
const restTimeoutRef = React.useRef(-1);
|
|
2985
|
+
const blockMouseMoveRef = React.useRef(true);
|
|
2986
|
+
const performedPointerEventsMutationRef = React.useRef(false);
|
|
2987
|
+
const unbindMouseMoveRef = React.useRef(() => {});
|
|
2988
|
+
const isHoverOpen = React.useCallback(() => {
|
|
2989
|
+
var _dataRef$current$open;
|
|
2990
|
+
const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type;
|
|
2991
|
+
return (type == null ? void 0 : type.includes('mouse')) && type !== 'mousedown';
|
|
2992
|
+
}, [dataRef]);
|
|
2993
|
+
React.useEffect(() => {
|
|
2994
|
+
if (!enabled) {
|
|
2995
|
+
return;
|
|
2996
|
+
}
|
|
2997
|
+
function onOpenChange(_ref) {
|
|
2998
|
+
let {
|
|
2999
|
+
open
|
|
3000
|
+
} = _ref;
|
|
3001
|
+
if (!open) {
|
|
3002
|
+
clearTimeout(timeoutRef.current);
|
|
3003
|
+
clearTimeout(restTimeoutRef.current);
|
|
3004
|
+
blockMouseMoveRef.current = true;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
events.on('openchange', onOpenChange);
|
|
3008
|
+
return () => {
|
|
3009
|
+
events.off('openchange', onOpenChange);
|
|
3010
|
+
};
|
|
3011
|
+
}, [enabled, events]);
|
|
3012
|
+
React.useEffect(() => {
|
|
3013
|
+
if (!enabled || !handleCloseRef.current || !open) {
|
|
3014
|
+
return;
|
|
3015
|
+
}
|
|
3016
|
+
function onLeave(event) {
|
|
3017
|
+
if (isHoverOpen()) {
|
|
3018
|
+
onOpenChange(false, event, 'hover');
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
const html = getDocument(floating).documentElement;
|
|
3022
|
+
html.addEventListener('mouseleave', onLeave);
|
|
3023
|
+
return () => {
|
|
3024
|
+
html.removeEventListener('mouseleave', onLeave);
|
|
3025
|
+
};
|
|
3026
|
+
}, [floating, open, onOpenChange, enabled, handleCloseRef, isHoverOpen]);
|
|
3027
|
+
const closeWithDelay = React.useCallback(function (event, runElseBranch, reason) {
|
|
3028
|
+
if (runElseBranch === void 0) {
|
|
3029
|
+
runElseBranch = true;
|
|
3030
|
+
}
|
|
3031
|
+
if (reason === void 0) {
|
|
3032
|
+
reason = 'hover';
|
|
3033
|
+
}
|
|
3034
|
+
const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
|
|
3035
|
+
if (closeDelay && !handlerRef.current) {
|
|
3036
|
+
clearTimeout(timeoutRef.current);
|
|
3037
|
+
timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
|
|
3038
|
+
} else if (runElseBranch) {
|
|
3039
|
+
clearTimeout(timeoutRef.current);
|
|
3040
|
+
onOpenChange(false, event, reason);
|
|
3041
|
+
}
|
|
3042
|
+
}, [delayRef, onOpenChange]);
|
|
3043
|
+
const cleanupMouseMoveHandler = useEffectEvent(() => {
|
|
3044
|
+
unbindMouseMoveRef.current();
|
|
3045
|
+
handlerRef.current = undefined;
|
|
3046
|
+
});
|
|
3047
|
+
const clearPointerEvents = useEffectEvent(() => {
|
|
3048
|
+
if (performedPointerEventsMutationRef.current) {
|
|
3049
|
+
const body = getDocument(floating).body;
|
|
3050
|
+
body.style.pointerEvents = '';
|
|
3051
|
+
body.removeAttribute(safePolygonIdentifier);
|
|
3052
|
+
performedPointerEventsMutationRef.current = false;
|
|
3053
|
+
}
|
|
3054
|
+
});
|
|
3055
|
+
React.useEffect(() => {
|
|
3056
|
+
if (!enabled) {
|
|
3057
|
+
return;
|
|
3058
|
+
}
|
|
3059
|
+
function isClickLikeOpenEvent() {
|
|
3060
|
+
return dataRef.current.openEvent ? ['click', 'mousedown'].includes(dataRef.current.openEvent.type) : false;
|
|
3061
|
+
}
|
|
3062
|
+
function onMouseEnter(event) {
|
|
3063
|
+
clearTimeout(timeoutRef.current);
|
|
3064
|
+
blockMouseMoveRef.current = false;
|
|
3065
|
+
if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && !getDelay(delayRef.current, 'open')) {
|
|
3066
|
+
return;
|
|
3067
|
+
}
|
|
3068
|
+
const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
|
|
3069
|
+
if (openDelay) {
|
|
3070
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
3071
|
+
onOpenChange(true, event, 'hover');
|
|
3072
|
+
}, openDelay);
|
|
3073
|
+
} else {
|
|
3074
|
+
onOpenChange(true, event, 'hover');
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
function onMouseLeave(event) {
|
|
3078
|
+
if (isClickLikeOpenEvent()) return;
|
|
3079
|
+
unbindMouseMoveRef.current();
|
|
3080
|
+
const doc = getDocument(floating);
|
|
3081
|
+
clearTimeout(restTimeoutRef.current);
|
|
3082
|
+
if (handleCloseRef.current && dataRef.current.floatingContext) {
|
|
3083
|
+
if (!open) {
|
|
3084
|
+
clearTimeout(timeoutRef.current);
|
|
3085
|
+
}
|
|
3086
|
+
handlerRef.current = handleCloseRef.current({
|
|
3087
|
+
...dataRef.current.floatingContext,
|
|
3088
|
+
tree,
|
|
3089
|
+
x: event.clientX,
|
|
3090
|
+
y: event.clientY,
|
|
3091
|
+
onClose() {
|
|
3092
|
+
clearPointerEvents();
|
|
3093
|
+
cleanupMouseMoveHandler();
|
|
3094
|
+
closeWithDelay(event, true, 'safe-polygon');
|
|
3095
|
+
}
|
|
3096
|
+
});
|
|
3097
|
+
const handler = handlerRef.current;
|
|
3098
|
+
doc.addEventListener('mousemove', handler);
|
|
3099
|
+
unbindMouseMoveRef.current = () => {
|
|
3100
|
+
doc.removeEventListener('mousemove', handler);
|
|
3101
|
+
};
|
|
3102
|
+
return;
|
|
3103
|
+
}
|
|
3104
|
+
const shouldClose = pointerTypeRef.current === 'touch' ? !contains(floating, event.relatedTarget) : true;
|
|
3105
|
+
if (shouldClose) {
|
|
3106
|
+
closeWithDelay(event);
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
function onScrollMouseLeave(event) {
|
|
3110
|
+
if (isClickLikeOpenEvent()) return;
|
|
3111
|
+
if (!dataRef.current.floatingContext) return;
|
|
3112
|
+
handleCloseRef.current == null || handleCloseRef.current({
|
|
3113
|
+
...dataRef.current.floatingContext,
|
|
3114
|
+
tree,
|
|
3115
|
+
x: event.clientX,
|
|
3116
|
+
y: event.clientY,
|
|
3117
|
+
onClose() {
|
|
3118
|
+
clearPointerEvents();
|
|
3119
|
+
cleanupMouseMoveHandler();
|
|
3120
|
+
closeWithDelay(event);
|
|
3121
|
+
}
|
|
3122
|
+
})(event);
|
|
3123
|
+
}
|
|
3124
|
+
if (isElement(domReference)) {
|
|
3125
|
+
const ref = domReference;
|
|
3126
|
+
open && ref.addEventListener('mouseleave', onScrollMouseLeave);
|
|
3127
|
+
floating == null || floating.addEventListener('mouseleave', onScrollMouseLeave);
|
|
3128
|
+
move && ref.addEventListener('mousemove', onMouseEnter, {
|
|
3129
|
+
once: true
|
|
3130
|
+
});
|
|
3131
|
+
ref.addEventListener('mouseenter', onMouseEnter);
|
|
3132
|
+
ref.addEventListener('mouseleave', onMouseLeave);
|
|
3133
|
+
return () => {
|
|
3134
|
+
open && ref.removeEventListener('mouseleave', onScrollMouseLeave);
|
|
3135
|
+
floating == null || floating.removeEventListener('mouseleave', onScrollMouseLeave);
|
|
3136
|
+
move && ref.removeEventListener('mousemove', onMouseEnter);
|
|
3137
|
+
ref.removeEventListener('mouseenter', onMouseEnter);
|
|
3138
|
+
ref.removeEventListener('mouseleave', onMouseLeave);
|
|
3139
|
+
};
|
|
3140
|
+
}
|
|
3141
|
+
}, [domReference, floating, enabled, context, mouseOnly, restMs, move, closeWithDelay, cleanupMouseMoveHandler, clearPointerEvents, onOpenChange, open, tree, delayRef, handleCloseRef, dataRef]);
|
|
3142
|
+
index(() => {
|
|
3143
|
+
var _handleCloseRef$curre;
|
|
3144
|
+
if (!enabled) {
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && _handleCloseRef$curre.__options.blockPointerEvents && isHoverOpen()) {
|
|
3148
|
+
const body = getDocument(floating).body;
|
|
3149
|
+
body.setAttribute(safePolygonIdentifier, '');
|
|
3150
|
+
body.style.pointerEvents = 'none';
|
|
3151
|
+
performedPointerEventsMutationRef.current = true;
|
|
3152
|
+
if (isElement(domReference) && floating) {
|
|
3153
|
+
var _tree$nodesRef$curren;
|
|
3154
|
+
const ref = domReference;
|
|
3155
|
+
const parentFloating = tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find(node => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren.elements.floating;
|
|
3156
|
+
if (parentFloating) {
|
|
3157
|
+
parentFloating.style.pointerEvents = '';
|
|
3158
|
+
}
|
|
3159
|
+
ref.style.pointerEvents = 'auto';
|
|
3160
|
+
floating.style.pointerEvents = 'auto';
|
|
3161
|
+
return () => {
|
|
3162
|
+
ref.style.pointerEvents = '';
|
|
3163
|
+
floating.style.pointerEvents = '';
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
}, [enabled, open, parentId, floating, domReference, tree, handleCloseRef, isHoverOpen]);
|
|
3168
|
+
index(() => {
|
|
3169
|
+
if (!open) {
|
|
3170
|
+
pointerTypeRef.current = undefined;
|
|
3171
|
+
cleanupMouseMoveHandler();
|
|
3172
|
+
clearPointerEvents();
|
|
3173
|
+
}
|
|
3174
|
+
}, [open, cleanupMouseMoveHandler, clearPointerEvents]);
|
|
3175
|
+
React.useEffect(() => {
|
|
3176
|
+
return () => {
|
|
3177
|
+
cleanupMouseMoveHandler();
|
|
3178
|
+
clearTimeout(timeoutRef.current);
|
|
3179
|
+
clearTimeout(restTimeoutRef.current);
|
|
3180
|
+
clearPointerEvents();
|
|
3181
|
+
};
|
|
3182
|
+
}, [enabled, domReference, cleanupMouseMoveHandler, clearPointerEvents]);
|
|
3183
|
+
return React.useMemo(() => {
|
|
3184
|
+
if (!enabled) {
|
|
3185
|
+
return {};
|
|
3186
|
+
}
|
|
3187
|
+
function setPointerRef(event) {
|
|
3188
|
+
pointerTypeRef.current = event.pointerType;
|
|
3189
|
+
}
|
|
3190
|
+
return {
|
|
3191
|
+
reference: {
|
|
3192
|
+
onPointerDown: setPointerRef,
|
|
3193
|
+
onPointerEnter: setPointerRef,
|
|
3194
|
+
onMouseMove(event) {
|
|
3195
|
+
const {
|
|
3196
|
+
nativeEvent
|
|
3197
|
+
} = event;
|
|
3198
|
+
function handleMouseMove() {
|
|
3199
|
+
if (!blockMouseMoveRef.current) {
|
|
3200
|
+
onOpenChange(true, nativeEvent, 'hover');
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current)) {
|
|
3204
|
+
return;
|
|
3205
|
+
}
|
|
3206
|
+
if (open || restMs === 0) {
|
|
3207
|
+
return;
|
|
3208
|
+
}
|
|
3209
|
+
clearTimeout(restTimeoutRef.current);
|
|
3210
|
+
if (pointerTypeRef.current === 'touch') {
|
|
3211
|
+
handleMouseMove();
|
|
3212
|
+
} else {
|
|
3213
|
+
restTimeoutRef.current = window.setTimeout(handleMouseMove, restMs);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
},
|
|
3217
|
+
floating: {
|
|
3218
|
+
onMouseEnter() {
|
|
3219
|
+
clearTimeout(timeoutRef.current);
|
|
3220
|
+
},
|
|
3221
|
+
onMouseLeave(event) {
|
|
3222
|
+
closeWithDelay(event.nativeEvent, false);
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
};
|
|
3226
|
+
}, [enabled, mouseOnly, open, restMs, onOpenChange, closeWithDelay]);
|
|
3227
|
+
}
|
|
3228
|
+
const NOOP = () => {};
|
|
3229
|
+
React.createContext({
|
|
3230
|
+
delay: 0,
|
|
3231
|
+
initialDelay: 0,
|
|
3232
|
+
timeoutMs: 0,
|
|
3233
|
+
currentId: null,
|
|
3234
|
+
setCurrentId: NOOP,
|
|
3235
|
+
setState: NOOP,
|
|
3236
|
+
isInstantPhase: false
|
|
3237
|
+
});
|
|
3238
|
+
function getChildren(nodes, id) {
|
|
3239
|
+
let allChildren = nodes.filter(node => {
|
|
3240
|
+
var _node$context;
|
|
3241
|
+
return node.parentId === id && ((_node$context = node.context) == null ? void 0 : _node$context.open);
|
|
3242
|
+
});
|
|
3243
|
+
let currentChildren = allChildren;
|
|
3244
|
+
while (currentChildren.length) {
|
|
3245
|
+
currentChildren = nodes.filter(node => {
|
|
3246
|
+
var _currentChildren;
|
|
3247
|
+
return (_currentChildren = currentChildren) == null ? void 0 : _currentChildren.some(n => {
|
|
3248
|
+
var _node$context2;
|
|
3249
|
+
return node.parentId === n.id && ((_node$context2 = node.context) == null ? void 0 : _node$context2.open);
|
|
3250
|
+
});
|
|
3251
|
+
});
|
|
3252
|
+
allChildren = allChildren.concat(currentChildren);
|
|
3253
|
+
}
|
|
3254
|
+
return allChildren;
|
|
3255
|
+
}
|
|
3256
|
+
const HIDDEN_STYLES = {
|
|
3257
|
+
border: 0,
|
|
3258
|
+
clip: 'rect(0 0 0 0)',
|
|
3259
|
+
height: '1px',
|
|
3260
|
+
margin: '-1px',
|
|
3261
|
+
overflow: 'hidden',
|
|
3262
|
+
padding: 0,
|
|
3263
|
+
position: 'fixed',
|
|
3264
|
+
whiteSpace: 'nowrap',
|
|
3265
|
+
width: '1px',
|
|
3266
|
+
top: 0,
|
|
3267
|
+
left: 0
|
|
3268
|
+
};
|
|
3269
|
+
let timeoutId;
|
|
3270
|
+
function setActiveElementOnTab(event) {
|
|
3271
|
+
if (event.key === 'Tab') {
|
|
3272
|
+
event.target;
|
|
3273
|
+
clearTimeout(timeoutId);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
React.forwardRef(function FocusGuard(props, ref) {
|
|
3277
|
+
const [role, setRole] = React.useState();
|
|
3278
|
+
index(() => {
|
|
3279
|
+
if (isSafari()) {
|
|
3280
|
+
setRole('button');
|
|
3281
|
+
}
|
|
3282
|
+
document.addEventListener('keydown', setActiveElementOnTab);
|
|
3283
|
+
return () => {
|
|
3284
|
+
document.removeEventListener('keydown', setActiveElementOnTab);
|
|
3285
|
+
};
|
|
3286
|
+
}, []);
|
|
3287
|
+
const restProps = {
|
|
3288
|
+
ref,
|
|
3289
|
+
tabIndex: 0,
|
|
3290
|
+
role,
|
|
3291
|
+
'aria-hidden': role ? undefined : true,
|
|
3292
|
+
[createAttribute('focus-guard')]: '',
|
|
3293
|
+
style: HIDDEN_STYLES
|
|
3294
|
+
};
|
|
3295
|
+
return React.createElement("span", _extends({}, props, restProps));
|
|
3296
|
+
});
|
|
3297
|
+
React.createContext(null);
|
|
3298
|
+
React.forwardRef(function VisuallyHiddenDismiss(props, ref) {
|
|
3299
|
+
return React.createElement("button", _extends({}, props, {
|
|
3300
|
+
type: "button",
|
|
3301
|
+
ref: ref,
|
|
3302
|
+
tabIndex: -1,
|
|
3303
|
+
style: HIDDEN_STYLES
|
|
3304
|
+
}));
|
|
3305
|
+
});
|
|
3306
|
+
const activeLocks = new Set();
|
|
3307
|
+
React.forwardRef(function FloatingOverlay(props, ref) {
|
|
3308
|
+
const {
|
|
3309
|
+
lockScroll = false,
|
|
3310
|
+
...rest
|
|
3311
|
+
} = props;
|
|
3312
|
+
const lockId = useId();
|
|
3313
|
+
index(() => {
|
|
3314
|
+
if (!lockScroll) return;
|
|
3315
|
+
activeLocks.add(lockId);
|
|
3316
|
+
const isIOS = /iP(hone|ad|od)|iOS/.test(getPlatform());
|
|
3317
|
+
const bodyStyle = document.body.style;
|
|
3318
|
+
const scrollbarX = Math.round(document.documentElement.getBoundingClientRect().left) + document.documentElement.scrollLeft;
|
|
3319
|
+
const paddingProp = scrollbarX ? 'paddingLeft' : 'paddingRight';
|
|
3320
|
+
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
3321
|
+
const scrollX = bodyStyle.left ? parseFloat(bodyStyle.left) : window.pageXOffset;
|
|
3322
|
+
const scrollY = bodyStyle.top ? parseFloat(bodyStyle.top) : window.pageYOffset;
|
|
3323
|
+
bodyStyle.overflow = 'hidden';
|
|
3324
|
+
if (scrollbarWidth) {
|
|
3325
|
+
bodyStyle[paddingProp] = scrollbarWidth + "px";
|
|
3326
|
+
}
|
|
3327
|
+
if (isIOS) {
|
|
3328
|
+
var _window$visualViewpor, _window$visualViewpor2;
|
|
3329
|
+
const offsetLeft = ((_window$visualViewpor = window.visualViewport) == null ? void 0 : _window$visualViewpor.offsetLeft) || 0;
|
|
3330
|
+
const offsetTop = ((_window$visualViewpor2 = window.visualViewport) == null ? void 0 : _window$visualViewpor2.offsetTop) || 0;
|
|
3331
|
+
Object.assign(bodyStyle, {
|
|
3332
|
+
position: 'fixed',
|
|
3333
|
+
top: -(scrollY - Math.floor(offsetTop)) + "px",
|
|
3334
|
+
left: -(scrollX - Math.floor(offsetLeft)) + "px",
|
|
3335
|
+
right: '0'
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
return () => {
|
|
3339
|
+
activeLocks.delete(lockId);
|
|
3340
|
+
if (activeLocks.size === 0) {
|
|
3341
|
+
Object.assign(bodyStyle, {
|
|
3342
|
+
overflow: '',
|
|
3343
|
+
[paddingProp]: ''
|
|
3344
|
+
});
|
|
3345
|
+
if (isIOS) {
|
|
3346
|
+
Object.assign(bodyStyle, {
|
|
3347
|
+
position: '',
|
|
3348
|
+
top: '',
|
|
3349
|
+
left: '',
|
|
3350
|
+
right: ''
|
|
3351
|
+
});
|
|
3352
|
+
window.scrollTo(scrollX, scrollY);
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
};
|
|
3356
|
+
}, [lockId, lockScroll]);
|
|
3357
|
+
return React.createElement("div", _extends({
|
|
3358
|
+
ref: ref
|
|
3359
|
+
}, rest, {
|
|
3360
|
+
style: {
|
|
3361
|
+
position: 'fixed',
|
|
3362
|
+
overflow: 'auto',
|
|
3363
|
+
top: 0,
|
|
3364
|
+
right: 0,
|
|
3365
|
+
bottom: 0,
|
|
3366
|
+
left: 0,
|
|
3367
|
+
...rest.style
|
|
3368
|
+
}
|
|
3369
|
+
}));
|
|
3370
|
+
});
|
|
3371
|
+
const bubbleHandlerKeys = {
|
|
3372
|
+
pointerdown: 'onPointerDown',
|
|
3373
|
+
mousedown: 'onMouseDown',
|
|
3374
|
+
click: 'onClick'
|
|
3375
|
+
};
|
|
3376
|
+
const captureHandlerKeys = {
|
|
3377
|
+
pointerdown: 'onPointerDownCapture',
|
|
3378
|
+
mousedown: 'onMouseDownCapture',
|
|
3379
|
+
click: 'onClickCapture'
|
|
3380
|
+
};
|
|
3381
|
+
const normalizeProp = normalizable => {
|
|
3382
|
+
var _normalizable$escapeK, _normalizable$outside;
|
|
3383
|
+
return {
|
|
3384
|
+
escapeKey: typeof normalizable === 'boolean' ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
|
|
3385
|
+
outsidePress: typeof normalizable === 'boolean' ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
|
|
3386
|
+
};
|
|
3387
|
+
};
|
|
3388
|
+
function useDismiss(context, props) {
|
|
3389
|
+
if (props === void 0) {
|
|
3390
|
+
props = {};
|
|
3391
|
+
}
|
|
3392
|
+
const {
|
|
3393
|
+
open,
|
|
3394
|
+
onOpenChange,
|
|
3395
|
+
elements: {
|
|
3396
|
+
reference,
|
|
3397
|
+
domReference,
|
|
3398
|
+
floating
|
|
3399
|
+
},
|
|
3400
|
+
dataRef
|
|
3401
|
+
} = context;
|
|
3402
|
+
const {
|
|
3403
|
+
enabled = true,
|
|
3404
|
+
escapeKey = true,
|
|
3405
|
+
outsidePress: unstable_outsidePress = true,
|
|
3406
|
+
outsidePressEvent = 'pointerdown',
|
|
3407
|
+
referencePress = false,
|
|
3408
|
+
referencePressEvent = 'pointerdown',
|
|
3409
|
+
ancestorScroll = false,
|
|
3410
|
+
bubbles,
|
|
3411
|
+
capture
|
|
3412
|
+
} = props;
|
|
3413
|
+
const tree = useFloatingTree();
|
|
3414
|
+
const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);
|
|
3415
|
+
const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;
|
|
3416
|
+
const insideReactTreeRef = React.useRef(false);
|
|
3417
|
+
const endedOrStartedInsideRef = React.useRef(false);
|
|
3418
|
+
const {
|
|
3419
|
+
escapeKey: escapeKeyBubbles,
|
|
3420
|
+
outsidePress: outsidePressBubbles
|
|
3421
|
+
} = normalizeProp(bubbles);
|
|
3422
|
+
const {
|
|
3423
|
+
escapeKey: escapeKeyCapture,
|
|
3424
|
+
outsidePress: outsidePressCapture
|
|
3425
|
+
} = normalizeProp(capture);
|
|
3426
|
+
const closeOnEscapeKeyDown = useEffectEvent(event => {
|
|
3427
|
+
var _dataRef$current$floa;
|
|
3428
|
+
if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
|
|
3429
|
+
return;
|
|
3430
|
+
}
|
|
3431
|
+
const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
|
|
3432
|
+
const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
|
|
3433
|
+
if (!escapeKeyBubbles) {
|
|
3434
|
+
event.stopPropagation();
|
|
3435
|
+
if (children.length > 0) {
|
|
3436
|
+
let shouldDismiss = true;
|
|
3437
|
+
children.forEach(child => {
|
|
3438
|
+
var _child$context;
|
|
3439
|
+
if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
|
|
3440
|
+
shouldDismiss = false;
|
|
3441
|
+
return;
|
|
3442
|
+
}
|
|
3443
|
+
});
|
|
3444
|
+
if (!shouldDismiss) {
|
|
3445
|
+
return;
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, 'escape-key');
|
|
3450
|
+
});
|
|
3451
|
+
const closeOnEscapeKeyDownCapture = useEffectEvent(event => {
|
|
3452
|
+
var _getTarget2;
|
|
3453
|
+
const callback = () => {
|
|
3454
|
+
var _getTarget;
|
|
3455
|
+
closeOnEscapeKeyDown(event);
|
|
3456
|
+
(_getTarget = getTarget(event)) == null || _getTarget.removeEventListener('keydown', callback);
|
|
3457
|
+
};
|
|
3458
|
+
(_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);
|
|
3459
|
+
});
|
|
3460
|
+
const closeOnPressOutside = useEffectEvent(event => {
|
|
3461
|
+
var _dataRef$current$floa2;
|
|
3462
|
+
const insideReactTree = insideReactTreeRef.current;
|
|
3463
|
+
insideReactTreeRef.current = false;
|
|
3464
|
+
const endedOrStartedInside = endedOrStartedInsideRef.current;
|
|
3465
|
+
endedOrStartedInsideRef.current = false;
|
|
3466
|
+
if (outsidePressEvent === 'click' && endedOrStartedInside) {
|
|
3467
|
+
return;
|
|
3468
|
+
}
|
|
3469
|
+
if (insideReactTree) {
|
|
3470
|
+
return;
|
|
3471
|
+
}
|
|
3472
|
+
if (typeof outsidePress === 'function' && !outsidePress(event)) {
|
|
3473
|
+
return;
|
|
3474
|
+
}
|
|
3475
|
+
const target = getTarget(event);
|
|
3476
|
+
const inertSelector = "[" + createAttribute('inert') + "]";
|
|
3477
|
+
const markers = getDocument(floating).querySelectorAll(inertSelector);
|
|
3478
|
+
let targetRootAncestor = isElement(target) ? target : null;
|
|
3479
|
+
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
|
|
3480
|
+
const nextParent = getParentNode(targetRootAncestor);
|
|
3481
|
+
if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
|
|
3482
|
+
break;
|
|
3483
|
+
}
|
|
3484
|
+
targetRootAncestor = nextParent;
|
|
3485
|
+
}
|
|
3486
|
+
if (markers.length && isElement(target) && !isRootElement(target) &&
|
|
3487
|
+
!contains(target, floating) &&
|
|
3488
|
+
Array.from(markers).every(marker => !contains(targetRootAncestor, marker))) {
|
|
3489
|
+
return;
|
|
3490
|
+
}
|
|
3491
|
+
if (isHTMLElement(target) && floating) {
|
|
3492
|
+
const canScrollX = target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
|
|
3493
|
+
const canScrollY = target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
|
|
3494
|
+
let xCond = canScrollY && event.offsetX > target.clientWidth;
|
|
3495
|
+
if (canScrollY) {
|
|
3496
|
+
const isRTL = getComputedStyle(target).direction === 'rtl';
|
|
3497
|
+
if (isRTL) {
|
|
3498
|
+
xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
if (xCond || canScrollX && event.offsetY > target.clientHeight) {
|
|
3502
|
+
return;
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
|
|
3506
|
+
const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
|
|
3507
|
+
var _node$context;
|
|
3508
|
+
return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
|
|
3509
|
+
});
|
|
3510
|
+
if (isEventTargetWithin(event, floating) || isEventTargetWithin(event, domReference) || targetIsInsideChildren) {
|
|
3511
|
+
return;
|
|
3512
|
+
}
|
|
3513
|
+
const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
|
|
3514
|
+
if (children.length > 0) {
|
|
3515
|
+
let shouldDismiss = true;
|
|
3516
|
+
children.forEach(child => {
|
|
3517
|
+
var _child$context2;
|
|
3518
|
+
if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
|
|
3519
|
+
shouldDismiss = false;
|
|
3520
|
+
return;
|
|
3521
|
+
}
|
|
3522
|
+
});
|
|
3523
|
+
if (!shouldDismiss) {
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
onOpenChange(false, event, 'outside-press');
|
|
3528
|
+
});
|
|
3529
|
+
const closeOnPressOutsideCapture = useEffectEvent(event => {
|
|
3530
|
+
var _getTarget4;
|
|
3531
|
+
const callback = () => {
|
|
3532
|
+
var _getTarget3;
|
|
3533
|
+
closeOnPressOutside(event);
|
|
3534
|
+
(_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
|
|
3535
|
+
};
|
|
3536
|
+
(_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
|
|
3537
|
+
});
|
|
3538
|
+
React.useEffect(() => {
|
|
3539
|
+
if (!open || !enabled) {
|
|
3540
|
+
return;
|
|
3541
|
+
}
|
|
3542
|
+
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
|
|
3543
|
+
dataRef.current.__outsidePressBubbles = outsidePressBubbles;
|
|
3544
|
+
function onScroll(event) {
|
|
3545
|
+
onOpenChange(false, event, 'ancestor-scroll');
|
|
3546
|
+
}
|
|
3547
|
+
const doc = getDocument(floating);
|
|
3548
|
+
escapeKey && doc.addEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
|
|
3549
|
+
outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
|
|
3550
|
+
let ancestors = [];
|
|
3551
|
+
if (ancestorScroll) {
|
|
3552
|
+
if (isElement(domReference)) {
|
|
3553
|
+
ancestors = getOverflowAncestors(domReference);
|
|
3554
|
+
}
|
|
3555
|
+
if (isElement(floating)) {
|
|
3556
|
+
ancestors = ancestors.concat(getOverflowAncestors(floating));
|
|
3557
|
+
}
|
|
3558
|
+
if (!isElement(reference) && reference && reference.contextElement) {
|
|
3559
|
+
ancestors = ancestors.concat(getOverflowAncestors(reference.contextElement));
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
ancestors = ancestors.filter(ancestor => {
|
|
3563
|
+
var _doc$defaultView;
|
|
3564
|
+
return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
|
|
3565
|
+
});
|
|
3566
|
+
ancestors.forEach(ancestor => {
|
|
3567
|
+
ancestor.addEventListener('scroll', onScroll, {
|
|
3568
|
+
passive: true
|
|
3569
|
+
});
|
|
3570
|
+
});
|
|
3571
|
+
return () => {
|
|
3572
|
+
escapeKey && doc.removeEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
|
|
3573
|
+
outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
|
|
3574
|
+
ancestors.forEach(ancestor => {
|
|
3575
|
+
ancestor.removeEventListener('scroll', onScroll);
|
|
3576
|
+
});
|
|
3577
|
+
};
|
|
3578
|
+
}, [dataRef, floating, domReference, reference, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
|
|
3579
|
+
React.useEffect(() => {
|
|
3580
|
+
insideReactTreeRef.current = false;
|
|
3581
|
+
}, [outsidePress, outsidePressEvent]);
|
|
3582
|
+
return React.useMemo(() => {
|
|
3583
|
+
if (!enabled) {
|
|
3584
|
+
return {};
|
|
3585
|
+
}
|
|
3586
|
+
return {
|
|
3587
|
+
reference: {
|
|
3588
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
3589
|
+
[bubbleHandlerKeys[referencePressEvent]]: event => {
|
|
3590
|
+
if (referencePress) {
|
|
3591
|
+
onOpenChange(false, event.nativeEvent, 'reference-press');
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
},
|
|
3595
|
+
floating: {
|
|
3596
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
3597
|
+
onMouseDown() {
|
|
3598
|
+
endedOrStartedInsideRef.current = true;
|
|
3599
|
+
},
|
|
3600
|
+
onMouseUp() {
|
|
3601
|
+
endedOrStartedInsideRef.current = true;
|
|
3602
|
+
},
|
|
3603
|
+
[captureHandlerKeys[outsidePressEvent]]: () => {
|
|
3604
|
+
insideReactTreeRef.current = true;
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
};
|
|
3608
|
+
}, [enabled, referencePress, outsidePressEvent, referencePressEvent, onOpenChange, closeOnEscapeKeyDown]);
|
|
3609
|
+
}
|
|
3610
|
+
function useFloatingRootContext(options) {
|
|
3611
|
+
const {
|
|
3612
|
+
open = false,
|
|
3613
|
+
onOpenChange: onOpenChangeProp,
|
|
3614
|
+
elements: elementsProp
|
|
3615
|
+
} = options;
|
|
3616
|
+
const floatingId = useId();
|
|
3617
|
+
const dataRef = React.useRef({});
|
|
3618
|
+
const [events] = React.useState(() => createPubSub());
|
|
3619
|
+
const nested = useFloatingParentNodeId() != null;
|
|
3620
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3621
|
+
const optionDomReference = elementsProp.reference;
|
|
3622
|
+
if (optionDomReference && !isElement(optionDomReference)) {
|
|
3623
|
+
error$1('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
|
|
3627
|
+
const onOpenChange = useEffectEvent((open, event, reason) => {
|
|
3628
|
+
dataRef.current.openEvent = open ? event : undefined;
|
|
3629
|
+
events.emit('openchange', {
|
|
3630
|
+
open,
|
|
3631
|
+
event,
|
|
3632
|
+
reason,
|
|
3633
|
+
nested
|
|
3634
|
+
});
|
|
3635
|
+
onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
|
|
3636
|
+
});
|
|
3637
|
+
const refs = React.useMemo(() => ({
|
|
3638
|
+
setPositionReference
|
|
3639
|
+
}), []);
|
|
3640
|
+
const elements = React.useMemo(() => ({
|
|
3641
|
+
reference: positionReference || elementsProp.reference || null,
|
|
3642
|
+
floating: elementsProp.floating || null,
|
|
3643
|
+
domReference: elementsProp.reference
|
|
3644
|
+
}), [positionReference, elementsProp.reference, elementsProp.floating]);
|
|
3645
|
+
return React.useMemo(() => ({
|
|
3646
|
+
dataRef,
|
|
3647
|
+
open,
|
|
3648
|
+
onOpenChange,
|
|
3649
|
+
elements,
|
|
3650
|
+
events,
|
|
3651
|
+
floatingId,
|
|
3652
|
+
refs
|
|
3653
|
+
}), [open, onOpenChange, elements, events, floatingId, refs]);
|
|
3654
|
+
}
|
|
3655
|
+
function useFloating(options) {
|
|
3656
|
+
if (options === void 0) {
|
|
3657
|
+
options = {};
|
|
3658
|
+
}
|
|
3659
|
+
const {
|
|
3660
|
+
nodeId
|
|
3661
|
+
} = options;
|
|
3662
|
+
const internalRootContext = useFloatingRootContext({
|
|
3663
|
+
...options,
|
|
3664
|
+
elements: {
|
|
3665
|
+
reference: null,
|
|
3666
|
+
floating: null,
|
|
3667
|
+
...options.elements
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3670
|
+
const rootContext = options.rootContext || internalRootContext;
|
|
3671
|
+
const computedElements = rootContext.elements;
|
|
3672
|
+
const [_domReference, setDomReference] = React.useState(null);
|
|
3673
|
+
const [positionReference, _setPositionReference] = React.useState(null);
|
|
3674
|
+
const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
|
|
3675
|
+
const domReference = optionDomReference || _domReference;
|
|
3676
|
+
const domReferenceRef = React.useRef(null);
|
|
3677
|
+
const tree = useFloatingTree();
|
|
3678
|
+
index(() => {
|
|
3679
|
+
if (domReference) {
|
|
3680
|
+
domReferenceRef.current = domReference;
|
|
3681
|
+
}
|
|
3682
|
+
}, [domReference]);
|
|
3683
|
+
const position = useFloating$1({
|
|
3684
|
+
...options,
|
|
3685
|
+
elements: {
|
|
3686
|
+
...computedElements,
|
|
3687
|
+
...(positionReference && {
|
|
3688
|
+
reference: positionReference
|
|
3689
|
+
})
|
|
3690
|
+
}
|
|
3691
|
+
});
|
|
3692
|
+
const setPositionReference = React.useCallback(node => {
|
|
3693
|
+
const computedPositionReference = isElement(node) ? {
|
|
3694
|
+
getBoundingClientRect: () => node.getBoundingClientRect(),
|
|
3695
|
+
contextElement: node
|
|
3696
|
+
} : node;
|
|
3697
|
+
_setPositionReference(computedPositionReference);
|
|
3698
|
+
position.refs.setReference(computedPositionReference);
|
|
3699
|
+
}, [position.refs]);
|
|
3700
|
+
const setReference = React.useCallback(node => {
|
|
3701
|
+
if (isElement(node) || node === null) {
|
|
3702
|
+
domReferenceRef.current = node;
|
|
3703
|
+
setDomReference(node);
|
|
3704
|
+
}
|
|
3705
|
+
if (isElement(position.refs.reference.current) || position.refs.reference.current === null ||
|
|
3706
|
+
node !== null && !isElement(node)) {
|
|
3707
|
+
position.refs.setReference(node);
|
|
3708
|
+
}
|
|
3709
|
+
}, [position.refs]);
|
|
3710
|
+
const refs = React.useMemo(() => ({
|
|
3711
|
+
...position.refs,
|
|
3712
|
+
setReference,
|
|
3713
|
+
setPositionReference,
|
|
3714
|
+
domReference: domReferenceRef
|
|
3715
|
+
}), [position.refs, setReference, setPositionReference]);
|
|
3716
|
+
const elements = React.useMemo(() => ({
|
|
3717
|
+
...position.elements,
|
|
3718
|
+
domReference: domReference
|
|
3719
|
+
}), [position.elements, domReference]);
|
|
3720
|
+
const context = React.useMemo(() => ({
|
|
3721
|
+
...position,
|
|
3722
|
+
...rootContext,
|
|
3723
|
+
refs,
|
|
3724
|
+
elements,
|
|
3725
|
+
nodeId
|
|
3726
|
+
}), [position, refs, elements, nodeId, rootContext]);
|
|
3727
|
+
index(() => {
|
|
3728
|
+
rootContext.dataRef.current.floatingContext = context;
|
|
3729
|
+
const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
|
|
3730
|
+
if (node) {
|
|
3731
|
+
node.context = context;
|
|
3732
|
+
}
|
|
3733
|
+
});
|
|
3734
|
+
return React.useMemo(() => ({
|
|
3735
|
+
...position,
|
|
3736
|
+
context,
|
|
3737
|
+
refs,
|
|
3738
|
+
elements
|
|
3739
|
+
}), [position, refs, elements, context]);
|
|
3740
|
+
}
|
|
3741
|
+
function useFocus(context, props) {
|
|
3742
|
+
if (props === void 0) {
|
|
3743
|
+
props = {};
|
|
3744
|
+
}
|
|
3745
|
+
const {
|
|
3746
|
+
open,
|
|
3747
|
+
onOpenChange,
|
|
3748
|
+
events,
|
|
3749
|
+
dataRef,
|
|
3750
|
+
elements: {
|
|
3751
|
+
domReference
|
|
3752
|
+
}
|
|
3753
|
+
} = context;
|
|
3754
|
+
const {
|
|
3755
|
+
enabled = true,
|
|
3756
|
+
visibleOnly = true
|
|
3757
|
+
} = props;
|
|
3758
|
+
const blockFocusRef = React.useRef(false);
|
|
3759
|
+
const timeoutRef = React.useRef();
|
|
3760
|
+
const keyboardModalityRef = React.useRef(true);
|
|
3761
|
+
React.useEffect(() => {
|
|
3762
|
+
if (!enabled) {
|
|
3763
|
+
return;
|
|
3764
|
+
}
|
|
3765
|
+
const win = getWindow(domReference);
|
|
3766
|
+
function onBlur() {
|
|
3767
|
+
if (!open && isHTMLElement(domReference) && domReference === activeElement(getDocument(domReference))) {
|
|
3768
|
+
blockFocusRef.current = true;
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
function onKeyDown() {
|
|
3772
|
+
keyboardModalityRef.current = true;
|
|
3773
|
+
}
|
|
3774
|
+
win.addEventListener('blur', onBlur);
|
|
3775
|
+
win.addEventListener('keydown', onKeyDown, true);
|
|
3776
|
+
return () => {
|
|
3777
|
+
win.removeEventListener('blur', onBlur);
|
|
3778
|
+
win.removeEventListener('keydown', onKeyDown, true);
|
|
3779
|
+
};
|
|
3780
|
+
}, [domReference, open, enabled]);
|
|
3781
|
+
React.useEffect(() => {
|
|
3782
|
+
if (!enabled) {
|
|
3783
|
+
return;
|
|
3784
|
+
}
|
|
3785
|
+
function onOpenChange(_ref) {
|
|
3786
|
+
let {
|
|
3787
|
+
reason
|
|
3788
|
+
} = _ref;
|
|
3789
|
+
if (reason === 'reference-press' || reason === 'escape-key') {
|
|
3790
|
+
blockFocusRef.current = true;
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
events.on('openchange', onOpenChange);
|
|
3794
|
+
return () => {
|
|
3795
|
+
events.off('openchange', onOpenChange);
|
|
3796
|
+
};
|
|
3797
|
+
}, [events, enabled]);
|
|
3798
|
+
React.useEffect(() => {
|
|
3799
|
+
return () => {
|
|
3800
|
+
clearTimeout(timeoutRef.current);
|
|
3801
|
+
};
|
|
3802
|
+
}, []);
|
|
3803
|
+
return React.useMemo(() => {
|
|
3804
|
+
if (!enabled) {
|
|
3805
|
+
return {};
|
|
3806
|
+
}
|
|
3807
|
+
return {
|
|
3808
|
+
reference: {
|
|
3809
|
+
onPointerDown(event) {
|
|
3810
|
+
if (isVirtualPointerEvent(event.nativeEvent)) return;
|
|
3811
|
+
keyboardModalityRef.current = false;
|
|
3812
|
+
},
|
|
3813
|
+
onMouseLeave() {
|
|
3814
|
+
blockFocusRef.current = false;
|
|
3815
|
+
},
|
|
3816
|
+
onFocus(event) {
|
|
3817
|
+
if (blockFocusRef.current) return;
|
|
3818
|
+
const target = getTarget(event.nativeEvent);
|
|
3819
|
+
if (visibleOnly && isElement(target)) {
|
|
3820
|
+
try {
|
|
3821
|
+
if (isSafari() && isMac()) throw Error();
|
|
3822
|
+
if (!target.matches(':focus-visible')) return;
|
|
3823
|
+
} catch (e) {
|
|
3824
|
+
if (!keyboardModalityRef.current && !isTypeableElement(target)) {
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
onOpenChange(true, event.nativeEvent, 'focus');
|
|
3830
|
+
},
|
|
3831
|
+
onBlur(event) {
|
|
3832
|
+
blockFocusRef.current = false;
|
|
3833
|
+
const relatedTarget = event.relatedTarget;
|
|
3834
|
+
const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute('focus-guard')) && relatedTarget.getAttribute('data-type') === 'outside';
|
|
3835
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
3836
|
+
var _dataRef$current$floa;
|
|
3837
|
+
const activeEl = activeElement(domReference ? domReference.ownerDocument : document);
|
|
3838
|
+
if (!relatedTarget && activeEl === domReference) return;
|
|
3839
|
+
if (contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
|
|
3840
|
+
return;
|
|
3841
|
+
}
|
|
3842
|
+
onOpenChange(false, event.nativeEvent, 'focus');
|
|
3843
|
+
});
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
321
3846
|
};
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
3847
|
+
}, [enabled, visibleOnly, dataRef, domReference, onOpenChange]);
|
|
3848
|
+
}
|
|
3849
|
+
const ACTIVE_KEY = 'active';
|
|
3850
|
+
const SELECTED_KEY = 'selected';
|
|
3851
|
+
function mergeProps(userProps, propsList, elementKey) {
|
|
3852
|
+
const map = new Map();
|
|
3853
|
+
const isItem = elementKey === 'item';
|
|
3854
|
+
let domUserProps = userProps;
|
|
3855
|
+
if (isItem && userProps) {
|
|
3856
|
+
const {
|
|
3857
|
+
[ACTIVE_KEY]: _,
|
|
3858
|
+
[SELECTED_KEY]: __,
|
|
3859
|
+
...validProps
|
|
3860
|
+
} = userProps;
|
|
3861
|
+
domUserProps = validProps;
|
|
3862
|
+
}
|
|
3863
|
+
return {
|
|
3864
|
+
...(elementKey === 'floating' && {
|
|
3865
|
+
tabIndex: -1
|
|
3866
|
+
}),
|
|
3867
|
+
...domUserProps,
|
|
3868
|
+
...propsList.map(value => {
|
|
3869
|
+
const propsOrGetProps = value ? value[elementKey] : null;
|
|
3870
|
+
if (typeof propsOrGetProps === 'function') {
|
|
3871
|
+
return userProps ? propsOrGetProps(userProps) : null;
|
|
3872
|
+
}
|
|
3873
|
+
return propsOrGetProps;
|
|
3874
|
+
}).concat(userProps).reduce((acc, props) => {
|
|
3875
|
+
if (!props) {
|
|
3876
|
+
return acc;
|
|
3877
|
+
}
|
|
3878
|
+
Object.entries(props).forEach(_ref => {
|
|
3879
|
+
let [key, value] = _ref;
|
|
3880
|
+
if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
|
|
3881
|
+
return;
|
|
338
3882
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
3883
|
+
if (key.indexOf('on') === 0) {
|
|
3884
|
+
if (!map.has(key)) {
|
|
3885
|
+
map.set(key, []);
|
|
3886
|
+
}
|
|
3887
|
+
if (typeof value === 'function') {
|
|
3888
|
+
var _map$get;
|
|
3889
|
+
(_map$get = map.get(key)) == null || _map$get.push(value);
|
|
3890
|
+
acc[key] = function () {
|
|
3891
|
+
var _map$get2;
|
|
3892
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3893
|
+
args[_key] = arguments[_key];
|
|
3894
|
+
}
|
|
3895
|
+
return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map(fn => fn(...args)).find(val => val !== undefined);
|
|
3896
|
+
};
|
|
3897
|
+
}
|
|
3898
|
+
} else {
|
|
3899
|
+
acc[key] = value;
|
|
3900
|
+
}
|
|
3901
|
+
});
|
|
3902
|
+
return acc;
|
|
3903
|
+
}, {})
|
|
3904
|
+
};
|
|
3905
|
+
}
|
|
3906
|
+
function useInteractions(propsList) {
|
|
3907
|
+
if (propsList === void 0) {
|
|
3908
|
+
propsList = [];
|
|
3909
|
+
}
|
|
3910
|
+
const deps = propsList;
|
|
3911
|
+
const getReferenceProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
|
|
3912
|
+
deps);
|
|
3913
|
+
const getFloatingProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
|
|
3914
|
+
deps);
|
|
3915
|
+
const getItemProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
|
|
3916
|
+
propsList.map(key => key == null ? void 0 : key.item));
|
|
3917
|
+
return React.useMemo(() => ({
|
|
3918
|
+
getReferenceProps,
|
|
3919
|
+
getFloatingProps,
|
|
3920
|
+
getItemProps
|
|
3921
|
+
}), [getReferenceProps, getFloatingProps, getItemProps]);
|
|
3922
|
+
}
|
|
3923
|
+
const componentRoleToAriaRoleMap = new Map([['select', 'listbox'], ['combobox', 'listbox'], ['label', false]]);
|
|
3924
|
+
function useRole(context, props) {
|
|
3925
|
+
var _componentRoleToAriaR;
|
|
3926
|
+
if (props === void 0) {
|
|
3927
|
+
props = {};
|
|
3928
|
+
}
|
|
3929
|
+
const {
|
|
3930
|
+
open,
|
|
3931
|
+
floatingId
|
|
3932
|
+
} = context;
|
|
3933
|
+
const {
|
|
3934
|
+
enabled = true,
|
|
3935
|
+
role = 'dialog'
|
|
3936
|
+
} = props;
|
|
3937
|
+
const ariaRole = (_componentRoleToAriaR = componentRoleToAriaRoleMap.get(role)) != null ? _componentRoleToAriaR : role;
|
|
3938
|
+
const referenceId = useId();
|
|
3939
|
+
const parentId = useFloatingParentNodeId();
|
|
3940
|
+
const isNested = parentId != null;
|
|
3941
|
+
return React.useMemo(() => {
|
|
3942
|
+
if (!enabled) return {};
|
|
3943
|
+
const floatingProps = {
|
|
3944
|
+
id: floatingId,
|
|
3945
|
+
...(ariaRole && {
|
|
3946
|
+
role: ariaRole
|
|
3947
|
+
})
|
|
3948
|
+
};
|
|
3949
|
+
if (ariaRole === 'tooltip' || role === 'label') {
|
|
3950
|
+
return {
|
|
3951
|
+
reference: {
|
|
3952
|
+
["aria-" + (role === 'label' ? 'labelledby' : 'describedby')]: open ? floatingId : undefined
|
|
3953
|
+
},
|
|
3954
|
+
floating: floatingProps
|
|
3955
|
+
};
|
|
3956
|
+
}
|
|
3957
|
+
return {
|
|
3958
|
+
reference: {
|
|
3959
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
3960
|
+
'aria-haspopup': ariaRole === 'alertdialog' ? 'dialog' : ariaRole,
|
|
3961
|
+
'aria-controls': open ? floatingId : undefined,
|
|
3962
|
+
...(ariaRole === 'listbox' && {
|
|
3963
|
+
role: 'combobox'
|
|
3964
|
+
}),
|
|
3965
|
+
...(ariaRole === 'menu' && {
|
|
3966
|
+
id: referenceId
|
|
3967
|
+
}),
|
|
3968
|
+
...(ariaRole === 'menu' && isNested && {
|
|
3969
|
+
role: 'menuitem'
|
|
3970
|
+
}),
|
|
3971
|
+
...(role === 'select' && {
|
|
3972
|
+
'aria-autocomplete': 'none'
|
|
3973
|
+
}),
|
|
3974
|
+
...(role === 'combobox' && {
|
|
3975
|
+
'aria-autocomplete': 'list'
|
|
3976
|
+
})
|
|
3977
|
+
},
|
|
3978
|
+
floating: {
|
|
3979
|
+
...floatingProps,
|
|
3980
|
+
...(ariaRole === 'menu' && {
|
|
3981
|
+
'aria-labelledby': referenceId
|
|
3982
|
+
})
|
|
3983
|
+
},
|
|
3984
|
+
item(_ref) {
|
|
3985
|
+
let {
|
|
3986
|
+
active,
|
|
3987
|
+
selected
|
|
3988
|
+
} = _ref;
|
|
3989
|
+
const commonProps = {
|
|
3990
|
+
role: 'option',
|
|
3991
|
+
...(active && {
|
|
3992
|
+
id: floatingId + "-option"
|
|
3993
|
+
})
|
|
3994
|
+
};
|
|
3995
|
+
switch (role) {
|
|
3996
|
+
case 'select':
|
|
3997
|
+
return {
|
|
3998
|
+
...commonProps,
|
|
3999
|
+
'aria-selected': active && selected
|
|
4000
|
+
};
|
|
4001
|
+
case 'combobox':
|
|
4002
|
+
{
|
|
4003
|
+
return {
|
|
4004
|
+
...commonProps,
|
|
4005
|
+
...(active && {
|
|
4006
|
+
'aria-selected': true
|
|
4007
|
+
})
|
|
4008
|
+
};
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
return {};
|
|
4012
|
+
}
|
|
4013
|
+
};
|
|
4014
|
+
}, [enabled, role, ariaRole, open, floatingId, referenceId, isNested]);
|
|
4015
|
+
}
|
|
411
4016
|
|
|
412
|
-
var
|
|
413
|
-
var children = props.children,
|
|
4017
|
+
var TooltipElement = function (props) {
|
|
4018
|
+
var children = props.children,
|
|
4019
|
+
//
|
|
4020
|
+
content = props.content,
|
|
4021
|
+
//
|
|
4022
|
+
placement = props.placement, isHidden = props.isHidden, isPointing = props.isPointing,
|
|
4023
|
+
//
|
|
4024
|
+
stylesOverrides = props.styles, dataCy = props.dataCy;
|
|
4025
|
+
var arrowRef = useRef(null);
|
|
4026
|
+
var _a = useState(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
4027
|
+
var _b = useFloating({
|
|
4028
|
+
open: isOpen,
|
|
4029
|
+
onOpenChange: setIsOpen,
|
|
4030
|
+
placement: placement,
|
|
4031
|
+
middleware: [
|
|
4032
|
+
offset(10),
|
|
4033
|
+
flip(),
|
|
4034
|
+
shift(),
|
|
4035
|
+
arrow({
|
|
4036
|
+
element: arrowRef,
|
|
4037
|
+
}),
|
|
4038
|
+
],
|
|
4039
|
+
whileElementsMounted: autoUpdate,
|
|
4040
|
+
}), refs = _b.refs, floatingStyles = _b.floatingStyles, context = _b.context;
|
|
4041
|
+
var hover = useHover(context, { move: false });
|
|
4042
|
+
var focus = useFocus(context);
|
|
4043
|
+
var dismiss = useDismiss(context);
|
|
4044
|
+
var role = useRole(context, {
|
|
4045
|
+
// If your reference element has its own label (text).
|
|
4046
|
+
role: 'tooltip',
|
|
4047
|
+
});
|
|
4048
|
+
// Merge all the interactions into prop getters
|
|
4049
|
+
var _c = useInteractions([
|
|
4050
|
+
hover,
|
|
4051
|
+
focus,
|
|
4052
|
+
dismiss,
|
|
4053
|
+
role,
|
|
4054
|
+
]), getReferenceProps = _c.getReferenceProps, getFloatingProps = _c.getFloatingProps;
|
|
414
4055
|
var handleGenerateStyle = function () {
|
|
415
4056
|
var result = deepCopyObject(styles$t.base);
|
|
416
4057
|
var keys = calculateNestedKeys(styles$t.base);
|
|
417
4058
|
keys.forEach(function (key) {
|
|
418
|
-
set(result, key, toClassName(get(styles$t.base, key),
|
|
4059
|
+
return set(result, key, toClassName(get(styles$t.base, key), get(stylesOverrides, key)));
|
|
419
4060
|
});
|
|
420
4061
|
return result;
|
|
421
4062
|
};
|
|
422
4063
|
var styles = handleGenerateStyle();
|
|
423
|
-
var
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
4064
|
+
var childrenWithProps = React__default.Children.map(children, function (child) {
|
|
4065
|
+
var props = __assign$1({ ref: refs.setReference }, getReferenceProps());
|
|
4066
|
+
if (React__default.isValidElement(child)) {
|
|
4067
|
+
return React__default.cloneElement(child, props);
|
|
4068
|
+
}
|
|
4069
|
+
return child;
|
|
4070
|
+
});
|
|
4071
|
+
if (isHidden)
|
|
4072
|
+
return children;
|
|
4073
|
+
return (jsxs(Fragment, { children: [childrenWithProps, isOpen && (jsxs("div", __assign$1({ "data-cy": dataCy, ref: refs.setFloating, style: floatingStyles, className: toClassName(styles.content, stylesOverrides === null || stylesOverrides === void 0 ? void 0 : stylesOverrides.content) }, getFloatingProps(), { children: [isPointing && (jsx(FloatingArrow, { ref: arrowRef, context: context, fill: styles.arrow.fill, stroke: styles.arrow.stroke, strokeWidth: Number(styles.arrow.strokeWidth) })), content] })))] }));
|
|
428
4074
|
};
|
|
429
4075
|
|
|
430
4076
|
var base$p = {
|
|
431
|
-
container: '
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
var indicator = {
|
|
439
|
-
container: 'px-2.5',
|
|
440
|
-
};
|
|
441
|
-
var close = {
|
|
442
|
-
container: 'pl-2.5 pr-1',
|
|
443
|
-
};
|
|
444
|
-
var primary$1 = {
|
|
445
|
-
container: "shadow-sm text-white bg-primary-600 hover:bg-primary-700",
|
|
446
|
-
};
|
|
447
|
-
var secondary$1 = {
|
|
448
|
-
container: "shadow-none text-primary-700 bg-primary-100 hover:bg-primary-200",
|
|
449
|
-
};
|
|
450
|
-
var outline$1 = {
|
|
451
|
-
container: "border-gray-300 text-gray-700 bg-white hover:bg-gray-50",
|
|
452
|
-
};
|
|
453
|
-
var sm$4 = {
|
|
454
|
-
container: 'text-xs',
|
|
455
|
-
indicator: 'mr-1.5 h-2 w-2 ',
|
|
456
|
-
};
|
|
457
|
-
var lg$4 = {
|
|
458
|
-
container: 'text-sm',
|
|
459
|
-
indicator: '-ml-0.5 mr-1.5 h-2 w-2',
|
|
460
|
-
};
|
|
461
|
-
var block$1 = {
|
|
462
|
-
container: 'rounded-md',
|
|
463
|
-
};
|
|
464
|
-
var rounded$1 = {
|
|
465
|
-
container: 'rounded-full',
|
|
466
|
-
};
|
|
467
|
-
var gray = {
|
|
468
|
-
container: 'bg-gray-100 text-gray-800',
|
|
469
|
-
indicator: 'text-gray-400',
|
|
470
|
-
button: 'text-gray-400 hover:bg-gray-200 hover:text-gray-500 focus:bg-gray-500',
|
|
471
|
-
};
|
|
472
|
-
var red = {
|
|
473
|
-
container: 'bg-red-100 text-red-800',
|
|
474
|
-
indicator: 'text-red-400',
|
|
475
|
-
button: 'text-red-400 hover:bg-red-200 hover:text-red-500 focus:bg-red-500',
|
|
476
|
-
};
|
|
477
|
-
var yellow = {
|
|
478
|
-
container: 'bg-yellow-100 text-yellow-800',
|
|
479
|
-
indicator: 'text-yellow-400',
|
|
480
|
-
button: 'text-yellow-400 hover:bg-yellow-200 hover:text-yellow-500 focus:bg-yellow-500',
|
|
481
|
-
};
|
|
482
|
-
var green = {
|
|
483
|
-
container: 'bg-green-100 text-green-800',
|
|
484
|
-
indicator: 'text-green-400',
|
|
485
|
-
button: 'text-green-400 hover:bg-green-200 hover:text-green-500 focus:bg-green-500',
|
|
486
|
-
};
|
|
487
|
-
var blue = {
|
|
488
|
-
container: 'bg-blue-100 text-blue-800',
|
|
489
|
-
indicator: 'text-blue-400',
|
|
490
|
-
button: 'text-blue-400 hover:bg-blue-200 hover:text-blue-500 focus:bg-blue-500',
|
|
491
|
-
};
|
|
492
|
-
var indigo = {
|
|
493
|
-
container: 'bg-primary-100 text-primary-800',
|
|
494
|
-
indicator: 'text-primary-400',
|
|
495
|
-
button: 'text-primary-400 hover:bg-primary-200 hover:text-primary-500 focus:outline-none focus:bg-primary-500',
|
|
496
|
-
};
|
|
497
|
-
var purple = {
|
|
498
|
-
container: 'bg-purple-100 text-purple-800',
|
|
499
|
-
indicator: 'text-purple-400',
|
|
500
|
-
button: 'text-purple-400 hover:bg-purple-200 hover:text-purple-500 focus:bg-purple-500',
|
|
501
|
-
};
|
|
502
|
-
var pink = {
|
|
503
|
-
container: 'bg-pink-100 text-pink-800',
|
|
504
|
-
indicator: 'text-pink-400',
|
|
505
|
-
button: 'text-pink-400 hover:bg-pink-200 hover:text-pink-500 focus:bg-purple-500',
|
|
506
|
-
};
|
|
507
|
-
var disabled$9 = {
|
|
508
|
-
container: 'opacity-20 cursor-not-allowed',
|
|
509
|
-
};
|
|
510
|
-
var loading$1 = {
|
|
511
|
-
container: 'cursor-progress',
|
|
4077
|
+
container: 'w-fit h-fit relative group/tooltip',
|
|
4078
|
+
content: 'absolute flex justify-center items-center z-200 tooltip-animate px-4 py-2 border whitespace-nowrap border-palette-grayDarker bg-white font-light text-xs rounded-sm',
|
|
4079
|
+
arrow: {
|
|
4080
|
+
stroke: '#e5e7eb',
|
|
4081
|
+
fill: 'white',
|
|
4082
|
+
strokeWidth: '1',
|
|
4083
|
+
},
|
|
512
4084
|
};
|
|
513
4085
|
var styles$t = {
|
|
514
4086
|
base: base$p,
|
|
515
|
-
normal: normal$8,
|
|
516
|
-
indicator: indicator,
|
|
517
|
-
close: close,
|
|
518
|
-
primary: primary$1,
|
|
519
|
-
secondary: secondary$1,
|
|
520
|
-
outline: outline$1,
|
|
521
|
-
sm: sm$4,
|
|
522
|
-
lg: lg$4,
|
|
523
|
-
block: block$1,
|
|
524
|
-
rounded: rounded$1,
|
|
525
|
-
gray: gray,
|
|
526
|
-
red: red,
|
|
527
|
-
yellow: yellow,
|
|
528
|
-
green: green,
|
|
529
|
-
blue: blue,
|
|
530
|
-
indigo: indigo,
|
|
531
|
-
purple: purple,
|
|
532
|
-
pink: pink,
|
|
533
|
-
disabled: disabled$9,
|
|
534
|
-
loading: loading$1,
|
|
535
4087
|
};
|
|
536
4088
|
|
|
537
4089
|
var ButtonElement = function (props) {
|
|
@@ -667,7 +4219,7 @@ var Container$3 = function (props) {
|
|
|
667
4219
|
};
|
|
668
4220
|
var styles = handleGenerateStyle();
|
|
669
4221
|
return (jsxs(Menu, { as: "div", className: toClassName(styles.container, !isEscapingOverflow && 'relative'), children: [jsxs("div", { children: [type === 'button' &&
|
|
670
|
-
(!trigger ? (jsxs(Menu.Button, { className: styles.button, "data-cy": dataCy, children: [label, jsx(ChevronDownIcon, { className: "-mr-1 ml-2 h-5 w-5", "aria-hidden": "true" })] })) : (jsx(Menu.Button, { "data-cy": dataCy, children: trigger }))), type === 'compact' && (jsxs(Menu.Button, { className: styles.compact, "data-cy": dataCy, children: [jsx("span", { className: "sr-only", children: label }), jsx(EllipsisVerticalIcon, { className: styles.dots, "aria-hidden": "true" })] }))] }), jsx(Transition, { as: Fragment, enter: "transition ease-out duration-100", enterFrom: "transform opacity-0 scale-95", enterTo: "transform opacity-100 scale-100", leave: "transition ease-in duration-75", leaveFrom: "transform opacity-100 scale-100", leaveTo: "transform opacity-0 scale-95", children: jsx(Menu.Items, { className: styles.items, children: children }) })] }));
|
|
4222
|
+
(!trigger ? (jsxs(Menu.Button, { className: styles.button, "data-cy": dataCy, children: [label, jsx(ChevronDownIcon, { className: "-mr-1 ml-2 h-5 w-5", "aria-hidden": "true" })] })) : (jsx(Menu.Button, { "data-cy": dataCy, children: trigger }))), type === 'compact' && (jsxs(Menu.Button, { className: styles.compact, "data-cy": dataCy, children: [jsx("span", { className: "sr-only", children: label }), jsx(EllipsisVerticalIcon, { className: styles.dots, "aria-hidden": "true" })] }))] }), jsx(Transition, { as: Fragment$1, enter: "transition ease-out duration-100", enterFrom: "transform opacity-0 scale-95", enterTo: "transform opacity-100 scale-100", leave: "transition ease-in duration-75", leaveFrom: "transform opacity-100 scale-100", leaveTo: "transform opacity-0 scale-95", children: jsx(Menu.Items, { className: styles.items, children: children }) })] }));
|
|
671
4223
|
};
|
|
672
4224
|
var DropdownElement = {
|
|
673
4225
|
Container: Container$3,
|
|
@@ -966,7 +4518,7 @@ var MediaObjectLayout = function (props) {
|
|
|
966
4518
|
var handleGenerateComponent = function () {
|
|
967
4519
|
var result = (jsx("svg", { className: styles.svg, preserveAspectRatio: "none", stroke: "currentColor", fill: "none", viewBox: "0 0 200 200", "aria-hidden": "true", children: jsx("path", { vectorEffect: "non-scaling-stroke", strokeWidth: 1, d: "M0 0l200 200M0 200L200 0" }) }));
|
|
968
4520
|
if (customFigure) {
|
|
969
|
-
result =
|
|
4521
|
+
result = React__default.cloneElement(customFigure, {
|
|
970
4522
|
className: styles.svg,
|
|
971
4523
|
});
|
|
972
4524
|
}
|
|
@@ -1408,16 +4960,16 @@ var PanelPaginationNavigation = function (props) {
|
|
|
1408
4960
|
var component;
|
|
1409
4961
|
switch (pageType) {
|
|
1410
4962
|
case 'first':
|
|
1411
|
-
component = (jsxs(Fragment
|
|
4963
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 1); }, children: min + 1 }), jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1412
4964
|
break;
|
|
1413
4965
|
case 'center':
|
|
1414
|
-
component = (jsxs(Fragment
|
|
4966
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), current - 2 !== min && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current - 1); }, children: current - 1 }), jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return handleChangeCurrent(current); }, children: current }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current + 1); }, children: current + 1 }), current + 2 !== max && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1415
4967
|
break;
|
|
1416
4968
|
case 'last':
|
|
1417
|
-
component = (jsxs(Fragment
|
|
4969
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: toClassName(styles.button.default, current === max - 2 && styles.button.active), onClick: function () { return handleChangeCurrent(max - 2); }, children: max - 2 }), jsx("button", { className: toClassName(styles.button.default, current === max - 1 && styles.button.active), onClick: function () { return handleChangeCurrent(max - 1); }, children: max - 1 }), jsx("button", { className: toClassName(styles.button.default, current === max && styles.button.active), onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1418
4970
|
break;
|
|
1419
4971
|
case 'simple':
|
|
1420
|
-
component = (jsxs(Fragment
|
|
4972
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), max >= min + 1 && (jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 1); }, children: min + 1 })), max >= min + 2 && (jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 })), max >= min + 3 && (jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 3); }, children: min + 3 }))] }));
|
|
1421
4973
|
break;
|
|
1422
4974
|
}
|
|
1423
4975
|
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: "flex flex-1 justify-between sm:hidden", children: [jsx("button", { className: toClassName(styles.mobile.button, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: "Previous" }), hasCustomizablePageSize && (jsx(SelectMenuForm, { name: "pageSize", isClearable: false, isSearchable: false, isMultiple: false, isSolo: true, options: pageSizeMenuOptions, value: pageSize, styles: { list: styles.pageSizeList }, onClear: noop$1, onChange: function (value) {
|
|
@@ -1559,7 +5111,7 @@ var TableList = function (props) {
|
|
|
1559
5111
|
return window === null || window === void 0 ? void 0 : window.localStorage.setItem("TableList.".concat(id, ".state"), idsWithVisibilityIndicator.join(','));
|
|
1560
5112
|
}
|
|
1561
5113
|
}, [id, table, order, visibility]);
|
|
1562
|
-
return (jsx(Fragment
|
|
5114
|
+
return (jsx(Fragment, { children: jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.controls.container, children: [jsx("div", { children: customControls }), jsxs("div", { className: styles.controls.body, children: [jsx(DropdownElement.Container, { styles: (_a = stylesOverrides === null || stylesOverrides === void 0 ? void 0 : stylesOverrides.components) === null || _a === void 0 ? void 0 : _a.dropdownElement, label: jsx(ViewColumnsIcon, { className: "w-6 h-6" }), children: jsx("div", { className: styles.controls.content, children: table
|
|
1563
5115
|
.getAllLeafColumns()
|
|
1564
5116
|
// .filter((column) => column?.getCanSort())
|
|
1565
5117
|
.map(function (column, index) {
|
|
@@ -1914,7 +5466,7 @@ var TableList2 = function (props) {
|
|
|
1914
5466
|
((_c = (_b = table === null || table === void 0 ? void 0 : table.getState()) === null || _b === void 0 ? void 0 : _b.pagination) === null || _c === void 0 ? void 0 : _c.pageSize) - 1 &&
|
|
1915
5467
|
'border-b border-gray-200'), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
1916
5468
|
}) }, row.id));
|
|
1917
|
-
}) }))] }), isEmpty(table === null || table === void 0 ? void 0 : table.getRowModel().rows) && !isLoading && (jsx(Fragment
|
|
5469
|
+
}) }))] }), isEmpty(table === null || table === void 0 ? void 0 : table.getRowModel().rows) && !isLoading && (jsx(Fragment, { children: ((_g = config === null || config === void 0 ? void 0 : config.options) === null || _g === void 0 ? void 0 : _g.emptyComponent) ? ((_h = config === null || config === void 0 ? void 0 : config.options) === null || _h === void 0 ? void 0 : _h.emptyComponent) : (jsx("div", { className: "w-full flex justify-center my-2", children: "There is no data to show..." })) })), isLoading && (jsx("div", { className: "flex flex-col gap-y-2 w-full pt-5", children: new Array(8).fill(undefined).map(function (index) { return (jsxs("div", { className: "flex gap-2", children: [jsx("div", { className: "w-20 h-12 rounded-md bg-gray-100 animate-pulse" }), jsx("div", { className: "w-full h-12 rounded-md bg-gray-100 animate-pulse" })] }, index)); }) }))] }) }) }) }), jsx("div", { className: styles.foot, children: foot && foot(state) })] }));
|
|
1918
5470
|
};
|
|
1919
5471
|
|
|
1920
5472
|
var base$c = {
|
|
@@ -2127,16 +5679,16 @@ var PagePaginationNavigation = function (props) {
|
|
|
2127
5679
|
var component;
|
|
2128
5680
|
switch (pageType) {
|
|
2129
5681
|
case 'first':
|
|
2130
|
-
component = (jsxs(Fragment
|
|
5682
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return setCurrent(min); }, children: min }), jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return setCurrent(min + 1); }, children: min + 1 }), jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return setCurrent(min + 2); }, children: min + 2 }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
2131
5683
|
break;
|
|
2132
5684
|
case 'center':
|
|
2133
|
-
component = (jsxs(Fragment
|
|
5685
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), current - 2 !== min && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current - 1); }, children: current - 1 }), jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return setCurrent(current); }, children: current }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current + 1); }, children: current + 1 }), current + 2 !== max && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
2134
5686
|
break;
|
|
2135
5687
|
case 'last':
|
|
2136
|
-
component = (jsxs(Fragment
|
|
5688
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: toClassName(styles.button.default, current === max - 2 && styles.button.active), onClick: function () { return setCurrent(max - 2); }, children: max - 2 }), jsx("button", { className: toClassName(styles.button.default, current === max - 1 && styles.button.active), onClick: function () { return setCurrent(max - 1); }, children: max - 1 }), jsx("button", { className: toClassName(styles.button.default, current === max && styles.button.active), onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
2137
5689
|
break;
|
|
2138
5690
|
case 'simple':
|
|
2139
|
-
component = (jsxs(Fragment
|
|
5691
|
+
component = (jsxs(Fragment, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return setCurrent(min); }, children: min }), max >= min + 1 && (jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return setCurrent(min + 1); }, children: min + 1 })), max >= min + 2 && (jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return setCurrent(min + 2); }, children: min + 2 })), max >= min + 3 && (jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return setCurrent(min + 3); }, children: min + 3 }))] }));
|
|
2140
5692
|
break;
|
|
2141
5693
|
}
|
|
2142
5694
|
useEffect(function () {
|
|
@@ -2254,7 +5806,7 @@ var Item$1 = function (props) {
|
|
|
2254
5806
|
};
|
|
2255
5807
|
var View$1 = function (props) {
|
|
2256
5808
|
var children = props.children;
|
|
2257
|
-
return jsx(Fragment
|
|
5809
|
+
return jsx(Fragment, { children: children });
|
|
2258
5810
|
};
|
|
2259
5811
|
var TabNavigation = {
|
|
2260
5812
|
Container: Container$1,
|
|
@@ -2336,7 +5888,7 @@ var Item = function (props) {
|
|
|
2336
5888
|
};
|
|
2337
5889
|
var View = function (props) {
|
|
2338
5890
|
var children = props.children;
|
|
2339
|
-
return jsx(Fragment
|
|
5891
|
+
return jsx(Fragment, { children: children });
|
|
2340
5892
|
};
|
|
2341
5893
|
var VerticalNavigation = {
|
|
2342
5894
|
Container: Container,
|
|
@@ -2358,10 +5910,15 @@ var styles$c = {
|
|
|
2358
5910
|
var ModalOverlay = function (props) {
|
|
2359
5911
|
var children = props.children, trigger = props.trigger, _a = props.size, size = _a === void 0 ? 'md' : _a, stylesOverrides = props.styles, dataCy = props.dataCy, onOpen = props.onOpen, onClose = props.onClose;
|
|
2360
5912
|
var _b = useState(trigger ? false : true), isOpen = _b[0], setIsOpen = _b[1];
|
|
5913
|
+
var handleClose = useCallback(function () {
|
|
5914
|
+
setIsOpen(false);
|
|
5915
|
+
if (onClose)
|
|
5916
|
+
setTimeout(onClose, 180);
|
|
5917
|
+
}, [onClose]);
|
|
2361
5918
|
var options = useMemo(function () { return ({
|
|
2362
5919
|
handleOpen: function () { return setIsOpen(true); },
|
|
2363
|
-
handleClose:
|
|
2364
|
-
}); }, []);
|
|
5920
|
+
handleClose: handleClose,
|
|
5921
|
+
}); }, [handleClose]);
|
|
2365
5922
|
var handleGenerateStyle = function () {
|
|
2366
5923
|
var result = deepCopyObject(styles$b.base);
|
|
2367
5924
|
var keys = calculateNestedKeys(styles$b.base);
|
|
@@ -2376,12 +5933,7 @@ var ModalOverlay = function (props) {
|
|
|
2376
5933
|
onOpen && onOpen();
|
|
2377
5934
|
}
|
|
2378
5935
|
}, [isOpen, onOpen]);
|
|
2379
|
-
|
|
2380
|
-
if (!isOpen) {
|
|
2381
|
-
onClose && onClose();
|
|
2382
|
-
}
|
|
2383
|
-
}, [isOpen, onClose]);
|
|
2384
|
-
return (jsxs(Fragment$1, { children: [jsx(Transition.Root, { show: isOpen, as: Fragment, children: jsxs(Dialog, { as: "div", className: styles.container, onClose: setIsOpen, children: [jsx(Transition.Child, { as: Fragment, enter: styles.background.transition.enter, enterFrom: styles.background.transition.enterFrom, enterTo: styles.background.transition.enterTo, leave: styles.background.transition.leave, leaveFrom: styles.background.transition.leaveFrom, leaveTo: styles.background.transition.leaveTo, children: jsx("div", { className: styles.background.container }) }), jsx("div", { className: styles.layout.container, children: jsx("div", { className: styles.layout.content, "data-cy": dataCy, children: jsx(Transition.Child, { as: Fragment, enter: styles.panel.transition.enter, enterFrom: styles.panel.transition.enterFrom, enterTo: styles.panel.transition.enterTo, leave: styles.panel.transition.leave, leaveFrom: styles.panel.transition.leaveFrom, leaveTo: styles.panel.transition.leaveTo, children: jsx(Dialog.Panel, { className: styles.panel.container, children: children(options) }) }) }) })] }) }), trigger && trigger(options)] }));
|
|
5936
|
+
return (jsxs(Fragment, { children: [jsx(Transition.Root, { show: isOpen, as: Fragment$1, children: jsxs(Dialog, { as: "div", className: styles.container, onClose: handleClose, children: [jsx(Transition.Child, { as: Fragment$1, enter: styles.background.transition.enter, enterFrom: styles.background.transition.enterFrom, enterTo: styles.background.transition.enterTo, leave: styles.background.transition.leave, leaveFrom: styles.background.transition.leaveFrom, leaveTo: styles.background.transition.leaveTo, children: jsx("div", { className: styles.background.container }) }), jsx("div", { className: styles.layout.container, children: jsx("div", { className: styles.layout.content, "data-cy": dataCy, children: jsx(Transition.Child, { as: Fragment$1, enter: styles.panel.transition.enter, enterFrom: styles.panel.transition.enterFrom, enterTo: styles.panel.transition.enterTo, leave: styles.panel.transition.leave, leaveFrom: styles.panel.transition.leaveFrom, leaveTo: styles.panel.transition.leaveTo, children: jsx(Dialog.Panel, { className: styles.panel.container, children: children(options) }) }) }) })] }) }), trigger && trigger(options)] }));
|
|
2385
5937
|
};
|
|
2386
5938
|
|
|
2387
5939
|
var base$8 = {
|
|
@@ -2476,7 +6028,7 @@ var NotificationOverlayItem = function (props) {
|
|
|
2476
6028
|
return result;
|
|
2477
6029
|
};
|
|
2478
6030
|
var styles = handleGenerateStyle();
|
|
2479
|
-
return (jsxs(Fragment
|
|
6031
|
+
return (jsxs(Fragment, { children: [jsx(Transition, { show: isOpen, as: Fragment$1, enter: styles.item.panel.transition.enter, enterFrom: styles.item.panel.transition.enterFrom, enterTo: styles.item.panel.transition.enterTo, leave: styles.item.panel.transition.leave, leaveFrom: styles.item.panel.transition.leaveFrom, leaveTo: styles.item.panel.transition.leaveTo, children: jsx("div", { className: styles.item.panel.container, children: children(options) }) }), trigger && trigger(options)] }));
|
|
2480
6032
|
};
|
|
2481
6033
|
var NotificationOverlay = {
|
|
2482
6034
|
Container: NotificationOverlayContainer,
|
|
@@ -2568,7 +6120,7 @@ var SlideOverOverlay = function (props) {
|
|
|
2568
6120
|
return result;
|
|
2569
6121
|
};
|
|
2570
6122
|
var styles = handleGenerateStyle();
|
|
2571
|
-
return (jsxs(Fragment
|
|
6123
|
+
return (jsxs(Fragment, { children: [jsx(Transition.Root, { show: isOpen, as: Fragment$1, children: jsxs(Dialog, { as: "div", className: styles.container, onClose: setIsOpen, children: [jsx(Transition.Child, { as: Fragment$1, enter: styles.background.transition.enter, enterFrom: styles.background.transition.enterFrom, enterTo: styles.background.transition.enterTo, leave: styles.background.transition.leave, leaveFrom: styles.background.transition.leaveFrom, leaveTo: styles.background.transition.leaveTo, children: jsx("div", { className: styles.background.container }) }), jsx("div", { className: styles.layout.container, children: jsx("div", { className: styles.layout.content, children: jsx("div", { className: styles.layout.inner, children: jsx(Transition.Child, { as: Fragment$1, enter: styles.panel.transition.enter, enterFrom: styles.panel.transition.enterFrom, enterTo: styles.panel.transition.enterTo, leave: styles.panel.transition.leave, leaveFrom: styles.panel.transition.leaveFrom, leaveTo: styles.panel.transition.leaveTo, children: jsx(Dialog.Panel, { className: styles.panel.container, children: children(options) }) }) }) }) })] }) }), trigger && trigger(options)] }));
|
|
2572
6124
|
};
|
|
2573
6125
|
|
|
2574
6126
|
var base$6 = {
|
|
@@ -2880,7 +6432,7 @@ var CheckboxInputGroupForm = function (props) {
|
|
|
2880
6432
|
var styles = handleGenerateStyle();
|
|
2881
6433
|
return (jsx(FormikProvider, { value: form, children: jsxs("div", { children: [jsx("legend", { className: styles.sr, children: name }), jsx("div", { className: styles.list, children: jsx(FieldArray, { name: name, render: function (_a) {
|
|
2882
6434
|
var remove = _a.remove, push = _a.push;
|
|
2883
|
-
return (jsx(Fragment
|
|
6435
|
+
return (jsx(Fragment, { children: options === null || options === void 0 ? void 0 : options.map(function (option) { return (jsxs("div", { className: styles.item.container, children: [jsx("div", { className: styles.item.head, children: jsx("input", { id: option.value, name: option.value, "data-cy": "form-".concat(name, "-checkbox-").concat(option.value), "aria-describedby": "".concat(option.value, "-description"), type: "checkbox", checked: values === null || values === void 0 ? void 0 : values.includes(option.value), className: styles.item.input, disabled: isDisabled, onChange: function (value) {
|
|
2884
6436
|
var isChecked = value.currentTarget.checked;
|
|
2885
6437
|
if (isChecked) {
|
|
2886
6438
|
push(option.value);
|
|
@@ -2982,7 +6534,7 @@ var Switch = function (props) {
|
|
|
2982
6534
|
return result;
|
|
2983
6535
|
};
|
|
2984
6536
|
var styles = handleGenerateStyle();
|
|
2985
|
-
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.head, children: [label && (jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsx("div", { className: styles.container, children: jsx("div", { "data-cy": inputDataCy, children: jsxs(Switch$1, { checked: value, disabled: isDisabled, onChange: onChange, className: toClassName(styles.switch.base, value ? styles.switch.checked : styles.switch.unchecked, isDisabled && styles.switch.disabled), children: [jsxs("span", { className: styles.switch.screenreader, children: ["Switch setting for ", name] }), jsx("span", { className: toClassName(styles.toggle.base, value ? styles.toggle.checked : styles.toggle.unchecked), children: iconAccessorChecked && iconAccessorUnchecked && (jsxs(Fragment
|
|
6537
|
+
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.head, children: [label && (jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsx("div", { className: styles.container, children: jsx("div", { "data-cy": inputDataCy, children: jsxs(Switch$1, { checked: value, disabled: isDisabled, onChange: onChange, className: toClassName(styles.switch.base, value ? styles.switch.checked : styles.switch.unchecked, isDisabled && styles.switch.disabled), children: [jsxs("span", { className: styles.switch.screenreader, children: ["Switch setting for ", name] }), jsx("span", { className: toClassName(styles.toggle.base, value ? styles.toggle.checked : styles.toggle.unchecked), children: iconAccessorChecked && iconAccessorUnchecked && (jsxs(Fragment, { children: [jsx("span", { className: toClassName(value ? styles.icon.hidden : styles.icon.shown, styles.icon.base), "aria-hidden": "true", children: jsx(IconElement, { accessor: iconAccessorUnchecked, className: styles.icon.icon }) }), jsx("span", { className: toClassName(value ? styles.icon.shown : styles.icon.hidden, styles.icon.base), "aria-hidden": "true", children: jsx(IconElement, { accessor: iconAccessorChecked, className: styles.icon.icon }) })] })) })] }) }) }), jsxs("div", { className: styles.foot, children: [description && !(error && isTouched) && (jsx("p", { className: styles.description, children: description })), error && isTouched && (jsx("p", { className: styles.error, "data-cy": errorDataCy, children: error }))] })] }));
|
|
2986
6538
|
};
|
|
2987
6539
|
|
|
2988
6540
|
var styles$4 = {
|
|
@@ -4398,7 +7950,7 @@ var Dropzone = forwardRef(function (_ref, ref) {
|
|
|
4398
7950
|
open: open
|
|
4399
7951
|
};
|
|
4400
7952
|
}, [open]);
|
|
4401
|
-
return
|
|
7953
|
+
return React__default.createElement(Fragment$1, null, children(_objectSpread(_objectSpread({}, props), {}, {
|
|
4402
7954
|
open: open
|
|
4403
7955
|
})));
|
|
4404
7956
|
});
|
|
@@ -9829,7 +13381,7 @@ var OpeningsHourInputGroupForm = function (props) {
|
|
|
9829
13381
|
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.head, children: [label && (jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsx("div", { className: styles.body, children: jsx(FormikProvider, { value: form, children: jsx(FieldArray, { name: name, render: function (_a) {
|
|
9830
13382
|
var _b, _c, _d, _e, _f;
|
|
9831
13383
|
var remove = _a.remove, push = _a.push, replace = _a.replace;
|
|
9832
|
-
return (jsxs(Fragment
|
|
13384
|
+
return (jsxs(Fragment, { children: [(_e = (_d = (_c = (_b = form.values) === null || _b === void 0 ? void 0 : _b[name]) === null || _c === void 0 ? void 0 : _c.map(function (value, index) { return ({ index: index, value: value }); })) === null || _d === void 0 ? void 0 : _d.sort(function (a, b) { return (a.value.day < b.value.day ? -1 : 1); })) === null || _e === void 0 ? void 0 : _e.map(function (_a) {
|
|
9833
13385
|
var openingHour = _a.value, index = _a.index;
|
|
9834
13386
|
return (jsx(OpeningHourItem, { id: index, openingHour: openingHour, lang: lang, onCreate: push, onUpdate: function (value) { return replace(index, value); }, onDelete: function (id) {
|
|
9835
13387
|
if (id) {
|
|
@@ -10296,7 +13848,7 @@ var Input = (function (_super) {
|
|
|
10296
13848
|
if (!attributes.tabIndex) {
|
|
10297
13849
|
attributes.tabIndex = 0;
|
|
10298
13850
|
}
|
|
10299
|
-
return (createElement(Fragment, null,
|
|
13851
|
+
return (createElement(Fragment$1, null,
|
|
10300
13852
|
shouldRenderLabel && (createElement("label", { className: "geosuggest__label", htmlFor: this.props.id }, this.props.label)),
|
|
10301
13853
|
createElement("input", __assign({ className: classes, id: "geosuggest__input" + (this.props.id ? "--" + this.props.id : ''), ref: function (i) { return (_this.input = i); }, type: this.props.inputType }, attributes, { value: this.props.value, style: this.props.style, onKeyDown: this.onInputKeyDown, onChange: this.onChange, onKeyPress: this.props.onKeyPress, onFocus: this.props.onFocus, onBlur: this.props.onBlur, role: "combobox", "aria-expanded": !this.props.isSuggestsHidden, "aria-activedescendant": this.props.activeSuggest
|
|
10302
13854
|
? this.props.activeSuggest.placeId
|
|
@@ -10918,7 +14470,7 @@ var AddressInputGroupForm = function (props) {
|
|
|
10918
14470
|
info: value === null || value === void 0 ? void 0 : value.info,
|
|
10919
14471
|
};
|
|
10920
14472
|
onBlur && onBlur(location);
|
|
10921
|
-
}, children: jsx(Fragment
|
|
14473
|
+
}, children: jsx(Fragment, {}) }) }), jsxs("div", { className: styles$1.foot, children: [description && !(error && isTouched) && (jsx("p", { className: styles$1.description, children: description })), error && isTouched && jsx("p", { className: styles$1.error, children: error })] })] }));
|
|
10922
14474
|
};
|
|
10923
14475
|
|
|
10924
14476
|
var base = {
|
|
@@ -11004,5 +14556,5 @@ var styles = {
|
|
|
11004
14556
|
disabled: disabled,
|
|
11005
14557
|
};
|
|
11006
14558
|
|
|
11007
|
-
export { AddressInputGroupForm, BadgeElement$1 as AlertElement, AvatarElement, BadgeElement, BreadcrumbsNavigation, ButtonElement, ButtonGroupElement, CheckboxInputForm as CheckboxInput, ContainerLayout, DateMenuForm, DividerLayout, DropdownElement, FileInputGroupForm, IconElement, InputGroupForm, ListContainerLayout, MediaObjectLayout, ModalOverlay, NotificationOverlay, OpeningsHourInputGroupForm, PagePaginationNavigation, LayoutPanel as PanelLayout, PanelPaginationNavigation, SelectMenuForm, SlideOverOverlay, Switch as SwitchForm, TabNavigation, TableColumnOptionsCustom, TableExcelExportCustom as TableExportCustom, TableList, TableList2, VerticalNavigation, CheckboxInputGroupForm as __DEPRECATED__CheckboxInputGroupForm, createColumnHelper, fromSelectMenuOptionToStringValue, useExcel };
|
|
14559
|
+
export { AddressInputGroupForm, BadgeElement$1 as AlertElement, AvatarElement, BadgeElement, BreadcrumbsNavigation, ButtonElement, ButtonGroupElement, CheckboxInputForm as CheckboxInput, ContainerLayout, DateMenuForm, DividerLayout, DropdownElement, FileInputGroupForm, IconElement, InputGroupForm, ListContainerLayout, MediaObjectLayout, ModalOverlay, NotificationOverlay, OpeningsHourInputGroupForm, PagePaginationNavigation, LayoutPanel as PanelLayout, PanelPaginationNavigation, SelectMenuForm, SlideOverOverlay, Switch as SwitchForm, TabNavigation, TableColumnOptionsCustom, TableExcelExportCustom as TableExportCustom, TableList, TableList2, TooltipElement as Tooltiplement, VerticalNavigation, CheckboxInputGroupForm as __DEPRECATED__CheckboxInputGroupForm, createColumnHelper, fromSelectMenuOptionToStringValue, useExcel };
|
|
11008
14560
|
//# sourceMappingURL=index.esm.js.map
|