@redsift/popovers 8.0.1 → 8.0.3
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.js.map → index.js.map} +1 -1
- package/package.json +3 -2
- package/coverage/clover.xml +0 -738
- package/coverage/coverage-final.json +0 -53
- package/coverage/lcov-report/Tooltip.tsx.html +0 -235
- package/coverage/lcov-report/TooltipContent.tsx.html +0 -235
- package/coverage/lcov-report/TooltipTrigger.tsx.html +0 -241
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/context.ts.html +0 -97
- package/coverage/lcov-report/dialog/Dialog.tsx.html +0 -271
- package/coverage/lcov-report/dialog/context.ts.html +0 -97
- package/coverage/lcov-report/dialog/index.html +0 -191
- package/coverage/lcov-report/dialog/index.ts.html +0 -100
- package/coverage/lcov-report/dialog/types.ts.html +0 -253
- package/coverage/lcov-report/dialog/useDialog.tsx.html +0 -346
- package/coverage/lcov-report/dialog/useDialogContext.tsx.html +0 -121
- package/coverage/lcov-report/dialog-content/DialogContent.tsx.html +0 -487
- package/coverage/lcov-report/dialog-content/index.html +0 -146
- package/coverage/lcov-report/dialog-content/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content/intl/index.html +0 -116
- package/coverage/lcov-report/dialog-content/intl/index.ts.html +0 -106
- package/coverage/lcov-report/dialog-content/styles.ts.html +0 -301
- package/coverage/lcov-report/dialog-content-actions/DialogContentActions.tsx.html +0 -205
- package/coverage/lcov-report/dialog-content-actions/index.html +0 -146
- package/coverage/lcov-report/dialog-content-actions/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-actions/styles.ts.html +0 -139
- package/coverage/lcov-report/dialog-content-body/DialogContentBody.tsx.html +0 -232
- package/coverage/lcov-report/dialog-content-body/index.html +0 -146
- package/coverage/lcov-report/dialog-content-body/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-body/styles.ts.html +0 -259
- package/coverage/lcov-report/dialog-content-header/DialogContentHeader.tsx.html +0 -328
- package/coverage/lcov-report/dialog-content-header/index.html +0 -146
- package/coverage/lcov-report/dialog-content-header/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-header/styles.ts.html +0 -193
- package/coverage/lcov-report/dialog-trigger/DialogTrigger.tsx.html +0 -214
- package/coverage/lcov-report/dialog-trigger/index.html +0 -131
- package/coverage/lcov-report/dialog-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -341
- package/coverage/lcov-report/index.ts.html +0 -97
- package/coverage/lcov-report/popover/Popover.tsx.html +0 -244
- package/coverage/lcov-report/popover/context.ts.html +0 -97
- package/coverage/lcov-report/popover/index.html +0 -191
- package/coverage/lcov-report/popover/index.ts.html +0 -100
- package/coverage/lcov-report/popover/types.ts.html +0 -244
- package/coverage/lcov-report/popover/usePopover.tsx.html +0 -295
- package/coverage/lcov-report/popover/usePopoverContext.tsx.html +0 -121
- package/coverage/lcov-report/popover-content/PopoverContent.tsx.html +0 -268
- package/coverage/lcov-report/popover-content/index.html +0 -146
- package/coverage/lcov-report/popover-content/index.ts.html +0 -91
- package/coverage/lcov-report/popover-content/styles.ts.html +0 -166
- package/coverage/lcov-report/popover-trigger/PopoverTrigger.tsx.html +0 -214
- package/coverage/lcov-report/popover-trigger/index.html +0 -131
- package/coverage/lcov-report/popover-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/styles.ts.html +0 -391
- package/coverage/lcov-report/toast/Toast.tsx.html +0 -451
- package/coverage/lcov-report/toast/index.html +0 -161
- package/coverage/lcov-report/toast/index.ts.html +0 -91
- package/coverage/lcov-report/toast/intl/index.html +0 -116
- package/coverage/lcov-report/toast/intl/index.ts.html +0 -106
- package/coverage/lcov-report/toast/styles.ts.html +0 -214
- package/coverage/lcov-report/toast/types.ts.html +0 -217
- package/coverage/lcov-report/toast-container/ToastContainer.tsx.html +0 -217
- package/coverage/lcov-report/toast-container/index.html +0 -161
- package/coverage/lcov-report/toast-container/index.ts.html +0 -94
- package/coverage/lcov-report/toast-container/styles.ts.html +0 -2323
- package/coverage/lcov-report/toast-container/useToast.tsx.html +0 -469
- package/coverage/lcov-report/toast-provider/ToastProvider.tsx.html +0 -256
- package/coverage/lcov-report/toast-provider/context.ts.html +0 -106
- package/coverage/lcov-report/toast-provider/index.html +0 -161
- package/coverage/lcov-report/toast-provider/index.ts.html +0 -97
- package/coverage/lcov-report/toast-provider/useToast.tsx.html +0 -109
- package/coverage/lcov-report/tooltip/Tooltip.tsx.html +0 -250
- package/coverage/lcov-report/tooltip/context.ts.html +0 -97
- package/coverage/lcov-report/tooltip/index.html +0 -191
- package/coverage/lcov-report/tooltip/index.ts.html +0 -100
- package/coverage/lcov-report/tooltip/types.ts.html +0 -250
- package/coverage/lcov-report/tooltip/useTooltip.tsx.html +0 -352
- package/coverage/lcov-report/tooltip/useTooltipContext.tsx.html +0 -121
- package/coverage/lcov-report/tooltip-content/TooltipContent.tsx.html +0 -313
- package/coverage/lcov-report/tooltip-content/index.html +0 -146
- package/coverage/lcov-report/tooltip-content/index.ts.html +0 -91
- package/coverage/lcov-report/tooltip-content/styles.ts.html +0 -337
- package/coverage/lcov-report/tooltip-trigger/TooltipTrigger.tsx.html +0 -211
- package/coverage/lcov-report/tooltip-trigger/index.html +0 -131
- package/coverage/lcov-report/tooltip-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/types.ts.html +0 -226
- package/coverage/lcov-report/useTooltip.tsx.html +0 -277
- package/coverage/lcov-report/useTooltipContext.tsx.html +0 -121
- package/coverage/lcov-report/useTooltipOpen.tsx.html +0 -559
- package/coverage/lcov.info +0 -1330
- package/dist/package.json +0 -96
- package/index.ts +0 -1
- package/jest.config.js +0 -3
- package/rollup.config.js +0 -13
- package/src/components/dialog/Dialog.stories.tsx +0 -201
- package/src/components/dialog/Dialog.test.tsx +0 -116
- package/src/components/dialog/Dialog.tsx +0 -62
- package/src/components/dialog/context.ts +0 -4
- package/src/components/dialog/index.ts +0 -5
- package/src/components/dialog/types.ts +0 -56
- package/src/components/dialog/useDialog.tsx +0 -87
- package/src/components/dialog/useDialogContext.tsx +0 -12
- package/src/components/dialog-content/DialogContent.stories.tsx +0 -337
- package/src/components/dialog-content/DialogContent.tsx +0 -134
- package/src/components/dialog-content/index.ts +0 -2
- package/src/components/dialog-content/intl/en-US.json +0 -3
- package/src/components/dialog-content/intl/fr-FR.json +0 -3
- package/src/components/dialog-content/intl/index.ts +0 -7
- package/src/components/dialog-content/styles.ts +0 -72
- package/src/components/dialog-content/types.ts +0 -11
- package/src/components/dialog-content-actions/DialogContentActions.test.tsx +0 -68
- package/src/components/dialog-content-actions/DialogContentActions.tsx +0 -40
- package/src/components/dialog-content-actions/index.ts +0 -2
- package/src/components/dialog-content-actions/styles.ts +0 -18
- package/src/components/dialog-content-actions/types.ts +0 -11
- package/src/components/dialog-content-body/DialogContentBody.test.tsx +0 -63
- package/src/components/dialog-content-body/DialogContentBody.tsx +0 -49
- package/src/components/dialog-content-body/index.ts +0 -2
- package/src/components/dialog-content-body/styles.ts +0 -58
- package/src/components/dialog-content-body/types.ts +0 -14
- package/src/components/dialog-content-header/DialogContentHeader.test.tsx +0 -63
- package/src/components/dialog-content-header/DialogContentHeader.tsx +0 -81
- package/src/components/dialog-content-header/index.ts +0 -2
- package/src/components/dialog-content-header/styles.ts +0 -36
- package/src/components/dialog-content-header/types.ts +0 -23
- package/src/components/dialog-trigger/DialogTrigger.tsx +0 -43
- package/src/components/dialog-trigger/index.ts +0 -2
- package/src/components/dialog-trigger/types.ts +0 -9
- package/src/components/popover/Popover.stories.tsx +0 -158
- package/src/components/popover/Popover.test.tsx +0 -102
- package/src/components/popover/Popover.tsx +0 -53
- package/src/components/popover/context.ts +0 -4
- package/src/components/popover/index.ts +0 -5
- package/src/components/popover/types.ts +0 -53
- package/src/components/popover/usePopover.tsx +0 -70
- package/src/components/popover/usePopoverContext.tsx +0 -12
- package/src/components/popover-content/PopoverContent.tsx +0 -61
- package/src/components/popover-content/index.ts +0 -2
- package/src/components/popover-content/styles.ts +0 -27
- package/src/components/popover-content/types.ts +0 -11
- package/src/components/popover-trigger/PopoverTrigger.tsx +0 -43
- package/src/components/popover-trigger/index.ts +0 -2
- package/src/components/popover-trigger/types.ts +0 -9
- package/src/components/toast/Toast.stories.tsx +0 -75
- package/src/components/toast/Toast.test.tsx +0 -63
- package/src/components/toast/Toast.tsx +0 -122
- package/src/components/toast/index.ts +0 -2
- package/src/components/toast/intl/en-US.json +0 -3
- package/src/components/toast/intl/fr-FR.json +0 -3
- package/src/components/toast/intl/index.ts +0 -7
- package/src/components/toast/styles.ts +0 -43
- package/src/components/toast/types.ts +0 -44
- package/src/components/toast-container/ToastContainer.stories.tsx +0 -349
- package/src/components/toast-container/ToastContainer.tsx +0 -44
- package/src/components/toast-container/index.ts +0 -3
- package/src/components/toast-container/styles.ts +0 -746
- package/src/components/toast-container/types.ts +0 -110
- package/src/components/toast-container/useToast.test.tsx +0 -111
- package/src/components/toast-container/useToast.tsx +0 -128
- package/src/components/tooltip/Tooltip.stories.tsx +0 -200
- package/src/components/tooltip/Tooltip.test.tsx +0 -119
- package/src/components/tooltip/Tooltip.tsx +0 -55
- package/src/components/tooltip/context.ts +0 -4
- package/src/components/tooltip/index.ts +0 -5
- package/src/components/tooltip/types.ts +0 -55
- package/src/components/tooltip/useTooltip.tsx +0 -89
- package/src/components/tooltip/useTooltipContext.tsx +0 -12
- package/src/components/tooltip-content/TooltipContent.tsx +0 -76
- package/src/components/tooltip-content/index.ts +0 -2
- package/src/components/tooltip-content/styles.ts +0 -84
- package/src/components/tooltip-content/types.ts +0 -14
- package/src/components/tooltip-trigger/TooltipTrigger.tsx +0 -42
- package/src/components/tooltip-trigger/index.ts +0 -2
- package/src/components/tooltip-trigger/types.ts +0 -9
- package/src/index.ts +0 -14
- package/tsconfig.json +0 -3
- package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
- package/{dist/index.d.ts → index.d.ts} +0 -0
- package/{dist/index.js → index.js} +2 -2
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { partitionComponents, isComponent } from '@redsift/design-system';
|
|
3
|
-
import { TooltipContent } from '../tooltip-content';
|
|
4
|
-
import { TooltipTrigger } from '../tooltip-trigger';
|
|
5
|
-
|
|
6
|
-
import { TooltipContext } from './context';
|
|
7
|
-
import { TooltipPlacement, TooltipProps } from './types';
|
|
8
|
-
import { useTooltip } from './useTooltip';
|
|
9
|
-
|
|
10
|
-
const COMPONENT_NAME = 'Tooltip';
|
|
11
|
-
const CLASSNAME = 'redsift-tooltip';
|
|
12
|
-
const DEFAULT_PROPS: Partial<TooltipProps> = {
|
|
13
|
-
delay: 500,
|
|
14
|
-
placement: TooltipPlacement.top,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The Tooltip component.
|
|
19
|
-
*/
|
|
20
|
-
export const BaseTooltip: React.FC<TooltipProps> & {
|
|
21
|
-
displayName?: string;
|
|
22
|
-
className?: string;
|
|
23
|
-
} = (props) => {
|
|
24
|
-
const { children, defaultOpen, delay, isOpen, onOpen, placement, tooltipId } =
|
|
25
|
-
props;
|
|
26
|
-
|
|
27
|
-
const tooltip = useTooltip({
|
|
28
|
-
defaultOpen,
|
|
29
|
-
delay,
|
|
30
|
-
placement,
|
|
31
|
-
isOpen,
|
|
32
|
-
onOpen,
|
|
33
|
-
tooltipId,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const [[trigger], [content]] = partitionComponents(
|
|
37
|
-
React.Children.toArray(children),
|
|
38
|
-
[isComponent('TooltipTrigger'), isComponent('TooltipContent')]
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<TooltipContext.Provider value={tooltip}>
|
|
43
|
-
{trigger}
|
|
44
|
-
{content}
|
|
45
|
-
</TooltipContext.Provider>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
BaseTooltip.className = CLASSNAME;
|
|
49
|
-
BaseTooltip.defaultProps = DEFAULT_PROPS;
|
|
50
|
-
BaseTooltip.displayName = COMPONENT_NAME;
|
|
51
|
-
|
|
52
|
-
export const Tooltip = Object.assign(BaseTooltip, {
|
|
53
|
-
Trigger: TooltipTrigger,
|
|
54
|
-
Content: TooltipContent,
|
|
55
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { ValueOf } from '@redsift/design-system';
|
|
3
|
-
import { useTooltip } from './useTooltip';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Context props.
|
|
7
|
-
*/
|
|
8
|
-
export type TooltipState = ReturnType<typeof useTooltip> | null;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Component variant.
|
|
12
|
-
*/
|
|
13
|
-
export const TooltipPlacement = {
|
|
14
|
-
top: 'top',
|
|
15
|
-
right: 'right',
|
|
16
|
-
bottom: 'bottom',
|
|
17
|
-
left: 'left',
|
|
18
|
-
'top-start': 'top-start',
|
|
19
|
-
'top-end': 'top-end',
|
|
20
|
-
'right-start': 'right-start',
|
|
21
|
-
'right-end': 'right-end',
|
|
22
|
-
'bottom-start': 'bottom-start',
|
|
23
|
-
'bottom-end': 'bottom-end',
|
|
24
|
-
'left-start': 'left-start',
|
|
25
|
-
'left-end': 'left-end',
|
|
26
|
-
} as const;
|
|
27
|
-
export type TooltipPlacement = ValueOf<typeof TooltipPlacement>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Component props.
|
|
31
|
-
*/
|
|
32
|
-
export interface TooltipProps {
|
|
33
|
-
/** Children. Can only be TooltipTrigger and TooltilContent. */
|
|
34
|
-
children: ReactNode;
|
|
35
|
-
/**
|
|
36
|
-
* Default open status.
|
|
37
|
-
* Used for uncontrolled version.
|
|
38
|
-
*/
|
|
39
|
-
defaultOpen?: boolean;
|
|
40
|
-
/** Delay time (in ms) for the tooltip to show up. */
|
|
41
|
-
delay?: number;
|
|
42
|
-
/** Default placement of the tooltip. */
|
|
43
|
-
placement?: TooltipPlacement;
|
|
44
|
-
/**
|
|
45
|
-
* Whether the component is opened or not.
|
|
46
|
-
* Used for controlled version.
|
|
47
|
-
*/
|
|
48
|
-
isOpen?: boolean;
|
|
49
|
-
/** Method to handle component change. */
|
|
50
|
-
onOpen?: (open: boolean) => void;
|
|
51
|
-
/** Id to the tooltip content. */
|
|
52
|
-
tooltipId?: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type StyledTooltipProps = TooltipProps;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
useFloating,
|
|
4
|
-
arrow,
|
|
5
|
-
autoUpdate,
|
|
6
|
-
offset,
|
|
7
|
-
flip,
|
|
8
|
-
shift,
|
|
9
|
-
useHover,
|
|
10
|
-
useFocus,
|
|
11
|
-
useDismiss,
|
|
12
|
-
useRole,
|
|
13
|
-
useInteractions,
|
|
14
|
-
} from '@floating-ui/react';
|
|
15
|
-
import { TooltipProps } from './types';
|
|
16
|
-
|
|
17
|
-
export function useTooltip({
|
|
18
|
-
defaultOpen,
|
|
19
|
-
delay,
|
|
20
|
-
placement,
|
|
21
|
-
isOpen: propsIsOpen,
|
|
22
|
-
onOpen,
|
|
23
|
-
tooltipId: propsTooltipId,
|
|
24
|
-
}: Omit<TooltipProps, 'children'>) {
|
|
25
|
-
const arrowRef = useRef(null);
|
|
26
|
-
const [isOpen, setIsOpen] = useState(propsIsOpen ?? defaultOpen);
|
|
27
|
-
|
|
28
|
-
const tooltipId = propsTooltipId ?? useId();
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
setIsOpen(propsIsOpen ?? defaultOpen);
|
|
32
|
-
}, [propsIsOpen, defaultOpen]);
|
|
33
|
-
|
|
34
|
-
const handleOpen = useCallback(
|
|
35
|
-
(collapsed: boolean) => {
|
|
36
|
-
if (onOpen) {
|
|
37
|
-
onOpen(collapsed);
|
|
38
|
-
}
|
|
39
|
-
if (propsIsOpen === undefined || propsIsOpen === null) {
|
|
40
|
-
setIsOpen(collapsed);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
[onOpen]
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const data = useFloating({
|
|
47
|
-
placement,
|
|
48
|
-
open: isOpen,
|
|
49
|
-
onOpenChange: handleOpen,
|
|
50
|
-
whileElementsMounted: autoUpdate,
|
|
51
|
-
middleware: [
|
|
52
|
-
offset(8),
|
|
53
|
-
flip({
|
|
54
|
-
fallbackAxisSideDirection: 'start',
|
|
55
|
-
}),
|
|
56
|
-
shift({ padding: 8 }),
|
|
57
|
-
arrow({
|
|
58
|
-
element: arrowRef,
|
|
59
|
-
}),
|
|
60
|
-
],
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const context = data.context;
|
|
64
|
-
|
|
65
|
-
const hover = useHover(context, {
|
|
66
|
-
move: false,
|
|
67
|
-
delay: {
|
|
68
|
-
open: delay,
|
|
69
|
-
close: 0,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
const focus = useFocus(context);
|
|
73
|
-
const dismiss = useDismiss(context);
|
|
74
|
-
const role = useRole(context, { role: 'tooltip' });
|
|
75
|
-
|
|
76
|
-
const interactions = useInteractions([hover, focus, dismiss, role]);
|
|
77
|
-
|
|
78
|
-
return React.useMemo(
|
|
79
|
-
() => ({
|
|
80
|
-
isOpen,
|
|
81
|
-
handleOpen,
|
|
82
|
-
...interactions,
|
|
83
|
-
...data,
|
|
84
|
-
arrowRef,
|
|
85
|
-
tooltipId,
|
|
86
|
-
}),
|
|
87
|
-
[isOpen, handleOpen, interactions, data, arrowRef, tooltipId]
|
|
88
|
-
);
|
|
89
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TooltipContext } from './context';
|
|
3
|
-
|
|
4
|
-
export const useTooltipContext = () => {
|
|
5
|
-
const context = React.useContext(TooltipContext);
|
|
6
|
-
|
|
7
|
-
if (context == null) {
|
|
8
|
-
throw new Error('Tooltip components must be wrapped in <Tooltip />');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return context;
|
|
12
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { useMergeRefs, FloatingPortal } from '@floating-ui/react';
|
|
3
|
-
|
|
4
|
-
import { Comp } from '@redsift/design-system';
|
|
5
|
-
import { TooltipContentProps } from './types';
|
|
6
|
-
import { TooltipPlacement, useTooltipContext } from '../tooltip';
|
|
7
|
-
import { StyledTooltipContent } from './styles';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
|
|
10
|
-
const COMPONENT_NAME = 'TooltipContent';
|
|
11
|
-
const CLASSNAME = 'redsift-tooltip-content';
|
|
12
|
-
const DEFAULT_PROPS: Partial<TooltipContentProps> = {};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The TooltipContent component.
|
|
16
|
-
*/
|
|
17
|
-
export const TooltipContent: Comp<TooltipContentProps, HTMLDivElement> =
|
|
18
|
-
forwardRef((props, ref) => {
|
|
19
|
-
const { children, className, style } = props;
|
|
20
|
-
const {
|
|
21
|
-
getFloatingProps,
|
|
22
|
-
isOpen,
|
|
23
|
-
placement,
|
|
24
|
-
refs,
|
|
25
|
-
strategy,
|
|
26
|
-
x,
|
|
27
|
-
y,
|
|
28
|
-
middlewareData: { arrow: { x: arrowX, y: arrowY } = {} },
|
|
29
|
-
} = useTooltipContext();
|
|
30
|
-
const popoverRef = useMergeRefs([refs.setFloating, ref]);
|
|
31
|
-
|
|
32
|
-
const { arrowRef } = useTooltipContext();
|
|
33
|
-
|
|
34
|
-
const staticSide = {
|
|
35
|
-
top: 'bottom',
|
|
36
|
-
right: 'left',
|
|
37
|
-
bottom: 'top',
|
|
38
|
-
left: 'right',
|
|
39
|
-
}[placement.split('-')[0]];
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<FloatingPortal id="redsift-app-container">
|
|
43
|
-
{isOpen && (
|
|
44
|
-
<StyledTooltipContent
|
|
45
|
-
className={classNames(TooltipContent.className, className)}
|
|
46
|
-
ref={popoverRef}
|
|
47
|
-
style={{
|
|
48
|
-
position: strategy,
|
|
49
|
-
top: y ?? 0,
|
|
50
|
-
left: x ?? 0,
|
|
51
|
-
visibility: x == null ? 'hidden' : 'visible',
|
|
52
|
-
...style,
|
|
53
|
-
}}
|
|
54
|
-
{...getFloatingProps(props)}
|
|
55
|
-
$placement={placement as TooltipPlacement}
|
|
56
|
-
>
|
|
57
|
-
<div
|
|
58
|
-
ref={arrowRef}
|
|
59
|
-
className={`${TooltipContent.className}__arrow`}
|
|
60
|
-
style={{
|
|
61
|
-
left: arrowX != null ? `${arrowX}px` : '',
|
|
62
|
-
top: arrowY != null ? `${arrowY}px` : '',
|
|
63
|
-
[staticSide!]: '-6px',
|
|
64
|
-
}}
|
|
65
|
-
/>
|
|
66
|
-
<div className={`${TooltipContent.className}__inner`}>
|
|
67
|
-
{children}
|
|
68
|
-
</div>
|
|
69
|
-
</StyledTooltipContent>
|
|
70
|
-
)}
|
|
71
|
-
</FloatingPortal>
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
TooltipContent.className = CLASSNAME;
|
|
75
|
-
TooltipContent.defaultProps = DEFAULT_PROPS;
|
|
76
|
-
TooltipContent.displayName = COMPONENT_NAME;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
import { baseContainer } from '@redsift/design-system';
|
|
3
|
-
import { TooltipPlacement } from '../tooltip';
|
|
4
|
-
import { StyledTooltipContentProps } from './types';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Component style.
|
|
8
|
-
*/
|
|
9
|
-
export const StyledTooltipContent = styled.div<StyledTooltipContentProps>`
|
|
10
|
-
${baseContainer}
|
|
11
|
-
|
|
12
|
-
align-items: center;
|
|
13
|
-
background-color: var(--redsift-color-neutral-white);
|
|
14
|
-
box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
15
|
-
color: var(--redsift-color-neutral-black);
|
|
16
|
-
display: flex;
|
|
17
|
-
filter: drop-shadow(0px 4px 5px rgba(0, 0, 0, 0.14))
|
|
18
|
-
drop-shadow(0px 1px 10px rgba(0, 0, 0, 0.12));
|
|
19
|
-
font-family: var(--redsift-typography-tooltip-font-family);
|
|
20
|
-
font-size: var(--redsift-typography-tooltip-font-size);
|
|
21
|
-
font-weight: var(--redsift-typography-tooltip-font-weight);
|
|
22
|
-
line-height: var(--redsift-typography-tooltip-line-height);
|
|
23
|
-
max-width: calc(100vw - 48px);
|
|
24
|
-
padding: 4px 8px;
|
|
25
|
-
z-index: var(--redsift-layout-z-index-tooltip);
|
|
26
|
-
|
|
27
|
-
.redsift-tooltip-content__arrow {
|
|
28
|
-
position: absolute;
|
|
29
|
-
width: 0;
|
|
30
|
-
height: 0;
|
|
31
|
-
border-color: var(--redsift-color-neutral-white);
|
|
32
|
-
border-style: solid;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
${({ $placement }) => {
|
|
36
|
-
switch ($placement) {
|
|
37
|
-
case TooltipPlacement.left:
|
|
38
|
-
case TooltipPlacement['left-end']:
|
|
39
|
-
case TooltipPlacement['left-start']:
|
|
40
|
-
return css`
|
|
41
|
-
.redsift-tooltip-content__arrow {
|
|
42
|
-
border-width: 6px 0 6px 6px;
|
|
43
|
-
border-top-color: transparent;
|
|
44
|
-
border-right-color: transparent;
|
|
45
|
-
border-bottom-color: transparent;
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
case TooltipPlacement.top:
|
|
49
|
-
case TooltipPlacement['top-end']:
|
|
50
|
-
case TooltipPlacement['top-start']:
|
|
51
|
-
return css`
|
|
52
|
-
.redsift-tooltip-content__arrow {
|
|
53
|
-
border-width: 6px 6px 0;
|
|
54
|
-
border-right-color: transparent;
|
|
55
|
-
border-bottom-color: transparent;
|
|
56
|
-
border-left-color: transparent;
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
case TooltipPlacement.right:
|
|
60
|
-
case TooltipPlacement['right-end']:
|
|
61
|
-
case TooltipPlacement['right-start']:
|
|
62
|
-
return css`
|
|
63
|
-
.redsift-tooltip-content__arrow {
|
|
64
|
-
border-width: 6px 6px 6px 0;
|
|
65
|
-
border-top-color: transparent;
|
|
66
|
-
border-bottom-color: transparent;
|
|
67
|
-
border-left-color: transparent;
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
case TooltipPlacement.bottom:
|
|
71
|
-
case TooltipPlacement['bottom-end']:
|
|
72
|
-
case TooltipPlacement['bottom-start']:
|
|
73
|
-
default:
|
|
74
|
-
return css`
|
|
75
|
-
.redsift-tooltip-content__arrow {
|
|
76
|
-
border-width: 0 6px 6px;
|
|
77
|
-
border-top-color: transparent;
|
|
78
|
-
border-right-color: transparent;
|
|
79
|
-
border-left-color: transparent;
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
82
|
-
}
|
|
83
|
-
}}
|
|
84
|
-
`;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
|
-
import { ContainerProps, InternalSpacingProps } from '@redsift/design-system';
|
|
3
|
-
import { TooltipPlacement } from '../tooltip';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Component props.
|
|
7
|
-
*/
|
|
8
|
-
export interface TooltipContentProps
|
|
9
|
-
extends ComponentProps<'div'>,
|
|
10
|
-
Omit<ContainerProps, keyof InternalSpacingProps> {}
|
|
11
|
-
|
|
12
|
-
export type StyledTooltipContentProps = TooltipContentProps & {
|
|
13
|
-
$placement: TooltipPlacement;
|
|
14
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, ReactElement } from 'react';
|
|
2
|
-
import { useMergeRefs } from '@floating-ui/react';
|
|
3
|
-
|
|
4
|
-
import { Comp } from '@redsift/design-system';
|
|
5
|
-
import { useTooltipContext } from '../tooltip';
|
|
6
|
-
import { TooltipTriggerProps } from './types';
|
|
7
|
-
|
|
8
|
-
const COMPONENT_NAME = 'TooltipTrigger';
|
|
9
|
-
const CLASSNAME = 'redsift-tooltip-trigger';
|
|
10
|
-
const DEFAULT_PROPS: Partial<TooltipTriggerProps> = {};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The TooltipTrigger component.
|
|
14
|
-
*/
|
|
15
|
-
export const TooltipTrigger: Comp<TooltipTriggerProps, HTMLSpanElement> =
|
|
16
|
-
forwardRef((props, ref) => {
|
|
17
|
-
const { children } = props;
|
|
18
|
-
|
|
19
|
-
const { getReferenceProps, refs, tooltipId } = useTooltipContext();
|
|
20
|
-
const childrenRef = (children as any).ref;
|
|
21
|
-
const triggerRef = useMergeRefs([refs.setReference, ref, childrenRef]);
|
|
22
|
-
|
|
23
|
-
if (React.isValidElement(children)) {
|
|
24
|
-
return React.cloneElement(children as ReactElement, {
|
|
25
|
-
...getReferenceProps({
|
|
26
|
-
ref: triggerRef,
|
|
27
|
-
...props,
|
|
28
|
-
'aria-describedby': tooltipId,
|
|
29
|
-
...children.props,
|
|
30
|
-
}),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<span ref={triggerRef} {...getReferenceProps(props)}>
|
|
36
|
-
{children}
|
|
37
|
-
</span>
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
TooltipTrigger.className = CLASSNAME;
|
|
41
|
-
TooltipTrigger.defaultProps = DEFAULT_PROPS;
|
|
42
|
-
TooltipTrigger.displayName = COMPONENT_NAME;
|
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './components/dialog';
|
|
2
|
-
export * from './components/dialog-content';
|
|
3
|
-
export * from './components/dialog-content-actions';
|
|
4
|
-
export * from './components/dialog-content-body';
|
|
5
|
-
export * from './components/dialog-content-header';
|
|
6
|
-
export * from './components/dialog-trigger';
|
|
7
|
-
export * from './components/popover';
|
|
8
|
-
export * from './components/popover-content';
|
|
9
|
-
export * from './components/popover-trigger';
|
|
10
|
-
export * from './components/toast';
|
|
11
|
-
export * from './components/toast-container';
|
|
12
|
-
export * from './components/tooltip';
|
|
13
|
-
export * from './components/tooltip-content';
|
|
14
|
-
export * from './components/tooltip-trigger';
|
package/tsconfig.json
DELETED
|
File without changes
|
|
File without changes
|
|
@@ -687,12 +687,12 @@ const PopoverPlacement = {
|
|
|
687
687
|
* Component style.
|
|
688
688
|
*/
|
|
689
689
|
const StyledPopoverContent = styled.div`
|
|
690
|
-
${baseContainer}
|
|
691
690
|
align-items: center;
|
|
691
|
+
display: flex;
|
|
692
|
+
${baseContainer}
|
|
692
693
|
background-color: var(--redsift-color-neutral-white);
|
|
693
694
|
box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
694
695
|
color: var(--redsift-color-neutral-black);
|
|
695
|
-
display: flex;
|
|
696
696
|
filter: drop-shadow(0px 4px 5px rgba(0, 0, 0, 0.14))
|
|
697
697
|
drop-shadow(0px 1px 10px rgba(0, 0, 0, 0.12));
|
|
698
698
|
font-family: var(--redsift-typography-popover-font-family);
|