datocms-react-ui 2.1.0-alpha.0 → 2.1.0-alpha.2
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/cjs/HotKey/index.js +105 -0
- package/dist/cjs/HotKey/index.js.map +1 -0
- package/dist/cjs/HotKey/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/SplitViewPane/index.js +14 -0
- package/dist/cjs/SplitView/SplitViewPane/index.js.map +1 -0
- package/dist/cjs/SplitView/SplitViewPane/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/SplitViewSash/index.js +76 -0
- package/dist/cjs/SplitView/SplitViewSash/index.js.map +1 -0
- package/dist/cjs/SplitView/SplitViewSash/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/index.js +206 -0
- package/dist/cjs/SplitView/index.js.map +1 -0
- package/dist/cjs/SplitView/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/types.js +3 -0
- package/dist/cjs/SplitView/types.js.map +1 -0
- package/dist/cjs/Tooltip/Tooltip/index.js +116 -0
- package/dist/cjs/Tooltip/Tooltip/index.js.map +1 -0
- package/dist/cjs/Tooltip/TooltipContent/index.js +147 -0
- package/dist/cjs/Tooltip/TooltipContent/index.js.map +1 -0
- package/dist/cjs/Tooltip/TooltipContent/styles.module.css.json +1 -0
- package/dist/cjs/Tooltip/TooltipDelayGroup/index.js +140 -0
- package/dist/cjs/Tooltip/TooltipDelayGroup/index.js.map +1 -0
- package/dist/cjs/Tooltip/TooltipTrigger/index.js +102 -0
- package/dist/cjs/Tooltip/TooltipTrigger/index.js.map +1 -0
- package/dist/cjs/Tooltip/index.js +12 -0
- package/dist/cjs/Tooltip/index.js.map +1 -0
- package/dist/cjs/Tooltip/utils.js +165 -0
- package/dist/cjs/Tooltip/utils.js.map +1 -0
- package/dist/cjs/VerticalSplit/index.js +337 -0
- package/dist/cjs/VerticalSplit/index.js.map +1 -0
- package/dist/cjs/VerticalSplit/styles.module.css.json +1 -0
- package/dist/cjs/icons.js +19 -1
- package/dist/cjs/icons.js.map +1 -1
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/HotKey/index.d.ts +70 -0
- package/dist/esm/HotKey/index.js +75 -0
- package/dist/esm/HotKey/index.js.map +1 -0
- package/dist/esm/HotKey/styles.module.css.json +1 -0
- package/dist/esm/SplitView/SplitViewPane/index.d.ts +7 -0
- package/dist/esm/SplitView/SplitViewPane/index.js +7 -0
- package/dist/esm/SplitView/SplitViewPane/index.js.map +1 -0
- package/dist/esm/SplitView/SplitViewPane/styles.module.css.json +1 -0
- package/dist/esm/SplitView/SplitViewSash/index.d.ts +17 -0
- package/dist/esm/SplitView/SplitViewSash/index.js +46 -0
- package/dist/esm/SplitView/SplitViewSash/index.js.map +1 -0
- package/dist/esm/SplitView/SplitViewSash/styles.module.css.json +1 -0
- package/dist/esm/SplitView/index.d.ts +16 -0
- package/dist/esm/SplitView/index.js +176 -0
- package/dist/esm/SplitView/index.js.map +1 -0
- package/dist/esm/SplitView/styles.module.css.json +1 -0
- package/dist/esm/SplitView/types.d.ts +8 -0
- package/dist/esm/SplitView/types.js +2 -0
- package/dist/esm/SplitView/types.js.map +1 -0
- package/dist/esm/Tooltip/Tooltip/index.d.ts +74 -0
- package/dist/esm/Tooltip/Tooltip/index.js +89 -0
- package/dist/esm/Tooltip/Tooltip/index.js.map +1 -0
- package/dist/esm/Tooltip/TooltipContent/index.d.ts +68 -0
- package/dist/esm/Tooltip/TooltipContent/index.js +118 -0
- package/dist/esm/Tooltip/TooltipContent/index.js.map +1 -0
- package/dist/esm/Tooltip/TooltipContent/styles.module.css.json +1 -0
- package/dist/esm/Tooltip/TooltipDelayGroup/index.d.ts +118 -0
- package/dist/esm/Tooltip/TooltipDelayGroup/index.js +113 -0
- package/dist/esm/Tooltip/TooltipDelayGroup/index.js.map +1 -0
- package/dist/esm/Tooltip/TooltipTrigger/index.d.ts +45 -0
- package/dist/esm/Tooltip/TooltipTrigger/index.js +76 -0
- package/dist/esm/Tooltip/TooltipTrigger/index.js.map +1 -0
- package/dist/esm/Tooltip/index.d.ts +8 -0
- package/dist/esm/Tooltip/index.js +5 -0
- package/dist/esm/Tooltip/index.js.map +1 -0
- package/dist/esm/Tooltip/utils.d.ts +166 -0
- package/dist/esm/Tooltip/utils.js +135 -0
- package/dist/esm/Tooltip/utils.js.map +1 -0
- package/dist/esm/VerticalSplit/index.d.ts +238 -0
- package/dist/esm/VerticalSplit/index.js +307 -0
- package/dist/esm/VerticalSplit/index.js.map +1 -0
- package/dist/esm/VerticalSplit/styles.module.css.json +1 -0
- package/dist/esm/icons.d.ts +3 -0
- package/dist/esm/icons.js +15 -0
- package/dist/esm/icons.js.map +1 -1
- package/dist/esm/index.d.ts +7 -3
- package/dist/esm/index.js +7 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/types/HotKey/index.d.ts +70 -0
- package/dist/types/SplitView/SplitViewPane/index.d.ts +7 -0
- package/dist/types/SplitView/SplitViewSash/index.d.ts +17 -0
- package/dist/types/SplitView/index.d.ts +16 -0
- package/dist/types/SplitView/types.d.ts +8 -0
- package/dist/types/Tooltip/Tooltip/index.d.ts +74 -0
- package/dist/types/Tooltip/TooltipContent/index.d.ts +68 -0
- package/dist/types/Tooltip/TooltipDelayGroup/index.d.ts +118 -0
- package/dist/types/Tooltip/TooltipTrigger/index.d.ts +45 -0
- package/dist/types/Tooltip/index.d.ts +8 -0
- package/dist/types/Tooltip/utils.d.ts +166 -0
- package/dist/types/VerticalSplit/index.d.ts +238 -0
- package/dist/types/icons.d.ts +3 -0
- package/dist/types/index.d.ts +7 -3
- package/package.json +4 -3
- package/src/HotKey/index.tsx +95 -0
- package/src/HotKey/styles.module.css +22 -0
- package/src/HotKey/styles.module.css.json +1 -0
- package/src/SplitView/SplitViewPane/index.tsx +19 -0
- package/src/SplitView/SplitViewPane/styles.module.css +6 -0
- package/src/SplitView/SplitViewPane/styles.module.css.json +1 -0
- package/src/SplitView/SplitViewSash/index.tsx +99 -0
- package/src/SplitView/SplitViewSash/styles.module.css +68 -0
- package/src/SplitView/SplitViewSash/styles.module.css.json +1 -0
- package/src/SplitView/index.tsx +256 -0
- package/src/SplitView/styles.module.css +22 -0
- package/src/SplitView/styles.module.css.json +1 -0
- package/src/SplitView/types.ts +9 -0
- package/src/Tooltip/Tooltip/index.tsx +85 -0
- package/src/Tooltip/TooltipContent/index.tsx +145 -0
- package/src/Tooltip/TooltipContent/styles.module.css +10 -0
- package/src/Tooltip/TooltipContent/styles.module.css.json +1 -0
- package/src/Tooltip/TooltipDelayGroup/index.tsx +128 -0
- package/src/Tooltip/TooltipTrigger/index.tsx +71 -0
- package/src/Tooltip/index.ts +8 -0
- package/src/Tooltip/utils.ts +176 -0
- package/src/VerticalSplit/index.tsx +401 -0
- package/src/VerticalSplit/styles.module.css +103 -0
- package/src/VerticalSplit/styles.module.css.json +1 -0
- package/src/global.css +31 -25
- package/src/icons.tsx +60 -0
- package/src/index.ts +7 -3
- package/styles.css +1 -1
- package/types.json +6126 -3451
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare type TooltipDelayGroupProps = {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
/** The delay in milliseconds before a tooltip opens on hover (default: 1000) */
|
|
5
|
+
delay?: number | {
|
|
6
|
+
open?: number;
|
|
7
|
+
close?: number;
|
|
8
|
+
};
|
|
9
|
+
/** How long to wait in milliseconds before closing the group (default: 0) */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* TooltipDelayGroup synchronizes hover delays across multiple tooltips.
|
|
14
|
+
*
|
|
15
|
+
* When tooltips are wrapped in a delay group, hovering over the first tooltip
|
|
16
|
+
* will use the configured delay, but subsequent tooltips in the group will
|
|
17
|
+
* open instantly. This creates a smoother UX when users explore multiple
|
|
18
|
+
* interactive elements with tooltips.
|
|
19
|
+
*
|
|
20
|
+
* @example Basic delay group
|
|
21
|
+
*
|
|
22
|
+
* Group multiple tooltips together so they open instantly after the first one:
|
|
23
|
+
*
|
|
24
|
+
* ```js
|
|
25
|
+
* <Canvas ctx={ctx}>
|
|
26
|
+
* <TooltipDelayGroup delay={500}>
|
|
27
|
+
* <div style={{ display: 'flex', gap: 'var(--spacing-m)' }}>
|
|
28
|
+
* <Tooltip>
|
|
29
|
+
* <TooltipTrigger>
|
|
30
|
+
* <Button leftIcon={<SaveIcon />} />
|
|
31
|
+
* </TooltipTrigger>
|
|
32
|
+
* <TooltipContent>Save changes</TooltipContent>
|
|
33
|
+
* </Tooltip>
|
|
34
|
+
*
|
|
35
|
+
* <Tooltip>
|
|
36
|
+
* <TooltipTrigger>
|
|
37
|
+
* <Button leftIcon={<UndoIcon />} />
|
|
38
|
+
* </TooltipTrigger>
|
|
39
|
+
* <TooltipContent>Undo</TooltipContent>
|
|
40
|
+
* </Tooltip>
|
|
41
|
+
*
|
|
42
|
+
* <Tooltip>
|
|
43
|
+
* <TooltipTrigger>
|
|
44
|
+
* <Button leftIcon={<RedoIcon />} />
|
|
45
|
+
* </TooltipTrigger>
|
|
46
|
+
* <TooltipContent>Redo</TooltipContent>
|
|
47
|
+
* </Tooltip>
|
|
48
|
+
* </div>
|
|
49
|
+
* </TooltipDelayGroup>
|
|
50
|
+
* </Canvas>;
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example Custom delay configuration
|
|
54
|
+
*
|
|
55
|
+
* Configure different delays for opening and closing tooltips in the group:
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* <Canvas ctx={ctx}>
|
|
59
|
+
* <TooltipDelayGroup delay={{ open: 800, close: 200 }} timeoutMs={500}>
|
|
60
|
+
* <div style={{ display: 'flex', gap: 'var(--spacing-s)' }}>
|
|
61
|
+
* <Tooltip>
|
|
62
|
+
* <TooltipTrigger>
|
|
63
|
+
* <Button>Action 1</Button>
|
|
64
|
+
* </TooltipTrigger>
|
|
65
|
+
* <TooltipContent>First action</TooltipContent>
|
|
66
|
+
* </Tooltip>
|
|
67
|
+
*
|
|
68
|
+
* <Tooltip>
|
|
69
|
+
* <TooltipTrigger>
|
|
70
|
+
* <Button>Action 2</Button>
|
|
71
|
+
* </TooltipTrigger>
|
|
72
|
+
* <TooltipContent>Second action</TooltipContent>
|
|
73
|
+
* </Tooltip>
|
|
74
|
+
* </div>
|
|
75
|
+
* </TooltipDelayGroup>
|
|
76
|
+
* </Canvas>;
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example Toolbar with grouped tooltips
|
|
80
|
+
*
|
|
81
|
+
* Create a toolbar where hovering between tools feels instant and responsive:
|
|
82
|
+
*
|
|
83
|
+
* ```js
|
|
84
|
+
* <Canvas ctx={ctx}>
|
|
85
|
+
* <TooltipDelayGroup delay={600}>
|
|
86
|
+
* <div style={{
|
|
87
|
+
* display: 'flex',
|
|
88
|
+
* gap: 'var(--spacing-xs)',
|
|
89
|
+
* padding: 'var(--spacing-s)',
|
|
90
|
+
* borderRadius: 'var(--border-radius-m)',
|
|
91
|
+
* backgroundColor: 'var(--light-bg-color)'
|
|
92
|
+
* }}>
|
|
93
|
+
* <Tooltip>
|
|
94
|
+
* <TooltipTrigger>
|
|
95
|
+
* <Button buttonSize="s" leftIcon={<BoldIcon />} />
|
|
96
|
+
* </TooltipTrigger>
|
|
97
|
+
* <TooltipContent>Bold</TooltipContent>
|
|
98
|
+
* </Tooltip>
|
|
99
|
+
*
|
|
100
|
+
* <Tooltip>
|
|
101
|
+
* <TooltipTrigger>
|
|
102
|
+
* <Button buttonSize="s" leftIcon={<ItalicIcon />} />
|
|
103
|
+
* </TooltipTrigger>
|
|
104
|
+
* <TooltipContent>Italic</TooltipContent>
|
|
105
|
+
* </Tooltip>
|
|
106
|
+
*
|
|
107
|
+
* <Tooltip>
|
|
108
|
+
* <TooltipTrigger>
|
|
109
|
+
* <Button buttonSize="s" leftIcon={<UnderlineIcon />} />
|
|
110
|
+
* </TooltipTrigger>
|
|
111
|
+
* <TooltipContent>Underline</TooltipContent>
|
|
112
|
+
* </Tooltip>
|
|
113
|
+
* </div>
|
|
114
|
+
* </TooltipDelayGroup>
|
|
115
|
+
* </Canvas>;
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function TooltipDelayGroup({ children, delay, timeoutMs, }: TooltipDelayGroupProps): JSX.Element;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { FloatingDelayGroup } from '@floating-ui/react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* TooltipDelayGroup synchronizes hover delays across multiple tooltips.
|
|
5
|
+
*
|
|
6
|
+
* When tooltips are wrapped in a delay group, hovering over the first tooltip
|
|
7
|
+
* will use the configured delay, but subsequent tooltips in the group will
|
|
8
|
+
* open instantly. This creates a smoother UX when users explore multiple
|
|
9
|
+
* interactive elements with tooltips.
|
|
10
|
+
*
|
|
11
|
+
* @example Basic delay group
|
|
12
|
+
*
|
|
13
|
+
* Group multiple tooltips together so they open instantly after the first one:
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* <Canvas ctx={ctx}>
|
|
17
|
+
* <TooltipDelayGroup delay={500}>
|
|
18
|
+
* <div style={{ display: 'flex', gap: 'var(--spacing-m)' }}>
|
|
19
|
+
* <Tooltip>
|
|
20
|
+
* <TooltipTrigger>
|
|
21
|
+
* <Button leftIcon={<SaveIcon />} />
|
|
22
|
+
* </TooltipTrigger>
|
|
23
|
+
* <TooltipContent>Save changes</TooltipContent>
|
|
24
|
+
* </Tooltip>
|
|
25
|
+
*
|
|
26
|
+
* <Tooltip>
|
|
27
|
+
* <TooltipTrigger>
|
|
28
|
+
* <Button leftIcon={<UndoIcon />} />
|
|
29
|
+
* </TooltipTrigger>
|
|
30
|
+
* <TooltipContent>Undo</TooltipContent>
|
|
31
|
+
* </Tooltip>
|
|
32
|
+
*
|
|
33
|
+
* <Tooltip>
|
|
34
|
+
* <TooltipTrigger>
|
|
35
|
+
* <Button leftIcon={<RedoIcon />} />
|
|
36
|
+
* </TooltipTrigger>
|
|
37
|
+
* <TooltipContent>Redo</TooltipContent>
|
|
38
|
+
* </Tooltip>
|
|
39
|
+
* </div>
|
|
40
|
+
* </TooltipDelayGroup>
|
|
41
|
+
* </Canvas>;
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Custom delay configuration
|
|
45
|
+
*
|
|
46
|
+
* Configure different delays for opening and closing tooltips in the group:
|
|
47
|
+
*
|
|
48
|
+
* ```js
|
|
49
|
+
* <Canvas ctx={ctx}>
|
|
50
|
+
* <TooltipDelayGroup delay={{ open: 800, close: 200 }} timeoutMs={500}>
|
|
51
|
+
* <div style={{ display: 'flex', gap: 'var(--spacing-s)' }}>
|
|
52
|
+
* <Tooltip>
|
|
53
|
+
* <TooltipTrigger>
|
|
54
|
+
* <Button>Action 1</Button>
|
|
55
|
+
* </TooltipTrigger>
|
|
56
|
+
* <TooltipContent>First action</TooltipContent>
|
|
57
|
+
* </Tooltip>
|
|
58
|
+
*
|
|
59
|
+
* <Tooltip>
|
|
60
|
+
* <TooltipTrigger>
|
|
61
|
+
* <Button>Action 2</Button>
|
|
62
|
+
* </TooltipTrigger>
|
|
63
|
+
* <TooltipContent>Second action</TooltipContent>
|
|
64
|
+
* </Tooltip>
|
|
65
|
+
* </div>
|
|
66
|
+
* </TooltipDelayGroup>
|
|
67
|
+
* </Canvas>;
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Toolbar with grouped tooltips
|
|
71
|
+
*
|
|
72
|
+
* Create a toolbar where hovering between tools feels instant and responsive:
|
|
73
|
+
*
|
|
74
|
+
* ```js
|
|
75
|
+
* <Canvas ctx={ctx}>
|
|
76
|
+
* <TooltipDelayGroup delay={600}>
|
|
77
|
+
* <div style={{
|
|
78
|
+
* display: 'flex',
|
|
79
|
+
* gap: 'var(--spacing-xs)',
|
|
80
|
+
* padding: 'var(--spacing-s)',
|
|
81
|
+
* borderRadius: 'var(--border-radius-m)',
|
|
82
|
+
* backgroundColor: 'var(--light-bg-color)'
|
|
83
|
+
* }}>
|
|
84
|
+
* <Tooltip>
|
|
85
|
+
* <TooltipTrigger>
|
|
86
|
+
* <Button buttonSize="s" leftIcon={<BoldIcon />} />
|
|
87
|
+
* </TooltipTrigger>
|
|
88
|
+
* <TooltipContent>Bold</TooltipContent>
|
|
89
|
+
* </Tooltip>
|
|
90
|
+
*
|
|
91
|
+
* <Tooltip>
|
|
92
|
+
* <TooltipTrigger>
|
|
93
|
+
* <Button buttonSize="s" leftIcon={<ItalicIcon />} />
|
|
94
|
+
* </TooltipTrigger>
|
|
95
|
+
* <TooltipContent>Italic</TooltipContent>
|
|
96
|
+
* </Tooltip>
|
|
97
|
+
*
|
|
98
|
+
* <Tooltip>
|
|
99
|
+
* <TooltipTrigger>
|
|
100
|
+
* <Button buttonSize="s" leftIcon={<UnderlineIcon />} />
|
|
101
|
+
* </TooltipTrigger>
|
|
102
|
+
* <TooltipContent>Underline</TooltipContent>
|
|
103
|
+
* </Tooltip>
|
|
104
|
+
* </div>
|
|
105
|
+
* </TooltipDelayGroup>
|
|
106
|
+
* </Canvas>;
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export function TooltipDelayGroup(_a) {
|
|
110
|
+
var children = _a.children, _b = _a.delay, delay = _b === void 0 ? 1000 : _b, _c = _a.timeoutMs, timeoutMs = _c === void 0 ? 0 : _c;
|
|
111
|
+
return (React.createElement(FloatingDelayGroup, { delay: delay, timeoutMs: timeoutMs }, children));
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Tooltip/TooltipDelayGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAIT;QAHvB,QAAQ,cAAA,EACR,aAAY,EAAZ,KAAK,mBAAG,IAAI,KAAA,EACZ,iBAAa,EAAb,SAAS,mBAAG,CAAC,KAAA;IAEb,OAAO,CACL,oBAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,IACnD,QAAQ,CACU,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare type TooltipTriggerProps = {
|
|
3
|
+
children: React.ReactElement;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* TooltipTrigger wraps the element that triggers the tooltip on hover/focus.
|
|
7
|
+
*
|
|
8
|
+
* The child must be a single React element that accepts ref and event handler props.
|
|
9
|
+
* Common triggers include buttons, icons, or other interactive elements.
|
|
10
|
+
*
|
|
11
|
+
* @example With Button component
|
|
12
|
+
*
|
|
13
|
+
* Wrap a button to show a tooltip when the user hovers over it:
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* <Canvas ctx={ctx}>
|
|
17
|
+
* <Tooltip>
|
|
18
|
+
* <TooltipTrigger>
|
|
19
|
+
* <Button>Hover for info</Button>
|
|
20
|
+
* </TooltipTrigger>
|
|
21
|
+
* <TooltipContent>
|
|
22
|
+
* Additional information appears here
|
|
23
|
+
* </TooltipContent>
|
|
24
|
+
* </Tooltip>
|
|
25
|
+
* </Canvas>;
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example With icon button
|
|
29
|
+
*
|
|
30
|
+
* Use tooltips with icon-only buttons to explain their purpose:
|
|
31
|
+
*
|
|
32
|
+
* ```js
|
|
33
|
+
* <Canvas ctx={ctx}>
|
|
34
|
+
* <Tooltip placement="bottom">
|
|
35
|
+
* <TooltipTrigger>
|
|
36
|
+
* <Button buttonSize="s" leftIcon={<InfoIcon />} />
|
|
37
|
+
* </TooltipTrigger>
|
|
38
|
+
* <TooltipContent>
|
|
39
|
+
* Click for more details
|
|
40
|
+
* </TooltipContent>
|
|
41
|
+
* </Tooltip>
|
|
42
|
+
* </Canvas>;
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipTriggerProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { useMergeRefs } from '@floating-ui/react';
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import { useTooltipState } from '../utils';
|
|
26
|
+
/**
|
|
27
|
+
* TooltipTrigger wraps the element that triggers the tooltip on hover/focus.
|
|
28
|
+
*
|
|
29
|
+
* The child must be a single React element that accepts ref and event handler props.
|
|
30
|
+
* Common triggers include buttons, icons, or other interactive elements.
|
|
31
|
+
*
|
|
32
|
+
* @example With Button component
|
|
33
|
+
*
|
|
34
|
+
* Wrap a button to show a tooltip when the user hovers over it:
|
|
35
|
+
*
|
|
36
|
+
* ```js
|
|
37
|
+
* <Canvas ctx={ctx}>
|
|
38
|
+
* <Tooltip>
|
|
39
|
+
* <TooltipTrigger>
|
|
40
|
+
* <Button>Hover for info</Button>
|
|
41
|
+
* </TooltipTrigger>
|
|
42
|
+
* <TooltipContent>
|
|
43
|
+
* Additional information appears here
|
|
44
|
+
* </TooltipContent>
|
|
45
|
+
* </Tooltip>
|
|
46
|
+
* </Canvas>;
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example With icon button
|
|
50
|
+
*
|
|
51
|
+
* Use tooltips with icon-only buttons to explain their purpose:
|
|
52
|
+
*
|
|
53
|
+
* ```js
|
|
54
|
+
* <Canvas ctx={ctx}>
|
|
55
|
+
* <Tooltip placement="bottom">
|
|
56
|
+
* <TooltipTrigger>
|
|
57
|
+
* <Button buttonSize="s" leftIcon={<InfoIcon />} />
|
|
58
|
+
* </TooltipTrigger>
|
|
59
|
+
* <TooltipContent>
|
|
60
|
+
* Click for more details
|
|
61
|
+
* </TooltipContent>
|
|
62
|
+
* </Tooltip>
|
|
63
|
+
* </Canvas>;
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export var TooltipTrigger = React.forwardRef(function TooltipTrigger(_a, propRef) {
|
|
67
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
68
|
+
var state = useTooltipState();
|
|
69
|
+
var childrenRef = children.ref;
|
|
70
|
+
var ref = useMergeRefs([state.refs.setReference, propRef, childrenRef]);
|
|
71
|
+
if (!React.isValidElement(children)) {
|
|
72
|
+
throw new Error('TooltipTrigger children must be a valid React element');
|
|
73
|
+
}
|
|
74
|
+
return React.cloneElement(children, state.getReferenceProps(__assign(__assign(__assign({ ref: ref }, props), children.props), { 'data-state': state.open ? 'open' : 'closed' })));
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Tooltip/TooltipTrigger/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,IAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAG5C,SAAS,cAAc,CAAC,EAAsB,EAAE,OAAO;IAA7B,IAAA,QAAQ,cAAA,EAAK,KAAK,cAApB,YAAsB,CAAF;IAC5C,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAEhC,IAAM,WAAW,GAAI,QAAgB,CAAC,GAAG,CAAC;IAC1C,IAAM,GAAG,GAAG,YAAY,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAE1E,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;IAED,OAAO,KAAK,CAAC,YAAY,CACvB,QAAQ,EACR,KAAK,CAAC,iBAAiB,8BACrB,GAAG,KAAA,IACA,KAAK,GACL,QAAQ,CAAC,KAAK,KACjB,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,IAC5C,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Tooltip } from './Tooltip';
|
|
2
|
+
export type { TooltipProps } from './Tooltip';
|
|
3
|
+
export { TooltipContent } from './TooltipContent';
|
|
4
|
+
export type { TooltipContentProps } from './TooltipContent';
|
|
5
|
+
export { TooltipDelayGroup } from './TooltipDelayGroup';
|
|
6
|
+
export type { TooltipDelayGroupProps } from './TooltipDelayGroup';
|
|
7
|
+
export { TooltipTrigger } from './TooltipTrigger';
|
|
8
|
+
export type { TooltipTriggerProps } from './TooltipTrigger';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { Placement } from '@floating-ui/react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare function getSharedPortalRoot(): HTMLDivElement;
|
|
4
|
+
export declare function releaseSharedPortalRoot(): void;
|
|
5
|
+
export interface TooltipOptions {
|
|
6
|
+
/** Whether the tooltip is initially open (uncontrolled mode) */
|
|
7
|
+
initialOpen?: boolean;
|
|
8
|
+
/** Placement of the tooltip relative to its trigger */
|
|
9
|
+
placement?: Placement;
|
|
10
|
+
/** Controlled open state */
|
|
11
|
+
open?: boolean;
|
|
12
|
+
/** Callback when open state changes (controlled mode) */
|
|
13
|
+
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Hook that manages tooltip state and positioning logic.
|
|
17
|
+
*
|
|
18
|
+
* This hook provides the core tooltip behavior including hover/focus detection,
|
|
19
|
+
* positioning, and accessibility features. Use this when you need full control
|
|
20
|
+
* over the tooltip structure.
|
|
21
|
+
*
|
|
22
|
+
* @example Basic tooltip hook usage
|
|
23
|
+
*
|
|
24
|
+
* Build a custom tooltip implementation using the hook directly for maximum flexibility:
|
|
25
|
+
*
|
|
26
|
+
* ```js
|
|
27
|
+
* function MyComponent() {
|
|
28
|
+
* const tooltip = useTooltip({ placement: 'top' });
|
|
29
|
+
*
|
|
30
|
+
* return (
|
|
31
|
+
* <>
|
|
32
|
+
* <button
|
|
33
|
+
* ref={tooltip.refs.setReference}
|
|
34
|
+
* {...tooltip.getReferenceProps()}
|
|
35
|
+
* >
|
|
36
|
+
* Hover me
|
|
37
|
+
* </button>
|
|
38
|
+
*
|
|
39
|
+
* {tooltip.open && (
|
|
40
|
+
* <div
|
|
41
|
+
* ref={tooltip.refs.setFloating}
|
|
42
|
+
* style={tooltip.floatingStyles}
|
|
43
|
+
* {...tooltip.getFloatingProps()}
|
|
44
|
+
* >
|
|
45
|
+
* Tooltip content
|
|
46
|
+
* </div>
|
|
47
|
+
* )}
|
|
48
|
+
* </>
|
|
49
|
+
* );
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example Controlled tooltip
|
|
54
|
+
*
|
|
55
|
+
* Control the tooltip's open state programmatically for click-to-toggle behavior:
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* function ControlledTooltip() {
|
|
59
|
+
* const [open, setOpen] = React.useState(false);
|
|
60
|
+
* const tooltip = useTooltip({ open, onOpenChange: setOpen });
|
|
61
|
+
*
|
|
62
|
+
* return (
|
|
63
|
+
* <Canvas ctx={ctx}>
|
|
64
|
+
* <button onClick={() => setOpen(!open)}>
|
|
65
|
+
* Toggle tooltip
|
|
66
|
+
* </button>
|
|
67
|
+
* </Canvas>
|
|
68
|
+
* );
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function useTooltip({ initialOpen, placement, open: controlledOpen, onOpenChange: setControlledOpen, }?: TooltipOptions): {
|
|
73
|
+
placement: Placement;
|
|
74
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
75
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
isPositioned: boolean;
|
|
79
|
+
update: () => void;
|
|
80
|
+
floatingStyles: React.CSSProperties;
|
|
81
|
+
refs: {
|
|
82
|
+
reference: React.MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
|
|
83
|
+
floating: React.MutableRefObject<HTMLElement | null>;
|
|
84
|
+
setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
|
|
85
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
86
|
+
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
87
|
+
elements: {
|
|
88
|
+
reference: import("@floating-ui/react-dom").ReferenceType | null;
|
|
89
|
+
floating: HTMLElement | null;
|
|
90
|
+
} & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
91
|
+
context: {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
placement: Placement;
|
|
95
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
96
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
97
|
+
isPositioned: boolean;
|
|
98
|
+
update: () => void;
|
|
99
|
+
floatingStyles: React.CSSProperties;
|
|
100
|
+
open: boolean;
|
|
101
|
+
onOpenChange: (open: boolean, event?: Event | undefined, reason?: import("@floating-ui/react").OpenChangeReason | undefined) => void;
|
|
102
|
+
events: import("@floating-ui/react").FloatingEvents;
|
|
103
|
+
dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
104
|
+
nodeId: string | undefined;
|
|
105
|
+
floatingId: string | undefined;
|
|
106
|
+
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
107
|
+
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
108
|
+
};
|
|
109
|
+
getReferenceProps: (userProps?: React.HTMLProps<Element> | undefined) => Record<string, unknown>;
|
|
110
|
+
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
111
|
+
getItemProps: (userProps?: (Omit<React.HTMLProps<HTMLElement>, "selected" | "active"> & {
|
|
112
|
+
active?: boolean | undefined;
|
|
113
|
+
selected?: boolean | undefined;
|
|
114
|
+
}) | undefined) => Record<string, unknown>;
|
|
115
|
+
open: boolean;
|
|
116
|
+
setOpen: (open: boolean) => void;
|
|
117
|
+
};
|
|
118
|
+
declare type ContextType = ReturnType<typeof useTooltip> | null;
|
|
119
|
+
export declare const TooltipContext: React.Context<ContextType>;
|
|
120
|
+
export declare const useTooltipState: () => {
|
|
121
|
+
placement: Placement;
|
|
122
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
123
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
isPositioned: boolean;
|
|
127
|
+
update: () => void;
|
|
128
|
+
floatingStyles: React.CSSProperties;
|
|
129
|
+
refs: {
|
|
130
|
+
reference: React.MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
|
|
131
|
+
floating: React.MutableRefObject<HTMLElement | null>;
|
|
132
|
+
setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
|
|
133
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
134
|
+
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
135
|
+
elements: {
|
|
136
|
+
reference: import("@floating-ui/react-dom").ReferenceType | null;
|
|
137
|
+
floating: HTMLElement | null;
|
|
138
|
+
} & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
139
|
+
context: {
|
|
140
|
+
x: number;
|
|
141
|
+
y: number;
|
|
142
|
+
placement: Placement;
|
|
143
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
144
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
145
|
+
isPositioned: boolean;
|
|
146
|
+
update: () => void;
|
|
147
|
+
floatingStyles: React.CSSProperties;
|
|
148
|
+
open: boolean;
|
|
149
|
+
onOpenChange: (open: boolean, event?: Event | undefined, reason?: import("@floating-ui/react").OpenChangeReason | undefined) => void;
|
|
150
|
+
events: import("@floating-ui/react").FloatingEvents;
|
|
151
|
+
dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
152
|
+
nodeId: string | undefined;
|
|
153
|
+
floatingId: string | undefined;
|
|
154
|
+
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
155
|
+
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
156
|
+
};
|
|
157
|
+
getReferenceProps: (userProps?: React.HTMLProps<Element> | undefined) => Record<string, unknown>;
|
|
158
|
+
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
159
|
+
getItemProps: (userProps?: (Omit<React.HTMLProps<HTMLElement>, "selected" | "active"> & {
|
|
160
|
+
active?: boolean | undefined;
|
|
161
|
+
selected?: boolean | undefined;
|
|
162
|
+
}) | undefined) => Record<string, unknown>;
|
|
163
|
+
open: boolean;
|
|
164
|
+
setOpen: (open: boolean) => void;
|
|
165
|
+
};
|
|
166
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { autoUpdate, flip, offset, shift, useDelayGroupContext, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, } from '@floating-ui/react';
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
// Create a single shared portal root for all tooltips
|
|
15
|
+
var sharedPortalRoot = null;
|
|
16
|
+
var portalRefCount = 0;
|
|
17
|
+
export function getSharedPortalRoot() {
|
|
18
|
+
if (!sharedPortalRoot) {
|
|
19
|
+
sharedPortalRoot = document.createElement('div');
|
|
20
|
+
sharedPortalRoot.style.position = 'relative';
|
|
21
|
+
sharedPortalRoot.style.zIndex = '100000';
|
|
22
|
+
sharedPortalRoot.style.height = '0px';
|
|
23
|
+
// Insert as the first child of body
|
|
24
|
+
if (document.body.firstChild) {
|
|
25
|
+
document.body.insertBefore(sharedPortalRoot, document.body.firstChild);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
document.body.appendChild(sharedPortalRoot);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
portalRefCount++;
|
|
32
|
+
return sharedPortalRoot;
|
|
33
|
+
}
|
|
34
|
+
export function releaseSharedPortalRoot() {
|
|
35
|
+
portalRefCount--;
|
|
36
|
+
if (portalRefCount === 0 && sharedPortalRoot) {
|
|
37
|
+
if (sharedPortalRoot.parentNode) {
|
|
38
|
+
sharedPortalRoot.parentNode.removeChild(sharedPortalRoot);
|
|
39
|
+
}
|
|
40
|
+
sharedPortalRoot = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hook that manages tooltip state and positioning logic.
|
|
45
|
+
*
|
|
46
|
+
* This hook provides the core tooltip behavior including hover/focus detection,
|
|
47
|
+
* positioning, and accessibility features. Use this when you need full control
|
|
48
|
+
* over the tooltip structure.
|
|
49
|
+
*
|
|
50
|
+
* @example Basic tooltip hook usage
|
|
51
|
+
*
|
|
52
|
+
* Build a custom tooltip implementation using the hook directly for maximum flexibility:
|
|
53
|
+
*
|
|
54
|
+
* ```js
|
|
55
|
+
* function MyComponent() {
|
|
56
|
+
* const tooltip = useTooltip({ placement: 'top' });
|
|
57
|
+
*
|
|
58
|
+
* return (
|
|
59
|
+
* <>
|
|
60
|
+
* <button
|
|
61
|
+
* ref={tooltip.refs.setReference}
|
|
62
|
+
* {...tooltip.getReferenceProps()}
|
|
63
|
+
* >
|
|
64
|
+
* Hover me
|
|
65
|
+
* </button>
|
|
66
|
+
*
|
|
67
|
+
* {tooltip.open && (
|
|
68
|
+
* <div
|
|
69
|
+
* ref={tooltip.refs.setFloating}
|
|
70
|
+
* style={tooltip.floatingStyles}
|
|
71
|
+
* {...tooltip.getFloatingProps()}
|
|
72
|
+
* >
|
|
73
|
+
* Tooltip content
|
|
74
|
+
* </div>
|
|
75
|
+
* )}
|
|
76
|
+
* </>
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @example Controlled tooltip
|
|
82
|
+
*
|
|
83
|
+
* Control the tooltip's open state programmatically for click-to-toggle behavior:
|
|
84
|
+
*
|
|
85
|
+
* ```js
|
|
86
|
+
* function ControlledTooltip() {
|
|
87
|
+
* const [open, setOpen] = React.useState(false);
|
|
88
|
+
* const tooltip = useTooltip({ open, onOpenChange: setOpen });
|
|
89
|
+
*
|
|
90
|
+
* return (
|
|
91
|
+
* <Canvas ctx={ctx}>
|
|
92
|
+
* <button onClick={() => setOpen(!open)}>
|
|
93
|
+
* Toggle tooltip
|
|
94
|
+
* </button>
|
|
95
|
+
* </Canvas>
|
|
96
|
+
* );
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export function useTooltip(_a) {
|
|
101
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.initialOpen, initialOpen = _c === void 0 ? false : _c, _d = _b.placement, placement = _d === void 0 ? 'top' : _d, controlledOpen = _b.open, setControlledOpen = _b.onOpenChange;
|
|
102
|
+
var _e = React.useState(initialOpen), uncontrolledOpen = _e[0], setUncontrolledOpen = _e[1];
|
|
103
|
+
var open = controlledOpen !== null && controlledOpen !== void 0 ? controlledOpen : uncontrolledOpen;
|
|
104
|
+
var setOpen = setControlledOpen !== null && setControlledOpen !== void 0 ? setControlledOpen : setUncontrolledOpen;
|
|
105
|
+
var delay = useDelayGroupContext().delay;
|
|
106
|
+
var data = useFloating({
|
|
107
|
+
placement: placement,
|
|
108
|
+
open: open,
|
|
109
|
+
onOpenChange: setOpen,
|
|
110
|
+
whileElementsMounted: autoUpdate,
|
|
111
|
+
middleware: [offset(5), flip(), shift()],
|
|
112
|
+
});
|
|
113
|
+
var context = data.context;
|
|
114
|
+
var hover = useHover(context, {
|
|
115
|
+
move: false,
|
|
116
|
+
enabled: controlledOpen == null,
|
|
117
|
+
delay: delay,
|
|
118
|
+
});
|
|
119
|
+
var focus = useFocus(context, {
|
|
120
|
+
enabled: controlledOpen == null,
|
|
121
|
+
});
|
|
122
|
+
var dismiss = useDismiss(context);
|
|
123
|
+
var role = useRole(context, { role: 'tooltip' });
|
|
124
|
+
var interactions = useInteractions([hover, focus, dismiss, role]);
|
|
125
|
+
return React.useMemo(function () { return (__assign(__assign({ open: open, setOpen: setOpen }, interactions), data)); }, [open, setOpen, interactions, data]);
|
|
126
|
+
}
|
|
127
|
+
export var TooltipContext = React.createContext(null);
|
|
128
|
+
export var useTooltipState = function () {
|
|
129
|
+
var context = React.useContext(TooltipContext);
|
|
130
|
+
if (context == null) {
|
|
131
|
+
throw new Error('Tooltip components must be wrapped in <Tooltip />');
|
|
132
|
+
}
|
|
133
|
+
return context;
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=utils.js.map
|