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.
Files changed (126) hide show
  1. package/dist/cjs/HotKey/index.js +105 -0
  2. package/dist/cjs/HotKey/index.js.map +1 -0
  3. package/dist/cjs/HotKey/styles.module.css.json +1 -0
  4. package/dist/cjs/SplitView/SplitViewPane/index.js +14 -0
  5. package/dist/cjs/SplitView/SplitViewPane/index.js.map +1 -0
  6. package/dist/cjs/SplitView/SplitViewPane/styles.module.css.json +1 -0
  7. package/dist/cjs/SplitView/SplitViewSash/index.js +76 -0
  8. package/dist/cjs/SplitView/SplitViewSash/index.js.map +1 -0
  9. package/dist/cjs/SplitView/SplitViewSash/styles.module.css.json +1 -0
  10. package/dist/cjs/SplitView/index.js +206 -0
  11. package/dist/cjs/SplitView/index.js.map +1 -0
  12. package/dist/cjs/SplitView/styles.module.css.json +1 -0
  13. package/dist/cjs/SplitView/types.js +3 -0
  14. package/dist/cjs/SplitView/types.js.map +1 -0
  15. package/dist/cjs/Tooltip/Tooltip/index.js +116 -0
  16. package/dist/cjs/Tooltip/Tooltip/index.js.map +1 -0
  17. package/dist/cjs/Tooltip/TooltipContent/index.js +147 -0
  18. package/dist/cjs/Tooltip/TooltipContent/index.js.map +1 -0
  19. package/dist/cjs/Tooltip/TooltipContent/styles.module.css.json +1 -0
  20. package/dist/cjs/Tooltip/TooltipDelayGroup/index.js +140 -0
  21. package/dist/cjs/Tooltip/TooltipDelayGroup/index.js.map +1 -0
  22. package/dist/cjs/Tooltip/TooltipTrigger/index.js +102 -0
  23. package/dist/cjs/Tooltip/TooltipTrigger/index.js.map +1 -0
  24. package/dist/cjs/Tooltip/index.js +12 -0
  25. package/dist/cjs/Tooltip/index.js.map +1 -0
  26. package/dist/cjs/Tooltip/utils.js +165 -0
  27. package/dist/cjs/Tooltip/utils.js.map +1 -0
  28. package/dist/cjs/VerticalSplit/index.js +337 -0
  29. package/dist/cjs/VerticalSplit/index.js.map +1 -0
  30. package/dist/cjs/VerticalSplit/styles.module.css.json +1 -0
  31. package/dist/cjs/icons.js +19 -1
  32. package/dist/cjs/icons.js.map +1 -1
  33. package/dist/cjs/index.js +7 -3
  34. package/dist/cjs/index.js.map +1 -1
  35. package/dist/esm/HotKey/index.d.ts +70 -0
  36. package/dist/esm/HotKey/index.js +75 -0
  37. package/dist/esm/HotKey/index.js.map +1 -0
  38. package/dist/esm/HotKey/styles.module.css.json +1 -0
  39. package/dist/esm/SplitView/SplitViewPane/index.d.ts +7 -0
  40. package/dist/esm/SplitView/SplitViewPane/index.js +7 -0
  41. package/dist/esm/SplitView/SplitViewPane/index.js.map +1 -0
  42. package/dist/esm/SplitView/SplitViewPane/styles.module.css.json +1 -0
  43. package/dist/esm/SplitView/SplitViewSash/index.d.ts +17 -0
  44. package/dist/esm/SplitView/SplitViewSash/index.js +46 -0
  45. package/dist/esm/SplitView/SplitViewSash/index.js.map +1 -0
  46. package/dist/esm/SplitView/SplitViewSash/styles.module.css.json +1 -0
  47. package/dist/esm/SplitView/index.d.ts +16 -0
  48. package/dist/esm/SplitView/index.js +176 -0
  49. package/dist/esm/SplitView/index.js.map +1 -0
  50. package/dist/esm/SplitView/styles.module.css.json +1 -0
  51. package/dist/esm/SplitView/types.d.ts +8 -0
  52. package/dist/esm/SplitView/types.js +2 -0
  53. package/dist/esm/SplitView/types.js.map +1 -0
  54. package/dist/esm/Tooltip/Tooltip/index.d.ts +74 -0
  55. package/dist/esm/Tooltip/Tooltip/index.js +89 -0
  56. package/dist/esm/Tooltip/Tooltip/index.js.map +1 -0
  57. package/dist/esm/Tooltip/TooltipContent/index.d.ts +68 -0
  58. package/dist/esm/Tooltip/TooltipContent/index.js +118 -0
  59. package/dist/esm/Tooltip/TooltipContent/index.js.map +1 -0
  60. package/dist/esm/Tooltip/TooltipContent/styles.module.css.json +1 -0
  61. package/dist/esm/Tooltip/TooltipDelayGroup/index.d.ts +118 -0
  62. package/dist/esm/Tooltip/TooltipDelayGroup/index.js +113 -0
  63. package/dist/esm/Tooltip/TooltipDelayGroup/index.js.map +1 -0
  64. package/dist/esm/Tooltip/TooltipTrigger/index.d.ts +45 -0
  65. package/dist/esm/Tooltip/TooltipTrigger/index.js +76 -0
  66. package/dist/esm/Tooltip/TooltipTrigger/index.js.map +1 -0
  67. package/dist/esm/Tooltip/index.d.ts +8 -0
  68. package/dist/esm/Tooltip/index.js +5 -0
  69. package/dist/esm/Tooltip/index.js.map +1 -0
  70. package/dist/esm/Tooltip/utils.d.ts +166 -0
  71. package/dist/esm/Tooltip/utils.js +135 -0
  72. package/dist/esm/Tooltip/utils.js.map +1 -0
  73. package/dist/esm/VerticalSplit/index.d.ts +238 -0
  74. package/dist/esm/VerticalSplit/index.js +307 -0
  75. package/dist/esm/VerticalSplit/index.js.map +1 -0
  76. package/dist/esm/VerticalSplit/styles.module.css.json +1 -0
  77. package/dist/esm/icons.d.ts +3 -0
  78. package/dist/esm/icons.js +15 -0
  79. package/dist/esm/icons.js.map +1 -1
  80. package/dist/esm/index.d.ts +7 -3
  81. package/dist/esm/index.js +7 -3
  82. package/dist/esm/index.js.map +1 -1
  83. package/dist/types/HotKey/index.d.ts +70 -0
  84. package/dist/types/SplitView/SplitViewPane/index.d.ts +7 -0
  85. package/dist/types/SplitView/SplitViewSash/index.d.ts +17 -0
  86. package/dist/types/SplitView/index.d.ts +16 -0
  87. package/dist/types/SplitView/types.d.ts +8 -0
  88. package/dist/types/Tooltip/Tooltip/index.d.ts +74 -0
  89. package/dist/types/Tooltip/TooltipContent/index.d.ts +68 -0
  90. package/dist/types/Tooltip/TooltipDelayGroup/index.d.ts +118 -0
  91. package/dist/types/Tooltip/TooltipTrigger/index.d.ts +45 -0
  92. package/dist/types/Tooltip/index.d.ts +8 -0
  93. package/dist/types/Tooltip/utils.d.ts +166 -0
  94. package/dist/types/VerticalSplit/index.d.ts +238 -0
  95. package/dist/types/icons.d.ts +3 -0
  96. package/dist/types/index.d.ts +7 -3
  97. package/package.json +4 -3
  98. package/src/HotKey/index.tsx +95 -0
  99. package/src/HotKey/styles.module.css +22 -0
  100. package/src/HotKey/styles.module.css.json +1 -0
  101. package/src/SplitView/SplitViewPane/index.tsx +19 -0
  102. package/src/SplitView/SplitViewPane/styles.module.css +6 -0
  103. package/src/SplitView/SplitViewPane/styles.module.css.json +1 -0
  104. package/src/SplitView/SplitViewSash/index.tsx +99 -0
  105. package/src/SplitView/SplitViewSash/styles.module.css +68 -0
  106. package/src/SplitView/SplitViewSash/styles.module.css.json +1 -0
  107. package/src/SplitView/index.tsx +256 -0
  108. package/src/SplitView/styles.module.css +22 -0
  109. package/src/SplitView/styles.module.css.json +1 -0
  110. package/src/SplitView/types.ts +9 -0
  111. package/src/Tooltip/Tooltip/index.tsx +85 -0
  112. package/src/Tooltip/TooltipContent/index.tsx +145 -0
  113. package/src/Tooltip/TooltipContent/styles.module.css +10 -0
  114. package/src/Tooltip/TooltipContent/styles.module.css.json +1 -0
  115. package/src/Tooltip/TooltipDelayGroup/index.tsx +128 -0
  116. package/src/Tooltip/TooltipTrigger/index.tsx +71 -0
  117. package/src/Tooltip/index.ts +8 -0
  118. package/src/Tooltip/utils.ts +176 -0
  119. package/src/VerticalSplit/index.tsx +401 -0
  120. package/src/VerticalSplit/styles.module.css +103 -0
  121. package/src/VerticalSplit/styles.module.css.json +1 -0
  122. package/src/global.css +31 -25
  123. package/src/icons.tsx +60 -0
  124. package/src/index.ts +7 -3
  125. package/styles.css +1 -1
  126. package/types.json +6126 -3451
