@neo4j-ndl/react 4.16.7 → 4.16.9
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/lib/cjs/color-picker/ColorPicker.js +3 -1
- package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
- package/lib/cjs/color-picker/stories/color-picker-dialog.story.js +40 -0
- package/lib/cjs/color-picker/stories/color-picker-dialog.story.js.map +1 -0
- package/lib/cjs/color-picker/stories/color-picker-popover.story.js +32 -0
- package/lib/cjs/color-picker/stories/color-picker-popover.story.js.map +1 -0
- package/lib/cjs/color-picker/stories/index.js +9 -1
- package/lib/cjs/color-picker/stories/index.js.map +1 -1
- package/lib/cjs/popover/use-popover.js +1 -1
- package/lib/cjs/popover/use-popover.js.map +1 -1
- package/lib/cjs/select/Select.js +2 -0
- package/lib/cjs/select/Select.js.map +1 -1
- package/lib/esm/color-picker/ColorPicker.js +3 -1
- package/lib/esm/color-picker/ColorPicker.js.map +1 -1
- package/lib/esm/color-picker/stories/color-picker-dialog.story.js +38 -0
- package/lib/esm/color-picker/stories/color-picker-dialog.story.js.map +1 -0
- package/lib/esm/color-picker/stories/color-picker-popover.story.js +30 -0
- package/lib/esm/color-picker/stories/color-picker-popover.story.js.map +1 -0
- package/lib/esm/color-picker/stories/index.js +6 -0
- package/lib/esm/color-picker/stories/index.js.map +1 -1
- package/lib/esm/popover/use-popover.js +1 -1
- package/lib/esm/popover/use-popover.js.map +1 -1
- package/lib/esm/select/Select.js +2 -0
- package/lib/esm/select/Select.js.map +1 -1
- package/lib/types/color-picker/ColorPicker.d.ts +4 -0
- package/lib/types/color-picker/ColorPicker.d.ts.map +1 -1
- package/lib/types/color-picker/stories/color-picker-dialog.story.d.ts +24 -0
- package/lib/types/color-picker/stories/color-picker-dialog.story.d.ts.map +1 -0
- package/lib/types/color-picker/stories/color-picker-popover.story.d.ts +24 -0
- package/lib/types/color-picker/stories/color-picker-popover.story.d.ts.map +1 -0
- package/lib/types/color-picker/stories/index.d.ts +4 -0
- package/lib/types/color-picker/stories/index.d.ts.map +1 -1
- package/lib/types/select/Select.d.ts.map +1 -1
- package/package.json +5 -2
- package/skills/ndl-react/SKILL.md +152 -0
- package/skills/ndl-react/components/accordion.md +386 -0
- package/skills/ndl-react/components/ai/code-preview.md +128 -0
- package/skills/ndl-react/components/ai/file-tag.md +90 -0
- package/skills/ndl-react/components/ai/image-tag.md +91 -0
- package/skills/ndl-react/components/ai/more-files.md +73 -0
- package/skills/ndl-react/components/ai/presence.md +54 -0
- package/skills/ndl-react/components/ai/preview.md +498 -0
- package/skills/ndl-react/components/ai/prompt.md +362 -0
- package/skills/ndl-react/components/ai/reasoning.md +95 -0
- package/skills/ndl-react/components/ai/response.md +1109 -0
- package/skills/ndl-react/components/ai/suggestion.md +84 -0
- package/skills/ndl-react/components/ai/thinking.md +43 -0
- package/skills/ndl-react/components/ai/tool-call.md +43 -0
- package/skills/ndl-react/components/ai/user-bubble.md +187 -0
- package/skills/ndl-react/components/avatar.md +169 -0
- package/skills/ndl-react/components/banner.md +225 -0
- package/skills/ndl-react/components/box.md +39 -0
- package/skills/ndl-react/components/breadcrumbs.md +245 -0
- package/skills/ndl-react/components/checkbox.md +269 -0
- package/skills/ndl-react/components/clean-icon-button.md +294 -0
- package/skills/ndl-react/components/clipboard-button.md +154 -0
- package/skills/ndl-react/components/code-block.md +276 -0
- package/skills/ndl-react/components/code.md +68 -0
- package/skills/ndl-react/components/color-picker.md +131 -0
- package/skills/ndl-react/components/conditional-wrap.md +46 -0
- package/skills/ndl-react/components/data-grid.md +3121 -0
- package/skills/ndl-react/components/date-picker.md +652 -0
- package/skills/ndl-react/components/dialog.md +485 -0
- package/skills/ndl-react/components/dismissible-tag.md +136 -0
- package/skills/ndl-react/components/divider.md +96 -0
- package/skills/ndl-react/components/drawer.md +543 -0
- package/skills/ndl-react/components/dropdown-button.md +161 -0
- package/skills/ndl-react/components/dropzone.md +371 -0
- package/skills/ndl-react/components/filled-button.md +26 -0
- package/skills/ndl-react/components/flex.md +82 -0
- package/skills/ndl-react/components/graph-label.md +167 -0
- package/skills/ndl-react/components/icon-button-array.md +187 -0
- package/skills/ndl-react/components/icon-button.md +193 -0
- package/skills/ndl-react/components/inline-edit.md +209 -0
- package/skills/ndl-react/components/kbd.md +63 -0
- package/skills/ndl-react/components/loading-bar.md +43 -0
- package/skills/ndl-react/components/loading-spinner.md +57 -0
- package/skills/ndl-react/components/logo.md +57 -0
- package/skills/ndl-react/components/menu.md +993 -0
- package/skills/ndl-react/components/modal.md +27 -0
- package/skills/ndl-react/components/next/tree-view.md +966 -0
- package/skills/ndl-react/components/outlined-button.md +26 -0
- package/skills/ndl-react/components/popover.md +283 -0
- package/skills/ndl-react/components/progress-bar.md +70 -0
- package/skills/ndl-react/components/radio.md +150 -0
- package/skills/ndl-react/components/read-only-tag.md +96 -0
- package/skills/ndl-react/components/segmented-control.md +200 -0
- package/skills/ndl-react/components/select-icon-button.md +183 -0
- package/skills/ndl-react/components/select.md +530 -0
- package/skills/ndl-react/components/selectable-tag.md +203 -0
- package/skills/ndl-react/components/side-navigation.md +652 -0
- package/skills/ndl-react/components/skeleton.md +274 -0
- package/skills/ndl-react/components/slider.md +308 -0
- package/skills/ndl-react/components/spotlight.md +796 -0
- package/skills/ndl-react/components/status-indicator.md +57 -0
- package/skills/ndl-react/components/status-label.md +132 -0
- package/skills/ndl-react/components/switch.md +167 -0
- package/skills/ndl-react/components/tabs.md +433 -0
- package/skills/ndl-react/components/tag.md +91 -0
- package/skills/ndl-react/components/text-area.md +178 -0
- package/skills/ndl-react/components/text-button.md +25 -0
- package/skills/ndl-react/components/text-input.md +475 -0
- package/skills/ndl-react/components/text-link.md +119 -0
- package/skills/ndl-react/components/time-picker.md +137 -0
- package/skills/ndl-react/components/timezone-picker.md +496 -0
- package/skills/ndl-react/components/tooltip.md +478 -0
- package/skills/ndl-react/components/tree-view.md +545 -0
- package/skills/ndl-react/components/typography.md +72 -0
- package/skills/ndl-react/components/wizard.md +152 -0
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
Import: `import { Tooltip } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Tooltip
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `autoUpdateOptions` | `AutoUpdateOptions` | | | |
|
|
12
|
+
| `children` | `ReactNode` | ✅ | | Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts |
|
|
13
|
+
| `floatingStrategy` | `'absolute' \| 'fixed'` | | | Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` |
|
|
14
|
+
| `followCursor` | `boolean` | | | Whether the tooltip should follow the mouse cursor. Only applies to 'simple' tooltips with mouse hover. |
|
|
15
|
+
| `hoverDelay` | `{ open: number; close: number; }` | | | Hover open/close delays in milliseconds |
|
|
16
|
+
| `isDisabled` | `boolean` | | `false` | Whether the tooltip is disabled |
|
|
17
|
+
| `isInitialOpen` | `boolean` | | | Whether the tooltip should be open on first render |
|
|
18
|
+
| `isOpen` | `boolean` | | | Controls the open state . If omitted, the tooltip manages its own state |
|
|
19
|
+
| `isPortaled` | `boolean` | | | Whether the content is rendered in a portal. |
|
|
20
|
+
| `onOpenChange` | `((open: boolean, event?: Event, reason?: OpenChangeReason) => void) \| undefined` | | | Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks |
|
|
21
|
+
| `placement` | `'bottom-end' \| 'bottom-start' \| 'bottom' \| 'left-end' \| 'left-start' \| 'left' \| 'right-end' \| 'right-start' \| 'right' \| 'top-end' \| 'top-start' \| 'top'` | | | Placement of the tooltip content relative to the trigger |
|
|
22
|
+
| `shouldCloseOnReferenceClick` | `boolean` | | | Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. |
|
|
23
|
+
| `type` | `'rich' \| 'simple'` | ✅ | | Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel @deprecated rich type will be removed in v5, use simple type instead. |
|
|
24
|
+
|
|
25
|
+
### Tooltip.Actions
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Required | Default | Description |
|
|
28
|
+
|------|------|----------|---------|-------------|
|
|
29
|
+
| `children` | `ReactNode` | ✅ | | Content displayed inside the actions container |
|
|
30
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
31
|
+
|
|
32
|
+
### Tooltip.Body
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Required | Default | Description |
|
|
35
|
+
|------|------|----------|---------|-------------|
|
|
36
|
+
| `children` | `ReactNode` | ✅ | | Content displayed inside the body |
|
|
37
|
+
| `passThroughProps` | `Partial<Omit<TypographyProps & { as?: ElementType<any, keyof IntrinsicElements>; } & BaseProps<ElementType<any, keyof IntrinsicElements>>, "ref">>` | | | Additional props to pass to the Typography component |
|
|
38
|
+
| `ref` | `Ref<HTMLSpanElement>` | | | A ref to apply to the root element. |
|
|
39
|
+
|
|
40
|
+
### Tooltip.Content
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Required | Default | Description |
|
|
43
|
+
|------|------|----------|---------|-------------|
|
|
44
|
+
| `children` | `ReactNode` | ✅ | | Content displayed inside the tooltip |
|
|
45
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
46
|
+
|
|
47
|
+
### Tooltip.Header
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Required | Default | Description |
|
|
50
|
+
|------|------|----------|---------|-------------|
|
|
51
|
+
| `children` | `ReactNode` | ✅ | | Content displayed inside the header |
|
|
52
|
+
| `passThroughProps` | `Partial<Omit<TypographyProps & { as?: ElementType<any, keyof IntrinsicElements>; } & BaseProps<ElementType<any, keyof IntrinsicElements>>, "ref">>` | | | @deprecated Use `typographyVariant` instead |
|
|
53
|
+
| `ref` | `Ref<HTMLSpanElement>` | | | A ref to apply to the root element. |
|
|
54
|
+
| `typographyVariant` | `'body-large' \| 'body-medium' \| 'body-small' \| 'code' \| 'display' \| 'label' \| 'subheading-large' \| 'subheading-medium' \| 'subheading-small' \| 'title-1' \| 'title-2' \| 'title-3' \| 'title-4'` | | `subheading-medium` | |
|
|
55
|
+
|
|
56
|
+
### Tooltip.Trigger
|
|
57
|
+
|
|
58
|
+
| Prop | Type | Required | Default | Description |
|
|
59
|
+
|------|------|----------|---------|-------------|
|
|
60
|
+
| `children` | `ReactNode` | ✅ | | Content displayed inside the trigger element |
|
|
61
|
+
| `hasButtonWrapper` | `boolean` | | `false` | Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs |
|
|
62
|
+
| `ref` | `Ref<HTMLButtonElement>` | | | A ref to apply to the root element. |
|
|
63
|
+
|
|
64
|
+
## Accessibility
|
|
65
|
+
|
|
66
|
+
## Keyboard interactions
|
|
67
|
+
|
|
68
|
+
Behavior depends on the `type` prop. Simple and rich tooltips follow different interaction models.
|
|
69
|
+
|
|
70
|
+
### Simple tooltips (`type="simple"`)
|
|
71
|
+
|
|
72
|
+
Implements the keyboard interactions defined in the [WAI-ARIA tooltip pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/).
|
|
73
|
+
|
|
74
|
+
| Key | Description |
|
|
75
|
+
|-----|-------------|
|
|
76
|
+
| `Tab` | Moves focus to the trigger; the tooltip opens when the trigger receives focus |
|
|
77
|
+
| `Shift + Tab` | Moves focus away from the trigger; the tooltip closes when focus leaves |
|
|
78
|
+
| `Escape` | Closes the tooltip while focus remains on the trigger |
|
|
79
|
+
|
|
80
|
+
Simple tooltips also open on mouse hover and close when the pointer leaves the trigger and tooltip area.
|
|
81
|
+
|
|
82
|
+
### Rich tooltips (`type="rich"`)
|
|
83
|
+
|
|
84
|
+
Rich tooltips use a light-dismiss dialog interaction model for panels with actions or structured content. It doesn't trap focus, and clicking outside it will immediately close the component.
|
|
85
|
+
|
|
86
|
+
| Key | Description |
|
|
87
|
+
|-----|-------------|
|
|
88
|
+
| `Tab` | When closed, moves focus to the trigger. When open, moves focus between focusable elements inside the tooltip |
|
|
89
|
+
| `Shift + Tab` | When open, moves focus between focusable elements. Tabbing past the last element closes the tooltip and returns focus to the trigger |
|
|
90
|
+
| `Space` | On the trigger, toggles the tooltip open and closed. When open, activates the focused button |
|
|
91
|
+
| `Enter` | On the trigger, toggles the tooltip open (same as click) |
|
|
92
|
+
| `Escape` | Closes the tooltip and returns focus to the trigger |
|
|
93
|
+
|
|
94
|
+
## WAI-ARIA roles and attributes
|
|
95
|
+
|
|
96
|
+
### Simple tooltips
|
|
97
|
+
|
|
98
|
+
Implements the [WAI-ARIA tooltip pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/).
|
|
99
|
+
|
|
100
|
+
- The popup (`Tooltip.Content`) has `role="tooltip"`
|
|
101
|
+
- When open, the trigger is described via `aria-describedby`, wired by Floating UI to the portaled tooltip element
|
|
102
|
+
|
|
103
|
+
### Rich tooltips
|
|
104
|
+
|
|
105
|
+
- The popup (`Tooltip.Content`) has `role="dialog"`
|
|
106
|
+
- The popup is labeled via `aria-labelledby` (auto-wired from `Tooltip.Header`) or `aria-label`
|
|
107
|
+
|
|
108
|
+
## Implementation guidelines
|
|
109
|
+
|
|
110
|
+
- Rich tooltips must have an accessible name — provide `Tooltip.Header` or set `aria-label` on `Tooltip.Content` via `htmlAttributes`. A console warning is emitted if neither is provided
|
|
111
|
+
- Use `hasButtonWrapper` on `Tooltip.Trigger` with Needle trigger buttons (`IconButton`, `FilledButton`, etc.) — accessible names are already provided via `description` or visible label text
|
|
112
|
+
- Do not rely on a simple tooltip as the only source of essential information — provide a persistent accessible name or description on the trigger when the content is required to operate the control
|
|
113
|
+
- Rich tooltips with `Tooltip.Actions` should use Needle `Button` variants (e.g. `OutlinedButton`, `TextButton`) or `TextLink` for actions so they are keyboard focusable, styled consistently, and operable
|
|
114
|
+
- Set `isDisabled` when the tooltip would open alongside another overlay (e.g. an open menu), which can create confusing or conflicting information for assistive technology users
|
|
115
|
+
|
|
116
|
+
### Related WCAG criteria
|
|
117
|
+
|
|
118
|
+
- [1.4.13 Content on Hover or Focus](https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html) (AA): Simple and rich tooltips can be dismissed with `Escape`; rich tooltips can also be dismissed by activating the trigger again
|
|
119
|
+
- [2.1.1 Keyboard](https://www.w3.org/WAI/WCAG22/Understanding/keyboard.html) (A): Simple tooltips are available to keyboard users via focus; rich tooltips and their actions are fully operable via keyboard
|
|
120
|
+
- [4.1.2 Name, Role, Value](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html) (A): `role="tooltip"` / `role="dialog"`, accessible name (`aria-labelledby` / `aria-label` for rich tooltips), and accessible description (`aria-describedby` for simple tooltips when open) are set automatically by the component
|
|
121
|
+
|
|
122
|
+
## Examples
|
|
123
|
+
|
|
124
|
+
### Default
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
128
|
+
|
|
129
|
+
import { Tooltip } from '@neo4j-ndl/react';
|
|
130
|
+
|
|
131
|
+
const Component = () => {
|
|
132
|
+
return (
|
|
133
|
+
<Tooltip type="simple">
|
|
134
|
+
<Tooltip.Trigger>Hover me!</Tooltip.Trigger>
|
|
135
|
+
<Tooltip.Content>This is a tooltip!</Tooltip.Content>
|
|
136
|
+
</Tooltip>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export default Component;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Controlled
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
147
|
+
|
|
148
|
+
import { FilledButton, Tooltip } from '@neo4j-ndl/react';
|
|
149
|
+
import { useState } from 'react';
|
|
150
|
+
|
|
151
|
+
const Component = () => {
|
|
152
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<Tooltip type="simple" isOpen={isOpen}>
|
|
156
|
+
<Tooltip.Trigger hasButtonWrapper>
|
|
157
|
+
<FilledButton size="medium" onClick={() => setIsOpen((prev) => !prev)}>
|
|
158
|
+
Click me
|
|
159
|
+
</FilledButton>
|
|
160
|
+
</Tooltip.Trigger>
|
|
161
|
+
<Tooltip.Content>This is a controlled tooltip</Tooltip.Content>
|
|
162
|
+
</Tooltip>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export default Component;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Disabled
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
173
|
+
|
|
174
|
+
import { Tooltip } from '@neo4j-ndl/react';
|
|
175
|
+
|
|
176
|
+
const Component = () => {
|
|
177
|
+
return (
|
|
178
|
+
<Tooltip type="simple" isDisabled={true}>
|
|
179
|
+
<Tooltip.Trigger>Hover me!</Tooltip.Trigger>
|
|
180
|
+
<Tooltip.Content>This is a tooltip!</Tooltip.Content>
|
|
181
|
+
</Tooltip>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export default Component;
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Follow Cursor
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
192
|
+
|
|
193
|
+
import { Tooltip } from '@neo4j-ndl/react';
|
|
194
|
+
|
|
195
|
+
const triggerStyle: React.CSSProperties = {
|
|
196
|
+
alignItems: 'center',
|
|
197
|
+
backgroundColor: 'var(--theme-color-primary-bg-weak)',
|
|
198
|
+
borderRadius: '4px',
|
|
199
|
+
color: 'var(--theme-color-primary-text-inverse)',
|
|
200
|
+
display: 'flex',
|
|
201
|
+
height: '300px',
|
|
202
|
+
justifyContent: 'center',
|
|
203
|
+
padding: '8px',
|
|
204
|
+
width: '300px',
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const Component = () => {
|
|
208
|
+
return (
|
|
209
|
+
<div style={{ display: 'flex', gap: '24px' }}>
|
|
210
|
+
<Tooltip type="simple" followCursor placement="bottom">
|
|
211
|
+
<Tooltip.Trigger>
|
|
212
|
+
<div style={triggerStyle}>Hover me (x-axis)</div>
|
|
213
|
+
</Tooltip.Trigger>
|
|
214
|
+
<Tooltip.Content>Follows cursor along x-axis</Tooltip.Content>
|
|
215
|
+
</Tooltip>
|
|
216
|
+
|
|
217
|
+
<Tooltip type="simple" followCursor placement="right">
|
|
218
|
+
<Tooltip.Trigger>
|
|
219
|
+
<div style={triggerStyle}>Hover me (y-axis)</div>
|
|
220
|
+
</Tooltip.Trigger>
|
|
221
|
+
<Tooltip.Content>Follows cursor along y-axis</Tooltip.Content>
|
|
222
|
+
</Tooltip>
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export default Component;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Hover Delay
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
234
|
+
|
|
235
|
+
import { Tooltip } from '@neo4j-ndl/react';
|
|
236
|
+
|
|
237
|
+
const Component = () => {
|
|
238
|
+
return (
|
|
239
|
+
<Tooltip type="simple" hoverDelay={{ close: 200, open: 200 }}>
|
|
240
|
+
<Tooltip.Trigger>Hover me!</Tooltip.Trigger>
|
|
241
|
+
<Tooltip.Content>This is a tooltip!</Tooltip.Content>
|
|
242
|
+
</Tooltip>
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export default Component;
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### In Dialog
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
253
|
+
|
|
254
|
+
import { Dialog, FilledButton, Tooltip, Typography } from '@neo4j-ndl/react';
|
|
255
|
+
import { useState } from 'react';
|
|
256
|
+
|
|
257
|
+
const Component = () => {
|
|
258
|
+
const [isDialogOpen, setDialogOpen] = useState(false);
|
|
259
|
+
const closeDialog = () => setDialogOpen(false);
|
|
260
|
+
return (
|
|
261
|
+
<div className="n-flex n-justify-center">
|
|
262
|
+
<FilledButton onClick={() => setDialogOpen(true)}>
|
|
263
|
+
Open Dialog
|
|
264
|
+
</FilledButton>
|
|
265
|
+
<Dialog isOpen={isDialogOpen} onClose={closeDialog}>
|
|
266
|
+
<Dialog.Header>Header</Dialog.Header>
|
|
267
|
+
<Dialog.Content>
|
|
268
|
+
<Tooltip type="simple">
|
|
269
|
+
<Tooltip.Trigger>
|
|
270
|
+
<Typography variant="body-medium">Hover me!</Typography>
|
|
271
|
+
</Tooltip.Trigger>
|
|
272
|
+
<Tooltip.Content>This is a long tooltip!</Tooltip.Content>
|
|
273
|
+
</Tooltip>
|
|
274
|
+
</Dialog.Content>
|
|
275
|
+
</Dialog>
|
|
276
|
+
</div>
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export default Component;
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Initial Open
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
287
|
+
|
|
288
|
+
import { Tooltip } from '@neo4j-ndl/react';
|
|
289
|
+
|
|
290
|
+
const Component = () => {
|
|
291
|
+
return (
|
|
292
|
+
<Tooltip type="simple" isInitialOpen={true}>
|
|
293
|
+
<Tooltip.Trigger>Hover me!</Tooltip.Trigger>
|
|
294
|
+
<Tooltip.Content>This is a tooltip!</Tooltip.Content>
|
|
295
|
+
</Tooltip>
|
|
296
|
+
);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
export default Component;
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Placements
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
306
|
+
|
|
307
|
+
import { FilledButton, Tooltip } from '@neo4j-ndl/react';
|
|
308
|
+
|
|
309
|
+
const Component = () => {
|
|
310
|
+
const placements = [
|
|
311
|
+
{ label: 'Top', placement: 'top' as const },
|
|
312
|
+
{ label: 'Bottom', placement: 'bottom' as const },
|
|
313
|
+
{ label: 'Left', placement: 'left' as const },
|
|
314
|
+
{ label: 'Right', placement: 'right' as const },
|
|
315
|
+
{ label: 'Top Start', placement: 'top-start' as const },
|
|
316
|
+
{ label: 'Top End', placement: 'top-end' as const },
|
|
317
|
+
{ label: 'Bottom Start', placement: 'bottom-start' as const },
|
|
318
|
+
{ label: 'Bottom End', placement: 'bottom-end' as const },
|
|
319
|
+
];
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<div className="n-grid n-grid-cols-4 n-gap-token-16 n-p-token-16 n-place-items-center">
|
|
323
|
+
{placements.map(({ placement, label }) => (
|
|
324
|
+
<Tooltip key={placement} type="simple" placement={placement}>
|
|
325
|
+
<Tooltip.Trigger hasButtonWrapper>
|
|
326
|
+
<FilledButton size="small">{label}</FilledButton>
|
|
327
|
+
</Tooltip.Trigger>
|
|
328
|
+
<Tooltip.Content>Tooltip on {label.toLowerCase()}</Tooltip.Content>
|
|
329
|
+
</Tooltip>
|
|
330
|
+
))}
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export default Component;
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Rich
|
|
339
|
+
|
|
340
|
+
```tsx
|
|
341
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
342
|
+
|
|
343
|
+
import { FilledButton, Tooltip } from '@neo4j-ndl/react';
|
|
344
|
+
|
|
345
|
+
const Component = () => {
|
|
346
|
+
return (
|
|
347
|
+
<Tooltip type="rich">
|
|
348
|
+
<Tooltip.Trigger hasButtonWrapper>
|
|
349
|
+
<FilledButton size="medium">Click me!</FilledButton>
|
|
350
|
+
</Tooltip.Trigger>
|
|
351
|
+
<Tooltip.Content>
|
|
352
|
+
<Tooltip.Header>Header</Tooltip.Header>
|
|
353
|
+
<Tooltip.Body>
|
|
354
|
+
This rich tooltip demonstrates all the available subcomponents: Header
|
|
355
|
+
and Body, without Actions.
|
|
356
|
+
</Tooltip.Body>
|
|
357
|
+
</Tooltip.Content>
|
|
358
|
+
</Tooltip>
|
|
359
|
+
);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
export default Component;
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Rich Actions
|
|
366
|
+
|
|
367
|
+
```tsx
|
|
368
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
369
|
+
|
|
370
|
+
import {
|
|
371
|
+
FilledButton,
|
|
372
|
+
OutlinedButton,
|
|
373
|
+
TextButton,
|
|
374
|
+
Tooltip,
|
|
375
|
+
} from '@neo4j-ndl/react';
|
|
376
|
+
|
|
377
|
+
const Component = () => {
|
|
378
|
+
return (
|
|
379
|
+
<Tooltip type="rich">
|
|
380
|
+
<Tooltip.Trigger hasButtonWrapper>
|
|
381
|
+
<FilledButton size="medium">Click me!</FilledButton>
|
|
382
|
+
</Tooltip.Trigger>
|
|
383
|
+
<Tooltip.Content>
|
|
384
|
+
<Tooltip.Header>Header</Tooltip.Header>
|
|
385
|
+
<Tooltip.Body>
|
|
386
|
+
This rich tooltip demonstrates all the available subcomponents:
|
|
387
|
+
Header, Body, and Actions.
|
|
388
|
+
</Tooltip.Body>
|
|
389
|
+
<Tooltip.Actions>
|
|
390
|
+
<OutlinedButton onClick={() => alert('Primary action')}>
|
|
391
|
+
Action
|
|
392
|
+
</OutlinedButton>
|
|
393
|
+
<TextButton onClick={() => alert('Secondary action')}>
|
|
394
|
+
Action
|
|
395
|
+
</TextButton>
|
|
396
|
+
</Tooltip.Actions>
|
|
397
|
+
</Tooltip.Content>
|
|
398
|
+
</Tooltip>
|
|
399
|
+
);
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
export default Component;
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Rich Link
|
|
406
|
+
|
|
407
|
+
```tsx
|
|
408
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
409
|
+
|
|
410
|
+
import { FilledButton, TextLink, Tooltip } from '@neo4j-ndl/react';
|
|
411
|
+
|
|
412
|
+
const Component = () => {
|
|
413
|
+
return (
|
|
414
|
+
<Tooltip type="rich">
|
|
415
|
+
<Tooltip.Trigger hasButtonWrapper>
|
|
416
|
+
<FilledButton size="medium">Click me!</FilledButton>
|
|
417
|
+
</Tooltip.Trigger>
|
|
418
|
+
<Tooltip.Content>
|
|
419
|
+
<Tooltip.Header>Header</Tooltip.Header>
|
|
420
|
+
<Tooltip.Body>
|
|
421
|
+
This rich tooltip demonstrates all the available subcomponents:
|
|
422
|
+
Header, Body, and Actions.
|
|
423
|
+
</Tooltip.Body>
|
|
424
|
+
<Tooltip.Actions>
|
|
425
|
+
<TextLink type="external" href="#">
|
|
426
|
+
External link
|
|
427
|
+
</TextLink>
|
|
428
|
+
</Tooltip.Actions>
|
|
429
|
+
</Tooltip.Content>
|
|
430
|
+
</Tooltip>
|
|
431
|
+
);
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export default Component;
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Trigger Button Wrapper
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
441
|
+
|
|
442
|
+
import { FilledButton, Tooltip } from '@neo4j-ndl/react';
|
|
443
|
+
|
|
444
|
+
const Component = () => {
|
|
445
|
+
return (
|
|
446
|
+
<Tooltip type="simple">
|
|
447
|
+
<Tooltip.Trigger hasButtonWrapper>
|
|
448
|
+
<FilledButton size="medium">Click me!</FilledButton>
|
|
449
|
+
</Tooltip.Trigger>
|
|
450
|
+
<Tooltip.Content>This is a tooltip!</Tooltip.Content>
|
|
451
|
+
</Tooltip>
|
|
452
|
+
);
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
export default Component;
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### With Keyboard Display
|
|
459
|
+
|
|
460
|
+
```tsx
|
|
461
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
462
|
+
|
|
463
|
+
import { Kbd, Tooltip } from '@neo4j-ndl/react';
|
|
464
|
+
|
|
465
|
+
const Component = () => {
|
|
466
|
+
return (
|
|
467
|
+
<Tooltip type="simple">
|
|
468
|
+
<Tooltip.Trigger>Hover me!</Tooltip.Trigger>
|
|
469
|
+
<Tooltip.Content>
|
|
470
|
+
This is a keyboard shortcut:{' '}
|
|
471
|
+
<Kbd modifierKeys={['meta']} keys={['B']} />
|
|
472
|
+
</Tooltip.Content>
|
|
473
|
+
</Tooltip>
|
|
474
|
+
);
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
export default Component;
|
|
478
|
+
```
|