datocms-react-ui 2.0.16 → 2.0.18
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/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/TooltipTrigger/index.js +102 -0
- package/dist/cjs/Tooltip/TooltipTrigger/index.js.map +1 -0
- package/dist/cjs/Tooltip/index.js +10 -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/index.js +2 -0
- 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/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/TooltipTrigger/index.d.ts +43 -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 +6 -0
- package/dist/esm/Tooltip/index.js +4 -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/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/HotKey/index.d.ts +70 -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/TooltipTrigger/index.d.ts +43 -0
- package/dist/types/Tooltip/index.d.ts +6 -0
- package/dist/types/Tooltip/utils.d.ts +166 -0
- package/dist/types/index.d.ts +2 -0
- 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/Tooltip/Tooltip/index.tsx +85 -0
- package/src/Tooltip/TooltipContent/index.tsx +140 -0
- package/src/Tooltip/TooltipContent/styles.module.css +10 -0
- package/src/Tooltip/TooltipContent/styles.module.css.json +1 -0
- package/src/Tooltip/TooltipTrigger/index.tsx +68 -0
- package/src/Tooltip/index.ts +6 -0
- package/src/Tooltip/utils.ts +176 -0
- package/src/global.css +2 -0
- package/src/index.ts +2 -0
- package/styles.css +1 -1
- package/types.json +7549 -1770
|
@@ -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 * as React from 'react';
|
|
24
|
+
import { useMergeRefs } from '@floating-ui/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,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,IAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAC5C,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;AACF,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Tooltip } from './Tooltip';
|
|
2
|
+
export type { TooltipProps } from './Tooltip';
|
|
3
|
+
export { TooltipContent } from './TooltipContent';
|
|
4
|
+
export type { TooltipContentProps } from './TooltipContent';
|
|
5
|
+
export { TooltipTrigger } from './TooltipTrigger';
|
|
6
|
+
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,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/Tooltip/utils.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,MAAM,EACN,KAAK,EACL,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,sDAAsD;AACtD,IAAI,gBAAgB,GAA0B,IAAI,CAAC;AACnD,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACjD,gBAAgB,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;QAC7C,gBAAgB,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC;QACzC,gBAAgB,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;QAEtC,oCAAoC;QACpC,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE;YAC5B,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACxE;aAAM;YACL,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;SAC7C;KACF;IACD,cAAc,EAAE,CAAC;IACjB,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,cAAc,EAAE,CAAC;IACjB,IAAI,cAAc,KAAK,CAAC,IAAI,gBAAgB,EAAE;QAC5C,IAAI,gBAAgB,CAAC,UAAU,EAAE;YAC/B,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;SAC3D;QACD,gBAAgB,GAAG,IAAI,CAAC;KACzB;AACH,CAAC;AAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,UAAU,UAAU,CAAC,EAKL;QALK,qBAKP,EAAE,KAAA,EAJpB,mBAAmB,EAAnB,WAAW,mBAAG,KAAK,KAAA,EACnB,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,EACX,cAAc,UAAA,EACN,iBAAiB,kBAAA;IAEzB,IAAA,KAA0C,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAApE,gBAAgB,QAAA,EAAE,mBAAmB,QAA+B,CAAC;IAE5E,IAAM,IAAI,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,gBAAgB,CAAC;IAChD,IAAM,OAAO,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,mBAAmB,CAAC;IAEjD,IAAA,KAAK,GAAK,oBAAoB,EAAE,MAA3B,CAA4B;IAEzC,IAAM,IAAI,GAAG,WAAW,CAAC;QACvB,SAAS,WAAA;QACT,IAAI,MAAA;QACJ,YAAY,EAAE,OAAO;QACrB,oBAAoB,EAAE,UAAU;QAChC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC;KACzC,CAAC,CAAC;IAEH,IAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAE7B,IAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE;QAC9B,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,cAAc,IAAI,IAAI;QAC/B,KAAK,OAAA;KACN,CAAC,CAAC;IACH,IAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE;QAC9B,OAAO,EAAE,cAAc,IAAI,IAAI;KAChC,CAAC,CAAC;IACH,IAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAEnD,IAAM,YAAY,GAAG,eAAe,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpE,OAAO,KAAK,CAAC,OAAO,CAClB,cAAM,OAAA,qBACJ,IAAI,MAAA,EACJ,OAAO,SAAA,IACJ,YAAY,GACZ,IAAI,EACP,EALI,CAKJ,EACF,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CACpC,CAAC;AACJ,CAAC;AAID,MAAM,CAAC,IAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAc,IAAI,CAAC,CAAC;AAErE,MAAM,CAAC,IAAM,eAAe,GAAG;IAC7B,IAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAEjD,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './FieldHint';
|
|
|
9
9
|
export * from './FieldWrapper';
|
|
10
10
|
export * from './Form';
|
|
11
11
|
export * from './FormLabel';
|
|
12
|
+
export * from './HotKey';
|
|
12
13
|
export * from './icons';
|
|
13
14
|
export * from './Section';
|
|
14
15
|
export * from './SelectField';
|
|
@@ -23,6 +24,7 @@ export * from './TextareaInput';
|
|
|
23
24
|
export * from './TextField';
|
|
24
25
|
export * from './TextInput';
|
|
25
26
|
export * from './Toolbar';
|
|
27
|
+
export * from './Tooltip';
|
|
26
28
|
export * from './useClickOutside';
|
|
27
29
|
export * from './useMediaQuery';
|
|
28
30
|
export * from './VerticalSplit';
|
package/dist/esm/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './FieldHint';
|
|
|
9
9
|
export * from './FieldWrapper';
|
|
10
10
|
export * from './Form';
|
|
11
11
|
export * from './FormLabel';
|
|
12
|
+
export * from './HotKey';
|
|
12
13
|
export * from './icons';
|
|
13
14
|
export * from './Section';
|
|
14
15
|
export * from './SelectField';
|
|
@@ -23,6 +24,7 @@ export * from './TextareaInput';
|
|
|
23
24
|
export * from './TextField';
|
|
24
25
|
export * from './TextInput';
|
|
25
26
|
export * from './Toolbar';
|
|
27
|
+
export * from './Tooltip';
|
|
26
28
|
export * from './useClickOutside';
|
|
27
29
|
export * from './useMediaQuery';
|
|
28
30
|
export * from './VerticalSplit';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type HotKeyProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Keyboard shortcut string. Use "mod" for platform-specific modifier (Cmd on Mac, Ctrl elsewhere).
|
|
5
|
+
* Separate keys with "+". Examples: "mod+s", "mod+shift+p", "alt+enter"
|
|
6
|
+
*/
|
|
7
|
+
hotkey: string;
|
|
8
|
+
/** Optional label to display before the key combination */
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* HotKey component displays keyboard shortcuts in a platform-aware format.
|
|
13
|
+
*
|
|
14
|
+
* The component automatically detects the user's platform and renders appropriate
|
|
15
|
+
* modifier key symbols (⌘ for Mac, Ctrl for Windows/Linux).
|
|
16
|
+
*
|
|
17
|
+
* @example Basic usage
|
|
18
|
+
*
|
|
19
|
+
* Display a simple keyboard shortcut without a label:
|
|
20
|
+
*
|
|
21
|
+
* ```js
|
|
22
|
+
* <Canvas ctx={ctx}>
|
|
23
|
+
* <HotKey hotkey="mod+s" />
|
|
24
|
+
* </Canvas>;
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example With label
|
|
28
|
+
*
|
|
29
|
+
* Include a descriptive label to explain what the keyboard shortcut does:
|
|
30
|
+
*
|
|
31
|
+
* ```js
|
|
32
|
+
* <Canvas ctx={ctx}>
|
|
33
|
+
* <HotKey hotkey="mod+s" label="Save" />
|
|
34
|
+
* </Canvas>;
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example Multiple hotkeys
|
|
38
|
+
*
|
|
39
|
+
* Display a list of keyboard shortcuts with labels for documenting available commands:
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* <Canvas ctx={ctx}>
|
|
43
|
+
* <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-m)' }}>
|
|
44
|
+
* <HotKey hotkey="mod+c" label="Copy" />
|
|
45
|
+
* <HotKey hotkey="mod+v" label="Paste" />
|
|
46
|
+
* <HotKey hotkey="mod+shift+z" label="Redo" />
|
|
47
|
+
* <HotKey hotkey="alt+enter" label="Submit" />
|
|
48
|
+
* </div>
|
|
49
|
+
* </Canvas>;
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example Platform-specific rendering
|
|
53
|
+
*
|
|
54
|
+
* The component automatically adapts modifier keys based on the user's platform:
|
|
55
|
+
* - `mod` renders as `⌘` on Mac and `Ctrl` on Windows/Linux
|
|
56
|
+
* - `alt` renders as `⌥` on Mac and `Alt` on Windows/Linux
|
|
57
|
+
*
|
|
58
|
+
* This ensures the correct symbols are displayed for the user's operating system:
|
|
59
|
+
*
|
|
60
|
+
* ```js
|
|
61
|
+
* <Canvas ctx={ctx}>
|
|
62
|
+
* <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-m)' }}>
|
|
63
|
+
* <HotKey hotkey="mod+k" label="Open command palette" />
|
|
64
|
+
* <HotKey hotkey="alt+enter" label="Submit form" />
|
|
65
|
+
* <HotKey hotkey="mod+alt+f" label="Find and replace" />
|
|
66
|
+
* </div>
|
|
67
|
+
* </Canvas>;
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function HotKey({ hotkey, label }: HotKeyProps): JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TooltipOptions } from '../utils';
|
|
3
|
+
export declare type TooltipProps = {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
} & TooltipOptions;
|
|
6
|
+
/**
|
|
7
|
+
* Tooltip wrapper component that provides context for TooltipTrigger and TooltipContent.
|
|
8
|
+
*
|
|
9
|
+
* This is a compound component pattern. The Tooltip component itself doesn't render anything,
|
|
10
|
+
* but provides the necessary context for its children (TooltipTrigger and TooltipContent).
|
|
11
|
+
*
|
|
12
|
+
* @example Basic tooltip
|
|
13
|
+
*
|
|
14
|
+
* Create a simple tooltip that appears when hovering over a button:
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* <Canvas ctx={ctx}>
|
|
18
|
+
* <Tooltip>
|
|
19
|
+
* <TooltipTrigger>
|
|
20
|
+
* <Button>Hover me</Button>
|
|
21
|
+
* </TooltipTrigger>
|
|
22
|
+
* <TooltipContent>
|
|
23
|
+
* This is helpful information!
|
|
24
|
+
* </TooltipContent>
|
|
25
|
+
* </Tooltip>
|
|
26
|
+
* </Canvas>;
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Tooltip with custom placement
|
|
30
|
+
*
|
|
31
|
+
* Control where the tooltip appears relative to its trigger using the `placement` prop:
|
|
32
|
+
*
|
|
33
|
+
* ```js
|
|
34
|
+
* <Canvas ctx={ctx}>
|
|
35
|
+
* <Tooltip placement="right">
|
|
36
|
+
* <TooltipTrigger>
|
|
37
|
+
* <Button>Right tooltip</Button>
|
|
38
|
+
* </TooltipTrigger>
|
|
39
|
+
* <TooltipContent>
|
|
40
|
+
* Appears on the right side
|
|
41
|
+
* </TooltipContent>
|
|
42
|
+
* </Tooltip>
|
|
43
|
+
* </Canvas>;
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example Multiple tooltips
|
|
47
|
+
*
|
|
48
|
+
* Use multiple tooltips on the same page to provide contextual help for different actions:
|
|
49
|
+
*
|
|
50
|
+
* ```js
|
|
51
|
+
* <Canvas ctx={ctx}>
|
|
52
|
+
* <div style={{ display: 'flex', gap: 'var(--spacing-m)' }}>
|
|
53
|
+
* <Tooltip>
|
|
54
|
+
* <TooltipTrigger>
|
|
55
|
+
* <Button leftIcon={<SaveIcon />} />
|
|
56
|
+
* </TooltipTrigger>
|
|
57
|
+
* <TooltipContent>
|
|
58
|
+
* Save changes (⌘S)
|
|
59
|
+
* </TooltipContent>
|
|
60
|
+
* </Tooltip>
|
|
61
|
+
*
|
|
62
|
+
* <Tooltip>
|
|
63
|
+
* <TooltipTrigger>
|
|
64
|
+
* <Button leftIcon={<DeleteIcon />} />
|
|
65
|
+
* </TooltipTrigger>
|
|
66
|
+
* <TooltipContent>
|
|
67
|
+
* Delete item
|
|
68
|
+
* </TooltipContent>
|
|
69
|
+
* </Tooltip>
|
|
70
|
+
* </div>
|
|
71
|
+
* </Canvas>;
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function Tooltip({ children, ...options }: TooltipProps): JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare type TooltipContentProps = {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* TooltipContent contains the content displayed in the floating tooltip.
|
|
7
|
+
*
|
|
8
|
+
* The content is automatically wrapped in a Canvas component to inherit the DatoCMS
|
|
9
|
+
* theme and styling. The tooltip uses a portal to render outside the normal DOM
|
|
10
|
+
* hierarchy, ensuring proper positioning and z-index stacking.
|
|
11
|
+
*
|
|
12
|
+
* @example Simple text tooltip
|
|
13
|
+
*
|
|
14
|
+
* Display plain text in a tooltip to provide helpful information:
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* <Canvas ctx={ctx}>
|
|
18
|
+
* <Tooltip>
|
|
19
|
+
* <TooltipTrigger>
|
|
20
|
+
* <Button>Delete</Button>
|
|
21
|
+
* </TooltipTrigger>
|
|
22
|
+
* <TooltipContent>
|
|
23
|
+
* This action cannot be undone
|
|
24
|
+
* </TooltipContent>
|
|
25
|
+
* </Tooltip>
|
|
26
|
+
* </Canvas>;
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Rich content tooltip
|
|
30
|
+
*
|
|
31
|
+
* Include formatted content with custom styles for more detailed information:
|
|
32
|
+
*
|
|
33
|
+
* ```js
|
|
34
|
+
* <Canvas ctx={ctx}>
|
|
35
|
+
* <Tooltip placement="right">
|
|
36
|
+
* <TooltipTrigger>
|
|
37
|
+
* <Button leftIcon={<HelpIcon />}>Help</Button>
|
|
38
|
+
* </TooltipTrigger>
|
|
39
|
+
* <TooltipContent>
|
|
40
|
+
* <div>
|
|
41
|
+
* <strong>Need assistance?</strong>
|
|
42
|
+
* <p style={{ margin: '5px 0 0 0', fontSize: 'var(--font-size-xs)' }}>
|
|
43
|
+
* Contact support@example.com
|
|
44
|
+
* </p>
|
|
45
|
+
* </div>
|
|
46
|
+
* </TooltipContent>
|
|
47
|
+
* </Tooltip>
|
|
48
|
+
* </Canvas>;
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example Tooltip with keyboard shortcut
|
|
52
|
+
*
|
|
53
|
+
* Combine tooltips with the HotKey component to show keyboard shortcuts:
|
|
54
|
+
*
|
|
55
|
+
* ```js
|
|
56
|
+
* <Canvas ctx={ctx}>
|
|
57
|
+
* <Tooltip>
|
|
58
|
+
* <TooltipTrigger>
|
|
59
|
+
* <Button leftIcon={<SaveIcon />}>Save</Button>
|
|
60
|
+
* </TooltipTrigger>
|
|
61
|
+
* <TooltipContent>
|
|
62
|
+
* <HotKey hotkey="mod+s" label="Save changes" />
|
|
63
|
+
* </TooltipContent>
|
|
64
|
+
* </Tooltip>
|
|
65
|
+
* </Canvas>;
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare const TooltipContent: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
|