@neo4j-ndl/react 4.16.8 → 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.
Files changed (76) hide show
  1. package/package.json +5 -2
  2. package/skills/ndl-react/SKILL.md +152 -0
  3. package/skills/ndl-react/components/accordion.md +386 -0
  4. package/skills/ndl-react/components/ai/code-preview.md +128 -0
  5. package/skills/ndl-react/components/ai/file-tag.md +90 -0
  6. package/skills/ndl-react/components/ai/image-tag.md +91 -0
  7. package/skills/ndl-react/components/ai/more-files.md +73 -0
  8. package/skills/ndl-react/components/ai/presence.md +54 -0
  9. package/skills/ndl-react/components/ai/preview.md +498 -0
  10. package/skills/ndl-react/components/ai/prompt.md +362 -0
  11. package/skills/ndl-react/components/ai/reasoning.md +95 -0
  12. package/skills/ndl-react/components/ai/response.md +1109 -0
  13. package/skills/ndl-react/components/ai/suggestion.md +84 -0
  14. package/skills/ndl-react/components/ai/thinking.md +43 -0
  15. package/skills/ndl-react/components/ai/tool-call.md +43 -0
  16. package/skills/ndl-react/components/ai/user-bubble.md +187 -0
  17. package/skills/ndl-react/components/avatar.md +169 -0
  18. package/skills/ndl-react/components/banner.md +225 -0
  19. package/skills/ndl-react/components/box.md +39 -0
  20. package/skills/ndl-react/components/breadcrumbs.md +245 -0
  21. package/skills/ndl-react/components/checkbox.md +269 -0
  22. package/skills/ndl-react/components/clean-icon-button.md +294 -0
  23. package/skills/ndl-react/components/clipboard-button.md +154 -0
  24. package/skills/ndl-react/components/code-block.md +276 -0
  25. package/skills/ndl-react/components/code.md +68 -0
  26. package/skills/ndl-react/components/color-picker.md +131 -0
  27. package/skills/ndl-react/components/conditional-wrap.md +46 -0
  28. package/skills/ndl-react/components/data-grid.md +3121 -0
  29. package/skills/ndl-react/components/date-picker.md +652 -0
  30. package/skills/ndl-react/components/dialog.md +485 -0
  31. package/skills/ndl-react/components/dismissible-tag.md +136 -0
  32. package/skills/ndl-react/components/divider.md +96 -0
  33. package/skills/ndl-react/components/drawer.md +543 -0
  34. package/skills/ndl-react/components/dropdown-button.md +161 -0
  35. package/skills/ndl-react/components/dropzone.md +371 -0
  36. package/skills/ndl-react/components/filled-button.md +26 -0
  37. package/skills/ndl-react/components/flex.md +82 -0
  38. package/skills/ndl-react/components/graph-label.md +167 -0
  39. package/skills/ndl-react/components/icon-button-array.md +187 -0
  40. package/skills/ndl-react/components/icon-button.md +193 -0
  41. package/skills/ndl-react/components/inline-edit.md +209 -0
  42. package/skills/ndl-react/components/kbd.md +63 -0
  43. package/skills/ndl-react/components/loading-bar.md +43 -0
  44. package/skills/ndl-react/components/loading-spinner.md +57 -0
  45. package/skills/ndl-react/components/logo.md +57 -0
  46. package/skills/ndl-react/components/menu.md +993 -0
  47. package/skills/ndl-react/components/modal.md +27 -0
  48. package/skills/ndl-react/components/next/tree-view.md +966 -0
  49. package/skills/ndl-react/components/outlined-button.md +26 -0
  50. package/skills/ndl-react/components/popover.md +283 -0
  51. package/skills/ndl-react/components/progress-bar.md +70 -0
  52. package/skills/ndl-react/components/radio.md +150 -0
  53. package/skills/ndl-react/components/read-only-tag.md +96 -0
  54. package/skills/ndl-react/components/segmented-control.md +200 -0
  55. package/skills/ndl-react/components/select-icon-button.md +183 -0
  56. package/skills/ndl-react/components/select.md +530 -0
  57. package/skills/ndl-react/components/selectable-tag.md +203 -0
  58. package/skills/ndl-react/components/side-navigation.md +652 -0
  59. package/skills/ndl-react/components/skeleton.md +274 -0
  60. package/skills/ndl-react/components/slider.md +308 -0
  61. package/skills/ndl-react/components/spotlight.md +796 -0
  62. package/skills/ndl-react/components/status-indicator.md +57 -0
  63. package/skills/ndl-react/components/status-label.md +132 -0
  64. package/skills/ndl-react/components/switch.md +167 -0
  65. package/skills/ndl-react/components/tabs.md +433 -0
  66. package/skills/ndl-react/components/tag.md +91 -0
  67. package/skills/ndl-react/components/text-area.md +178 -0
  68. package/skills/ndl-react/components/text-button.md +25 -0
  69. package/skills/ndl-react/components/text-input.md +475 -0
  70. package/skills/ndl-react/components/text-link.md +119 -0
  71. package/skills/ndl-react/components/time-picker.md +137 -0
  72. package/skills/ndl-react/components/timezone-picker.md +496 -0
  73. package/skills/ndl-react/components/tooltip.md +478 -0
  74. package/skills/ndl-react/components/tree-view.md +545 -0
  75. package/skills/ndl-react/components/typography.md +72 -0
  76. package/skills/ndl-react/components/wizard.md +152 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react",
