@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,386 @@
|
|
|
1
|
+
# Accordion
|
|
2
|
+
|
|
3
|
+
Import: `import { Accordion } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Accordion
|
|
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
|
+
| `children` | `ReactNode` | ✅ | | The content to display inside the accordion. Should only be `<Accordion.Item>` or `<Accordion.CleanItem>`. |
|
|
13
|
+
| `expandedItemId` | `AccordionItemId \| null` | ✅ | | The id of the expanded accordion item. Only applicable if `isMultiple` is `false`. |
|
|
14
|
+
| `expandedItemIds` | `T[]` | ✅ | | The ids of the expanded accordion items. Only applicable if `isMultiple` is `true`. |
|
|
15
|
+
| `isMultiple` | `boolean \| undefined` | ✅ | | Whether multiple accordion items can be open at the same time. |
|
|
16
|
+
| `onChange` | `((expandedItemIds: T[]) => void) \| ((expandedItemId: T \| null) => void)` | ✅ | | Callback function on component item expand/collapse change. |
|
|
17
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
18
|
+
|
|
19
|
+
Where `T` is of the type `string | number | undefined`.
|
|
20
|
+
|
|
21
|
+
### Accordion.CleanItem
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Required | Default | Description |
|
|
24
|
+
|------|------|----------|---------|-------------|
|
|
25
|
+
| `arrowPosition` | `'leading' \| 'trailing'` | | `leading` | The position of the arrow. |
|
|
26
|
+
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
27
|
+
| `children` | `ReactNode` | | | |
|
|
28
|
+
| `headingLevel` | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | | `2` | The heading level for the accordion item title (1–6). Defaults to 2. |
|
|
29
|
+
| `isDisabled` | `boolean` | | `false` | Whether the accordion item is disabled. |
|
|
30
|
+
| `itemId` | `AccordionItemId` | ✅ | | The id of the accordion item. |
|
|
31
|
+
| `onExpandedChange` | `(expanded: boolean) => void` | | | Callback function on accordion item expand/collapse change. |
|
|
32
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
33
|
+
| `title` | `string` | ✅ | | The title of the accordion item. |
|
|
34
|
+
| `titleTypographyVariant` | `'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` | The typography variant for the title. |
|
|
35
|
+
| `trailingContent` | `ReactNode` | | | The content to display on the trailing side of accordion item. |
|
|
36
|
+
|
|
37
|
+
Where `T` is of the type `string | number | undefined`.
|
|
38
|
+
|
|
39
|
+
### Accordion.Item
|
|
40
|
+
|
|
41
|
+
| Prop | Type | Required | Default | Description |
|
|
42
|
+
|------|------|----------|---------|-------------|
|
|
43
|
+
| `arrowPosition` | `'leading' \| 'trailing'` | | `leading` | The position of the arrow. |
|
|
44
|
+
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
|
|
45
|
+
| `children` | `ReactNode` | | | |
|
|
46
|
+
| `headingLevel` | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | | `2` | The heading level for the accordion item title (1–6). Defaults to 2. |
|
|
47
|
+
| `isDisabled` | `boolean` | | `false` | Whether the accordion item is disabled. |
|
|
48
|
+
| `itemId` | `AccordionItemId` | ✅ | | The id of the accordion item. |
|
|
49
|
+
| `onExpandedChange` | `(expanded: boolean) => void` | | | Callback function on accordion item expand/collapse change. |
|
|
50
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
51
|
+
| `title` | `string` | ✅ | | The title of the accordion item. |
|
|
52
|
+
|
|
53
|
+
Where `T` is of the type `string | number | undefined`.
|
|
54
|
+
|
|
55
|
+
`TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code' | 'label'`.
|
|
56
|
+
|
|
57
|
+
## Accessibility
|
|
58
|
+
|
|
59
|
+
## Implementation guidelines
|
|
60
|
+
|
|
61
|
+
Each accordion item is a tabbable element. You can also use the arrow keys to navigate through the accordion items. `Space` or `Enter` can be used to expand or collapse the accordion item. Interactive elements within expanded accordion items integrate into the tab order automatically.
|
|
62
|
+
Be sure to align the heading level of the accordion item title with the heading structure of the page.
|
|
63
|
+
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
### Clean Items Expanded
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
70
|
+
|
|
71
|
+
import { Accordion } from '@neo4j-ndl/react';
|
|
72
|
+
import { useState } from 'react';
|
|
73
|
+
|
|
74
|
+
type AccordionItemId = React.ComponentProps<
|
|
75
|
+
typeof Accordion.CleanItem
|
|
76
|
+
>['itemId'];
|
|
77
|
+
|
|
78
|
+
const Component = () => {
|
|
79
|
+
const itemIds = ['item-1', 'item-2', 'item-3', 'item-4'];
|
|
80
|
+
|
|
81
|
+
const [expandedItemId, setExpandedItemId] = useState<AccordionItemId | null>(
|
|
82
|
+
null,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const onChange = (expandedItemId: AccordionItemId | null) =>
|
|
86
|
+
setExpandedItemId(expandedItemId);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<Accordion
|
|
90
|
+
expandedItemId={expandedItemId}
|
|
91
|
+
isMultiple={false}
|
|
92
|
+
onChange={onChange}
|
|
93
|
+
>
|
|
94
|
+
<Accordion.CleanItem
|
|
95
|
+
itemId={itemIds[0]}
|
|
96
|
+
title={`Accordion ${itemIds[0]}`}
|
|
97
|
+
>
|
|
98
|
+
{itemIds[0]}
|
|
99
|
+
</Accordion.CleanItem>
|
|
100
|
+
<Accordion.CleanItem
|
|
101
|
+
itemId={itemIds[1]}
|
|
102
|
+
title={`Accordion ${itemIds[1]}`}
|
|
103
|
+
>
|
|
104
|
+
{itemIds[1]}
|
|
105
|
+
</Accordion.CleanItem>
|
|
106
|
+
<Accordion.CleanItem
|
|
107
|
+
itemId={itemIds[2]}
|
|
108
|
+
title={`Accordion ${itemIds[2]}`}
|
|
109
|
+
>
|
|
110
|
+
{itemIds[2]}
|
|
111
|
+
</Accordion.CleanItem>
|
|
112
|
+
<Accordion.CleanItem
|
|
113
|
+
itemId={itemIds[3]}
|
|
114
|
+
title={`Accordion ${itemIds[3]}`}
|
|
115
|
+
>
|
|
116
|
+
{itemIds[3]}
|
|
117
|
+
</Accordion.CleanItem>
|
|
118
|
+
</Accordion>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default Component;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Default Expanded
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
129
|
+
|
|
130
|
+
import { Accordion } from '@neo4j-ndl/react';
|
|
131
|
+
import { useState } from 'react';
|
|
132
|
+
|
|
133
|
+
type AccordionItemId = React.ComponentProps<typeof Accordion.Item>['itemId'];
|
|
134
|
+
|
|
135
|
+
const Component = () => {
|
|
136
|
+
const itemIds = ['item-1', 'item-2', 'item-3', 'item-4'];
|
|
137
|
+
|
|
138
|
+
const [expandedItemId, setExpandedItemId] = useState<AccordionItemId | null>(
|
|
139
|
+
undefined,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const onChange = (expandedItemId: AccordionItemId | null) =>
|
|
143
|
+
setExpandedItemId(expandedItemId);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Accordion
|
|
147
|
+
expandedItemId={expandedItemId}
|
|
148
|
+
isMultiple={undefined}
|
|
149
|
+
onChange={onChange}
|
|
150
|
+
>
|
|
151
|
+
<Accordion.Item itemId={itemIds[0]} title={`Accordion ${itemIds[0]}`}>
|
|
152
|
+
{itemIds[0]}
|
|
153
|
+
</Accordion.Item>
|
|
154
|
+
<Accordion.Item itemId={itemIds[1]} title={`Accordion ${itemIds[1]}`}>
|
|
155
|
+
{itemIds[1]}
|
|
156
|
+
</Accordion.Item>
|
|
157
|
+
<Accordion.Item itemId={itemIds[2]} title={`Accordion ${itemIds[2]}`}>
|
|
158
|
+
{itemIds[2]}
|
|
159
|
+
</Accordion.Item>
|
|
160
|
+
<Accordion.Item itemId={itemIds[3]} title={`Accordion ${itemIds[3]}`}>
|
|
161
|
+
{itemIds[3]}
|
|
162
|
+
</Accordion.Item>
|
|
163
|
+
</Accordion>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export default Component;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Full
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
174
|
+
|
|
175
|
+
import { Accordion, Checkbox } from '@neo4j-ndl/react';
|
|
176
|
+
import { useState } from 'react';
|
|
177
|
+
|
|
178
|
+
type AccordionItemId = React.ComponentProps<
|
|
179
|
+
typeof Accordion.CleanItem
|
|
180
|
+
>['itemId'];
|
|
181
|
+
|
|
182
|
+
const Component = () => {
|
|
183
|
+
const itemIds = ['item-1', 'item-2', 'item-3', 'item-4'];
|
|
184
|
+
|
|
185
|
+
const [expandedItemIds, setExpandedItemIds] = useState<AccordionItemId[]>([
|
|
186
|
+
itemIds[1],
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
const onChange = (expandedItemIds: AccordionItemId[]) =>
|
|
190
|
+
setExpandedItemIds(expandedItemIds);
|
|
191
|
+
|
|
192
|
+
const onExpandedChange = (hasExpanded: boolean) =>
|
|
193
|
+
console.info(`Expanded change: ${hasExpanded}`);
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<Accordion
|
|
197
|
+
expandedItemIds={expandedItemIds}
|
|
198
|
+
isMultiple={true}
|
|
199
|
+
onChange={onChange}
|
|
200
|
+
>
|
|
201
|
+
<Accordion.CleanItem
|
|
202
|
+
itemId={itemIds[0]}
|
|
203
|
+
title={`Accordion ${itemIds[0]}`}
|
|
204
|
+
>
|
|
205
|
+
{itemIds[0]}
|
|
206
|
+
</Accordion.CleanItem>
|
|
207
|
+
<Accordion.CleanItem
|
|
208
|
+
arrowPosition="trailing"
|
|
209
|
+
isDisabled={false}
|
|
210
|
+
itemId={itemIds[1]}
|
|
211
|
+
onExpandedChange={onExpandedChange}
|
|
212
|
+
trailingContent={<Checkbox label="Right content" />}
|
|
213
|
+
title={`Accordion ${itemIds[1]}`}
|
|
214
|
+
titleTypographyVariant="title-4"
|
|
215
|
+
>
|
|
216
|
+
{itemIds[1]}
|
|
217
|
+
</Accordion.CleanItem>
|
|
218
|
+
<Accordion.CleanItem
|
|
219
|
+
itemId={itemIds[2]}
|
|
220
|
+
title={`Accordion ${itemIds[2]}`}
|
|
221
|
+
>
|
|
222
|
+
{itemIds[2]}
|
|
223
|
+
</Accordion.CleanItem>
|
|
224
|
+
<Accordion.CleanItem
|
|
225
|
+
itemId={itemIds[3]}
|
|
226
|
+
title={`Accordion ${itemIds[3]}`}
|
|
227
|
+
>
|
|
228
|
+
{itemIds[3]}
|
|
229
|
+
</Accordion.CleanItem>
|
|
230
|
+
</Accordion>
|
|
231
|
+
);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export default Component;
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Multiple Expanded
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
241
|
+
|
|
242
|
+
import { Accordion } from '@neo4j-ndl/react';
|
|
243
|
+
import { useState } from 'react';
|
|
244
|
+
|
|
245
|
+
type AccordionItemId = React.ComponentProps<typeof Accordion.Item>['itemId'];
|
|
246
|
+
|
|
247
|
+
const Component = () => {
|
|
248
|
+
const itemIds = ['item-1', 'item-2', 'item-3', 'item-4'];
|
|
249
|
+
|
|
250
|
+
const [expandedItemIds, setExpandedItemIds] = useState<AccordionItemId[]>([
|
|
251
|
+
itemIds[0],
|
|
252
|
+
itemIds[2],
|
|
253
|
+
]);
|
|
254
|
+
|
|
255
|
+
const onChange = (expandedItemIds: AccordionItemId[]) =>
|
|
256
|
+
setExpandedItemIds(expandedItemIds);
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<Accordion
|
|
260
|
+
expandedItemIds={expandedItemIds}
|
|
261
|
+
isMultiple={true}
|
|
262
|
+
onChange={onChange}
|
|
263
|
+
>
|
|
264
|
+
<Accordion.Item itemId={itemIds[0]} title={`Accordion ${itemIds[0]}`}>
|
|
265
|
+
{itemIds[0]}
|
|
266
|
+
</Accordion.Item>
|
|
267
|
+
<Accordion.Item itemId={itemIds[1]} title={`Accordion ${itemIds[1]}`}>
|
|
268
|
+
{itemIds[1]}
|
|
269
|
+
</Accordion.Item>
|
|
270
|
+
<Accordion.Item itemId={itemIds[2]} title={`Accordion ${itemIds[2]}`}>
|
|
271
|
+
{itemIds[2]}
|
|
272
|
+
</Accordion.Item>
|
|
273
|
+
<Accordion.Item itemId={itemIds[3]} title={`Accordion ${itemIds[3]}`}>
|
|
274
|
+
{itemIds[3]}
|
|
275
|
+
</Accordion.Item>
|
|
276
|
+
</Accordion>
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export default Component;
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Right Content
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
287
|
+
|
|
288
|
+
import { Accordion, Checkbox } from '@neo4j-ndl/react';
|
|
289
|
+
import { useState } from 'react';
|
|
290
|
+
|
|
291
|
+
type AccordionItemId = React.ComponentProps<
|
|
292
|
+
typeof Accordion.CleanItem
|
|
293
|
+
>['itemId'];
|
|
294
|
+
|
|
295
|
+
const Component = () => {
|
|
296
|
+
const itemIds = ['item-1', 'item-2', 'item-3', 'item-4'];
|
|
297
|
+
|
|
298
|
+
const [expandedItemId, setExpandedItemId] = useState<AccordionItemId | null>(
|
|
299
|
+
undefined,
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
const onChange = (expandedItemId: AccordionItemId | null) =>
|
|
303
|
+
setExpandedItemId(expandedItemId);
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<Accordion
|
|
307
|
+
expandedItemId={expandedItemId}
|
|
308
|
+
isMultiple={undefined}
|
|
309
|
+
onChange={onChange}
|
|
310
|
+
>
|
|
311
|
+
<Accordion.CleanItem
|
|
312
|
+
itemId={itemIds[0]}
|
|
313
|
+
title={`Accordion ${itemIds[0]}`}
|
|
314
|
+
trailingContent={<Checkbox label="Right content" />}
|
|
315
|
+
>
|
|
316
|
+
{itemIds[0]}
|
|
317
|
+
</Accordion.CleanItem>
|
|
318
|
+
<Accordion.CleanItem
|
|
319
|
+
itemId={itemIds[1]}
|
|
320
|
+
title={`Accordion ${itemIds[1]}`}
|
|
321
|
+
>
|
|
322
|
+
{itemIds[1]}
|
|
323
|
+
</Accordion.CleanItem>
|
|
324
|
+
<Accordion.CleanItem
|
|
325
|
+
itemId={itemIds[2]}
|
|
326
|
+
title={`Accordion ${itemIds[2]}`}
|
|
327
|
+
>
|
|
328
|
+
{itemIds[2]}
|
|
329
|
+
</Accordion.CleanItem>
|
|
330
|
+
<Accordion.CleanItem
|
|
331
|
+
itemId={itemIds[3]}
|
|
332
|
+
title={`Accordion ${itemIds[3]}`}
|
|
333
|
+
>
|
|
334
|
+
{itemIds[3]}
|
|
335
|
+
</Accordion.CleanItem>
|
|
336
|
+
</Accordion>
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export default Component;
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Single Expanded
|
|
344
|
+
|
|
345
|
+
```tsx
|
|
346
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
347
|
+
|
|
348
|
+
import { Accordion } from '@neo4j-ndl/react';
|
|
349
|
+
import { useState } from 'react';
|
|
350
|
+
|
|
351
|
+
type AccordionItemId = React.ComponentProps<typeof Accordion.Item>['itemId'];
|
|
352
|
+
|
|
353
|
+
const Component = () => {
|
|
354
|
+
const itemIds = ['item-1', 'item-2', 'item-3', 'item-4'];
|
|
355
|
+
|
|
356
|
+
const [expandedItemId, setExpandedItemId] = useState<AccordionItemId | null>(
|
|
357
|
+
itemIds[1],
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
const onChange = (expandedItemId: AccordionItemId | null) =>
|
|
361
|
+
setExpandedItemId(expandedItemId);
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<Accordion
|
|
365
|
+
expandedItemId={expandedItemId}
|
|
366
|
+
isMultiple={false}
|
|
367
|
+
onChange={onChange}
|
|
368
|
+
>
|
|
369
|
+
<Accordion.Item itemId={itemIds[0]} title={`Accordion ${itemIds[0]}`}>
|
|
370
|
+
{itemIds[0]}
|
|
371
|
+
</Accordion.Item>
|
|
372
|
+
<Accordion.Item itemId={itemIds[1]} title={`Accordion ${itemIds[1]}`}>
|
|
373
|
+
{itemIds[1]}
|
|
374
|
+
</Accordion.Item>
|
|
375
|
+
<Accordion.Item itemId={itemIds[2]} title={`Accordion ${itemIds[2]}`}>
|
|
376
|
+
{itemIds[2]}
|
|
377
|
+
</Accordion.Item>
|
|
378
|
+
<Accordion.Item itemId={itemIds[3]} title={`Accordion ${itemIds[3]}`}>
|
|
379
|
+
{itemIds[3]}
|
|
380
|
+
</Accordion.Item>
|
|
381
|
+
</Accordion>
|
|
382
|
+
);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
export default Component;
|
|
386
|
+
```
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# CodePreview
|
|
2
|
+
|
|
3
|
+
Import: `import { CodePreview } from '@neo4j-ndl/react/ai'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### CodePreview
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `code` | `string` | ✅ | | The code content to display |
|
|
12
|
+
| `headerActions` | `ReactNode` | | | The actions to display in the header. Should be small CleanIconButton components. |
|
|
13
|
+
| `isLoading` | `boolean` | | `false` | Whether the code block is loading |
|
|
14
|
+
| `label` | `'read' \| 'write'` | | | The current state of the code block |
|
|
15
|
+
| `language` | `'asciidoc' \| 'bash' \| 'c' \| 'csharp' \| 'css-extras' \| 'css' \| 'cypher' \| 'docker' \| 'go' \| 'graphql' \| 'java' \| 'javadoc' \| 'javascript' \| 'json' \| 'jsx' \| 'kotlin' \| 'php' \| 'python' \| 'regex' \| 'rust' \| 'sql' \| 'text' \| 'typescript' \| 'xml' \| 'yaml'` | ✅ | | The language of the code (e.g., 'cypher', 'python', 'javascript') |
|
|
16
|
+
| `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
|
|
17
|
+
| `theme` | `'ndl-code-dark' \| 'ndl-code-light'` | | | The theme of the code block |
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### Languages
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { CodePreview } from '@neo4j-ndl/react/ai';
|
|
25
|
+
|
|
26
|
+
const pythonCode = `def show_functions(username, function_type='ALL'):
|
|
27
|
+
"""
|
|
28
|
+
Show functions executable by user
|
|
29
|
+
"""
|
|
30
|
+
query = f"SHOW {function_type} FUNCTIONS EXECUTABLE BY {username}"
|
|
31
|
+
return query`;
|
|
32
|
+
|
|
33
|
+
export const Component = () => {
|
|
34
|
+
return <CodePreview code={pythonCode} language="python" />;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default Component;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Loading
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { CodePreview } from '@neo4j-ndl/react/ai';
|
|
44
|
+
|
|
45
|
+
export const Component = () => {
|
|
46
|
+
return <CodePreview code="" language="cypher" isLoading={true} />;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default Component;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Read
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { OutlinedButton } from '@neo4j-ndl/react';
|
|
56
|
+
import { CodePreview } from '@neo4j-ndl/react/ai';
|
|
57
|
+
import { PencilSquareIconOutline } from '@neo4j-ndl/react/icons';
|
|
58
|
+
|
|
59
|
+
const cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY
|
|
60
|
+
username
|
|
61
|
+
[YIELD { * | field[, ...] } [ORDER BY field ...`;
|
|
62
|
+
|
|
63
|
+
export const Component = () => {
|
|
64
|
+
return (
|
|
65
|
+
<CodePreview
|
|
66
|
+
code={cypherCode}
|
|
67
|
+
language="cypher"
|
|
68
|
+
label="read"
|
|
69
|
+
headerActions={
|
|
70
|
+
<OutlinedButton
|
|
71
|
+
leadingVisual={<PencilSquareIconOutline />}
|
|
72
|
+
variant="neutral"
|
|
73
|
+
size="small"
|
|
74
|
+
>
|
|
75
|
+
Send to Query
|
|
76
|
+
</OutlinedButton>
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default Component;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Write
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { CleanIconButton } from '@neo4j-ndl/react';
|
|
89
|
+
import { CodePreview } from '@neo4j-ndl/react/ai';
|
|
90
|
+
import {
|
|
91
|
+
PencilSquareIconOutline,
|
|
92
|
+
PlayCircleIconOutline,
|
|
93
|
+
} from '@neo4j-ndl/react/icons';
|
|
94
|
+
|
|
95
|
+
const cypherCode = `SHOW [ALL|BUILT IN|USER DEFINED] FUNCTION[S] EXECUTABLE BY
|
|
96
|
+
username
|
|
97
|
+
[YIELD { * | field[, ...] } [ORDER BY field ...`;
|
|
98
|
+
|
|
99
|
+
export const Component = () => {
|
|
100
|
+
return (
|
|
101
|
+
<CodePreview
|
|
102
|
+
code={cypherCode}
|
|
103
|
+
language="cypher"
|
|
104
|
+
label="write"
|
|
105
|
+
headerActions={
|
|
106
|
+
<>
|
|
107
|
+
<CleanIconButton
|
|
108
|
+
variant="neutral"
|
|
109
|
+
description="Send to Query"
|
|
110
|
+
size="small"
|
|
111
|
+
>
|
|
112
|
+
<PencilSquareIconOutline />
|
|
113
|
+
</CleanIconButton>
|
|
114
|
+
<CleanIconButton
|
|
115
|
+
variant="neutral"
|
|
116
|
+
description="Run in Query"
|
|
117
|
+
size="small"
|
|
118
|
+
>
|
|
119
|
+
<PlayCircleIconOutline />
|
|
120
|
+
</CleanIconButton>
|
|
121
|
+
</>
|
|
122
|
+
}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export default Component;
|
|
128
|
+
```
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# FileTag
|
|
2
|
+
|
|
3
|
+
Import: `import { FileTag } from '@neo4j-ndl/react/ai'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### FileTag
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `fileName` | `string` | ✅ | | The name of the file |
|
|
12
|
+
| `fileType` | `string` | ✅ | | The type of the file, e.g. 'pdf', 'docx', 'txt', etc. |
|
|
13
|
+
| `icon` | `ReactNode` | ✅ | | The icon that represents the file type |
|
|
14
|
+
| `isLoading` | `boolean` | | `false` | Whether the file tag is loading |
|
|
15
|
+
| `isRemovable` | `boolean` | | `false` | Whether the file tag is removable |
|
|
16
|
+
| `onClick` | `((e: MouseEvent<HTMLElement, MouseEvent>) => void)` | | | Callback function triggered either when the file tag is clicked, or when the remove button is clicked (if isRemovable is true) |
|
|
17
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### Chat
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
25
|
+
|
|
26
|
+
import { FileTag } from '@neo4j-ndl/react/ai';
|
|
27
|
+
import { DocumentIconOutline } from '@neo4j-ndl/react/icons';
|
|
28
|
+
|
|
29
|
+
const Component = () => {
|
|
30
|
+
return (
|
|
31
|
+
<FileTag
|
|
32
|
+
icon={<DocumentIconOutline />}
|
|
33
|
+
fileName="Science Fiction Bestsellers"
|
|
34
|
+
fileType="pdf"
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default Component;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Loading
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
46
|
+
|
|
47
|
+
import { FileTag } from '@neo4j-ndl/react/ai';
|
|
48
|
+
import { DocumentIconOutline } from '@neo4j-ndl/react/icons';
|
|
49
|
+
|
|
50
|
+
const Component = () => {
|
|
51
|
+
return (
|
|
52
|
+
<FileTag
|
|
53
|
+
isLoading={true}
|
|
54
|
+
icon={<DocumentIconOutline />}
|
|
55
|
+
fileName="Science Fiction Bestsellers"
|
|
56
|
+
fileType="pdf"
|
|
57
|
+
onClick={() => {
|
|
58
|
+
alert('remove file');
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default Component;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Prompt
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
71
|
+
|
|
72
|
+
import { FileTag } from '@neo4j-ndl/react/ai';
|
|
73
|
+
import { DocumentIconOutline } from '@neo4j-ndl/react/icons';
|
|
74
|
+
|
|
75
|
+
const Component = () => {
|
|
76
|
+
return (
|
|
77
|
+
<FileTag
|
|
78
|
+
icon={<DocumentIconOutline />}
|
|
79
|
+
fileName="Science Fiction Bestsellers"
|
|
80
|
+
fileType="pdf"
|
|
81
|
+
isRemovable={true}
|
|
82
|
+
onClick={() => {
|
|
83
|
+
alert('remove file');
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default Component;
|
|
90
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# ImageTag
|
|
2
|
+
|
|
3
|
+
Import: `import { ImageTag } from '@neo4j-ndl/react/ai'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### ImageTag
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `alt` | `string` | ✅ | | The alt text of the image |
|
|
12
|
+
| `fileName` | `string` | ✅ | | The name of the image |
|
|
13
|
+
| `fileType` | `string` | ✅ | | The type of the image, e.g. 'jpg', 'png', 'gif', etc. |
|
|
14
|
+
| `isLoading` | `boolean` | | `false` | Whether the image tag is loading |
|
|
15
|
+
| `isRemovable` | `boolean` | | `false` | Whether the image tag is removable |
|
|
16
|
+
| `onClick` | `((e: MouseEvent<HTMLElement, MouseEvent>) => void)` | | | Callback function triggered either when the image tag is clicked, or when the remove button is clicked (if isRemovable is true) |
|
|
17
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
18
|
+
| `src` | `string` | ✅ | | The source of the image |
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Chat
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
26
|
+
|
|
27
|
+
import { ImageTag } from '@neo4j-ndl/react/ai';
|
|
28
|
+
|
|
29
|
+
const Component = () => {
|
|
30
|
+
return (
|
|
31
|
+
<ImageTag
|
|
32
|
+
src="https://plus.unsplash.com/premium_photo-1676496046182-356a6a0ed002?q=80&w=2952&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
33
|
+
alt="Landscape image"
|
|
34
|
+
fileName="Landscape image"
|
|
35
|
+
fileType="jpg"
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default Component;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Loading
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
47
|
+
|
|
48
|
+
import { ImageTag } from '@neo4j-ndl/react/ai';
|
|
49
|
+
|
|
50
|
+
const Component = () => {
|
|
51
|
+
return (
|
|
52
|
+
<ImageTag
|
|
53
|
+
isLoading={true}
|
|
54
|
+
src="https://plus.unsplash.com/premium_photo-1676496046182-356a6a0ed002?q=80&w=2952&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
55
|
+
alt="Landscape image"
|
|
56
|
+
fileName="Landscape image"
|
|
57
|
+
fileType="jpg"
|
|
58
|
+
onClick={() => {
|
|
59
|
+
alert('remove image');
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default Component;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Prompt
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
72
|
+
|
|
73
|
+
import { ImageTag } from '@neo4j-ndl/react/ai';
|
|
74
|
+
|
|
75
|
+
const Component = () => {
|
|
76
|
+
return (
|
|
77
|
+
<ImageTag
|
|
78
|
+
src="https://plus.unsplash.com/premium_photo-1676496046182-356a6a0ed002?q=80&w=2952&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
79
|
+
alt="Landscape image"
|
|
80
|
+
fileName="Landscape image"
|
|
81
|
+
fileType="jpg"
|
|
82
|
+
isRemovable={true}
|
|
83
|
+
onClick={() => {
|
|
84
|
+
alert('remove image');
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default Component;
|
|
91
|
+
```
|