@wonderflow/react-components 2.14.7 → 2.15.1
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/card/card.d.ts +1 -1
- package/card/card.js +2 -2
- package/disclosure/disclosure.js +2 -1
- package/disclosure/disclosure.module.css +1 -1
- package/dropdown/dropdown-item.d.ts +1 -0
- package/dropdown/dropdown-item.js +9 -6
- package/dropdown/dropdown-item.module.css +2 -2
- package/dropdown/dropdown.d.ts +2 -2
- package/dropdown/dropdown.js +34 -52
- package/dropdown/dropdown.module.css +1 -6
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +3 -2
- package/tab/tab.module.css +0 -2
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/themes.css +6 -3
- package/tooltip/index.d.ts +2 -0
- package/tooltip/index.js +1 -0
- package/tooltip/tooltip.d.ts +10 -0
- package/tooltip/tooltip.js +58 -0
- package/tooltip/tooltip.module.css +47 -0
package/card/card.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import type * as Polymorphic from '@radix-ui/react-polymorphic';
|
|
3
3
|
import { StackProps } from '../stack';
|
|
4
4
|
import { TokensTypes } from '@wonderflow/tokens/platforms/web/types';
|
|
5
|
-
export declare type CardProps = PropsWithClass & Pick<StackProps, 'wrap' | 'columnGap' | 'verticalAlign' | 'horizontalAlign'> & {
|
|
5
|
+
export declare type CardProps = PropsWithClass & Pick<StackProps, 'wrap' | 'columnGap' | 'rowGap' | 'verticalAlign' | 'horizontalAlign'> & {
|
|
6
6
|
padding?: false | TokensTypes['space'];
|
|
7
7
|
left?: ReactNode;
|
|
8
8
|
right?: ReactNode;
|
package/card/card.js
CHANGED
|
@@ -15,13 +15,13 @@ import { Stack } from '../stack';
|
|
|
15
15
|
import clsx from 'clsx';
|
|
16
16
|
import { Card as CardClass, Left, Content, Right } from './card.module.css';
|
|
17
17
|
export const Card = forwardRef((_a, forwardedRef) => {
|
|
18
|
-
var { as: Wrapper = 'div', children, className, padding = 24, radius = 8, left, right, dimmed, columnGap = 24, verticalAlign = 'start', horizontalAlign = 'space-between', wrap, style } = _a, props = __rest(_a, ["as", "children", "className", "padding", "radius", "left", "right", "dimmed", "columnGap", "verticalAlign", "horizontalAlign", "wrap", "style"]);
|
|
18
|
+
var { as: Wrapper = 'div', children, className, padding = 24, radius = 8, left, right, dimmed, columnGap = 24, rowGap = 24, verticalAlign = 'start', horizontalAlign = 'space-between', wrap, style } = _a, props = __rest(_a, ["as", "children", "className", "padding", "radius", "left", "right", "dimmed", "columnGap", "rowGap", "verticalAlign", "horizontalAlign", "wrap", "style"]);
|
|
19
19
|
const dynamicStyle = {
|
|
20
20
|
'--padding': padding ? tkns.space[padding] : '0',
|
|
21
21
|
'--radius': radius ? tkns.radius[radius] : '0'
|
|
22
22
|
};
|
|
23
23
|
return (React.createElement(Wrapper, Object.assign({ ref: forwardedRef, className: clsx(CardClass, className), style: Object.assign(Object.assign({}, dynamicStyle), style), "data-card-dimmed": dimmed }, props),
|
|
24
|
-
React.createElement(Stack, { direction: "row", fill: false, verticalAlign: verticalAlign, horizontalAlign: horizontalAlign, columnGap: columnGap, wrap: wrap },
|
|
24
|
+
React.createElement(Stack, { direction: "row", fill: false, verticalAlign: verticalAlign, horizontalAlign: horizontalAlign, columnGap: columnGap, rowGap: rowGap, wrap: wrap },
|
|
25
25
|
left && React.createElement("div", { className: Left }, left),
|
|
26
26
|
children && (React.createElement(Stack, { className: Content }, children)),
|
|
27
27
|
right && (React.createElement(Stack, { className: Right }, right)))));
|
package/disclosure/disclosure.js
CHANGED
|
@@ -14,6 +14,7 @@ import clsx from 'clsx';
|
|
|
14
14
|
import { Disclosure as DisclosureClass, Summary, ExpandIcon, Content } from './disclosure.module.css';
|
|
15
15
|
import { Icon } from '../icon';
|
|
16
16
|
import { Text } from '../text';
|
|
17
|
+
import { motion } from 'framer-motion';
|
|
17
18
|
export const Disclosure = forwardRef((_a, forwardedRef) => {
|
|
18
19
|
var { children, open = false, padding = true, className, summary, contentMaxHeight, dimension = 'regular', iconPosition = 'left', expandable = true, style } = _a, props = __rest(_a, ["children", "open", "padding", "className", "summary", "contentMaxHeight", "dimension", "iconPosition", "expandable", "style"]);
|
|
19
20
|
const [isOpen, setIsOpen] = useState(open);
|
|
@@ -39,6 +40,6 @@ export const Disclosure = forwardRef((_a, forwardedRef) => {
|
|
|
39
40
|
React.createElement(Text, { as: "summary", onClick: handleOpen(), className: Summary, fluid: false, "aria-expanded": isOpen, tabIndex: !expandable ? -1 : 0, size: dimension ? sizes[dimension].summary : undefined, weight: "bold", role: "button" },
|
|
40
41
|
summary,
|
|
41
42
|
expandable && (React.createElement(Icon, { className: ExpandIcon, name: "chevron-right", dimension: dimension !== 'big' ? 16 : 24 }))),
|
|
42
|
-
React.createElement(
|
|
43
|
+
React.createElement(motion.div, { className: Content, "data-disclosure-padding": padding, "data-disclosure-height": Boolean(contentMaxHeight), animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } }, children)));
|
|
43
44
|
});
|
|
44
45
|
Disclosure.displayName = 'Disclosure';
|
|
@@ -7,6 +7,7 @@ export declare type DropdownItemProps = PropsWithClass & {
|
|
|
7
7
|
dimension?: 'small' | 'regular';
|
|
8
8
|
onClick?: () => void;
|
|
9
9
|
iconPosition: 'left' | 'right';
|
|
10
|
+
description?: ReactNode;
|
|
10
11
|
};
|
|
11
12
|
declare type PolymorphicDropdownItem = Polymorphic.ForwardRefComponent<'button', DropdownItemProps>;
|
|
12
13
|
export declare const DropdownItem: PolymorphicDropdownItem;
|
|
@@ -9,14 +9,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { useCallback, forwardRef, useRef } from 'react';
|
|
12
|
+
import React, { useCallback, forwardRef, useRef, useMemo } from 'react';
|
|
13
13
|
import { Icon } from '../icon';
|
|
14
14
|
import { Stack } from '../stack';
|
|
15
15
|
import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
|
|
16
16
|
import { DropdownItem as DropdownItemClass, Icon as IconClass } from './dropdown-item.module.css';
|
|
17
|
+
import { Tooltip } from '../tooltip';
|
|
17
18
|
import clsx from 'clsx';
|
|
18
19
|
export const DropdownItem = forwardRef((_a, forwardedRef) => {
|
|
19
|
-
var { className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left' } = _a, props = __rest(_a, ["className", "children", "onClick", "icon", "dimension", "as", "iconPosition"]);
|
|
20
|
+
var { className, children, onClick, icon, dimension = 'regular', as: Wrapper = 'button', iconPosition = 'left', description } = _a, props = __rest(_a, ["className", "children", "onClick", "icon", "dimension", "as", "iconPosition", "description"]);
|
|
20
21
|
const itemRef = useRef(forwardedRef);
|
|
21
22
|
const [tabIndex, focused, handleKeyDown, handleClick] = useRovingTabIndex(itemRef, false);
|
|
22
23
|
const isIconRight = iconPosition === 'right';
|
|
@@ -27,9 +28,11 @@ export const DropdownItem = forwardRef((_a, forwardedRef) => {
|
|
|
27
28
|
onClick();
|
|
28
29
|
}
|
|
29
30
|
}, [handleClick, onClick]);
|
|
30
|
-
|
|
31
|
-
React.createElement(
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const InnerContent = useMemo(() => (React.createElement(Stack, { direction: "row", as: "span", fill: false, horizontalAlign: isIconRight ? 'space-between' : 'start', verticalAlign: "center", columnGap: 8, horizontalPadding: 16, verticalPadding: 8 },
|
|
32
|
+
icon && (React.createElement(Icon, { "data-dropdown-icon-right": isIconRight, className: IconClass, name: icon, dimension: dimension === 'small' ? 14 : 16 })),
|
|
33
|
+
children)), [children, dimension, icon, isIconRight]);
|
|
34
|
+
return (React.createElement(Wrapper, Object.assign({ ref: itemRef, className: clsx(DropdownItemClass, className), onClick: triggerClick, onKeyDown: handleKeyDown, tabIndex: tabIndex, type: Wrapper === 'button' ? 'button' : undefined, "data-dropdown-item-dimension": dimension }, props), description
|
|
35
|
+
? (React.createElement(Tooltip, { show: focused, placement: "right-start", style: { width: '100%' }, trigger: InnerContent }, description))
|
|
36
|
+
: InnerContent));
|
|
34
37
|
});
|
|
35
38
|
DropdownItem.displayName = 'Dropdown.Item';
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
color: var(--dimmed-6);
|
|
7
7
|
line-height: 1.2;
|
|
8
8
|
font-weight: 600;
|
|
9
|
-
outline: none;
|
|
10
9
|
cursor: pointer;
|
|
11
10
|
inline-size: 100%;
|
|
12
11
|
box-sizing: border-box;
|
|
@@ -24,8 +23,9 @@
|
|
|
24
23
|
opacity: 0.6;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
&:is(:hover) {
|
|
26
|
+
&:is(:hover, :focus-visible) {
|
|
28
27
|
color: var(--cta-default);
|
|
28
|
+
outline: none;
|
|
29
29
|
|
|
30
30
|
&::before {
|
|
31
31
|
background-color: var(--dimmed-2);
|
package/dropdown/dropdown.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core
|
|
2
|
+
import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core';
|
|
3
3
|
export declare type DropdownProps = PropsWithClass & {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
trigger: ReactNode;
|
|
@@ -7,7 +7,7 @@ export declare type DropdownProps = PropsWithClass & {
|
|
|
7
7
|
placement?: AutoPlacement | BasePlacement | VariationPlacement;
|
|
8
8
|
};
|
|
9
9
|
export declare const Dropdown: {
|
|
10
|
-
({ className, children, trigger, offset, placement
|
|
10
|
+
({ className, children, trigger, offset, placement }: DropdownProps): JSX.Element;
|
|
11
11
|
Menu: React.ForwardRefExoticComponent<PropsWithClass & {
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
} & React.RefAttributes<HTMLUListElement>>;
|
package/dropdown/dropdown.js
CHANGED
|
@@ -1,73 +1,55 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import clsx from 'clsx';
|
|
13
|
-
import React, { useState,
|
|
14
|
-
import {
|
|
15
|
-
import { Dropdown as DropdownClass,
|
|
2
|
+
import React, { useState, Children, cloneElement, useCallback } from 'react';
|
|
3
|
+
import { useKey } from 'react-use';
|
|
4
|
+
import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
|
|
16
5
|
import { useUIDSeed } from 'react-uid';
|
|
17
6
|
import { useFocusWithin } from '@react-aria/interactions';
|
|
18
7
|
import { DropdownMenu } from './dropdown-menu';
|
|
19
8
|
import { DropdownItem } from './dropdown-item';
|
|
20
|
-
import {
|
|
21
|
-
import { motion
|
|
22
|
-
export const Dropdown = (
|
|
23
|
-
var { className, children, trigger, offset = 8, placement = 'auto-start' } = _a, props = __rest(_a, ["className", "children", "trigger", "offset", "placement"]);
|
|
24
|
-
const DropDownRef = useRef(null);
|
|
25
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
9
|
+
import { Popper, Target, Content } from 'react-nested-popper';
|
|
10
|
+
import { motion } from 'framer-motion';
|
|
11
|
+
export const Dropdown = ({ className, children, trigger, offset = 8, placement = 'auto-start' }) => {
|
|
26
12
|
const seedID = useUIDSeed();
|
|
27
|
-
const [
|
|
28
|
-
const [popUpElement, setPopUpElement] = useState(null);
|
|
29
|
-
const { styles: popUpStyles, attributes: popUpAttributes } = usePopper(triggerRef, popUpElement, {
|
|
30
|
-
placement: placement,
|
|
31
|
-
modifiers: [
|
|
32
|
-
{
|
|
33
|
-
name: 'flip',
|
|
34
|
-
enabled: true,
|
|
35
|
-
options: {
|
|
36
|
-
fallbackPlacements: ['bottom', 'top']
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'offset',
|
|
41
|
-
options: {
|
|
42
|
-
offset: [0, offset]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
});
|
|
13
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
47
14
|
const { focusWithinProps } = useFocusWithin({
|
|
48
15
|
onFocusWithin: () => null,
|
|
49
|
-
onBlurWithin: () => setIsOpen(false),
|
|
16
|
+
onBlurWithin: (e) => e.relatedTarget && setIsOpen(false),
|
|
50
17
|
onFocusWithinChange: () => null
|
|
51
18
|
});
|
|
52
19
|
const handleOpen = useCallback((action) => () => {
|
|
53
20
|
setIsOpen(action);
|
|
54
21
|
}, []);
|
|
55
|
-
useKey('Escape', handleOpen(false));
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
React.createElement("div", { className: Trigger }, Children.map(trigger, (child) => cloneElement(child, {
|
|
59
|
-
onClick: handleOpen(!isOpen),
|
|
22
|
+
useKey('Escape', () => handleOpen(false));
|
|
23
|
+
return (React.createElement(Popper, { show: isOpen, outsideClickType: "all", onOutsideClick: handleOpen(false), onTargetClick: handleOpen(!isOpen), usePortal: false },
|
|
24
|
+
React.createElement(Target, { className: clsx(DropdownClass, className) }, Children.map(trigger, (child) => cloneElement(child, {
|
|
60
25
|
id: seedID('dropdown-trigger'),
|
|
61
|
-
ref: setTriggerRef,
|
|
62
26
|
'aria-haspopup': 'true',
|
|
63
27
|
'aria-controls': seedID('dropdown-menu'),
|
|
64
28
|
'aria-expanded': isOpen
|
|
65
29
|
}))),
|
|
66
|
-
React.createElement(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
30
|
+
React.createElement(Content, { className: PopUp, popperOptions: {
|
|
31
|
+
placement: placement,
|
|
32
|
+
modifiers: [
|
|
33
|
+
{
|
|
34
|
+
name: 'flip',
|
|
35
|
+
enabled: true,
|
|
36
|
+
options: {
|
|
37
|
+
fallbackPlacements: ['bottom', 'top']
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'offset',
|
|
42
|
+
options: {
|
|
43
|
+
offset: [0, offset]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
} },
|
|
48
|
+
React.createElement(motion.div, { animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 } },
|
|
49
|
+
React.createElement("div", Object.assign({}, focusWithinProps), Children.map(children, (child) => cloneElement(child, {
|
|
50
|
+
id: seedID('dropdown-menu'),
|
|
51
|
+
'aria-labelledby': seedID('dropdown-trigger')
|
|
52
|
+
})))))));
|
|
71
53
|
};
|
|
72
54
|
Dropdown.Menu = DropdownMenu;
|
|
73
55
|
Dropdown.Item = DropdownItem;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
3
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.15.1",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"postcss": "8.3.6",
|
|
68
68
|
"react": ">=17.0.2",
|
|
69
69
|
"react-dom": ">=17.0.2",
|
|
70
|
-
"react-popper": "
|
|
70
|
+
"react-nested-popper": "1.0.0",
|
|
71
71
|
"react-roving-tabindex": "3.1.1",
|
|
72
72
|
"react-uid": "2.3.1",
|
|
73
73
|
"react-use": "17.3.1",
|
|
@@ -118,6 +118,7 @@
|
|
|
118
118
|
"ora": "5.4.1",
|
|
119
119
|
"rimraf": "3.0.2",
|
|
120
120
|
"semantic-release": "17.4.7",
|
|
121
|
+
"storybook-addon-themes": "6.1.0",
|
|
121
122
|
"storybook-css-modules-preset": "1.1.1",
|
|
122
123
|
"stylelint": "13.13.1",
|
|
123
124
|
"svgo": "2.5.0",
|
package/tab/tab.module.css
CHANGED
package/themes/dark.css
CHANGED
package/themes/light.css
CHANGED
package/themes.css
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
:root,
|
|
3
3
|
[data-theme='light'] {
|
|
4
|
+
color: var(--global-foreground);
|
|
4
5
|
/**
|
|
5
6
|
* Do not edit directly
|
|
6
|
-
* Generated on
|
|
7
|
+
* Generated on Mon, 20 Sep 2021 13:39:18 GMT
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
|
|
@@ -46,9 +47,10 @@
|
|
|
46
47
|
|
|
47
48
|
@media (prefers-color-scheme: dark) {
|
|
48
49
|
:root:not([data-theme='light']) {
|
|
50
|
+
color: var(--global-foreground);
|
|
49
51
|
/**
|
|
50
52
|
* Do not edit directly
|
|
51
|
-
* Generated on
|
|
53
|
+
* Generated on Mon, 20 Sep 2021 13:39:18 GMT
|
|
52
54
|
*/
|
|
53
55
|
|
|
54
56
|
|
|
@@ -92,9 +94,10 @@
|
|
|
92
94
|
|
|
93
95
|
[data-theme='dark'],
|
|
94
96
|
:root[data-theme='dark'] {
|
|
97
|
+
color: var(--global-foreground);
|
|
95
98
|
/**
|
|
96
99
|
* Do not edit directly
|
|
97
|
-
* Generated on
|
|
100
|
+
* Generated on Mon, 20 Sep 2021 13:39:18 GMT
|
|
98
101
|
*/
|
|
99
102
|
|
|
100
103
|
|
package/tooltip/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tooltip } from './tooltip';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { AutoPlacement, BasePlacement, VariationPlacement } from '@popperjs/core/lib';
|
|
3
|
+
export declare type TooltipProps = PropsWithClass & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
trigger: ReactNode;
|
|
6
|
+
placement?: AutoPlacement | BasePlacement | VariationPlacement;
|
|
7
|
+
show?: boolean;
|
|
8
|
+
delay?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const Tooltip: React.FC<TooltipProps>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React, { Children, cloneElement, useEffect, useState } from 'react';
|
|
3
|
+
import { useUIDSeed } from 'react-uid';
|
|
4
|
+
import { useDebounce } from 'react-use';
|
|
5
|
+
import { useFocusWithin } from '@react-aria/interactions';
|
|
6
|
+
import { Tooltip as TooltipClass, Arrow, Trigger as TriggerClass } from './tooltip.module.css';
|
|
7
|
+
import { Popper, Target, Content } from 'react-nested-popper';
|
|
8
|
+
export const Tooltip = ({ children, className, trigger, placement = 'bottom-start', style, show, delay = 700 }) => {
|
|
9
|
+
const seedID = useUIDSeed();
|
|
10
|
+
const [visible, setVisible] = useState(false);
|
|
11
|
+
const [internalDelay, setInternalDelay] = useState(delay);
|
|
12
|
+
const [debouncedVisible, setDebouncedVisible] = useState(visible);
|
|
13
|
+
const [, cancel] = useDebounce(() => {
|
|
14
|
+
setDebouncedVisible(visible);
|
|
15
|
+
}, internalDelay, [visible]);
|
|
16
|
+
const { focusWithinProps } = useFocusWithin({
|
|
17
|
+
onFocusWithin: () => {
|
|
18
|
+
setInternalDelay(0);
|
|
19
|
+
setVisible(true);
|
|
20
|
+
},
|
|
21
|
+
onBlurWithin: () => {
|
|
22
|
+
setInternalDelay(delay);
|
|
23
|
+
setVisible(false);
|
|
24
|
+
},
|
|
25
|
+
onFocusWithinChange: () => null
|
|
26
|
+
});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
cancel();
|
|
29
|
+
}, [cancel]);
|
|
30
|
+
return (React.createElement(Popper, { show: show || debouncedVisible, onClick: () => null, outsideClickType: "all", shouldCloseOnOutsideClick: () => true },
|
|
31
|
+
React.createElement(Target, Object.assign({ onMouseEnter: () => setVisible(true), onMouseLeave: () => setVisible(false), onClick: () => null, style: Object.assign({}, style), className: TriggerClass }, focusWithinProps), Children.map(trigger, (child) => cloneElement(child, {
|
|
32
|
+
'aria-describedby': seedID('tooltip-content')
|
|
33
|
+
}))),
|
|
34
|
+
React.createElement(Content, { className: clsx(TooltipClass, className), includeArrow: true, innerRef: (el) => {
|
|
35
|
+
if (el) {
|
|
36
|
+
el.dataset.elevation = '2';
|
|
37
|
+
el.dataset.theme = 'dark';
|
|
38
|
+
}
|
|
39
|
+
}, arrowClassName: Arrow, popperOptions: {
|
|
40
|
+
placement: placement,
|
|
41
|
+
modifiers: [
|
|
42
|
+
{
|
|
43
|
+
name: 'flip',
|
|
44
|
+
enabled: true,
|
|
45
|
+
options: {
|
|
46
|
+
fallbackPlacements: ['right-start', 'left-start', 'bottom', 'top']
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'offset',
|
|
51
|
+
options: {
|
|
52
|
+
offset: [0, 16]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
} },
|
|
57
|
+
React.createElement("div", { role: "tooltip", id: seedID('tooltip-content') }, children))));
|
|
58
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.Tooltip {
|
|
2
|
+
position: relative;
|
|
3
|
+
padding: env(--space-8) env(--space-16);
|
|
4
|
+
border-radius: env(--radius-4);
|
|
5
|
+
background-color: hsl(env(--color-primary-80));
|
|
6
|
+
max-inline-size: var(--maxW);
|
|
7
|
+
font-size: env(--font-size-16);
|
|
8
|
+
z-index: 2;
|
|
9
|
+
|
|
10
|
+
&[data-popper-reference-hidden='true'] {
|
|
11
|
+
visibility: hidden;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.Trigger {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.Arrow {
|
|
21
|
+
&::before {
|
|
22
|
+
content: '';
|
|
23
|
+
position: absolute;
|
|
24
|
+
inline-size: 12px;
|
|
25
|
+
block-size: 12px;
|
|
26
|
+
background-color: hsl(env(--color-primary-80));
|
|
27
|
+
visibility: visible;
|
|
28
|
+
transform: rotate(45deg);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@nest .Tooltip[data-popper-reference-hidden='true'] & {
|
|
32
|
+
visibility: hidden;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
@nest .Tooltip[data-popper-placement^='top'] & {
|
|
36
|
+
bottom: -6px;
|
|
37
|
+
}
|
|
38
|
+
@nest .Tooltip[data-popper-placement^='bottom'] & {
|
|
39
|
+
top: -6px;
|
|
40
|
+
}
|
|
41
|
+
@nest .Tooltip[data-popper-placement^='left'] & {
|
|
42
|
+
right: -6px;
|
|
43
|
+
}
|
|
44
|
+
@nest .Tooltip[data-popper-placement^='right'] & {
|
|
45
|
+
left: -6px;
|
|
46
|
+
}
|
|
47
|
+
}
|