3
- "version": "4.16.8",
3
+ "version": "4.16.9",
4
4
  "sideEffects": false,
5
5
  "description": "React implementation of Neo4j Design System",
6
6
  "keywords": [
@@ -354,7 +354,8 @@
354
354
  },
355
355
  "files": [
356
356
  "lib",
357
- "icons"
357
+ "icons",
358
+ "skills"
358
359
  ],
359
360
  "publishConfig": {
360
361
  "access": "public"
@@ -427,6 +428,8 @@
427
428
  "scripts": {
428
429
  "generate-component": "node ./scripts/component-generator.js",
429
430
  "docs:generate": "pnpm --dir ../.. run docs:generate -- --package react",
431
+ "docs:generate-skills": "pnpm --dir ../.. run docs:generate-skills -- --package react",
432
+ "docs:generate-all": "pnpm run docs:generate && pnpm run docs:generate-skills",
430
433
  "generate:exports": "node ./scripts/generate-exports.js",
431
434
  "check:exports": "node ./scripts/generate-exports.js --check",
432
435
  "pretest": "pnpm run lint && pnpm run check:exports",
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: ndl-react
3
+ description: >-
4
+ Build and edit UI with the Neo4j Needle React design system
5
+ (@neo4j-ndl/react). Use when adding, composing, or modifying Needle components
6
+ in a React app. Provides per-component props, accessibility requirements, and
7
+ runnable usage examples. Works with any agent that supports skills (Cursor,
8
+ Claude, etc.).
9
+ ---
10
+
11
+ # Neo4j Needle (@neo4j-ndl/react)
12
+
13
+ > 📌 Shipped with `@neo4j-ndl/react`. Once installed into your repo (e.g. via
14
+ > `npx skills add`) this folder is detached from the package — the installed
15
+ > package (TypeScript types in `node_modules/@neo4j-ndl/react`) is the source of
16
+ > truth.
17
+
18
+ Use Neo4j Needle components instead of hand-rolling equivalent UI.
19
+
20
+ ## Setup
21
+
22
+ - Import the base stylesheet once at the app root (if not already wired):
23
+ `import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';`
24
+ - Import components from `@neo4j-ndl/react`; some live under the
25
+ `@neo4j-ndl/react/next` and `@neo4j-ndl/react/ai` subpaths (see the catalog).
26
+ - Prefer icons exported from `@neo4j-ndl/react/icons` (e.g.
27
+ `MagnifyingGlassIconOutline`) for design-system parity.
28
+
29
+ ## Rules
30
+
31
+ - **Never hallucinate props.** Before using any prop — including common-sounding
32
+ ones like `size`, `tone`, or `shadow` — confirm it appears in the component's
33
+ doc here or in the package's TypeScript types. Do not assume APIs from other
34
+ libraries (MUI, Radix, Chakra). If something is unclear, ask the user — or when
35
+ running unattended, prefer the TypeScript types and omit the uncertain prop
36
+ rather than guessing.
37
+ - These docs are the primary source for props, accessibility, and examples. The
38
+ package's `.d.ts` type contract is authoritative: if the types disagree with
39
+ these docs, the **types win**. Do not reverse-engineer behavior from the
40
+ compiled implementation source in `node_modules`.
41
+ - Pass native HTML attributes, `aria-*`, and `data-*` via the `htmlAttributes`
42
+ prop, only where the component's doc says so.
43
+ - Compound components are exposed as subcomponents (e.g. `Tooltip.Trigger`,
44
+ `Tooltip.Content`). Follow each component's own doc — don't assume one
45
+ component's compound shape matches another's.
46
+ - Follow the accessibility guidance in each component's doc; don't strip built-in
47
+ roles or keyboard behavior.
48
+
49
+ ## How to use this skill
50
+
51
+ 1. Find the component in the catalog below to get its docs file and import path.
52
+ 2. Read `components/<file>` for that component's props, accessibility
53
+ requirements, and runnable examples; prefer those examples.
54
+
55
+ ## Components
56
+
57
+ Import from `@neo4j-ndl/react`.
58
+
59
+ | Component | Docs | Accessibility | Examples |
60
+ |-----------|------|---------------|----------|
61
+ | `Accordion` | [components/accordion.md](components/accordion.md) | ✅ | 6 |
62
+ | `Avatar` | [components/avatar.md](components/avatar.md) | ✅ | 7 |
63
+ | `Banner` | [components/banner.md](components/banner.md) | ✅ | 6 |
64
+ | `Box` | [components/box.md](components/box.md) | | 1 |
65
+ | `Breadcrumbs` | [components/breadcrumbs.md](components/breadcrumbs.md) | ✅ | 4 |
66
+ | `Checkbox` | [components/checkbox.md](components/checkbox.md) | ✅ | 9 |
67
+ | `CleanIconButton` | [components/clean-icon-button.md](components/clean-icon-button.md) | ✅ | 8 |
68
+ | `ClipboardButton` | [components/clipboard-button.md](components/clipboard-button.md) | | 7 |
69
+ | `Code` | [components/code.md](components/code.md) | ✅ | 2 |
70
+ | `CodeBlock` | [components/code-block.md](components/code-block.md) | | 8 |
71
+ | `ColorPicker` | [components/color-picker.md](components/color-picker.md) | | 3 |
72
+ | `ConditionalWrap` | [components/conditional-wrap.md](components/conditional-wrap.md) | | 1 |
73
+ | `DataGrid` | [components/data-grid.md](components/data-grid.md) | | 20 |
74
+ | `DatePicker` | [components/date-picker.md](components/date-picker.md) | ✅ | 14 |
75
+ | `Dialog` | [components/dialog.md](components/dialog.md) | ✅ | 7 |
76
+ | `DismissibleTag` | [components/dismissible-tag.md](components/dismissible-tag.md) | | 4 |
77
+ | `Divider` | [components/divider.md](components/divider.md) | | 3 |
78
+ | `Drawer` | [components/drawer.md](components/drawer.md) | ✅ | 8 |
79
+ | `DropdownButton` | [components/dropdown-button.md](components/dropdown-button.md) | | 7 |
80
+ | `Dropzone` | [components/dropzone.md](components/dropzone.md) | | 6 |
81
+ | `FilledButton` | [components/filled-button.md](components/filled-button.md) | | 0 |
82
+ | `Flex` | [components/flex.md](components/flex.md) | | 1 |
83
+ | `GraphLabel` | [components/graph-label.md](components/graph-label.md) | | 7 |
84
+ | `IconButton` | [components/icon-button.md](components/icon-button.md) | ✅ | 7 |
85
+ | `IconButtonArrayComponent` | [components/icon-button-array.md](components/icon-button-array.md) | | 5 |
86
+ | `InlineEdit` | [components/inline-edit.md](components/inline-edit.md) | ✅ | 9 |
87
+ | `Kbd` | [components/kbd.md](components/kbd.md) | ✅ | 2 |
88
+ | `LoadingBar` | [components/loading-bar.md](components/loading-bar.md) | | 2 |
89
+ | `LoadingSpinner` | [components/loading-spinner.md](components/loading-spinner.md) | ✅ | 2 |
90
+ | `Logo` | [components/logo.md](components/logo.md) | | 3 |
91
+ | `Menu` | [components/menu.md](components/menu.md) | ✅ | 13 |
92
+ | `Modal` | [components/modal.md](components/modal.md) | ✅ | 0 |
93
+ | `OutlinedButton` | [components/outlined-button.md](components/outlined-button.md) | | 0 |
94
+ | `Popover` | [components/popover.md](components/popover.md) | ✅ | 6 |
95
+ | `ProgressBar` | [components/progress-bar.md](components/progress-bar.md) | ✅ | 3 |
96
+ | `Radio` | [components/radio.md](components/radio.md) | ✅ | 7 |
97
+ | `ReadOnlyTag` | [components/read-only-tag.md](components/read-only-tag.md) | | 4 |
98
+ | `SegmentedControl` | [components/segmented-control.md](components/segmented-control.md) | ✅ | 5 |
99
+ | `Select` | [components/select.md](components/select.md) | | 13 |
100
+ | `SelectIconButton` | [components/select-icon-button.md](components/select-icon-button.md) | | 4 |
101
+ | `SelectableTag` | [components/selectable-tag.md](components/selectable-tag.md) | | 6 |
102
+ | `SideNavigation` | [components/side-navigation.md](components/side-navigation.md) | | 4 |
103
+ | `Skeleton` | [components/skeleton.md](components/skeleton.md) | | 5 |
104
+ | `Slider` | [components/slider.md](components/slider.md) | ✅ | 8 |
105
+ | `Spotlight` | [components/spotlight.md](components/spotlight.md) | ✅ | 9 |
106
+ | `StatusIndicator` | [components/status-indicator.md](components/status-indicator.md) | ✅ | 1 |
107
+ | `StatusLabel` | [components/status-label.md](components/status-label.md) | | 4 |
108
+ | `Switch` | [components/switch.md](components/switch.md) | ✅ | 7 |
109
+ | `Tabs` | [components/tabs.md](components/tabs.md) | ✅ | 7 |
110
+ | `Tag` | [components/tag.md](components/tag.md) | | 2 |
111
+ | `TextArea` | [components/text-area.md](components/text-area.md) | ✅ | 8 |
112
+ | `TextButton` | [components/text-button.md](components/text-button.md) | | 0 |
113
+ | `TextInput` | [components/text-input.md](components/text-input.md) | ✅ | 16 |
114
+ | `TextLink` | [components/text-link.md](components/text-link.md) | ✅ | 5 |
115
+ | `TimePicker` | [components/time-picker.md](components/time-picker.md) | | 4 |
116
+ | `TimeZonePicker` | [components/timezone-picker.md](components/timezone-picker.md) | | 9 |
117
+ | `Tooltip` | [components/tooltip.md](components/tooltip.md) | ✅ | 13 |
118
+ | `TreeView` | [components/tree-view.md](components/tree-view.md) | | 3 |
119
+ | `Typography` | [components/typography.md](components/typography.md) | | 3 |
120
+ | `Wizard` | [components/wizard.md](components/wizard.md) | | 5 |
121
+
122
+ ## Next components
123
+
124
+ Import from `@neo4j-ndl/react/next`.
125
+
126
+ Next-generation components, imported from the `@neo4j-ndl/react/next` subpath. A `next` component may share a name with a stable one (e.g. `TreeView`) but is a **distinct** implementation with its own API — import it from this subpath, and do not mix it with the same-named default component.
127
+
128
+ | Component | Docs | Accessibility | Examples |
129
+ |-----------|------|---------------|----------|
130
+ | `TreeView` | [components/next/tree-view.md](components/next/tree-view.md) | ✅ | 8 |
131
+
132
+ ## AI components
133
+
134
+ Import from `@neo4j-ndl/react/ai`.
135
+
136
+ Building blocks for AI chat / agent UIs, imported from the `@neo4j-ndl/react/ai` subpath.
137
+
138
+ | Component | Docs | Accessibility | Examples |
139
+ |-----------|------|---------------|----------|
140
+ | `CodePreview` | [components/ai/code-preview.md](components/ai/code-preview.md) | | 4 |
141
+ | `FileTag` | [components/ai/file-tag.md](components/ai/file-tag.md) | | 3 |
142
+ | `ImageTag` | [components/ai/image-tag.md](components/ai/image-tag.md) | | 3 |
143
+ | `MoreFilesComponent` | [components/ai/more-files.md](components/ai/more-files.md) | | 1 |
144
+ | `Presence` | [components/ai/presence.md](components/ai/presence.md) | | 2 |
145
+ | `Preview` | [components/ai/preview.md](components/ai/preview.md) | | 9 |
146
+ | `Prompt` | [components/ai/prompt.md](components/ai/prompt.md) | | 6 |
147
+ | `Reasoning` | [components/ai/reasoning.md](components/ai/reasoning.md) | | 1 |
148
+ | `Response` | [components/ai/response.md](components/ai/response.md) | | 7 |
149
+ | `Suggestion` | [components/ai/suggestion.md](components/ai/suggestion.md) | | 4 |
150
+ | `Thinking` | [components/ai/thinking.md](components/ai/thinking.md) | | 2 |
151
+ | `ToolCall` | [components/ai/tool-call.md](components/ai/tool-call.md) | | 2 |
152
+ | `UserBubbleComponent` | [components/ai/user-bubble.md](components/ai/user-bubble.md) | | 4 |
@@ -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
+ ```