@indico-data/design-system 2.31.0 → 2.32.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/lib/index.d.ts +2 -1
- package/lib/index.esm.js +2977 -2600
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +2371 -1994
- package/lib/index.js.map +1 -1
- package/lib/src/components/floatUI/FloatUI.d.ts +1 -1
- package/lib/src/components/floatUI/types.d.ts +1 -0
- package/package.json +2 -1
- package/src/components/floatUI/FloatUI.stories.tsx +12 -0
- package/src/components/floatUI/FloatUI.tsx +22 -18
- package/src/components/floatUI/types.ts +1 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FloatUIProps } from './types';
|
|
2
|
-
export declare function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, floatingOptions, }: FloatUIProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal, floatingOptions, }: FloatUIProps): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indico-data/design-system",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.32.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@babel/preset-env": "^7.23.9",
|
|
72
72
|
"@babel/preset-react": "^7.23.3",
|
|
73
73
|
"@babel/preset-typescript": "^7.23.3",
|
|
74
|
+
"@floating-ui/react": "^0.26.22",
|
|
74
75
|
"@mdx-js/loader": "^3.0.1",
|
|
75
76
|
"@react-aria/button": "^3.9.3",
|
|
76
77
|
"@react-aria/focus": "^3.16.2",
|
|
@@ -51,6 +51,18 @@ const meta: Meta<typeof FloatUI> = {
|
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
|
+
isPortal: {
|
|
55
|
+
control: 'boolean',
|
|
56
|
+
defaultValue: false,
|
|
57
|
+
description:
|
|
58
|
+
'Controls whether the FloatUI content is rendered as a portal (i.e. rendered outside the app root and into the body)',
|
|
59
|
+
table: {
|
|
60
|
+
category: 'Props',
|
|
61
|
+
type: {
|
|
62
|
+
summary: 'boolean',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
54
66
|
setIsOpen: {
|
|
55
67
|
control: false,
|
|
56
68
|
description: 'Function to toggle the visibility of the FloatUI (for controlled mode).',
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
shift,
|
|
8
8
|
Placement,
|
|
9
9
|
} from '@floating-ui/react-dom';
|
|
10
|
+
import { FloatingPortal } from '@floating-ui/react';
|
|
10
11
|
import { useClickOutside } from '@/hooks/useClickOutside';
|
|
11
12
|
import { FloatUIProps } from './types';
|
|
12
13
|
|
|
@@ -20,6 +21,7 @@ export function FloatUI({
|
|
|
20
21
|
ariaLabel,
|
|
21
22
|
isOpen: controlledIsOpen,
|
|
22
23
|
setIsOpen: controlledSetIsOpen,
|
|
24
|
+
isPortal = false,
|
|
23
25
|
floatingOptions = defaultOptions,
|
|
24
26
|
}: FloatUIProps) {
|
|
25
27
|
const [internalIsOpen, setInternalIsOpen] = useState(false);
|
|
@@ -54,29 +56,31 @@ export function FloatUI({
|
|
|
54
56
|
|
|
55
57
|
useClickOutside(floatUIContentRef, () => setIsOpen(false));
|
|
56
58
|
|
|
59
|
+
const tooltipContent = (
|
|
60
|
+
<div
|
|
61
|
+
// Used to position the floating element relative to the reference element
|
|
62
|
+
ref={refs.setFloating}
|
|
63
|
+
style={{
|
|
64
|
+
position: strategy,
|
|
65
|
+
top: y ?? 0,
|
|
66
|
+
left: x ?? 0,
|
|
67
|
+
}}
|
|
68
|
+
role="dialog"
|
|
69
|
+
aria-label={ariaLabel}
|
|
70
|
+
className="floatui-container"
|
|
71
|
+
>
|
|
72
|
+
<div ref={floatUIContentRef} className="floatui-content">
|
|
73
|
+
{content}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
|
|
57
78
|
return (
|
|
58
79
|
<>
|
|
59
80
|
<div ref={referenceElementRef} onClick={() => setIsOpen(!isOpen)}>
|
|
60
81
|
{trigger}
|
|
61
82
|
</div>
|
|
62
|
-
{isOpen && (
|
|
63
|
-
<div
|
|
64
|
-
// Used to position the floating element relative to the reference element
|
|
65
|
-
ref={refs.setFloating}
|
|
66
|
-
style={{
|
|
67
|
-
position: strategy,
|
|
68
|
-
top: y ?? 0,
|
|
69
|
-
left: x ?? 0,
|
|
70
|
-
}}
|
|
71
|
-
role="dialog"
|
|
72
|
-
aria-label={ariaLabel}
|
|
73
|
-
className="floatui-container"
|
|
74
|
-
>
|
|
75
|
-
<div ref={floatUIContentRef} className="floatui-content">
|
|
76
|
-
{content}
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
)}
|
|
83
|
+
{isOpen && (isPortal ? <FloatingPortal>{tooltipContent}</FloatingPortal> : tooltipContent)}
|
|
80
84
|
</>
|
|
81
85
|
);
|
|
82
86
|
}
|