@jobber/components 6.65.0 → 6.66.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/Modal/index.mjs +1 -1
- package/dist/Popover/PopoverContext.d.ts +7 -1
- package/dist/Popover/index.cjs +1 -1
- package/dist/Popover/index.mjs +1 -1
- package/dist/Popover/usePopover.d.ts +8 -5
- package/dist/Popover-cjs.js +78 -31
- package/dist/Popover-es.js +78 -31
- package/dist/floating-ui.react-cjs.js +291 -0
- package/dist/floating-ui.react-es.js +290 -1
- package/dist/styles.css +8 -29
- package/package.json +2 -2
package/dist/Modal/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { H as Heading } from '../Heading-es.js';
|
|
|
9
9
|
import { B as Button } from '../Button-es.js';
|
|
10
10
|
import { B as ButtonDismiss } from '../ButtonDismiss-es.js';
|
|
11
11
|
import { n as noop } from '../noop-es.js';
|
|
12
|
-
import { a as useFloatingNodeId, b as useFloating,
|
|
12
|
+
import { a as useFloatingNodeId, b as useFloating, k as useClick, e as useDismiss, l as useRole, f as useInteractions, u as useFloatingParentNodeId, F as FloatingTree, g as FloatingNode, h as FloatingPortal, m as FloatingOverlay, n as FloatingFocusManager } from '../floating-ui.react-es.js';
|
|
13
13
|
import { b as identity } from '../identity-es.js';
|
|
14
14
|
import { A as AtlantisPortalContent } from '../AtlantisPortalContent-es.js';
|
|
15
15
|
import '../Typography-es.js';
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { Placement } from "@floating-ui/react";
|
|
1
2
|
import React, { CSSProperties } from "react";
|
|
2
3
|
import { PopoverProviderProps } from "./Popover.types";
|
|
3
4
|
interface PopoverContextProps {
|
|
4
5
|
setArrowElement: (element: HTMLElement | null) => void;
|
|
5
6
|
popperStyles: {
|
|
6
|
-
|
|
7
|
+
popper: CSSProperties;
|
|
8
|
+
arrow?: {
|
|
9
|
+
x?: number;
|
|
10
|
+
y?: number;
|
|
11
|
+
};
|
|
7
12
|
};
|
|
13
|
+
placement?: Placement;
|
|
8
14
|
}
|
|
9
15
|
export declare function usePopoverContext(): PopoverContextProps;
|
|
10
16
|
export declare function PopoverProvider({ children, preferredPlacement, attachTo, open, UNSAFE_className, UNSAFE_style, }: PopoverProviderProps): React.JSX.Element | null;
|
package/dist/Popover/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ require('../tslib.es6-cjs.js');
|
|
|
5
5
|
require('react');
|
|
6
6
|
require('classnames');
|
|
7
7
|
require('react-dom');
|
|
8
|
-
require('react-
|
|
8
|
+
require('../floating-ui.react-cjs.js');
|
|
9
9
|
require('../useRefocusOnActivator-cjs.js');
|
|
10
10
|
require('../AtlantisPortalContent-cjs.js');
|
|
11
11
|
require('../AtlantisThemeContext-cjs.js');
|
package/dist/Popover/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import '../tslib.es6-es.js';
|
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'classnames';
|
|
5
5
|
import 'react-dom';
|
|
6
|
-
import 'react-
|
|
6
|
+
import '../floating-ui.react-es.js';
|
|
7
7
|
import '../useRefocusOnActivator-es.js';
|
|
8
8
|
import '../AtlantisPortalContent-es.js';
|
|
9
9
|
import '../AtlantisThemeContext-es.js';
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { PopoverProps } from "./Popover.types";
|
|
2
2
|
export declare const usePopover: ({ preferredPlacement, attachTo, open, }: Pick<PopoverProps, "preferredPlacement" | "attachTo" | "open">) => {
|
|
3
|
-
setPopperElement:
|
|
3
|
+
setPopperElement: ((node: HTMLElement | null) => void) & ((node: HTMLElement | null) => void);
|
|
4
4
|
setArrowElement: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null | undefined>>;
|
|
5
5
|
popperStyles: {
|
|
6
|
-
|
|
6
|
+
popper: import("react").CSSProperties;
|
|
7
|
+
arrow: (Partial<import("@floating-ui/core").Coords> & {
|
|
8
|
+
centerOffset: number;
|
|
9
|
+
alignmentOffset?: number;
|
|
10
|
+
}) | undefined;
|
|
7
11
|
};
|
|
12
|
+
placement: import("@floating-ui/utils").Placement;
|
|
8
13
|
attributes: {
|
|
9
|
-
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
} | undefined;
|
|
14
|
+
popper: {};
|
|
12
15
|
};
|
|
13
16
|
};
|
package/dist/Popover-cjs.js
CHANGED
|
@@ -4,40 +4,66 @@ var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
6
|
var ReactDOM = require('react-dom');
|
|
7
|
-
var
|
|
7
|
+
var floatingUi_react = require('./floating-ui.react-cjs.js');
|
|
8
8
|
var useRefocusOnActivator = require('./useRefocusOnActivator-cjs.js');
|
|
9
9
|
var AtlantisPortalContent = require('./AtlantisPortalContent-cjs.js');
|
|
10
10
|
var ButtonDismiss = require('./ButtonDismiss-cjs.js');
|
|
11
11
|
|
|
12
|
+
const POPOVER_OFFSET = 10;
|
|
13
|
+
const POPOVER_SHIFT_PADDING = 8;
|
|
14
|
+
const POPOVER_ARROW_PADDING = 6;
|
|
12
15
|
const usePopover = ({ preferredPlacement, attachTo, open, }) => {
|
|
13
|
-
const [popperElement, setPopperElement] = React.useState();
|
|
14
16
|
const [arrowElement, setArrowElement] = React.useState();
|
|
15
17
|
const modifiers = React.useMemo(() => {
|
|
18
|
+
const baseModifiers = [
|
|
19
|
+
floatingUi_react.offset(POPOVER_OFFSET),
|
|
20
|
+
floatingUi_react.shift({
|
|
21
|
+
mainAxis: true,
|
|
22
|
+
crossAxis: false,
|
|
23
|
+
padding: POPOVER_SHIFT_PADDING,
|
|
24
|
+
}),
|
|
25
|
+
];
|
|
26
|
+
const placementMiddleware = preferredPlacement === "auto"
|
|
27
|
+
? floatingUi_react.autoPlacement({
|
|
28
|
+
allowedPlacements: ["top", "bottom", "left", "right"],
|
|
29
|
+
})
|
|
30
|
+
: floatingUi_react.flip({
|
|
31
|
+
fallbackPlacements: ["top", "bottom", "left", "right"],
|
|
32
|
+
});
|
|
16
33
|
return [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
options: {
|
|
24
|
-
offset: [0, 10],
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "flip",
|
|
29
|
-
options: {
|
|
30
|
-
fallbackPlacements: ["auto"],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
34
|
+
...baseModifiers,
|
|
35
|
+
placementMiddleware,
|
|
36
|
+
floatingUi_react.arrow({
|
|
37
|
+
element: arrowElement || null,
|
|
38
|
+
padding: POPOVER_ARROW_PADDING,
|
|
39
|
+
}),
|
|
33
40
|
];
|
|
34
|
-
}, [arrowElement]);
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
}, [arrowElement, preferredPlacement]);
|
|
42
|
+
const referenceElement = isHTMLElement(attachTo)
|
|
43
|
+
? attachTo
|
|
44
|
+
: attachTo.current;
|
|
45
|
+
const { refs, floatingStyles, middlewareData, placement } = floatingUi_react.useFloating({
|
|
46
|
+
placement: preferredPlacement === "auto" ? undefined : preferredPlacement,
|
|
47
|
+
strategy: "absolute",
|
|
48
|
+
middleware: modifiers,
|
|
49
|
+
elements: {
|
|
50
|
+
reference: referenceElement || null,
|
|
51
|
+
},
|
|
52
|
+
// Only use this option when the floating element is conditionally rendered
|
|
53
|
+
// (which we are), not hidden with css. https://floating-ui.com/docs/autoUpdate
|
|
54
|
+
whileElementsMounted: floatingUi_react.autoUpdate,
|
|
38
55
|
});
|
|
39
56
|
useRefocusOnActivator.useRefocusOnActivator_2(open);
|
|
40
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
setPopperElement: refs.setFloating,
|
|
59
|
+
setArrowElement,
|
|
60
|
+
popperStyles: {
|
|
61
|
+
popper: floatingStyles,
|
|
62
|
+
arrow: middlewareData.arrow,
|
|
63
|
+
},
|
|
64
|
+
placement,
|
|
65
|
+
attributes: { popper: {} },
|
|
66
|
+
};
|
|
41
67
|
};
|
|
42
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
69
|
function isHTMLElement(el) {
|
|
@@ -55,7 +81,7 @@ const usePopoverStyles = () => {
|
|
|
55
81
|
};
|
|
56
82
|
|
|
57
83
|
const PopoverContext = React.createContext({
|
|
58
|
-
popperStyles: {},
|
|
84
|
+
popperStyles: { popper: {} },
|
|
59
85
|
setArrowElement: () => {
|
|
60
86
|
// noop
|
|
61
87
|
},
|
|
@@ -63,8 +89,8 @@ const PopoverContext = React.createContext({
|
|
|
63
89
|
function usePopoverContext() {
|
|
64
90
|
return React.useContext(PopoverContext);
|
|
65
91
|
}
|
|
66
|
-
function PopoverProvider({ children, preferredPlacement, attachTo, open, UNSAFE_className, UNSAFE_style, }) {
|
|
67
|
-
const { setPopperElement, setArrowElement, popperStyles,
|
|
92
|
+
function PopoverProvider({ children, preferredPlacement = "auto", attachTo, open, UNSAFE_className, UNSAFE_style, }) {
|
|
93
|
+
const { setPopperElement, setArrowElement, popperStyles, placement } = usePopover({
|
|
68
94
|
preferredPlacement,
|
|
69
95
|
attachTo,
|
|
70
96
|
open,
|
|
@@ -74,15 +100,16 @@ function PopoverProvider({ children, preferredPlacement, attachTo, open, UNSAFE_
|
|
|
74
100
|
return (React.createElement(PopoverContext.Provider, { value: {
|
|
75
101
|
setArrowElement,
|
|
76
102
|
popperStyles,
|
|
103
|
+
placement,
|
|
77
104
|
} },
|
|
78
|
-
React.createElement(PopoverWrapper, {
|
|
105
|
+
React.createElement(PopoverWrapper, { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, setPopperElement: setPopperElement, placement: placement }, children)));
|
|
79
106
|
}
|
|
80
|
-
function PopoverWrapper({ children,
|
|
107
|
+
function PopoverWrapper({ children, setPopperElement, UNSAFE_className, UNSAFE_style, placement, }) {
|
|
81
108
|
const popoverStyles = usePopoverStyles();
|
|
82
109
|
const { popperStyles } = usePopoverContext();
|
|
83
110
|
const classes = classnames(popoverStyles.container, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.container);
|
|
84
111
|
const content = (React.createElement(AtlantisPortalContent.AtlantisPortalContent, null,
|
|
85
|
-
React.createElement("div",
|
|
112
|
+
React.createElement("div", { role: "dialog", "data-elevation": "elevated", ref: setPopperElement, style: Object.assign(Object.assign({}, popperStyles.popper), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.container), className: classes, "data-popover-placement": placement, "data-testid": "ATL-Popover-Container" }, children)));
|
|
86
113
|
return ReactDOM.createPortal(content, document.body);
|
|
87
114
|
}
|
|
88
115
|
|
|
@@ -94,10 +121,30 @@ function Popover({ onRequestClose, children, attachTo, open, preferredPlacement
|
|
|
94
121
|
}
|
|
95
122
|
Popover.Provider = PopoverProvider;
|
|
96
123
|
Popover.Arrow = function PopoverArrow({ UNSAFE_className, UNSAFE_style, }) {
|
|
97
|
-
|
|
124
|
+
var _a, _b, _c, _d;
|
|
125
|
+
const { setArrowElement, popperStyles, placement } = usePopoverContext();
|
|
98
126
|
const popoverStyles = usePopoverStyles();
|
|
99
127
|
const classes = classnames(popoverStyles.arrow, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.arrow);
|
|
100
|
-
|
|
128
|
+
// the arrow will get positioned opposite to the placement side
|
|
129
|
+
const staticSideMap = {
|
|
130
|
+
top: "bottom",
|
|
131
|
+
right: "left",
|
|
132
|
+
bottom: "top",
|
|
133
|
+
left: "right",
|
|
134
|
+
};
|
|
135
|
+
const staticSide = staticSideMap[placement];
|
|
136
|
+
const arrowStyles = {
|
|
137
|
+
position: "absolute",
|
|
138
|
+
// only left or top will be defined at a time
|
|
139
|
+
left: ((_a = popperStyles.arrow) === null || _a === void 0 ? void 0 : _a.x) != null ? `${(_b = popperStyles.arrow) === null || _b === void 0 ? void 0 : _b.x}px` : "",
|
|
140
|
+
top: ((_c = popperStyles.arrow) === null || _c === void 0 ? void 0 : _c.y) != null ? `${(_d = popperStyles.arrow) === null || _d === void 0 ? void 0 : _d.y}px` : "",
|
|
141
|
+
right: "",
|
|
142
|
+
bottom: "",
|
|
143
|
+
[staticSide]: "var(--popover--position--offset)",
|
|
144
|
+
width: "var(--base-unit)",
|
|
145
|
+
height: "var(--base-unit)",
|
|
146
|
+
};
|
|
147
|
+
return (React.createElement("div", { ref: setArrowElement, className: classes, style: Object.assign(Object.assign({}, arrowStyles), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.arrow), "data-testid": "ATL-Popover-Arrow" }));
|
|
101
148
|
};
|
|
102
149
|
Popover.DismissButton = function PopoverDismissButton(props) {
|
|
103
150
|
var _a;
|
package/dist/Popover-es.js
CHANGED
|
@@ -2,40 +2,66 @@ import { _ as __rest } from './tslib.es6-es.js';
|
|
|
2
2
|
import React__default, { useState, useMemo, createContext, useContext } from 'react';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import ReactDOM__default from 'react-dom';
|
|
5
|
-
import {
|
|
5
|
+
import { i as arrow, b as useFloating, d as autoUpdate, o as offset, s as shift, c as autoPlacement, j as flip } from './floating-ui.react-es.js';
|
|
6
6
|
import { u as useRefocusOnActivator_2 } from './useRefocusOnActivator-es.js';
|
|
7
7
|
import { A as AtlantisPortalContent } from './AtlantisPortalContent-es.js';
|
|
8
8
|
import { B as ButtonDismiss } from './ButtonDismiss-es.js';
|
|
9
9
|
|
|
10
|
+
const POPOVER_OFFSET = 10;
|
|
11
|
+
const POPOVER_SHIFT_PADDING = 8;
|
|
12
|
+
const POPOVER_ARROW_PADDING = 6;
|
|
10
13
|
const usePopover = ({ preferredPlacement, attachTo, open, }) => {
|
|
11
|
-
const [popperElement, setPopperElement] = useState();
|
|
12
14
|
const [arrowElement, setArrowElement] = useState();
|
|
13
15
|
const modifiers = useMemo(() => {
|
|
16
|
+
const baseModifiers = [
|
|
17
|
+
offset(POPOVER_OFFSET),
|
|
18
|
+
shift({
|
|
19
|
+
mainAxis: true,
|
|
20
|
+
crossAxis: false,
|
|
21
|
+
padding: POPOVER_SHIFT_PADDING,
|
|
22
|
+
}),
|
|
23
|
+
];
|
|
24
|
+
const placementMiddleware = preferredPlacement === "auto"
|
|
25
|
+
? autoPlacement({
|
|
26
|
+
allowedPlacements: ["top", "bottom", "left", "right"],
|
|
27
|
+
})
|
|
28
|
+
: flip({
|
|
29
|
+
fallbackPlacements: ["top", "bottom", "left", "right"],
|
|
30
|
+
});
|
|
14
31
|
return [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
options: {
|
|
22
|
-
offset: [0, 10],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "flip",
|
|
27
|
-
options: {
|
|
28
|
-
fallbackPlacements: ["auto"],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
32
|
+
...baseModifiers,
|
|
33
|
+
placementMiddleware,
|
|
34
|
+
arrow({
|
|
35
|
+
element: arrowElement || null,
|
|
36
|
+
padding: POPOVER_ARROW_PADDING,
|
|
37
|
+
}),
|
|
31
38
|
];
|
|
32
|
-
}, [arrowElement]);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
}, [arrowElement, preferredPlacement]);
|
|
40
|
+
const referenceElement = isHTMLElement(attachTo)
|
|
41
|
+
? attachTo
|
|
42
|
+
: attachTo.current;
|
|
43
|
+
const { refs, floatingStyles, middlewareData, placement } = useFloating({
|
|
44
|
+
placement: preferredPlacement === "auto" ? undefined : preferredPlacement,
|
|
45
|
+
strategy: "absolute",
|
|
46
|
+
middleware: modifiers,
|
|
47
|
+
elements: {
|
|
48
|
+
reference: referenceElement || null,
|
|
49
|
+
},
|
|
50
|
+
// Only use this option when the floating element is conditionally rendered
|
|
51
|
+
// (which we are), not hidden with css. https://floating-ui.com/docs/autoUpdate
|
|
52
|
+
whileElementsMounted: autoUpdate,
|
|
36
53
|
});
|
|
37
54
|
useRefocusOnActivator_2(open);
|
|
38
|
-
return {
|
|
55
|
+
return {
|
|
56
|
+
setPopperElement: refs.setFloating,
|
|
57
|
+
setArrowElement,
|
|
58
|
+
popperStyles: {
|
|
59
|
+
popper: floatingStyles,
|
|
60
|
+
arrow: middlewareData.arrow,
|
|
61
|
+
},
|
|
62
|
+
placement,
|
|
63
|
+
attributes: { popper: {} },
|
|
64
|
+
};
|
|
39
65
|
};
|
|
40
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
67
|
function isHTMLElement(el) {
|
|
@@ -53,7 +79,7 @@ const usePopoverStyles = () => {
|
|
|
53
79
|
};
|
|
54
80
|
|
|
55
81
|
const PopoverContext = createContext({
|
|
56
|
-
popperStyles: {},
|
|
82
|
+
popperStyles: { popper: {} },
|
|
57
83
|
setArrowElement: () => {
|
|
58
84
|
// noop
|
|
59
85
|
},
|
|
@@ -61,8 +87,8 @@ const PopoverContext = createContext({
|
|
|
61
87
|
function usePopoverContext() {
|
|
62
88
|
return useContext(PopoverContext);
|
|
63
89
|
}
|
|
64
|
-
function PopoverProvider({ children, preferredPlacement, attachTo, open, UNSAFE_className, UNSAFE_style, }) {
|
|
65
|
-
const { setPopperElement, setArrowElement, popperStyles,
|
|
90
|
+
function PopoverProvider({ children, preferredPlacement = "auto", attachTo, open, UNSAFE_className, UNSAFE_style, }) {
|
|
91
|
+
const { setPopperElement, setArrowElement, popperStyles, placement } = usePopover({
|
|
66
92
|
preferredPlacement,
|
|
67
93
|
attachTo,
|
|
68
94
|
open,
|
|
@@ -72,15 +98,16 @@ function PopoverProvider({ children, preferredPlacement, attachTo, open, UNSAFE_
|
|
|
72
98
|
return (React__default.createElement(PopoverContext.Provider, { value: {
|
|
73
99
|
setArrowElement,
|
|
74
100
|
popperStyles,
|
|
101
|
+
placement,
|
|
75
102
|
} },
|
|
76
|
-
React__default.createElement(PopoverWrapper, {
|
|
103
|
+
React__default.createElement(PopoverWrapper, { UNSAFE_className: UNSAFE_className, UNSAFE_style: UNSAFE_style, setPopperElement: setPopperElement, placement: placement }, children)));
|
|
77
104
|
}
|
|
78
|
-
function PopoverWrapper({ children,
|
|
105
|
+
function PopoverWrapper({ children, setPopperElement, UNSAFE_className, UNSAFE_style, placement, }) {
|
|
79
106
|
const popoverStyles = usePopoverStyles();
|
|
80
107
|
const { popperStyles } = usePopoverContext();
|
|
81
108
|
const classes = classnames(popoverStyles.container, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.container);
|
|
82
109
|
const content = (React__default.createElement(AtlantisPortalContent, null,
|
|
83
|
-
React__default.createElement("div",
|
|
110
|
+
React__default.createElement("div", { role: "dialog", "data-elevation": "elevated", ref: setPopperElement, style: Object.assign(Object.assign({}, popperStyles.popper), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.container), className: classes, "data-popover-placement": placement, "data-testid": "ATL-Popover-Container" }, children)));
|
|
84
111
|
return ReactDOM__default.createPortal(content, document.body);
|
|
85
112
|
}
|
|
86
113
|
|
|
@@ -92,10 +119,30 @@ function Popover({ onRequestClose, children, attachTo, open, preferredPlacement
|
|
|
92
119
|
}
|
|
93
120
|
Popover.Provider = PopoverProvider;
|
|
94
121
|
Popover.Arrow = function PopoverArrow({ UNSAFE_className, UNSAFE_style, }) {
|
|
95
|
-
|
|
122
|
+
var _a, _b, _c, _d;
|
|
123
|
+
const { setArrowElement, popperStyles, placement } = usePopoverContext();
|
|
96
124
|
const popoverStyles = usePopoverStyles();
|
|
97
125
|
const classes = classnames(popoverStyles.arrow, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.arrow);
|
|
98
|
-
|
|
126
|
+
// the arrow will get positioned opposite to the placement side
|
|
127
|
+
const staticSideMap = {
|
|
128
|
+
top: "bottom",
|
|
129
|
+
right: "left",
|
|
130
|
+
bottom: "top",
|
|
131
|
+
left: "right",
|
|
132
|
+
};
|
|
133
|
+
const staticSide = staticSideMap[placement];
|
|
134
|
+
const arrowStyles = {
|
|
135
|
+
position: "absolute",
|
|
136
|
+
// only left or top will be defined at a time
|
|
137
|
+
left: ((_a = popperStyles.arrow) === null || _a === void 0 ? void 0 : _a.x) != null ? `${(_b = popperStyles.arrow) === null || _b === void 0 ? void 0 : _b.x}px` : "",
|
|
138
|
+
top: ((_c = popperStyles.arrow) === null || _c === void 0 ? void 0 : _c.y) != null ? `${(_d = popperStyles.arrow) === null || _d === void 0 ? void 0 : _d.y}px` : "",
|
|
139
|
+
right: "",
|
|
140
|
+
bottom: "",
|
|
141
|
+
[staticSide]: "var(--popover--position--offset)",
|
|
142
|
+
width: "var(--base-unit)",
|
|
143
|
+
height: "var(--base-unit)",
|
|
144
|
+
};
|
|
145
|
+
return (React__default.createElement("div", { ref: setArrowElement, className: classes, style: Object.assign(Object.assign({}, arrowStyles), UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.arrow), "data-testid": "ATL-Popover-Arrow" }));
|
|
99
146
|
};
|
|
100
147
|
Popover.DismissButton = function PopoverDismissButton(props) {
|
|
101
148
|
var _a;
|
|
@@ -2186,9 +2186,41 @@ function getAlignmentSides(placement, rects, rtl) {
|
|
|
2186
2186
|
}
|
|
2187
2187
|
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
2188
2188
|
}
|
|
2189
|
+
function getExpandedPlacements(placement) {
|
|
2190
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
2191
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
2192
|
+
}
|
|
2189
2193
|
function getOppositeAlignmentPlacement(placement) {
|
|
2190
2194
|
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
2191
2195
|
}
|
|
2196
|
+
function getSideList(side, isStart, rtl) {
|
|
2197
|
+
const lr = ['left', 'right'];
|
|
2198
|
+
const rl = ['right', 'left'];
|
|
2199
|
+
const tb = ['top', 'bottom'];
|
|
2200
|
+
const bt = ['bottom', 'top'];
|
|
2201
|
+
switch (side) {
|
|
2202
|
+
case 'top':
|
|
2203
|
+
case 'bottom':
|
|
2204
|
+
if (rtl) return isStart ? rl : lr;
|
|
2205
|
+
return isStart ? lr : rl;
|
|
2206
|
+
case 'left':
|
|
2207
|
+
case 'right':
|
|
2208
|
+
return isStart ? tb : bt;
|
|
2209
|
+
default:
|
|
2210
|
+
return [];
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
2214
|
+
const alignment = getAlignment(placement);
|
|
2215
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
2216
|
+
if (alignment) {
|
|
2217
|
+
list = list.map(side => side + "-" + alignment);
|
|
2218
|
+
if (flipAlignment) {
|
|
2219
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
return list;
|
|
2223
|
+
}
|
|
2192
2224
|
function getOppositePlacement(placement) {
|
|
2193
2225
|
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
2194
2226
|
}
|
|
@@ -2430,6 +2462,88 @@ async function detectOverflow(state, options) {
|
|
|
2430
2462
|
};
|
|
2431
2463
|
}
|
|
2432
2464
|
|
|
2465
|
+
/**
|
|
2466
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2467
|
+
* appears centered to the reference element.
|
|
2468
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2469
|
+
*/
|
|
2470
|
+
const arrow$2 = options => ({
|
|
2471
|
+
name: 'arrow',
|
|
2472
|
+
options,
|
|
2473
|
+
async fn(state) {
|
|
2474
|
+
const {
|
|
2475
|
+
x,
|
|
2476
|
+
y,
|
|
2477
|
+
placement,
|
|
2478
|
+
rects,
|
|
2479
|
+
platform,
|
|
2480
|
+
elements,
|
|
2481
|
+
middlewareData
|
|
2482
|
+
} = state;
|
|
2483
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
2484
|
+
const {
|
|
2485
|
+
element,
|
|
2486
|
+
padding = 0
|
|
2487
|
+
} = evaluate(options, state) || {};
|
|
2488
|
+
if (element == null) {
|
|
2489
|
+
return {};
|
|
2490
|
+
}
|
|
2491
|
+
const paddingObject = getPaddingObject(padding);
|
|
2492
|
+
const coords = {
|
|
2493
|
+
x,
|
|
2494
|
+
y
|
|
2495
|
+
};
|
|
2496
|
+
const axis = getAlignmentAxis(placement);
|
|
2497
|
+
const length = getAxisLength(axis);
|
|
2498
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
2499
|
+
const isYAxis = axis === 'y';
|
|
2500
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
2501
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
2502
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
2503
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
2504
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
2505
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
2506
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
2507
|
+
|
|
2508
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
2509
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
2510
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
2511
|
+
}
|
|
2512
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
2513
|
+
|
|
2514
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
2515
|
+
// centered, modify the padding so that it is centered.
|
|
2516
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
2517
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
2518
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
2519
|
+
|
|
2520
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
2521
|
+
// point is outside the floating element's bounds.
|
|
2522
|
+
const min$1 = minPadding;
|
|
2523
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
2524
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
2525
|
+
const offset = clamp(min$1, center, max);
|
|
2526
|
+
|
|
2527
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
2528
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
2529
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
2530
|
+
// a single reset is performed when this is true.
|
|
2531
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
2532
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
2533
|
+
return {
|
|
2534
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
2535
|
+
data: {
|
|
2536
|
+
[axis]: offset,
|
|
2537
|
+
centerOffset: center - offset - alignmentOffset,
|
|
2538
|
+
...(shouldAddOffset && {
|
|
2539
|
+
alignmentOffset
|
|
2540
|
+
})
|
|
2541
|
+
},
|
|
2542
|
+
reset: shouldAddOffset
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
});
|
|
2546
|
+
|
|
2433
2547
|
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
2434
2548
|
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
2435
2549
|
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
@@ -2533,6 +2647,121 @@ const autoPlacement$1 = function (options) {
|
|
|
2533
2647
|
};
|
|
2534
2648
|
};
|
|
2535
2649
|
|
|
2650
|
+
/**
|
|
2651
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2652
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2653
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2654
|
+
* @see https://floating-ui.com/docs/flip
|
|
2655
|
+
*/
|
|
2656
|
+
const flip$1 = function (options) {
|
|
2657
|
+
if (options === void 0) {
|
|
2658
|
+
options = {};
|
|
2659
|
+
}
|
|
2660
|
+
return {
|
|
2661
|
+
name: 'flip',
|
|
2662
|
+
options,
|
|
2663
|
+
async fn(state) {
|
|
2664
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
2665
|
+
const {
|
|
2666
|
+
placement,
|
|
2667
|
+
middlewareData,
|
|
2668
|
+
rects,
|
|
2669
|
+
initialPlacement,
|
|
2670
|
+
platform,
|
|
2671
|
+
elements
|
|
2672
|
+
} = state;
|
|
2673
|
+
const {
|
|
2674
|
+
mainAxis: checkMainAxis = true,
|
|
2675
|
+
crossAxis: checkCrossAxis = true,
|
|
2676
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
2677
|
+
fallbackStrategy = 'bestFit',
|
|
2678
|
+
fallbackAxisSideDirection = 'none',
|
|
2679
|
+
flipAlignment = true,
|
|
2680
|
+
...detectOverflowOptions
|
|
2681
|
+
} = evaluate(options, state);
|
|
2682
|
+
|
|
2683
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
2684
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
2685
|
+
// work.
|
|
2686
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
2687
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
2688
|
+
return {};
|
|
2689
|
+
}
|
|
2690
|
+
const side = getSide(placement);
|
|
2691
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
2692
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
2693
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
2694
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
2695
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
2696
|
+
}
|
|
2697
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
2698
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
2699
|
+
const overflows = [];
|
|
2700
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
2701
|
+
if (checkMainAxis) {
|
|
2702
|
+
overflows.push(overflow[side]);
|
|
2703
|
+
}
|
|
2704
|
+
if (checkCrossAxis) {
|
|
2705
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
2706
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
2707
|
+
}
|
|
2708
|
+
overflowsData = [...overflowsData, {
|
|
2709
|
+
placement,
|
|
2710
|
+
overflows
|
|
2711
|
+
}];
|
|
2712
|
+
|
|
2713
|
+
// One or more sides is overflowing.
|
|
2714
|
+
if (!overflows.every(side => side <= 0)) {
|
|
2715
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
2716
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
2717
|
+
const nextPlacement = placements[nextIndex];
|
|
2718
|
+
if (nextPlacement) {
|
|
2719
|
+
// Try next placement and re-run the lifecycle.
|
|
2720
|
+
return {
|
|
2721
|
+
data: {
|
|
2722
|
+
index: nextIndex,
|
|
2723
|
+
overflows: overflowsData
|
|
2724
|
+
},
|
|
2725
|
+
reset: {
|
|
2726
|
+
placement: nextPlacement
|
|
2727
|
+
}
|
|
2728
|
+
};
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
2732
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
2733
|
+
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;
|
|
2734
|
+
|
|
2735
|
+
// Otherwise fallback.
|
|
2736
|
+
if (!resetPlacement) {
|
|
2737
|
+
switch (fallbackStrategy) {
|
|
2738
|
+
case 'bestFit':
|
|
2739
|
+
{
|
|
2740
|
+
var _overflowsData$map$so;
|
|
2741
|
+
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];
|
|
2742
|
+
if (placement) {
|
|
2743
|
+
resetPlacement = placement;
|
|
2744
|
+
}
|
|
2745
|
+
break;
|
|
2746
|
+
}
|
|
2747
|
+
case 'initialPlacement':
|
|
2748
|
+
resetPlacement = initialPlacement;
|
|
2749
|
+
break;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
if (placement !== resetPlacement) {
|
|
2753
|
+
return {
|
|
2754
|
+
reset: {
|
|
2755
|
+
placement: resetPlacement
|
|
2756
|
+
}
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
return {};
|
|
2761
|
+
}
|
|
2762
|
+
};
|
|
2763
|
+
};
|
|
2764
|
+
|
|
2536
2765
|
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
2537
2766
|
// Derivable.
|
|
2538
2767
|
async function convertValueToCoords(state, options) {
|
|
@@ -3640,6 +3869,44 @@ function useFloating$1(options) {
|
|
|
3640
3869
|
}), [data, update, refs, elements, floatingStyles]);
|
|
3641
3870
|
}
|
|
3642
3871
|
|
|
3872
|
+
/**
|
|
3873
|
+
* Provides data to position an inner element of the floating element so that it
|
|
3874
|
+
* appears centered to the reference element.
|
|
3875
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
3876
|
+
* @see https://floating-ui.com/docs/arrow
|
|
3877
|
+
*/
|
|
3878
|
+
const arrow$1 = options => {
|
|
3879
|
+
function isRef(value) {
|
|
3880
|
+
return {}.hasOwnProperty.call(value, 'current');
|
|
3881
|
+
}
|
|
3882
|
+
return {
|
|
3883
|
+
name: 'arrow',
|
|
3884
|
+
options,
|
|
3885
|
+
fn(state) {
|
|
3886
|
+
const {
|
|
3887
|
+
element,
|
|
3888
|
+
padding
|
|
3889
|
+
} = typeof options === 'function' ? options(state) : options;
|
|
3890
|
+
if (element && isRef(element)) {
|
|
3891
|
+
if (element.current != null) {
|
|
3892
|
+
return arrow$2({
|
|
3893
|
+
element: element.current,
|
|
3894
|
+
padding
|
|
3895
|
+
}).fn(state);
|
|
3896
|
+
}
|
|
3897
|
+
return {};
|
|
3898
|
+
}
|
|
3899
|
+
if (element) {
|
|
3900
|
+
return arrow$2({
|
|
3901
|
+
element,
|
|
3902
|
+
padding
|
|
3903
|
+
}).fn(state);
|
|
3904
|
+
}
|
|
3905
|
+
return {};
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3908
|
+
};
|
|
3909
|
+
|
|
3643
3910
|
/**
|
|
3644
3911
|
* Modifies the placement by translating the floating element along the
|
|
3645
3912
|
* specified axes.
|
|
@@ -3662,6 +3929,17 @@ const shift = (options, deps) => ({
|
|
|
3662
3929
|
options: [options, deps]
|
|
3663
3930
|
});
|
|
3664
3931
|
|
|
3932
|
+
/**
|
|
3933
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
3934
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
3935
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
3936
|
+
* @see https://floating-ui.com/docs/flip
|
|
3937
|
+
*/
|
|
3938
|
+
const flip = (options, deps) => ({
|
|
3939
|
+
...flip$1(options),
|
|
3940
|
+
options: [options, deps]
|
|
3941
|
+
});
|
|
3942
|
+
|
|
3665
3943
|
/**
|
|
3666
3944
|
* Optimizes the visibility of the floating element by choosing the placement
|
|
3667
3945
|
* that has the most space available automatically, without needing to specify a
|
|
@@ -3673,6 +3951,17 @@ const autoPlacement = (options, deps) => ({
|
|
|
3673
3951
|
options: [options, deps]
|
|
3674
3952
|
});
|
|
3675
3953
|
|
|
3954
|
+
/**
|
|
3955
|
+
* Provides data to position an inner element of the floating element so that it
|
|
3956
|
+
* appears centered to the reference element.
|
|
3957
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
3958
|
+
* @see https://floating-ui.com/docs/arrow
|
|
3959
|
+
*/
|
|
3960
|
+
const arrow = (options, deps) => ({
|
|
3961
|
+
...arrow$1(options),
|
|
3962
|
+
options: [options, deps]
|
|
3963
|
+
});
|
|
3964
|
+
|
|
3676
3965
|
// https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
|
|
3677
3966
|
const SafeReact = {
|
|
3678
3967
|
...React__namespace
|
|
@@ -5597,8 +5886,10 @@ exports.FloatingNode = FloatingNode;
|
|
|
5597
5886
|
exports.FloatingOverlay = FloatingOverlay;
|
|
5598
5887
|
exports.FloatingPortal = FloatingPortal;
|
|
5599
5888
|
exports.FloatingTree = FloatingTree;
|
|
5889
|
+
exports.arrow = arrow;
|
|
5600
5890
|
exports.autoPlacement = autoPlacement;
|
|
5601
5891
|
exports.autoUpdate = autoUpdate;
|
|
5892
|
+
exports.flip = flip;
|
|
5602
5893
|
exports.offset = offset;
|
|
5603
5894
|
exports.shift = shift;
|
|
5604
5895
|
exports.useClick = useClick;
|
|
@@ -2165,9 +2165,41 @@ function getAlignmentSides(placement, rects, rtl) {
|
|
|
2165
2165
|
}
|
|
2166
2166
|
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
2167
2167
|
}
|
|
2168
|
+
function getExpandedPlacements(placement) {
|
|
2169
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
2170
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
2171
|
+
}
|
|
2168
2172
|
function getOppositeAlignmentPlacement(placement) {
|
|
2169
2173
|
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
2170
2174
|
}
|
|
2175
|
+
function getSideList(side, isStart, rtl) {
|
|
2176
|
+
const lr = ['left', 'right'];
|
|
2177
|
+
const rl = ['right', 'left'];
|
|
2178
|
+
const tb = ['top', 'bottom'];
|
|
2179
|
+
const bt = ['bottom', 'top'];
|
|
2180
|
+
switch (side) {
|
|
2181
|
+
case 'top':
|
|
2182
|
+
case 'bottom':
|
|
2183
|
+
if (rtl) return isStart ? rl : lr;
|
|
2184
|
+
return isStart ? lr : rl;
|
|
2185
|
+
case 'left':
|
|
2186
|
+
case 'right':
|
|
2187
|
+
return isStart ? tb : bt;
|
|
2188
|
+
default:
|
|
2189
|
+
return [];
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
2193
|
+
const alignment = getAlignment(placement);
|
|
2194
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
2195
|
+
if (alignment) {
|
|
2196
|
+
list = list.map(side => side + "-" + alignment);
|
|
2197
|
+
if (flipAlignment) {
|
|
2198
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
return list;
|
|
2202
|
+
}
|
|
2171
2203
|
function getOppositePlacement(placement) {
|
|
2172
2204
|
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
2173
2205
|
}
|
|
@@ -2409,6 +2441,88 @@ async function detectOverflow(state, options) {
|
|
|
2409
2441
|
};
|
|
2410
2442
|
}
|
|
2411
2443
|
|
|
2444
|
+
/**
|
|
2445
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2446
|
+
* appears centered to the reference element.
|
|
2447
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2448
|
+
*/
|
|
2449
|
+
const arrow$2 = options => ({
|
|
2450
|
+
name: 'arrow',
|
|
2451
|
+
options,
|
|
2452
|
+
async fn(state) {
|
|
2453
|
+
const {
|
|
2454
|
+
x,
|
|
2455
|
+
y,
|
|
2456
|
+
placement,
|
|
2457
|
+
rects,
|
|
2458
|
+
platform,
|
|
2459
|
+
elements,
|
|
2460
|
+
middlewareData
|
|
2461
|
+
} = state;
|
|
2462
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
2463
|
+
const {
|
|
2464
|
+
element,
|
|
2465
|
+
padding = 0
|
|
2466
|
+
} = evaluate(options, state) || {};
|
|
2467
|
+
if (element == null) {
|
|
2468
|
+
return {};
|
|
2469
|
+
}
|
|
2470
|
+
const paddingObject = getPaddingObject(padding);
|
|
2471
|
+
const coords = {
|
|
2472
|
+
x,
|
|
2473
|
+
y
|
|
2474
|
+
};
|
|
2475
|
+
const axis = getAlignmentAxis(placement);
|
|
2476
|
+
const length = getAxisLength(axis);
|
|
2477
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
2478
|
+
const isYAxis = axis === 'y';
|
|
2479
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
2480
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
2481
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
2482
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
2483
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
2484
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
2485
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
2486
|
+
|
|
2487
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
2488
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
2489
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
2490
|
+
}
|
|
2491
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
2492
|
+
|
|
2493
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
2494
|
+
// centered, modify the padding so that it is centered.
|
|
2495
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
2496
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
2497
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
2498
|
+
|
|
2499
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
2500
|
+
// point is outside the floating element's bounds.
|
|
2501
|
+
const min$1 = minPadding;
|
|
2502
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
2503
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
2504
|
+
const offset = clamp(min$1, center, max);
|
|
2505
|
+
|
|
2506
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
2507
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
2508
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
2509
|
+
// a single reset is performed when this is true.
|
|
2510
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
2511
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
2512
|
+
return {
|
|
2513
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
2514
|
+
data: {
|
|
2515
|
+
[axis]: offset,
|
|
2516
|
+
centerOffset: center - offset - alignmentOffset,
|
|
2517
|
+
...(shouldAddOffset && {
|
|
2518
|
+
alignmentOffset
|
|
2519
|
+
})
|
|
2520
|
+
},
|
|
2521
|
+
reset: shouldAddOffset
|
|
2522
|
+
};
|
|
2523
|
+
}
|
|
2524
|
+
});
|
|
2525
|
+
|
|
2412
2526
|
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
2413
2527
|
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
2414
2528
|
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
@@ -2512,6 +2626,121 @@ const autoPlacement$1 = function (options) {
|
|
|
2512
2626
|
};
|
|
2513
2627
|
};
|
|
2514
2628
|
|
|
2629
|
+
/**
|
|
2630
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2631
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2632
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2633
|
+
* @see https://floating-ui.com/docs/flip
|
|
2634
|
+
*/
|
|
2635
|
+
const flip$1 = function (options) {
|
|
2636
|
+
if (options === void 0) {
|
|
2637
|
+
options = {};
|
|
2638
|
+
}
|
|
2639
|
+
return {
|
|
2640
|
+
name: 'flip',
|
|
2641
|
+
options,
|
|
2642
|
+
async fn(state) {
|
|
2643
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
2644
|
+
const {
|
|
2645
|
+
placement,
|
|
2646
|
+
middlewareData,
|
|
2647
|
+
rects,
|
|
2648
|
+
initialPlacement,
|
|
2649
|
+
platform,
|
|
2650
|
+
elements
|
|
2651
|
+
} = state;
|
|
2652
|
+
const {
|
|
2653
|
+
mainAxis: checkMainAxis = true,
|
|
2654
|
+
crossAxis: checkCrossAxis = true,
|
|
2655
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
2656
|
+
fallbackStrategy = 'bestFit',
|
|
2657
|
+
fallbackAxisSideDirection = 'none',
|
|
2658
|
+
flipAlignment = true,
|
|
2659
|
+
...detectOverflowOptions
|
|
2660
|
+
} = evaluate(options, state);
|
|
2661
|
+
|
|
2662
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
2663
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
2664
|
+
// work.
|
|
2665
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
2666
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
2667
|
+
return {};
|
|
2668
|
+
}
|
|
2669
|
+
const side = getSide(placement);
|
|
2670
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
2671
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
2672
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
2673
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
2674
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
2675
|
+
}
|
|
2676
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
2677
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
2678
|
+
const overflows = [];
|
|
2679
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
2680
|
+
if (checkMainAxis) {
|
|
2681
|
+
overflows.push(overflow[side]);
|
|
2682
|
+
}
|
|
2683
|
+
if (checkCrossAxis) {
|
|
2684
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
2685
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
2686
|
+
}
|
|
2687
|
+
overflowsData = [...overflowsData, {
|
|
2688
|
+
placement,
|
|
2689
|
+
overflows
|
|
2690
|
+
}];
|
|
2691
|
+
|
|
2692
|
+
// One or more sides is overflowing.
|
|
2693
|
+
if (!overflows.every(side => side <= 0)) {
|
|
2694
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
2695
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
2696
|
+
const nextPlacement = placements[nextIndex];
|
|
2697
|
+
if (nextPlacement) {
|
|
2698
|
+
// Try next placement and re-run the lifecycle.
|
|
2699
|
+
return {
|
|
2700
|
+
data: {
|
|
2701
|
+
index: nextIndex,
|
|
2702
|
+
overflows: overflowsData
|
|
2703
|
+
},
|
|
2704
|
+
reset: {
|
|
2705
|
+
placement: nextPlacement
|
|
2706
|
+
}
|
|
2707
|
+
};
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
2711
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
2712
|
+
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;
|
|
2713
|
+
|
|
2714
|
+
// Otherwise fallback.
|
|
2715
|
+
if (!resetPlacement) {
|
|
2716
|
+
switch (fallbackStrategy) {
|
|
2717
|
+
case 'bestFit':
|
|
2718
|
+
{
|
|
2719
|
+
var _overflowsData$map$so;
|
|
2720
|
+
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];
|
|
2721
|
+
if (placement) {
|
|
2722
|
+
resetPlacement = placement;
|
|
2723
|
+
}
|
|
2724
|
+
break;
|
|
2725
|
+
}
|
|
2726
|
+
case 'initialPlacement':
|
|
2727
|
+
resetPlacement = initialPlacement;
|
|
2728
|
+
break;
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
if (placement !== resetPlacement) {
|
|
2732
|
+
return {
|
|
2733
|
+
reset: {
|
|
2734
|
+
placement: resetPlacement
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
return {};
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2515
2744
|
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
2516
2745
|
// Derivable.
|
|
2517
2746
|
async function convertValueToCoords(state, options) {
|
|
@@ -3619,6 +3848,44 @@ function useFloating$1(options) {
|
|
|
3619
3848
|
}), [data, update, refs, elements, floatingStyles]);
|
|
3620
3849
|
}
|
|
3621
3850
|
|
|
3851
|
+
/**
|
|
3852
|
+
* Provides data to position an inner element of the floating element so that it
|
|
3853
|
+
* appears centered to the reference element.
|
|
3854
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
3855
|
+
* @see https://floating-ui.com/docs/arrow
|
|
3856
|
+
*/
|
|
3857
|
+
const arrow$1 = options => {
|
|
3858
|
+
function isRef(value) {
|
|
3859
|
+
return {}.hasOwnProperty.call(value, 'current');
|
|
3860
|
+
}
|
|
3861
|
+
return {
|
|
3862
|
+
name: 'arrow',
|
|
3863
|
+
options,
|
|
3864
|
+
fn(state) {
|
|
3865
|
+
const {
|
|
3866
|
+
element,
|
|
3867
|
+
padding
|
|
3868
|
+
} = typeof options === 'function' ? options(state) : options;
|
|
3869
|
+
if (element && isRef(element)) {
|
|
3870
|
+
if (element.current != null) {
|
|
3871
|
+
return arrow$2({
|
|
3872
|
+
element: element.current,
|
|
3873
|
+
padding
|
|
3874
|
+
}).fn(state);
|
|
3875
|
+
}
|
|
3876
|
+
return {};
|
|
3877
|
+
}
|
|
3878
|
+
if (element) {
|
|
3879
|
+
return arrow$2({
|
|
3880
|
+
element,
|
|
3881
|
+
padding
|
|
3882
|
+
}).fn(state);
|
|
3883
|
+
}
|
|
3884
|
+
return {};
|
|
3885
|
+
}
|
|
3886
|
+
};
|
|
3887
|
+
};
|
|
3888
|
+
|
|
3622
3889
|
/**
|
|
3623
3890
|
* Modifies the placement by translating the floating element along the
|
|
3624
3891
|
* specified axes.
|
|
@@ -3641,6 +3908,17 @@ const shift = (options, deps) => ({
|
|
|
3641
3908
|
options: [options, deps]
|
|
3642
3909
|
});
|
|
3643
3910
|
|
|
3911
|
+
/**
|
|
3912
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
3913
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
3914
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
3915
|
+
* @see https://floating-ui.com/docs/flip
|
|
3916
|
+
*/
|
|
3917
|
+
const flip = (options, deps) => ({
|
|
3918
|
+
...flip$1(options),
|
|
3919
|
+
options: [options, deps]
|
|
3920
|
+
});
|
|
3921
|
+
|
|
3644
3922
|
/**
|
|
3645
3923
|
* Optimizes the visibility of the floating element by choosing the placement
|
|
3646
3924
|
* that has the most space available automatically, without needing to specify a
|
|
@@ -3652,6 +3930,17 @@ const autoPlacement = (options, deps) => ({
|
|
|
3652
3930
|
options: [options, deps]
|
|
3653
3931
|
});
|
|
3654
3932
|
|
|
3933
|
+
/**
|
|
3934
|
+
* Provides data to position an inner element of the floating element so that it
|
|
3935
|
+
* appears centered to the reference element.
|
|
3936
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
3937
|
+
* @see https://floating-ui.com/docs/arrow
|
|
3938
|
+
*/
|
|
3939
|
+
const arrow = (options, deps) => ({
|
|
3940
|
+
...arrow$1(options),
|
|
3941
|
+
options: [options, deps]
|
|
3942
|
+
});
|
|
3943
|
+
|
|
3655
3944
|
// https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
|
|
3656
3945
|
const SafeReact = {
|
|
3657
3946
|
...React
|
|
@@ -5571,4 +5860,4 @@ function useRole(context, props) {
|
|
|
5571
5860
|
} : {}, [enabled, reference, floating, item]);
|
|
5572
5861
|
}
|
|
5573
5862
|
|
|
5574
|
-
export { FloatingTree as F, useFloatingNodeId as a, useFloating as b, autoPlacement as c, autoUpdate as d, useDismiss as e, useInteractions as f, FloatingNode as g, FloatingPortal as h,
|
|
5863
|
+
export { FloatingTree as F, useFloatingNodeId as a, useFloating as b, autoPlacement as c, autoUpdate as d, useDismiss as e, useInteractions as f, FloatingNode as g, FloatingPortal as h, arrow as i, flip as j, useClick as k, useRole as l, FloatingOverlay as m, FloatingFocusManager as n, offset as o, shift as s, useFloatingParentNodeId as u };
|
package/dist/styles.css
CHANGED
|
@@ -9099,58 +9099,37 @@ input.oOrjwubmsVA- {
|
|
|
9099
9099
|
}
|
|
9100
9100
|
|
|
9101
9101
|
.uClo-5-xhAc- {
|
|
9102
|
-
visibility: hidden;
|
|
9103
|
-
}
|
|
9104
|
-
|
|
9105
|
-
.uClo-5-xhAc-,
|
|
9106
|
-
.uClo-5-xhAc-::before {
|
|
9107
9102
|
position: absolute;
|
|
9108
9103
|
width: 16px;
|
|
9109
9104
|
width: var(--base-unit);
|
|
9110
9105
|
height: 16px;
|
|
9111
9106
|
height: var(--base-unit);
|
|
9112
|
-
background: inherit;
|
|
9113
|
-
}
|
|
9114
|
-
|
|
9115
|
-
.uClo-5-xhAc-::before {
|
|
9116
|
-
content: "";
|
|
9117
|
-
visibility: visible;
|
|
9118
9107
|
border: 1px solid hsl(200, 13%, 87%);
|
|
9119
9108
|
border: var(--border-base) solid var(--color-border);
|
|
9120
|
-
|
|
9121
|
-
transform: rotate(45deg);
|
|
9109
|
+
background: inherit;
|
|
9122
9110
|
-webkit-transform-origin: center;
|
|
9123
9111
|
transform-origin: center;
|
|
9124
9112
|
clip-path: polygon(-4px -4px, 15.3px 0, 0 15.3px);
|
|
9125
9113
|
}
|
|
9126
9114
|
|
|
9127
|
-
|
|
9128
|
-
bottom: var(--popover--position--offset);
|
|
9129
|
-
}
|
|
9115
|
+
/* Arrow rotation based on placement */
|
|
9130
9116
|
|
|
9131
|
-
.rY8OtuArIi0-[data-
|
|
9117
|
+
.rY8OtuArIi0-[data-popover-placement^="top"] > .uClo-5-xhAc- {
|
|
9132
9118
|
-webkit-transform: rotate(-135deg);
|
|
9133
9119
|
transform: rotate(-135deg);
|
|
9134
9120
|
}
|
|
9135
9121
|
|
|
9136
|
-
.rY8OtuArIi0-[data-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
.rY8OtuArIi0-[data-popper-placement^="left"] > .uClo-5-xhAc- {
|
|
9141
|
-
right: var(--popover--position--offset);
|
|
9122
|
+
.rY8OtuArIi0-[data-popover-placement^="bottom"] > .uClo-5-xhAc- {
|
|
9123
|
+
-webkit-transform: rotate(45deg);
|
|
9124
|
+
transform: rotate(45deg);
|
|
9142
9125
|
}
|
|
9143
9126
|
|
|
9144
|
-
.rY8OtuArIi0-[data-
|
|
9127
|
+
.rY8OtuArIi0-[data-popover-placement^="left"] > .uClo-5-xhAc- {
|
|
9145
9128
|
-webkit-transform: rotate(135deg);
|
|
9146
9129
|
transform: rotate(135deg);
|
|
9147
9130
|
}
|
|
9148
9131
|
|
|
9149
|
-
.rY8OtuArIi0-[data-
|
|
9150
|
-
left: var(--popover--position--offset);
|
|
9151
|
-
}
|
|
9152
|
-
|
|
9153
|
-
.rY8OtuArIi0-[data-popper-placement^="right"] > .uClo-5-xhAc-::before {
|
|
9132
|
+
.rY8OtuArIi0-[data-popover-placement^="right"] > .uClo-5-xhAc- {
|
|
9154
9133
|
-webkit-transform: rotate(-45deg);
|
|
9155
9134
|
transform: rotate(-45deg);
|
|
9156
9135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.66.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -542,5 +542,5 @@
|
|
|
542
542
|
"> 1%",
|
|
543
543
|
"IE 10"
|
|
544
544
|
],
|
|
545
|
-
"gitHead": "
|
|
545
|
+
"gitHead": "c4b9bf8f3dab846ea63b3f772f993a5232de10af"
|
|
546
546
|
}
|