@@ -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,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,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,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,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,7 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ export declare type SplitViewPaneProps = {
3
+ maxSize?: number | string;
4
+ minSize?: number | string;
5
+ style?: React.CSSProperties;
6
+ };
7
+ export declare function SplitViewPane({ style, children, }: PropsWithChildren<SplitViewPaneProps>): JSX.Element;
@@ -0,0 +1,17 @@
1
+ import React, { ReactNode } from 'react';
2
+ export declare type SashAction = {
3
+ icon: ReactNode;
4
+ onClick: () => void;
5
+ };
6
+ declare type SplitViewSashProps = {
7
+ className?: string;
8
+ style: React.CSSProperties;
9
+ split: 'vertical' | 'horizontal';
10
+ allowResize?: boolean;
11
+ action?: SashAction;
12
+ onMouseDown: (x: number, y: number) => void;
13
+ onMouseMove: (x: number, y: number) => void;
14
+ onMouseUp: () => void;
15
+ };
16
+ export declare function SplitViewSash({ onMouseDown, onMouseMove, onMouseUp, style, split, allowResize, action, }: SplitViewSashProps): JSX.Element;
17
+ export {};
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { SashAction } from './SplitViewSash';
3
+ declare type SplitViewProps = {
4
+ children: JSX.Element[];
5
+ allowResize?: boolean;
6
+ split?: 'vertical' | 'horizontal';
7
+ sizes: (string | number)[];
8
+ onChange: (sizes: number[]) => void;
9
+ onDragStart?: () => void;
10
+ onDragEnd?: () => void;
11
+ performanceMode?: boolean;
12
+ resizerSize?: number;
13
+ sashAction?: SashAction;
14
+ };
15
+ export declare const SplitView: ({ children, sizes: propSizes, allowResize, split, resizerSize, performanceMode, onChange, onDragStart, onDragEnd, sashAction, }: SplitViewProps) => JSX.Element;
16
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare type IAxis = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ export declare type ICacheSizes = {
6
+ sizes: (string | number)[];
7
+ sashPosSizes: (string | number)[];
8
+ };
@@ -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>>;
@@ -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,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,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,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 {};