@conveyorhq/arrow-ds 1.123.0 → 1.125.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/package.json +1 -1
- package/public/components/Floating/FloatingTooltip.d.ts +4 -2
- package/public/components/Floating/FloatingTooltip.js +9 -2
- package/public/components/Popover/Popover.d.ts +1 -0
- package/public/components/Popover/Popover.js +2 -2
- package/src/components/Floating/FloatingTooltip.tsx +14 -2
- package/src/components/Popover/Popover.tsx +8 -0
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React, { HTMLProps, PropsWithChildren } from "react";
|
|
2
|
-
import type { Placement } from "@floating-ui/react";
|
|
2
|
+
import type { Placement, Strategy } from "@floating-ui/react";
|
|
3
3
|
import { PortalRootElementType } from "../Portal";
|
|
4
4
|
interface FloatingTooltipOptions {
|
|
5
5
|
initialOpen?: boolean;
|
|
6
6
|
placement?: Placement;
|
|
7
7
|
open?: boolean;
|
|
8
8
|
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
strategy?: Strategy;
|
|
10
|
+
disableShiftMiddleware?: boolean;
|
|
9
11
|
}
|
|
10
|
-
export declare function useFloatingTooltip({ initialOpen, placement, open: controlledOpen, onOpenChange: setControlledOpen, }?: FloatingTooltipOptions): any;
|
|
12
|
+
export declare function useFloatingTooltip({ initialOpen, placement, open: controlledOpen, onOpenChange: setControlledOpen, strategy, disableShiftMiddleware, }?: FloatingTooltipOptions): any;
|
|
11
13
|
export declare const useFloatingTooltipState: any;
|
|
12
14
|
export declare function FloatingTooltipRoot({ children, ...options }: PropsWithChildren<FloatingTooltipOptions>): JSX.Element;
|
|
13
15
|
export declare const FloatingTooltipTrigger: React.ForwardRefExoticComponent<Pick<React.HTMLProps<HTMLElement> & {
|
|
@@ -31,17 +31,24 @@ const tokens_1 = require("../../style-dictionary/dist/tokens");
|
|
|
31
31
|
const bem_1 = require("../../utilities/bem");
|
|
32
32
|
const Box_1 = require("../Box");
|
|
33
33
|
const cn = bem_1.bemHOF("FloatingTooltip");
|
|
34
|
-
function useFloatingTooltip({ initialOpen = false, placement = "top", open: controlledOpen, onOpenChange: setControlledOpen, } = {}) {
|
|
34
|
+
function useFloatingTooltip({ initialOpen = false, placement = "top", open: controlledOpen, onOpenChange: setControlledOpen, strategy, disableShiftMiddleware, } = {}) {
|
|
35
35
|
const [uncontrolledOpen, setUncontrolledOpen] = react_1.useState(initialOpen);
|
|
36
36
|
const arrowRef = react_1.useRef(null);
|
|
37
37
|
const open = controlledOpen !== null && controlledOpen !== void 0 ? controlledOpen : uncontrolledOpen;
|
|
38
38
|
const setOpen = setControlledOpen !== null && setControlledOpen !== void 0 ? setControlledOpen : setUncontrolledOpen;
|
|
39
|
+
const shiftMiddleware = disableShiftMiddleware ? [] : [react_2.shift()];
|
|
39
40
|
const data = react_2.useFloating({
|
|
40
41
|
placement,
|
|
41
42
|
open,
|
|
42
43
|
onOpenChange: setOpen,
|
|
43
44
|
whileElementsMounted: react_2.autoUpdate,
|
|
44
|
-
middleware: [
|
|
45
|
+
middleware: [
|
|
46
|
+
react_2.offset(8),
|
|
47
|
+
react_2.flip(),
|
|
48
|
+
...shiftMiddleware,
|
|
49
|
+
react_2.arrow({ element: arrowRef }),
|
|
50
|
+
],
|
|
51
|
+
strategy,
|
|
45
52
|
});
|
|
46
53
|
const { context } = data;
|
|
47
54
|
const hover = react_2.useHover(context, {
|
|
@@ -13,6 +13,7 @@ export interface PopoverTooltipSharedProps extends BoxProps {
|
|
|
13
13
|
interface PopoverDefaultProps extends PopoverTooltipSharedProps, InlineSharedProps {
|
|
14
14
|
inline?: false;
|
|
15
15
|
showArrow?: boolean;
|
|
16
|
+
strategy?: "absolute" | "fixed";
|
|
16
17
|
}
|
|
17
18
|
interface PopoverInlineProps extends InlineSharedProps, BoxProps {
|
|
18
19
|
inline: true;
|
|
@@ -51,7 +51,7 @@ const Popover = ({ removePadding = false, ...props }) => {
|
|
|
51
51
|
return (react_1.default.createElement(InlinePopover, Object.assign({ "data-placement": placement, className: className, style: styleProp, removePadding: removePadding }, rest), children));
|
|
52
52
|
}
|
|
53
53
|
if (!props.inline) {
|
|
54
|
-
const { referenceElement, popperModifiers, isVisible, placement, className, style: styleProp, children, inline, showArrow = false, ...rest } = props;
|
|
54
|
+
const { referenceElement, popperModifiers, isVisible, placement, className, style: styleProp, children, inline, showArrow = false, strategy = "absolute", ...rest } = props;
|
|
55
55
|
const offset = [0, 8];
|
|
56
56
|
const defaultPopperModifiers = [
|
|
57
57
|
{
|
|
@@ -63,7 +63,7 @@ const Popover = ({ removePadding = false, ...props }) => {
|
|
|
63
63
|
];
|
|
64
64
|
const propModifiers = popperModifiers || [];
|
|
65
65
|
return (react_1.default.createElement(react_popper_2_1.Manager, null,
|
|
66
|
-
isVisible && (react_1.default.createElement(react_popper_2_1.Popper, { placement: placement, modifiers: [...defaultPopperModifiers, ...propModifiers] }, ({ ref, style, placement: popperPlacement, arrowProps, update, }) => (react_1.default.createElement(InlinePopover, Object.assign({ ref: ref, style: {
|
|
66
|
+
isVisible && (react_1.default.createElement(react_popper_2_1.Popper, { placement: placement, modifiers: [...defaultPopperModifiers, ...propModifiers], strategy: strategy }, ({ ref, style, placement: popperPlacement, arrowProps, update, }) => (react_1.default.createElement(InlinePopover, Object.assign({ ref: ref, style: {
|
|
67
67
|
...style,
|
|
68
68
|
...styleProp,
|
|
69
69
|
}, className: className, "data-placement": popperPlacement, hasPortal: true, removePadding: removePadding }, rest),
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
useInteractions,
|
|
26
26
|
FloatingPortal,
|
|
27
27
|
} from "@floating-ui/react";
|
|
28
|
-
import type { Placement } from "@floating-ui/react";
|
|
28
|
+
import type { Placement, Strategy } from "@floating-ui/react";
|
|
29
29
|
import classNames from "classnames";
|
|
30
30
|
import { tokens } from "../../style-dictionary/dist/tokens";
|
|
31
31
|
import { bemHOF } from "../../utilities/bem";
|
|
@@ -39,6 +39,8 @@ interface FloatingTooltipOptions {
|
|
|
39
39
|
placement?: Placement;
|
|
40
40
|
open?: boolean;
|
|
41
41
|
onOpenChange?: (open: boolean) => void;
|
|
42
|
+
strategy?: Strategy;
|
|
43
|
+
disableShiftMiddleware?: boolean;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export function useFloatingTooltip({
|
|
@@ -46,18 +48,28 @@ export function useFloatingTooltip({
|
|
|
46
48
|
placement = "top",
|
|
47
49
|
open: controlledOpen,
|
|
48
50
|
onOpenChange: setControlledOpen,
|
|
51
|
+
strategy,
|
|
52
|
+
disableShiftMiddleware,
|
|
49
53
|
}: FloatingTooltipOptions = {}) {
|
|
50
54
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
51
55
|
const arrowRef = useRef<HTMLDivElement>(null);
|
|
52
56
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
53
57
|
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
54
58
|
|
|
59
|
+
const shiftMiddleware = disableShiftMiddleware ? [] : [shift()];
|
|
60
|
+
|
|
55
61
|
const data = useFloating({
|
|
56
62
|
placement,
|
|
57
63
|
open,
|
|
58
64
|
onOpenChange: setOpen,
|
|
59
65
|
whileElementsMounted: autoUpdate,
|
|
60
|
-
middleware: [
|
|
66
|
+
middleware: [
|
|
67
|
+
offset(8),
|
|
68
|
+
flip(),
|
|
69
|
+
...shiftMiddleware,
|
|
70
|
+
arrow({ element: arrowRef }),
|
|
71
|
+
],
|
|
72
|
+
strategy,
|
|
61
73
|
});
|
|
62
74
|
|
|
63
75
|
const { context } = data;
|
|
@@ -60,6 +60,12 @@ interface PopoverDefaultProps
|
|
|
60
60
|
* Toggles the popover arrow on and off
|
|
61
61
|
*/
|
|
62
62
|
showArrow?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Describes the positioning strategy to use. By default, it is absolute,
|
|
65
|
+
* which in the simplest cases does not require repositioning of the popper.
|
|
66
|
+
* If your reference element is in a fixed container, use the fixed strategy.
|
|
67
|
+
*/
|
|
68
|
+
strategy?: "absolute" | "fixed";
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
interface PopoverInlineProps extends InlineSharedProps, BoxProps {
|
|
@@ -159,6 +165,7 @@ export const Popover = ({ removePadding = false, ...props }: PopoverProps) => {
|
|
|
159
165
|
children,
|
|
160
166
|
inline,
|
|
161
167
|
showArrow = false,
|
|
168
|
+
strategy = "absolute",
|
|
162
169
|
...rest
|
|
163
170
|
} = props;
|
|
164
171
|
|
|
@@ -181,6 +188,7 @@ export const Popover = ({ removePadding = false, ...props }: PopoverProps) => {
|
|
|
181
188
|
<Popper
|
|
182
189
|
placement={placement}
|
|
183
190
|
modifiers={[...defaultPopperModifiers, ...propModifiers]}
|
|
191
|
+
strategy={strategy}
|
|
184
192
|
>
|
|
185
193
|
{({
|
|
186
194
|
ref,
|