@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,26 @@
|
|
|
1
|
+
# OutlinedButton
|
|
2
|
+
|
|
3
|
+
Import: `import { OutlinedButton } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### OutlinedButton
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `as` | `("a" & ElementType<any, keyof IntrinsicElements>) \| ("symbol" & ElementType<any, keyof IntrinsicElements>) \| ... 178 more ...` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
12
|
+
| `children` | `ReactNode` | | | |
|
|
13
|
+
| `href` | `string` | | | The URL to link to. Only applies when `as="a"` |
|
|
14
|
+
| `isDisabled` | `boolean` | | `false` | If the button is in disabled state |
|
|
15
|
+
| `isFloating` | `boolean` | | `false` | If the button is in floating state |
|
|
16
|
+
| `isFluid` | `boolean` | | | If the button is fluid, it will take the full width of its container |
|
|
17
|
+
| `isLoading` | `boolean` | | `false` | If the button is doing something Async, it will display a loading spinner |
|
|
18
|
+
| `leadingVisual` | `ReactNode` | | | Icon to display before the button content |
|
|
19
|
+
| `loadingMessage` | `string` | | | Accessible message for screen readers when the button is in a loading state |
|
|
20
|
+
| `onClick` | `((e: MouseEvent<HTMLButtonElement, MouseEvent>) => void)` | | | onClick callback |
|
|
21
|
+
| `onKeyDown` | `((e: KeyboardEvent<HTMLButtonElement>) => void)` | | | onKeyDown callback |
|
|
22
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
23
|
+
| `size` | `'large' \| 'medium' \| 'small'` | | `medium` | Size of button |
|
|
24
|
+
| `target` | `HTMLAttributeAnchorTarget` | | | The target window for the link. Only applies when `as="a"`. Not present or required for other element types. |
|
|
25
|
+
| `type` | `'button' \| 'reset' \| 'submit'` | | `button` | Type of button |
|
|
26
|
+
| `variant` | `'danger' \| 'neutral' \| 'primary'` | | `primary` | Variant of the button |
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# Popover
|
|
2
|
+
|
|
3
|
+
Import: `import { Popover } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Popover
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `anchorElement` | `Element \| null` | | | Can be used if the anchor should be separated from the trigger. Note: to visually separate the anchor from the trigger, use the Popover.Anchor component instead. |
|
|
12
|
+
| `anchorPosition` | `{ x: number; y: number; }` | | | If the anchorPosition is provided the anchorElement will be ignored |
|
|
13
|
+
| `children` | `ReactNode` | | | The content of the popover |
|
|
14
|
+
| `closeOnClickOutside` | `boolean` | | `true` | If the popover should close when the user clicks outside of it |
|
|
15
|
+
| `hasAnchorPortal` | `boolean` | | | Use anchorEl for portal's container. Should be used if the popover is portaled and is inside a Dialog for example. |
|
|
16
|
+
| `initialFocus` | `number \| RefObject<HTMLElement \| null>` | | | Which element to initially focus. * |
|
|
17
|
+
| `isOpen` | `boolean` | | | if the popover is open |
|
|
18
|
+
| `isPortaled` | `boolean` | | | Whether the content is rendered in a portal |
|
|
19
|
+
| `offset` | `OffsetOptions` | | | can take either a number, an object or a function. Full documentation here: https://floating-ui.com/docs/offset |
|
|
20
|
+
| `onOpenChange` | `((isOpen: boolean, event?: Event) => void)` | | | Called when an internal state change is triggered, when the floating element either opens or closes. It is not called when `isOpen` is updated by the consumer. |
|
|
21
|
+
| `placement` | `'bottom-end-bottom-start' \| 'bottom-end-top-end' \| 'bottom-middle-top-middle' \| 'bottom-start-bottom-end' \| 'bottom-start-top-start' \| 'middle-end-middle-start' \| 'middle-start-middle-end' \| 'top-end-bottom-end' \| 'top-end-top-start' \| 'top-middle-bottom-middle' \| 'top-start-bottom-start' \| 'top-start-top-end'` | | | The placement of the floating element is determined by two sets of words. The first set of words specifies the point on the anchor element where the floating element will be attached. The second set of coordinates specifies the point on the floating element that will attach to the anchor element. |
|
|
22
|
+
| `role` | `'alertdialog' \| 'dialog' \| 'grid' \| 'listbox' \| 'menu' \| 'tooltip' \| 'tree'` | | | The role of the popover. @deprecated - This prop will be removed in v5. |
|
|
23
|
+
| `shouldCaptureFocus` | `boolean` | | `false` | If the popover should constrain the focus inside the popover while open |
|
|
24
|
+
| `shouldConstrainSize` | `boolean` | | | When true, limits the popover's max-height and max-width to the available viewport space. The consumer is responsible for adding overflow handling (e.g. overflow-y: auto) to the content. |
|
|
25
|
+
| `strategy` | `'absolute' \| 'fixed'` | | | The strategy of the popover. Fixed should be used when the popover is inside a Dialog. |
|
|
26
|
+
|
|
27
|
+
### Popover.Anchor
|
|
28
|
+
|
|
29
|
+
| Prop | Type | Required | Default | Description |
|
|
30
|
+
|------|------|----------|---------|-------------|
|
|
31
|
+
| `children` | `ReactNode` | | | |
|
|
32
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
33
|
+
|
|
34
|
+
### Popover.Content
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Required | Default | Description |
|
|
37
|
+
|------|------|----------|---------|-------------|
|
|
38
|
+
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
39
|
+
| `children` | `ReactNode` | ✅ | | |
|
|
40
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
41
|
+
|
|
42
|
+
### Popover.Trigger
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Required | Default | Description |
|
|
45
|
+
|------|------|----------|---------|-------------|
|
|
46
|
+
| `children` | `ReactNode` | ✅ | | The content of the trigger |
|
|
47
|
+
| `hasButtonWrapper` | `boolean` | | `false` | Whether the trigger should render a button element, or pass its props to the child element |
|
|
48
|
+
| `ref` | `Ref<HTMLButtonElement>` | | | A ref to apply to the root element. |
|
|
49
|
+
|
|
50
|
+
## Accessibility
|
|
51
|
+
|
|
52
|
+
## Implementation guidelines
|
|
53
|
+
|
|
54
|
+
When used with a toggle button, the button should have aria-expanded (true when open, false when closed), aria-haspopup set to the role of the popover, and aria-controls set to the id of the popover.
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
### Default
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
62
|
+
|
|
63
|
+
import { FilledButton, Popover } from '@neo4j-ndl/react';
|
|
64
|
+
|
|
65
|
+
const Component = () => {
|
|
66
|
+
return (
|
|
67
|
+
<Popover>
|
|
68
|
+
<Popover.Trigger hasButtonWrapper>
|
|
69
|
+
<FilledButton>Open Popover</FilledButton>
|
|
70
|
+
</Popover.Trigger>
|
|
71
|
+
<Popover.Content className="n-p-token-16">
|
|
72
|
+
Popover content
|
|
73
|
+
</Popover.Content>
|
|
74
|
+
</Popover>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default Component;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Controlled
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
85
|
+
|
|
86
|
+
import { FilledButton, Popover } from '@neo4j-ndl/react';
|
|
87
|
+
import { useState } from 'react';
|
|
88
|
+
|
|
89
|
+
const Component = () => {
|
|
90
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
91
|
+
return (
|
|
92
|
+
<Popover
|
|
93
|
+
isOpen={isOpen}
|
|
94
|
+
onOpenChange={(open) => {
|
|
95
|
+
setIsOpen(open);
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
<Popover.Trigger hasButtonWrapper>
|
|
99
|
+
<FilledButton onClick={() => setIsOpen((prev) => !prev)}>
|
|
100
|
+
Open Popover
|
|
101
|
+
</FilledButton>
|
|
102
|
+
</Popover.Trigger>
|
|
103
|
+
<Popover.Content className="n-p-token-16">
|
|
104
|
+
Popover content
|
|
105
|
+
</Popover.Content>
|
|
106
|
+
</Popover>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default Component;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Custom Offset
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
117
|
+
|
|
118
|
+
import { FilledButton, Popover, Select } from '@neo4j-ndl/react';
|
|
119
|
+
import { useState } from 'react';
|
|
120
|
+
|
|
121
|
+
const offsetOptions = [
|
|
122
|
+
{
|
|
123
|
+
label: 'crossAxis-anchor-element-width',
|
|
124
|
+
value: 'crossAxis-anchor-element-width',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
label: 'crossAxis-anchor-element-negative-width',
|
|
128
|
+
value: 'crossAxis-anchor-element-negative-width',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: 'crossAxis-floating-element-negative-width',
|
|
132
|
+
value: 'crossAxis-floating-element-negative-width',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
label: 'crossAxis-floating-element-width',
|
|
136
|
+
value: 'crossAxis-floating-element-width',
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
const offsetTranslation: Record<
|
|
141
|
+
string,
|
|
142
|
+
React.ComponentProps<typeof Popover>['offset']
|
|
143
|
+
> = {
|
|
144
|
+
'crossAxis-anchor-element-negative-width': ({ rects }) => ({
|
|
145
|
+
crossAxis: -rects.reference.width,
|
|
146
|
+
}),
|
|
147
|
+
'crossAxis-anchor-element-width': ({ rects }) => ({
|
|
148
|
+
crossAxis: rects.reference.width,
|
|
149
|
+
}),
|
|
150
|
+
'crossAxis-floating-element-negative-width': ({ rects }) => ({
|
|
151
|
+
crossAxis: -rects.floating.width,
|
|
152
|
+
}),
|
|
153
|
+
'crossAxis-floating-element-width': ({ rects }) => ({
|
|
154
|
+
crossAxis: rects.floating.width,
|
|
155
|
+
}),
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const Component = () => {
|
|
159
|
+
const [selectedPosition, setSelectedPosition] = useState(
|
|
160
|
+
offsetOptions[0].value,
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<div className="n-flex n-flex-col n-gap-token-32 n-items-center">
|
|
165
|
+
<Popover offset={offsetTranslation[selectedPosition]}>
|
|
166
|
+
<Popover.Trigger hasButtonWrapper>
|
|
167
|
+
<FilledButton>Open Popover</FilledButton>
|
|
168
|
+
</Popover.Trigger>
|
|
169
|
+
<Popover.Content className="n-p-token-16">
|
|
170
|
+
Popover content
|
|
171
|
+
</Popover.Content>
|
|
172
|
+
</Popover>
|
|
173
|
+
|
|
174
|
+
<Select
|
|
175
|
+
type="select"
|
|
176
|
+
label="Example positions"
|
|
177
|
+
selectProps={{
|
|
178
|
+
defaultValue: offsetOptions[0],
|
|
179
|
+
onChange: (e) => {
|
|
180
|
+
if (e) {
|
|
181
|
+
setSelectedPosition(e.value);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
options: offsetOptions,
|
|
185
|
+
}}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export default Component;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### In Dialog
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
198
|
+
|
|
199
|
+
import { Dialog, FilledButton, Popover } from '@neo4j-ndl/react';
|
|
200
|
+
import { useState } from 'react';
|
|
201
|
+
|
|
202
|
+
const Component = () => {
|
|
203
|
+
const [isDialogOpen, setDialogOpen] = useState(false);
|
|
204
|
+
const closeDialog = () => setDialogOpen(false);
|
|
205
|
+
return (
|
|
206
|
+
<div className="n-flex n-justify-center">
|
|
207
|
+
<FilledButton onClick={() => setDialogOpen(true)}>
|
|
208
|
+
Open Dialog
|
|
209
|
+
</FilledButton>
|
|
210
|
+
<Dialog isOpen={isDialogOpen} onClose={closeDialog}>
|
|
211
|
+
<Dialog.Header>Dialog</Dialog.Header>
|
|
212
|
+
<Dialog.Content>
|
|
213
|
+
<Popover>
|
|
214
|
+
<Popover.Trigger hasButtonWrapper>
|
|
215
|
+
<FilledButton className="n-mx-auto">Open Popover</FilledButton>
|
|
216
|
+
</Popover.Trigger>
|
|
217
|
+
<Popover.Content className="n-p-token-16">
|
|
218
|
+
Custom Popover content
|
|
219
|
+
</Popover.Content>
|
|
220
|
+
</Popover>
|
|
221
|
+
</Dialog.Content>
|
|
222
|
+
</Dialog>
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export default Component;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### No Button Wrapper
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
234
|
+
|
|
235
|
+
import { Popover } from '@neo4j-ndl/react';
|
|
236
|
+
|
|
237
|
+
const Component = () => {
|
|
238
|
+
return (
|
|
239
|
+
<Popover>
|
|
240
|
+
<Popover.Trigger>
|
|
241
|
+
<div>Open Popover</div>
|
|
242
|
+
</Popover.Trigger>
|
|
243
|
+
<Popover.Content className="n-p-token-16">
|
|
244
|
+
Popover content
|
|
245
|
+
</Popover.Content>
|
|
246
|
+
</Popover>
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export default Component;
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Separate Anchor
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
257
|
+
|
|
258
|
+
import { FilledButton, Popover } from '@neo4j-ndl/react';
|
|
259
|
+
import { useState } from 'react';
|
|
260
|
+
|
|
261
|
+
const Component = () => {
|
|
262
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
263
|
+
return (
|
|
264
|
+
<div className="n-flex n-justify-between n-w-full">
|
|
265
|
+
<Popover isOpen={isOpen} onOpenChange={(open) => setIsOpen(open)}>
|
|
266
|
+
<Popover.Anchor>
|
|
267
|
+
<div>Anchor Element</div>
|
|
268
|
+
</Popover.Anchor>
|
|
269
|
+
<Popover.Trigger hasButtonWrapper>
|
|
270
|
+
<FilledButton onClick={() => setIsOpen(true)}>
|
|
271
|
+
Click to open popover
|
|
272
|
+
</FilledButton>
|
|
273
|
+
</Popover.Trigger>
|
|
274
|
+
<Popover.Content className="n-p-token-16">
|
|
275
|
+
Popover content
|
|
276
|
+
</Popover.Content>
|
|
277
|
+
</Popover>
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export default Component;
|
|
283
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# ProgressBar
|
|
2
|
+
|
|
3
|
+
Import: `import { ProgressBar } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### ProgressBar
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
12
|
+
| `heading` | `string` | | | The heading displayed above the progress bar |
|
|
13
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
14
|
+
| `size` | `'large' \| 'small'` | | `small` | Size of the progress bar |
|
|
15
|
+
| `value` | `number` | ✅ | | The current progress value, should be between 0 and 100 |
|
|
16
|
+
|
|
17
|
+
## Accessibility
|
|
18
|
+
|
|
19
|
+
## Implementation guidelines
|
|
20
|
+
|
|
21
|
+
The progress bar component uses `role='progressbar'` and `aria-valuemin`, `aria-valuemax`, and `aria-valuenow` attributes to communicate its current state to assistive technologies. This ensures that users with disabilities can understand the progress being made.
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
### Default
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
29
|
+
|
|
30
|
+
import { ProgressBar } from '@neo4j-ndl/react';
|
|
31
|
+
|
|
32
|
+
const Component = () => {
|
|
33
|
+
return <ProgressBar value={75} size="large" />;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default Component;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Heading
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
43
|
+
|
|
44
|
+
import { ProgressBar } from '@neo4j-ndl/react';
|
|
45
|
+
|
|
46
|
+
const Component = () => {
|
|
47
|
+
return <ProgressBar heading="Importing data" value={75} size="large" />;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default Component;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Sizes
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
57
|
+
|
|
58
|
+
import { ProgressBar } from '@neo4j-ndl/react';
|
|
59
|
+
|
|
60
|
+
const Component = () => {
|
|
61
|
+
return (
|
|
62
|
+
<div className="n-flex n-flex-col n-gap-token-16">
|
|
63
|
+
<ProgressBar value={75} size="small" heading="Small" />
|
|
64
|
+
<ProgressBar value={75} size="large" heading="Large" />
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default Component;
|
|
70
|
+
```
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Radio
|
|
2
|
+
|
|
3
|
+
Import: `import { Radio } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Radio
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `ariaLabel` | `string` | | | The aria label of the radio. Required if the label is not a string. |
|
|
12
|
+
| `hasLeadingLabel` | `boolean` | | | Whether the label should be displayed before the radio |
|
|
13
|
+
| `isChecked` | `boolean` | | | Whether the radio is checked |
|
|
14
|
+
| `isDefaultChecked` | `boolean` | | | Selects the radio by default in uncontrolled mode |
|
|
15
|
+
| `isDisabled` | `boolean` | | `false` | Whether the radio is disabled |
|
|
16
|
+
| `isFluid` | `boolean` | | `false` | Whether the radio & label should take the full available width of its container |
|
|
17
|
+
| `label` | `ReactNode` | | | The label of the radio. If not a string, supply an aria label for screen reader support. |
|
|
18
|
+
| `onChange` | `((event: ChangeEvent<HTMLInputElement, Element>) => void)` | | | The callback function triggered when the radio value changes |
|
|
19
|
+
| `onClick` | `((event: MouseEvent<HTMLInputElement, MouseEvent>) => void)` | | | The callback function triggered when the radio is clicked |
|
|
20
|
+
| `ref` | `Ref<HTMLInputElement>` | | | A ref to apply to the root element. |
|
|
21
|
+
| `value` | `string \| number \| readonly string[]` | | | The value of the radio |
|
|
22
|
+
|
|
23
|
+
## Accessibility
|
|
24
|
+
|
|
25
|
+
## Implementation guidelines
|
|
26
|
+
|
|
27
|
+
The Radio component uses implicit label wrapping to associate the visible label with the input for screen readers. If you omit the label prop or use an invalid label (no text content), the `ariaLabel` prop will be required to ensure an accessible name.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
### Default
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
35
|
+
|
|
36
|
+
import { Radio } from '@neo4j-ndl/react';
|
|
37
|
+
|
|
38
|
+
const Component = () => {
|
|
39
|
+
return <Radio label="Radio label" />;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default Component;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Controlled
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
49
|
+
|
|
50
|
+
import { Radio } from '@neo4j-ndl/react';
|
|
51
|
+
import { useState } from 'react';
|
|
52
|
+
|
|
53
|
+
const Component = () => {
|
|
54
|
+
const [isChecked, setIsChecked] = useState(false);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Radio
|
|
58
|
+
label="Controlled radio"
|
|
59
|
+
isChecked={isChecked}
|
|
60
|
+
onChange={(event) => setIsChecked(event.target.checked)}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default Component;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Custom Label
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
72
|
+
|
|
73
|
+
import { Radio, Typography } from '@neo4j-ndl/react';
|
|
74
|
+
|
|
75
|
+
const Component = () => {
|
|
76
|
+
return (
|
|
77
|
+
<Radio
|
|
78
|
+
label={<Typography variant="label">Custom label</Typography>}
|
|
79
|
+
ariaLabel="example aria label"
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default Component;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Disabled
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
91
|
+
|
|
92
|
+
import { Radio } from '@neo4j-ndl/react';
|
|
93
|
+
|
|
94
|
+
const Component = () => {
|
|
95
|
+
return (
|
|
96
|
+
<div className="n-flex n-flex-col n-gap-token-12">
|
|
97
|
+
<Radio label="Radio label" isDisabled />
|
|
98
|
+
<Radio label="Radio label" isDisabled isChecked />
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default Component;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Has Label Before
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
110
|
+
|
|
111
|
+
import { Radio } from '@neo4j-ndl/react';
|
|
112
|
+
|
|
113
|
+
const Component = () => {
|
|
114
|
+
return <Radio label="Radio label" hasLeadingLabel />;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default Component;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### No Label
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
124
|
+
|
|
125
|
+
import { Radio } from '@neo4j-ndl/react';
|
|
126
|
+
|
|
127
|
+
const Component = () => {
|
|
128
|
+
return <Radio ariaLabel="Radio without label" />;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export default Component;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Truncated Label
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
138
|
+
|
|
139
|
+
import { Radio } from '@neo4j-ndl/react';
|
|
140
|
+
|
|
141
|
+
const Component = () => {
|
|
142
|
+
return (
|
|
143
|
+
<div className="n-max-w-32">
|
|
144
|
+
<Radio label="This is a long label that will overflow" />
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default Component;
|
|
150
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# ReadOnlyTag
|
|
2
|
+
|
|
3
|
+
Import: `import { ReadOnlyTag } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### ReadOnlyTag
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `children` | `ReactNode` | | | The content of the tag |
|
|
12
|
+
| `color` | `'1' \| '2' \| '3' \| '4' \| '5' \| '6' \| '7' \| '8'` | | | Categorical color for the background |
|
|
13
|
+
| `leadingVisual` | `ReactNode` | | | Icon to display before the content |
|
|
14
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
15
|
+
| `size` | `'large' \| 'medium' \| 'small' \| 'x-small'` | | | Size of the tag |
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Default
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
+
|
|
24
|
+
import { ReadOnlyTag } from '@neo4j-ndl/react';
|
|
25
|
+
|
|
26
|
+
const Component = () => {
|
|
27
|
+
return <ReadOnlyTag>Read-only Tag</ReadOnlyTag>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default Component;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Colors
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
37
|
+
|
|
38
|
+
import { ReadOnlyTag } from '@neo4j-ndl/react';
|
|
39
|
+
|
|
40
|
+
const Component = () => {
|
|
41
|
+
return (
|
|
42
|
+
<div className="n-flex n-flex-col n-gap-token-16">
|
|
43
|
+
<ReadOnlyTag color="1">Categorical color 1</ReadOnlyTag>
|
|
44
|
+
<ReadOnlyTag color="2">Categorical color 2</ReadOnlyTag>
|
|
45
|
+
<ReadOnlyTag color="3">Categorical color 3</ReadOnlyTag>
|
|
46
|
+
<ReadOnlyTag color="4">Categorical color 4</ReadOnlyTag>
|
|
47
|
+
<ReadOnlyTag color="5">Categorical color 5</ReadOnlyTag>
|
|
48
|
+
<ReadOnlyTag color="6">Categorical color 6</ReadOnlyTag>
|
|
49
|
+
<ReadOnlyTag color="7">Categorical color 7</ReadOnlyTag>
|
|
50
|
+
<ReadOnlyTag color="8">Categorical color 8</ReadOnlyTag>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default Component;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Sizes
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
62
|
+
|
|
63
|
+
import { ReadOnlyTag } from '@neo4j-ndl/react';
|
|
64
|
+
|
|
65
|
+
const Component = () => {
|
|
66
|
+
return (
|
|
67
|
+
<div className="n-flex n-flex-row n-gap-token-8">
|
|
68
|
+
<ReadOnlyTag size="x-small">X-Small</ReadOnlyTag>
|
|
69
|
+
<ReadOnlyTag size="small">Small</ReadOnlyTag>
|
|
70
|
+
<ReadOnlyTag size="medium">Medium</ReadOnlyTag>
|
|
71
|
+
<ReadOnlyTag size="large">Large</ReadOnlyTag>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default Component;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### With Leading Icon
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
83
|
+
|
|
84
|
+
import { ReadOnlyTag } from '@neo4j-ndl/react';
|
|
85
|
+
import { DatabasePlusIcon } from '@neo4j-ndl/react/icons';
|
|
86
|
+
|
|
87
|
+
const Component = () => {
|
|
88
|
+
return (
|
|
89
|
+
<ReadOnlyTag leadingVisual={<DatabasePlusIcon />}>
|
|
90
|
+
Read-only Tag with leading icon
|
|
91
|
+
</ReadOnlyTag>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default Component;
|
|
96
|
+
```
|