@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,274 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
Import: `import { Skeleton } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Skeleton
|
|
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` | | | Content displayed inside the skeleton. Size is inherited from the children if height or width are not provided. |
|
|
13
|
+
| `height` | `string` | | | Height of the skeleton |
|
|
14
|
+
| `isLoading` | `boolean` | | `true` | Whether the skeleton is loading |
|
|
15
|
+
| `onBackground` | `'default' \| 'weak'` | | `default` | What background the skeleton is placed on. |
|
|
16
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
17
|
+
| `shape` | `'circular' \| 'rectangular'` | | `rectangular` | Shape of the skeleton |
|
|
18
|
+
| `width` | `string` | | | Width of the skeleton |
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Default
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
26
|
+
|
|
27
|
+
import { Skeleton } from '@neo4j-ndl/react';
|
|
28
|
+
|
|
29
|
+
const Component = () => {
|
|
30
|
+
return (
|
|
31
|
+
<div className="n-flex n-flex-col n-gap-4">
|
|
32
|
+
<Skeleton height="50px" width="100%" />
|
|
33
|
+
<Skeleton height="30px" width="80%" />
|
|
34
|
+
<Skeleton height="20px" width="60%" />
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default Component;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Circular
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
46
|
+
|
|
47
|
+
import { Skeleton } from '@neo4j-ndl/react';
|
|
48
|
+
|
|
49
|
+
const Component = () => {
|
|
50
|
+
return (
|
|
51
|
+
<div className="n-flex n-gap-4 n-items-center">
|
|
52
|
+
<Skeleton shape="circular" height="50px" width="50px" />
|
|
53
|
+
<Skeleton shape="circular" height="40px" width="40px" />
|
|
54
|
+
<Skeleton shape="circular" height="30px" width="30px" />
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default Component;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Full Example
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
66
|
+
|
|
67
|
+
import { Skeleton, TextButton, Typography } from '@neo4j-ndl/react';
|
|
68
|
+
|
|
69
|
+
const Component = () => {
|
|
70
|
+
return (
|
|
71
|
+
<div className="n-flex n-flex-row n-gap-2">
|
|
72
|
+
<div className="n-flex n-flex-col n-gap-2 n-bg-neutral-bg-weak n-shadow-light-raised n-w-72 n-rounded-2xl n-p-2">
|
|
73
|
+
<div className="n-bg-neutral-bg-default n-flex n-items-center n-justify-center n-h-36 n-rounded-2xl n-mb-4">
|
|
74
|
+
<svg
|
|
75
|
+
width="48"
|
|
76
|
+
height="48"
|
|
77
|
+
viewBox="0 0 48 48"
|
|
78
|
+
fill="none"
|
|
79
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
80
|
+
>
|
|
81
|
+
<g clipPath="url(#clip0_5044_6981)">
|
|
82
|
+
<path
|
|
83
|
+
d="M1.5 33.75C1.5 35.1424 2.05312 36.4777 3.03769 37.4623C4.02226 38.4469 5.35761 39 6.75 39C8.14239 39 9.47774 38.4469 10.4623 37.4623C11.4469 36.4777 12 35.1424 12 33.75C12 32.3576 11.4469 31.0223 10.4623 30.0377C9.47774 29.0531 8.14239 28.5 6.75 28.5C5.35761 28.5 4.02226 29.0531 3.03769 30.0377C2.05312 31.0223 1.5 32.3576 1.5 33.75V33.75Z"
|
|
84
|
+
stroke="#4C99A4"
|
|
85
|
+
strokeWidth="2"
|
|
86
|
+
strokeLinecap="round"
|
|
87
|
+
strokeLinejoin="round"
|
|
88
|
+
/>
|
|
89
|
+
<path
|
|
90
|
+
d="M36 33.75C36 34.4394 36.1358 35.1221 36.3996 35.7591C36.6635 36.396 37.0502 36.9748 37.5377 37.4623C38.0252 37.9498 38.604 38.3365 39.2409 38.6004C39.8779 38.8642 40.5606 39 41.25 39C41.9394 39 42.6221 38.8642 43.2591 38.6004C43.896 38.3365 44.4748 37.9498 44.9623 37.4623C45.4498 36.9748 45.8365 36.396 46.1004 35.7591C46.3642 35.1221 46.5 34.4394 46.5 33.75C46.5 33.0606 46.3642 32.3779 46.1004 31.7409C45.8365 31.104 45.4498 30.5252 44.9623 30.0377C44.4748 29.5502 43.896 29.1635 43.2591 28.8996C42.6221 28.6358 41.9394 28.5 41.25 28.5C40.5606 28.5 39.8779 28.6358 39.2409 28.8996C38.604 29.1635 38.0252 29.5502 37.5377 30.0377C37.0502 30.5252 36.6635 31.104 36.3996 31.7409C36.1358 32.3779 36 33.0606 36 33.75Z"
|
|
91
|
+
stroke="#4C99A4"
|
|
92
|
+
strokeWidth="2"
|
|
93
|
+
strokeLinecap="round"
|
|
94
|
+
strokeLinejoin="round"
|
|
95
|
+
/>
|
|
96
|
+
<path
|
|
97
|
+
d="M18.75 33.75C18.75 35.1424 19.3031 36.4777 20.2877 37.4623C21.2723 38.4469 22.6076 39 24 39C25.3924 39 26.7277 38.4469 27.7123 37.4623C28.6969 36.4777 29.25 35.1424 29.25 33.75C29.25 32.3576 28.6969 31.0223 27.7123 30.0377C26.7277 29.0531 25.3924 28.5 24 28.5C22.6076 28.5 21.2723 29.0531 20.2877 30.0377C19.3031 31.0223 18.75 32.3576 18.75 33.75V33.75Z"
|
|
98
|
+
stroke="#4C99A4"
|
|
99
|
+
strokeWidth="2"
|
|
100
|
+
strokeLinecap="round"
|
|
101
|
+
strokeLinejoin="round"
|
|
102
|
+
/>
|
|
103
|
+
<path
|
|
104
|
+
d="M15.376 46.5C14.8905 45.1818 14.1085 43.9928 13.0906 43.0247C12.0727 42.0566 10.846 41.3353 9.50508 40.9165C8.1642 40.4977 6.74503 40.3926 5.35707 40.6092C3.96911 40.8258 2.64948 41.3585 1.5 42.1659"
|
|
105
|
+
stroke="#4C99A4"
|
|
106
|
+
strokeWidth="2"
|
|
107
|
+
strokeLinecap="round"
|
|
108
|
+
strokeLinejoin="round"
|
|
109
|
+
/>
|
|
110
|
+
<path
|
|
111
|
+
d="M32.626 46.5C33.1113 45.1818 33.893 43.9928 34.9107 43.0248C35.9284 42.0567 37.155 41.3354 38.4957 40.9165C39.8365 40.4977 41.2555 40.3926 42.6434 40.6092C44.0312 40.8258 45.3507 41.3585 46.5 42.166"
|
|
112
|
+
stroke="#4C99A4"
|
|
113
|
+
strokeWidth="2"
|
|
114
|
+
strokeLinecap="round"
|
|
115
|
+
strokeLinejoin="round"
|
|
116
|
+
/>
|
|
117
|
+
<path
|
|
118
|
+
d="M32.626 46.5C31.9729 44.7387 30.7962 43.2195 29.2541 42.1467C27.7121 41.0738 25.8786 40.4988 24 40.4988C22.1215 40.4988 20.288 41.0738 18.7459 42.1467C17.2039 43.2195 16.0272 44.7387 15.374 46.5"
|
|
119
|
+
stroke="#4C99A4"
|
|
120
|
+
strokeWidth="2"
|
|
121
|
+
strokeLinecap="round"
|
|
122
|
+
strokeLinejoin="round"
|
|
123
|
+
/>
|
|
124
|
+
<path
|
|
125
|
+
d="M28.5 22.5C28.5 22.5 30 15 36 13.5"
|
|
126
|
+
stroke="#5CC3C9"
|
|
127
|
+
strokeWidth="2"
|
|
128
|
+
strokeLinecap="round"
|
|
129
|
+
strokeLinejoin="round"
|
|
130
|
+
/>
|
|
131
|
+
<path
|
|
132
|
+
d="M40.5 12H46.5"
|
|
133
|
+
stroke="#5CC3C9"
|
|
134
|
+
strokeWidth="2"
|
|
135
|
+
strokeLinecap="round"
|
|
136
|
+
strokeLinejoin="round"
|
|
137
|
+
/>
|
|
138
|
+
<path
|
|
139
|
+
d="M43.5 9V15"
|
|
140
|
+
stroke="#5CC3C9"
|
|
141
|
+
strokeWidth="2"
|
|
142
|
+
strokeLinecap="round"
|
|
143
|
+
strokeLinejoin="round"
|
|
144
|
+
/>
|
|
145
|
+
<path
|
|
146
|
+
d="M19.5 22.5C19.5 22.5 18 15 12 13.5"
|
|
147
|
+
stroke="#5CC3C9"
|
|
148
|
+
strokeWidth="2"
|
|
149
|
+
strokeLinecap="round"
|
|
150
|
+
strokeLinejoin="round"
|
|
151
|
+
/>
|
|
152
|
+
<path
|
|
153
|
+
d="M7.5 12H1.5"
|
|
154
|
+
stroke="#5CC3C9"
|
|
155
|
+
strokeWidth="2"
|
|
156
|
+
strokeLinecap="round"
|
|
157
|
+
strokeLinejoin="round"
|
|
158
|
+
/>
|
|
159
|
+
<path
|
|
160
|
+
d="M4.5 9V15"
|
|
161
|
+
stroke="#5CC3C9"
|
|
162
|
+
strokeWidth="2"
|
|
163
|
+
strokeLinecap="round"
|
|
164
|
+
strokeLinejoin="round"
|
|
165
|
+
/>
|
|
166
|
+
<path
|
|
167
|
+
d="M21 4.5H27"
|
|
168
|
+
stroke="#5CC3C9"
|
|
169
|
+
strokeWidth="2"
|
|
170
|
+
strokeLinecap="round"
|
|
171
|
+
strokeLinejoin="round"
|
|
172
|
+
/>
|
|
173
|
+
<path
|
|
174
|
+
d="M24 1.5V7.5"
|
|
175
|
+
stroke="#5CC3C9"
|
|
176
|
+
strokeWidth="2"
|
|
177
|
+
strokeLinecap="round"
|
|
178
|
+
strokeLinejoin="round"
|
|
179
|
+
/>
|
|
180
|
+
<path
|
|
181
|
+
d="M24 22.5V13.5"
|
|
182
|
+
stroke="#5CC3C9"
|
|
183
|
+
strokeWidth="2"
|
|
184
|
+
strokeLinecap="round"
|
|
185
|
+
strokeLinejoin="round"
|
|
186
|
+
/>
|
|
187
|
+
</g>
|
|
188
|
+
<defs>
|
|
189
|
+
<clipPath id="clip0_5044_6981">
|
|
190
|
+
<rect width="48" height="48" fill="white" />
|
|
191
|
+
</clipPath>
|
|
192
|
+
</defs>
|
|
193
|
+
</svg>
|
|
194
|
+
</div>
|
|
195
|
+
<Typography variant="title-3">Customer stories</Typography>
|
|
196
|
+
<Typography variant="body-medium">
|
|
197
|
+
Customer success stories across industries
|
|
198
|
+
</Typography>
|
|
199
|
+
<TextButton className="n-w-fit">Go to case studies</TextButton>
|
|
200
|
+
</div>
|
|
201
|
+
<div className="n-flex n-flex-col n-gap-2 n-bg-neutral-bg-weak n-shadow-light-raised n-w-72 n-rounded-2xl n-p-2">
|
|
202
|
+
<Skeleton
|
|
203
|
+
shape="rectangular"
|
|
204
|
+
className="n-w-full n-h-36 n-rounded-2xl n-mb-4"
|
|
205
|
+
onBackground="weak"
|
|
206
|
+
/>
|
|
207
|
+
<div className="n-flex n-flex-col n-gap-2">
|
|
208
|
+
<Skeleton
|
|
209
|
+
shape="rectangular"
|
|
210
|
+
className="n-w-full"
|
|
211
|
+
onBackground="weak"
|
|
212
|
+
width="80%"
|
|
213
|
+
>
|
|
214
|
+
<Typography variant="title-3">Customer stories</Typography>
|
|
215
|
+
</Skeleton>
|
|
216
|
+
<Skeleton className="n-w-full" onBackground="weak" width="60%">
|
|
217
|
+
<Typography variant="body-medium">Customer</Typography>
|
|
218
|
+
</Skeleton>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export default Component;
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Inherit Height
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
232
|
+
|
|
233
|
+
import { Skeleton, Typography } from '@neo4j-ndl/react';
|
|
234
|
+
|
|
235
|
+
const Component = () => {
|
|
236
|
+
return (
|
|
237
|
+
<div className="n-flex n-flex-col n-gap-4">
|
|
238
|
+
<Skeleton>
|
|
239
|
+
<Typography variant="display">Large display text</Typography>
|
|
240
|
+
</Skeleton>
|
|
241
|
+
<Skeleton>
|
|
242
|
+
<Typography variant="body-medium">Regular body text</Typography>
|
|
243
|
+
</Skeleton>
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export default Component;
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Inherit Width
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
255
|
+
|
|
256
|
+
import { Skeleton, Typography } from '@neo4j-ndl/react';
|
|
257
|
+
|
|
258
|
+
const Component = () => {
|
|
259
|
+
return (
|
|
260
|
+
<div className="n-flex n-flex-col n-gap-4">
|
|
261
|
+
<Skeleton shape="rectangular">
|
|
262
|
+
<Typography variant="body-medium">
|
|
263
|
+
This text determines the skeleton width
|
|
264
|
+
</Typography>
|
|
265
|
+
</Skeleton>
|
|
266
|
+
<Skeleton shape="rectangular">
|
|
267
|
+
<Typography variant="title-3">Shorter text</Typography>
|
|
268
|
+
</Skeleton>
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export default Component;
|
|
274
|
+
```
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# Slider
|
|
2
|
+
|
|
3
|
+
Import: `import { Slider } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### Slider
|
|
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
|
+
| `inputProps` | `HtmlAttributes<"input">` | | `{}` | Input props of the underlying input element |
|
|
13
|
+
| `isDisabled` | `boolean` | | `false` | Whether the slider is disabled |
|
|
14
|
+
| `maxValue` | `number` | | `100` | The maximum value possible to choose |
|
|
15
|
+
| `minValue` | `number` | | `0` | The minimum value possible to choose |
|
|
16
|
+
| `onChange` | `((value: number) => void) \| ((value: [number, number]) => void)` | ✅ | | Callback function triggered when the slider value(s) changes. The function parameter varies depending on the slider type, for single slider, it is a number and for range slider, it is an array of two numbers. |
|
|
17
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
18
|
+
| `showSteps` | `boolean` | | `false` | Whether to display visual indicators for each step in the slider |
|
|
19
|
+
| `showValues` | `boolean` | | `false` | Whether to display a tooltip with the current value when the slider is being dragged |
|
|
20
|
+
| `step` | `number` | | `1` | Determines the step size that will be added or removed from the current value when moving the slider button |
|
|
21
|
+
| `type` | `'range' \| 'single'` | | `single` | Type of the slider |
|
|
22
|
+
| `value` | `number` | ✅ | | Current value of the single slider. **Only required when the type is 'single'**. |
|
|
23
|
+
| `values` | `[number, number]` | ✅ | | Current values of the range slider as an array of two numbers `[min, max]`. **Only required when the type is 'range'**. |
|
|
24
|
+
|
|
25
|
+
The `type` prop is used to determine the type of the slider. It can be `single` or `range`. The `value` prop is required when the `type` is `single` and `values` is required when the `type` is `range`. It also affects the `onChange` prop type.
|
|
26
|
+
|
|
27
|
+
## Accessibility
|
|
28
|
+
|
|
29
|
+
## Implementation guidelines
|
|
30
|
+
|
|
31
|
+
The Slider component is built with full accessibility support using React Aria. It includes proper ARIA attributes, keyboard navigation support, and focus management. Users can interact with the slider using:
|
|
32
|
+
|
|
33
|
+
- **Mouse/Touch**: Click and drag the thumb(s) to adjust values
|
|
34
|
+
- **Keyboard**: Use arrow keys to increment/decrement values, Home/End keys to jump to min/max values
|
|
35
|
+
- **Screen Readers**: Proper ARIA labels and value announcements
|
|
36
|
+
|
|
37
|
+
The component supports explicit and custom `aria-valuetext` through the `inputProps` for enhanced screen reader experience.
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
### Default
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { Slider } from '@neo4j-ndl/react';
|
|
45
|
+
|
|
46
|
+
const Component = () => {
|
|
47
|
+
return (
|
|
48
|
+
<Slider
|
|
49
|
+
minValue={0}
|
|
50
|
+
maxValue={100}
|
|
51
|
+
value={50}
|
|
52
|
+
onChange={(newValue) => {
|
|
53
|
+
console.info('onChange', newValue);
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default Component;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Custom Step Length
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { Slider } from '@neo4j-ndl/react';
|
|
66
|
+
|
|
67
|
+
const Component = () => {
|
|
68
|
+
return (
|
|
69
|
+
<Slider
|
|
70
|
+
minValue={0}
|
|
71
|
+
maxValue={100}
|
|
72
|
+
step={10}
|
|
73
|
+
value={50}
|
|
74
|
+
onChange={(newValue) => {
|
|
75
|
+
console.info('onChange', newValue);
|
|
76
|
+
}}
|
|
77
|
+
showSteps
|
|
78
|
+
showValues
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default Component;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Disabled
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { Slider } from '@neo4j-ndl/react';
|
|
90
|
+
|
|
91
|
+
const Component = () => {
|
|
92
|
+
return (
|
|
93
|
+
<Slider
|
|
94
|
+
minValue={0}
|
|
95
|
+
maxValue={100}
|
|
96
|
+
step={10}
|
|
97
|
+
value={50}
|
|
98
|
+
onChange={(newValue) => {
|
|
99
|
+
console.info('onChange', newValue);
|
|
100
|
+
}}
|
|
101
|
+
isDisabled
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default Component;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Range
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { Slider } from '@neo4j-ndl/react';
|
|
113
|
+
|
|
114
|
+
const Component = () => {
|
|
115
|
+
return (
|
|
116
|
+
<Slider
|
|
117
|
+
type="range"
|
|
118
|
+
values={[10, 50]}
|
|
119
|
+
onChange={(newValue) => {
|
|
120
|
+
console.info('onChange', newValue);
|
|
121
|
+
}}
|
|
122
|
+
minValue={0}
|
|
123
|
+
maxValue={200}
|
|
124
|
+
step={10}
|
|
125
|
+
isDisabled={false}
|
|
126
|
+
showSteps={true}
|
|
127
|
+
showValues={true}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default Component;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Show Steps
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { Slider } from '@neo4j-ndl/react';
|
|
139
|
+
|
|
140
|
+
const Component = () => {
|
|
141
|
+
return (
|
|
142
|
+
<Slider
|
|
143
|
+
minValue={0}
|
|
144
|
+
maxValue={100}
|
|
145
|
+
value={50}
|
|
146
|
+
onChange={(newValue) => {
|
|
147
|
+
console.info('onChange', newValue);
|
|
148
|
+
}}
|
|
149
|
+
showSteps
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default Component;
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Show Values
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import { Slider } from '@neo4j-ndl/react';
|
|
161
|
+
|
|
162
|
+
const Component = () => {
|
|
163
|
+
return (
|
|
164
|
+
<Slider
|
|
165
|
+
minValue={0}
|
|
166
|
+
maxValue={100}
|
|
167
|
+
value={50}
|
|
168
|
+
onChange={(newValue) => {
|
|
169
|
+
console.info('onChange', newValue);
|
|
170
|
+
}}
|
|
171
|
+
showValues
|
|
172
|
+
/>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export default Component;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Single
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { Slider } from '@neo4j-ndl/react';
|
|
183
|
+
|
|
184
|
+
const Component = () => {
|
|
185
|
+
return (
|
|
186
|
+
<Slider
|
|
187
|
+
type="single"
|
|
188
|
+
value={100}
|
|
189
|
+
onChange={(newValue) => {
|
|
190
|
+
console.info('onChange', newValue);
|
|
191
|
+
}}
|
|
192
|
+
minValue={0}
|
|
193
|
+
maxValue={200}
|
|
194
|
+
isDisabled={false}
|
|
195
|
+
step={10}
|
|
196
|
+
showSteps={true}
|
|
197
|
+
showValues={true}
|
|
198
|
+
inputProps={{ 'aria-valuetext': 'percent' }}
|
|
199
|
+
/>
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export default Component;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Single Controlled
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import { Slider, TextInput } from '@neo4j-ndl/react';
|
|
210
|
+
import { useCallback, useState } from 'react';
|
|
211
|
+
|
|
212
|
+
const MIN_VALUE = 0;
|
|
213
|
+
const MAX_VALUE = 100;
|
|
214
|
+
const STEP = 5;
|
|
215
|
+
const INITIAL_VALUE = 50;
|
|
216
|
+
|
|
217
|
+
const getValidationError = (
|
|
218
|
+
input: string,
|
|
219
|
+
): { error: string; isValid: false } | { error: undefined; isValid: true } => {
|
|
220
|
+
const trimmed = input.trim();
|
|
221
|
+
|
|
222
|
+
if (!trimmed) {
|
|
223
|
+
return { error: 'Value is required', isValid: false };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const numValue = Number(trimmed);
|
|
227
|
+
if (isNaN(numValue)) {
|
|
228
|
+
return { error: 'Please enter a valid number', isValid: false };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (!Number.isInteger(numValue)) {
|
|
232
|
+
return { error: 'Please enter a whole number', isValid: false };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (numValue < MIN_VALUE) {
|
|
236
|
+
return { error: `Value must be at least ${MIN_VALUE}`, isValid: false };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (numValue > MAX_VALUE) {
|
|
240
|
+
return { error: `Value must be at most ${MAX_VALUE}`, isValid: false };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return { error: undefined, isValid: true };
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const Component = () => {
|
|
247
|
+
const [value, setValue] = useState(INITIAL_VALUE);
|
|
248
|
+
const [inputValue, setInputValue] = useState(String(INITIAL_VALUE));
|
|
249
|
+
const { error, isValid } = getValidationError(inputValue);
|
|
250
|
+
const hasError = !isValid;
|
|
251
|
+
|
|
252
|
+
const handleInputChange = useCallback(
|
|
253
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
254
|
+
const newInputValue = e.target.value;
|
|
255
|
+
setInputValue(newInputValue);
|
|
256
|
+
|
|
257
|
+
if (isValid) {
|
|
258
|
+
setValue(Number(newInputValue));
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
[setInputValue, setValue, isValid],
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
const handleSliderChange = useCallback(
|
|
265
|
+
(newValue: number) => {
|
|
266
|
+
setValue(newValue);
|
|
267
|
+
setInputValue(String(newValue));
|
|
268
|
+
},
|
|
269
|
+
[setInputValue, setValue],
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<div className="n-flex n-flex-col n-gap-token-16">
|
|
274
|
+
<TextInput
|
|
275
|
+
label="Slider value"
|
|
276
|
+
helpText={`Enter a value between ${MIN_VALUE} and ${MAX_VALUE}`}
|
|
277
|
+
isRequired
|
|
278
|
+
errorText={error}
|
|
279
|
+
htmlAttributes={{
|
|
280
|
+
max: MAX_VALUE,
|
|
281
|
+
min: MIN_VALUE,
|
|
282
|
+
step: STEP,
|
|
283
|
+
type: 'number',
|
|
284
|
+
}}
|
|
285
|
+
value={inputValue}
|
|
286
|
+
onChange={handleInputChange}
|
|
287
|
+
/>
|
|
288
|
+
|
|
289
|
+
<Slider
|
|
290
|
+
type="single"
|
|
291
|
+
value={value}
|
|
292
|
+
onChange={handleSliderChange}
|
|
293
|
+
minValue={MIN_VALUE}
|
|
294
|
+
maxValue={MAX_VALUE}
|
|
295
|
+
step={STEP}
|
|
296
|
+
showSteps
|
|
297
|
+
showValues
|
|
298
|
+
isDisabled={hasError}
|
|
299
|
+
inputProps={{
|
|
300
|
+
'aria-valuetext': `${value} out of ${MAX_VALUE}`,
|
|
301
|
+
}}
|
|
302
|
+
/>
|
|
303
|
+
</div>
|
|
304
|
+
);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export default Component;
|
|
308
|
+
```
|