@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.
Files changed (109) hide show
  1. package/lib/cjs/color-picker/ColorPicker.js +3 -1
  2. package/lib/cjs/color-picker/ColorPicker.js.map +1 -1
  3. package/lib/cjs/color-picker/stories/color-picker-dialog.story.js +40 -0
  4. package/lib/cjs/color-picker/stories/color-picker-dialog.story.js.map +1 -0
  5. package/lib/cjs/color-picker/stories/color-picker-popover.story.js +32 -0
  6. package/lib/cjs/color-picker/stories/color-picker-popover.story.js.map +1 -0
  7. package/lib/cjs/color-picker/stories/index.js +9 -1
  8. package/lib/cjs/color-picker/stories/index.js.map +1 -1
  9. package/lib/cjs/popover/use-popover.js +1 -1
  10. package/lib/cjs/popover/use-popover.js.map +1 -1
  11. package/lib/cjs/select/Select.js +2 -0
  12. package/lib/cjs/select/Select.js.map +1 -1
  13. package/lib/esm/color-picker/ColorPicker.js +3 -1
  14. package/lib/esm/color-picker/ColorPicker.js.map +1 -1
  15. package/lib/esm/color-picker/stories/color-picker-dialog.story.js +38 -0
  16. package/lib/esm/color-picker/stories/color-picker-dialog.story.js.map +1 -0
  17. package/lib/esm/color-picker/stories/color-picker-popover.story.js +30 -0
  18. package/lib/esm/color-picker/stories/color-picker-popover.story.js.map +1 -0
  19. package/lib/esm/color-picker/stories/index.js +6 -0
  20. package/lib/esm/color-picker/stories/index.js.map +1 -1
  21. package/lib/esm/popover/use-popover.js +1 -1
  22. package/lib/esm/popover/use-popover.js.map +1 -1
  23. package/lib/esm/select/Select.js +2 -0
  24. package/lib/esm/select/Select.js.map +1 -1
  25. package/lib/types/color-picker/ColorPicker.d.ts +4 -0
  26. package/lib/types/color-picker/ColorPicker.d.ts.map +1 -1
  27. package/lib/types/color-picker/stories/color-picker-dialog.story.d.ts +24 -0
  28. package/lib/types/color-picker/stories/color-picker-dialog.story.d.ts.map +1 -0
  29. package/lib/types/color-picker/stories/color-picker-popover.story.d.ts +24 -0
  30. package/lib/types/color-picker/stories/color-picker-popover.story.d.ts.map +1 -0
  31. package/lib/types/color-picker/stories/index.d.ts +4 -0
  32. package/lib/types/color-picker/stories/index.d.ts.map +1 -1
  33. package/lib/types/select/Select.d.ts.map +1 -1
  34. package/package.json +5 -2
  35. package/skills/ndl-react/SKILL.md +152 -0
  36. package/skills/ndl-react/components/accordion.md +386 -0
  37. package/skills/ndl-react/components/ai/code-preview.md +128 -0
  38. package/skills/ndl-react/components/ai/file-tag.md +90 -0
  39. package/skills/ndl-react/components/ai/image-tag.md +91 -0
  40. package/skills/ndl-react/components/ai/more-files.md +73 -0
  41. package/skills/ndl-react/components/ai/presence.md +54 -0
  42. package/skills/ndl-react/components/ai/preview.md +498 -0
  43. package/skills/ndl-react/components/ai/prompt.md +362 -0
  44. package/skills/ndl-react/components/ai/reasoning.md +95 -0
  45. package/skills/ndl-react/components/ai/response.md +1109 -0
  46. package/skills/ndl-react/components/ai/suggestion.md +84 -0
  47. package/skills/ndl-react/components/ai/thinking.md +43 -0
  48. package/skills/ndl-react/components/ai/tool-call.md +43 -0
  49. package/skills/ndl-react/components/ai/user-bubble.md +187 -0
  50. package/skills/ndl-react/components/avatar.md +169 -0
  51. package/skills/ndl-react/components/banner.md +225 -0
  52. package/skills/ndl-react/components/box.md +39 -0
  53. package/skills/ndl-react/components/breadcrumbs.md +245 -0
  54. package/skills/ndl-react/components/checkbox.md +269 -0
  55. package/skills/ndl-react/components/clean-icon-button.md +294 -0
  56. package/skills/ndl-react/components/clipboard-button.md +154 -0
  57. package/skills/ndl-react/components/code-block.md +276 -0
  58. package/skills/ndl-react/components/code.md +68 -0
  59. package/skills/ndl-react/components/color-picker.md +131 -0
  60. package/skills/ndl-react/components/conditional-wrap.md +46 -0
  61. package/skills/ndl-react/components/data-grid.md +3121 -0
  62. package/skills/ndl-react/components/date-picker.md +652 -0
  63. package/skills/ndl-react/components/dialog.md +485 -0
  64. package/skills/ndl-react/components/dismissible-tag.md +136 -0
  65. package/skills/ndl-react/components/divider.md +96 -0
  66. package/skills/ndl-react/components/drawer.md +543 -0
  67. package/skills/ndl-react/components/dropdown-button.md +161 -0
  68. package/skills/ndl-react/components/dropzone.md +371 -0
  69. package/skills/ndl-react/components/filled-button.md +26 -0
  70. package/skills/ndl-react/components/flex.md +82 -0
  71. package/skills/ndl-react/components/graph-label.md +167 -0
  72. package/skills/ndl-react/components/icon-button-array.md +187 -0
  73. package/skills/ndl-react/components/icon-button.md +193 -0
  74. package/skills/ndl-react/components/inline-edit.md +209 -0
  75. package/skills/ndl-react/components/kbd.md +63 -0
  76. package/skills/ndl-react/components/loading-bar.md +43 -0
  77. package/skills/ndl-react/components/loading-spinner.md +57 -0
  78. package/skills/ndl-react/components/logo.md +57 -0
  79. package/skills/ndl-react/components/menu.md +993 -0
  80. package/skills/ndl-react/components/modal.md +27 -0
  81. package/skills/ndl-react/components/next/tree-view.md +966 -0
  82. package/skills/ndl-react/components/outlined-button.md +26 -0
  83. package/skills/ndl-react/components/popover.md +283 -0
  84. package/skills/ndl-react/components/progress-bar.md +70 -0
  85. package/skills/ndl-react/components/radio.md +150 -0
  86. package/skills/ndl-react/components/read-only-tag.md +96 -0
  87. package/skills/ndl-react/components/segmented-control.md +200 -0
  88. package/skills/ndl-react/components/select-icon-button.md +183 -0
  89. package/skills/ndl-react/components/select.md +530 -0
  90. package/skills/ndl-react/components/selectable-tag.md +203 -0
  91. package/skills/ndl-react/components/side-navigation.md +652 -0
  92. package/skills/ndl-react/components/skeleton.md +274 -0
  93. package/skills/ndl-react/components/slider.md +308 -0
  94. package/skills/ndl-react/components/spotlight.md +796 -0
  95. package/skills/ndl-react/components/status-indicator.md +57 -0
  96. package/skills/ndl-react/components/status-label.md +132 -0
  97. package/skills/ndl-react/components/switch.md +167 -0
  98. package/skills/ndl-react/components/tabs.md +433 -0
  99. package/skills/ndl-react/components/tag.md +91 -0
  100. package/skills/ndl-react/components/text-area.md +178 -0
  101. package/skills/ndl-react/components/text-button.md +25 -0
  102. package/skills/ndl-react/components/text-input.md +475 -0
  103. package/skills/ndl-react/components/text-link.md +119 -0
  104. package/skills/ndl-react/components/time-picker.md +137 -0
  105. package/skills/ndl-react/components/timezone-picker.md +496 -0
  106. package/skills/ndl-react/components/tooltip.md +478 -0
  107. package/skills/ndl-react/components/tree-view.md +545 -0
  108. package/skills/ndl-react/components/typography.md +72 -0
  109. package/skills/ndl-react/components/wizard.md +152 -0
@@ -0,0 +1,485 @@
1
+ # Dialog
2
+
3
+ Import: `import { Dialog } from '@neo4j-ndl/react'`
4
+
5
+ ## Props
6
+
7
+ ### Dialog
8
+
9
+ | Prop | Type | Required | Default | Description |
10
+ |------|------|----------|---------|-------------|
11
+ | `children` | `ReactNode` | ✅ | | Content to render inside the Modal. |
12
+ | `container` | `Element` | | | The container where the modal will be rendered. |
13
+ | `hasDisabledCloseButton` | `boolean` | | `false` | Whether to disable the close button in the top-right corner. |
14
+ | `isOpen` | `boolean` | ✅ | | Controls whether the dialog is open or closed. |
15
+ | `onClose` | `((e: MouseEvent<HTMLElement, MouseEvent> \| KeyboardEvent<HTMLElement>, reason?: DialogCloseReason) => void)` | | | Callback function called when the dialog is closed. |
16
+ | `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
17
+ | `rootProps` | `HtmlAttributes<"div">` | | | Forwards the props to the modal container's wrapper - use with caution |
18
+ | `size` | `'large' \| 'medium' \| 'small' \| 'unset'` | | | Sets the size(max-width) of the Modal, use 'unset' for custom sizing. |
19
+ | `variant` | `'danger' \| 'info' \| 'warning'` | | | Type of dialog, which determines the icon and styling. |
20
+
21
+ ### Dialog.Actions
22
+
23
+ | Prop | Type | Required | Default | Description |
24
+ |------|------|----------|---------|-------------|
25
+ | `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
26
+ | `children` | `ReactNode` | | | The content to display within the dialog component. |
27
+ | `ref` | `any` | | | A ref to apply to the root element. |
28
+
29
+ ### Dialog.Content
30
+
31
+ | Prop | Type | Required | Default | Description |
32
+ |------|------|----------|---------|-------------|
33
+ | `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
34
+ | `children` | `ReactNode` | | | The content to display within the dialog component. |
35
+ | `ref` | `any` | | | A ref to apply to the root element. |
36
+
37
+ ### Dialog.Description
38
+
39
+ | Prop | Type | Required | Default | Description |
40
+ |------|------|----------|---------|-------------|
41
+ | `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
42
+ | `children` | `ReactNode` | | | The content to display within the dialog component. |
43
+ | `ref` | `any` | | | A ref to apply to the root element. |
44
+
45
+ ### Dialog.Header
46
+
47
+ | Prop | Type | Required | Default | Description |
48
+ |------|------|----------|---------|-------------|
49
+ | `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
50
+ | `children` | `ReactNode` | | | The content to display within the dialog component. |
51
+ | `ref` | `any` | | | A ref to apply to the root element. |
52
+
53
+ ### Dialog.Image
54
+
55
+ | Prop | Type | Required | Default | Description |
56
+ |------|------|----------|---------|-------------|
57
+ | `alt` | `string` | ✅ | | Alternative text for the image |
58
+ | `ref` | `Ref<HTMLImageElement>` | | | A ref to apply to the root element. |
59
+ | `src` | `string` | ✅ | | Source URL of the image |
60
+
61
+ ### Dialog.Subtitle
62
+
63
+ | Prop | Type | Required | Default | Description |
64
+ |------|------|----------|---------|-------------|
65
+ | `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
66
+ | `children` | `ReactNode` | | | The content to display within the dialog component. |
67
+ | `ref` | `any` | | | A ref to apply to the root element. |
68
+
69
+ ## Accessibility
70
+
71
+ ## Keyboard interactions
72
+
73
+ Implements the keyboard interactions defined in the [WAI-ARIA dialog (modal) pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).
74
+
75
+ | Key | Description |
76
+ | ------------- | --------------------------------------------------------------- |
77
+ | `Tab` | Moves focus to the next focusable element within the dialog |
78
+ | `Shift + Tab` | Moves focus to the previous focusable element within the dialog |
79
+ | `Escape` | Closes the dialog |
80
+
81
+ Escape always closes the dialog — this behavior cannot be disabled. The `onClose` callback receives a `reason` parameter (`escapeKeyDown` or `closeButtonClick`) so you can distinguish how the dialog was closed.
82
+
83
+ ## WAI-ARIA roles and attributes
84
+
85
+ The Dialog component follows the [WAI-ARIA dialog (modal) pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).
86
+
87
+ - The dialog container has `role="dialog"` and `aria-modal="true"`. When `variant` is `warning` or `danger`, the role is set to `alertdialog` per the [WAI-ARIA alertdialog pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/)
88
+ - Focus is trapped within the dialog while open and returned to the trigger on close
89
+ - Initial focus moves to the first focusable element inside the dialog
90
+ - The dialog is labeled via `aria-labelledby` (auto-wired from `Dialog.Header`) or `aria-label`
91
+ - The dialog is described via `aria-describedby` (auto-wired from `Dialog.Description`)
92
+ - The close button has `aria-label="Close"`
93
+ - When a `variant` is set (`info`, `warning`, or `danger`), the icon is announced to screen readers via `aria-label`
94
+ - Document scroll is locked while the dialog is open
95
+ - Clicking the backdrop does not close the dialog, keeping the user's context preserved
96
+
97
+ ## Implementation guidelines
98
+
99
+ - Always provide either a `Dialog.Header` or an `aria-label` via `htmlAttributes` so the dialog has an accessible name. A console warning is emitted if neither is provided
100
+ - If using a button as the trigger, set `aria-haspopup="dialog"` and `aria-controls` on the trigger button
101
+ - If `hasDisabledCloseButton` is set to `true`, the built-in close button is removed. You must provide an alternative visible way to close the dialog (e.g. action buttons). `Escape` still works but it is not discoverable by all users and is unavailable on touch devices.
102
+ - `aria-describedby` is auto-wired from `Dialog.Description`. For `alertdialog` variants (`warning`/`danger`), screen readers will announce this description automatically when the dialog opens
103
+ - For `warning` and `danger` variants the dialog text must clearly communicate the consequences of the action. The variant icon and `alertdialog` role signal urgency but screen reader users rely on the text content alone to understand what is at stake. For example: "Are you sure you want to delete this project? This action cannot be undone."
104
+ - The dialog does not support setting a custom initial focus element — focus always moves to the first focusable element (the close button). Be aware of how you structure your content and how you want focus to be ordered.
105
+
106
+ ### Related WCAG criteria
107
+
108
+ - [2.4.3 Focus Order](https://www.w3.org/WAI/WCAG22/Understanding/focus-order.html) (A): Focus is automatically trapped within the dialog and returned to the trigger on close
109
+ - [2.4.11 Focus Not Obscured](https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum.html) (AA): The modal overlay and scroll lock prevent interaction with obscured content behind the dialog
110
+ - [4.1.2 Name, Role, Value](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html) (A): `role="dialog"`/`role="alertdialog"`, `aria-modal`, accessible name (`aria-labelledby`), and accessible description (`aria-describedby`) are set automatically by the component
111
+
112
+ ## Examples
113
+
114
+ ### Default
115
+
116
+ ```tsx
117
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
118
+
119
+ import { Dialog, FilledButton, OutlinedButton } from '@neo4j-ndl/react';
120
+ import { useRef, useState } from 'react';
121
+
122
+ const Component = (props: { isOpen: boolean }) => {
123
+ const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
124
+ const handleClick = () => setIsOpen((prev) => !prev);
125
+ const handleClose = () => setIsOpen(false);
126
+
127
+ const ref = useRef<HTMLDivElement | null>(null);
128
+
129
+ return (
130
+ <div
131
+ ref={ref}
132
+ className="n-flex n-flex-col n-items-center n-justify-center n-relative n-h-[500px] n-w-full"
133
+ >
134
+ <div className="n-flex n-justify-center">
135
+ <FilledButton
136
+ onClick={handleClick}
137
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
138
+ >
139
+ Open Dialog
140
+ </FilledButton>
141
+ </div>
142
+ <Dialog
143
+ onClose={handleClose}
144
+ isOpen={isOpen}
145
+ container={ref?.current || undefined}
146
+ htmlAttributes={{ id: 'default-dialog' }}
147
+ >
148
+ <Dialog.Header>Header</Dialog.Header>
149
+ <Dialog.Description>This is a description</Dialog.Description>
150
+ <Dialog.Content>This is where you put your content</Dialog.Content>
151
+ <Dialog.Actions>
152
+ <OutlinedButton onClick={handleClose} variant="neutral" size="medium">
153
+ Secondary
154
+ </OutlinedButton>
155
+ <FilledButton onClick={handleClose} size="medium">
156
+ Primary
157
+ </FilledButton>
158
+ </Dialog.Actions>
159
+ </Dialog>
160
+ </div>
161
+ );
162
+ };
163
+
164
+ export default Component;
165
+ ```
166
+
167
+ ### Danger
168
+
169
+ ```tsx
170
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
171
+
172
+ import { Dialog, FilledButton, OutlinedButton } from '@neo4j-ndl/react';
173
+ import { useState } from 'react';
174
+
175
+ const Component = (props: { isOpen: boolean }) => {
176
+ const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
177
+ const handleClick = () => setIsOpen((prev) => !prev);
178
+ const handleClose = () => setIsOpen(false);
179
+
180
+ return (
181
+ <>
182
+ <div className="n-flex n-justify-center">
183
+ <FilledButton
184
+ onClick={handleClick}
185
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
186
+ >
187
+ Open Dialog
188
+ </FilledButton>
189
+ </div>
190
+ <Dialog
191
+ onClose={handleClose}
192
+ isOpen={isOpen}
193
+ htmlAttributes={{
194
+ id: 'danger-dialog',
195
+ }}
196
+ variant="danger"
197
+ >
198
+ <Dialog.Header>Header</Dialog.Header>
199
+ <Dialog.Subtitle>This is a subtitle</Dialog.Subtitle>
200
+ <Dialog.Description>This is a description</Dialog.Description>
201
+ <Dialog.Actions>
202
+ <OutlinedButton onClick={handleClose} variant="neutral" size="medium">
203
+ Secondary
204
+ </OutlinedButton>
205
+ <FilledButton onClick={handleClose} size="medium">
206
+ Primary
207
+ </FilledButton>
208
+ </Dialog.Actions>
209
+ </Dialog>
210
+ </>
211
+ );
212
+ };
213
+
214
+ export default Component;
215
+ ```
216
+
217
+ ### Image
218
+
219
+ ```tsx
220
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
221
+
222
+ import { Dialog, FilledButton, OutlinedButton } from '@neo4j-ndl/react';
223
+ import { useState } from 'react';
224
+
225
+ import DialogExample from './assets/DialogExample.png';
226
+
227
+ const Component = (props: { isOpen: boolean }) => {
228
+ const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
229
+ const handleClick = () => setIsOpen((prev) => !prev);
230
+ const handleClose = () => setIsOpen(false);
231
+
232
+ return (
233
+ <>
234
+ <div className="n-flex n-justify-center">
235
+ <FilledButton
236
+ onClick={handleClick}
237
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
238
+ >
239
+ Open Dialog
240
+ </FilledButton>
241
+ </div>
242
+ <Dialog
243
+ htmlAttributes={{
244
+ id: 'image-dialog',
245
+ }}
246
+ onClose={handleClose}
247
+ isOpen={isOpen}
248
+ >
249
+ <Dialog.Header>Header</Dialog.Header>
250
+ <Dialog.Image src={DialogExample} alt="Example image" />
251
+ <Dialog.Description>This is a description.</Dialog.Description>
252
+ <Dialog.Actions>
253
+ <OutlinedButton onClick={handleClose} variant="neutral" size="medium">
254
+ Secondary
255
+ </OutlinedButton>
256
+ <FilledButton onClick={handleClose} size="medium">
257
+ Primary
258
+ </FilledButton>
259
+ </Dialog.Actions>
260
+ </Dialog>
261
+ </>
262
+ );
263
+ };
264
+
265
+ export default Component;
266
+ ```
267
+
268
+ ### Info
269
+
270
+ ```tsx
271
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
272
+
273
+ import { Dialog, FilledButton, OutlinedButton } from '@neo4j-ndl/react';
274
+ import { useState } from 'react';
275
+
276
+ const Component = (props: { isOpen: boolean }) => {
277
+ const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
278
+ const handleClick = () => setIsOpen((prev) => !prev);
279
+ const handleClose = () => setIsOpen(false);
280
+
281
+ return (
282
+ <>
283
+ <div className="n-flex n-justify-center">
284
+ <FilledButton
285
+ onClick={handleClick}
286
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
287
+ >
288
+ Open Dialog
289
+ </FilledButton>
290
+ </div>
291
+ <Dialog
292
+ onClose={handleClose}
293
+ isOpen={isOpen}
294
+ htmlAttributes={{
295
+ id: 'info-dialog',
296
+ }}
297
+ variant="info"
298
+ >
299
+ <Dialog.Header>Header</Dialog.Header>
300
+ <Dialog.Subtitle>This is a subtitle</Dialog.Subtitle>
301
+ <Dialog.Description>This is a description</Dialog.Description>
302
+ <Dialog.Actions>
303
+ <OutlinedButton onClick={handleClose} variant="neutral" size="medium">
304
+ Secondary
305
+ </OutlinedButton>
306
+ <FilledButton onClick={handleClose} size="medium">
307
+ Primary
308
+ </FilledButton>
309
+ </Dialog.Actions>
310
+ </Dialog>
311
+ </>
312
+ );
313
+ };
314
+
315
+ export default Component;
316
+ ```
317
+
318
+ ### Top Aligned
319
+
320
+ ```tsx
321
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
322
+
323
+ import { Dialog, FilledButton, OutlinedButton } from '@neo4j-ndl/react';
324
+ import { useState } from 'react';
325
+
326
+ const Component = (props: { isOpen: boolean }) => {
327
+ const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
328
+ const handleClick = () => setIsOpen((prev) => !prev);
329
+ const handleClose = () => setIsOpen(false);
330
+
331
+ return (
332
+ <>
333
+ <div className="n-flex n-justify-center">
334
+ <FilledButton
335
+ onClick={handleClick}
336
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
337
+ >
338
+ Open Dialog
339
+ </FilledButton>
340
+ </div>
341
+ <Dialog
342
+ htmlAttributes={{
343
+ id: 'top-aligned-dialog',
344
+ }}
345
+ className="n-align-top n-mt-token-16"
346
+ onClose={handleClose}
347
+ isOpen={isOpen}
348
+ >
349
+ <Dialog.Header>Header</Dialog.Header>
350
+ <Dialog.Content>This is where you put your content</Dialog.Content>
351
+ <Dialog.Actions>
352
+ <OutlinedButton onClick={handleClose} variant="neutral" size="medium">
353
+ Secondary
354
+ </OutlinedButton>
355
+ <FilledButton onClick={handleClose} size="medium">
356
+ Primary
357
+ </FilledButton>
358
+ </Dialog.Actions>
359
+ </Dialog>
360
+ </>
361
+ );
362
+ };
363
+
364
+ export default Component;
365
+ ```
366
+
367
+ ### Variants
368
+
369
+ ```tsx
370
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
371
+
372
+ import { Dialog, FilledButton, OutlinedButton } from '@neo4j-ndl/react';
373
+ import { useState } from 'react';
374
+
375
+ const Component = (props: { isOpen: boolean }) => {
376
+ const [variant, setVariant] = useState<
377
+ React.ComponentProps<typeof Dialog>['variant'] | undefined
378
+ >(undefined);
379
+ const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
380
+ const handleClick = (
381
+ variant: React.ComponentProps<typeof Dialog>['variant'],
382
+ ) => {
383
+ setVariant(variant);
384
+ setIsOpen((prev) => !prev);
385
+ };
386
+ const handleClose = () => setIsOpen(false);
387
+
388
+ return (
389
+ <>
390
+ <div className="n-flex n-justify-center n-gap-token-16">
391
+ <FilledButton
392
+ onClick={() => handleClick('info')}
393
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
394
+ >
395
+ Info Dialog
396
+ </FilledButton>
397
+ <FilledButton
398
+ onClick={() => handleClick('warning')}
399
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
400
+ >
401
+ Warning Dialog
402
+ </FilledButton>
403
+ <FilledButton
404
+ onClick={() => handleClick('danger')}
405
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
406
+ >
407
+ Danger Dialog
408
+ </FilledButton>
409
+ </div>
410
+ <Dialog
411
+ htmlAttributes={{
412
+ id: `${variant}-dialog`,
413
+ }}
414
+ onClose={handleClose}
415
+ isOpen={isOpen}
416
+ variant={variant}
417
+ >
418
+ <Dialog.Header>Header</Dialog.Header>
419
+ <Dialog.Subtitle>This is a subtitle</Dialog.Subtitle>
420
+ <Dialog.Description>This is a description</Dialog.Description>
421
+ <Dialog.Actions>
422
+ <OutlinedButton onClick={handleClose} variant="neutral" size="medium">
423
+ Secondary
424
+ </OutlinedButton>
425
+ <FilledButton onClick={handleClose} size="medium">
426
+ Primary
427
+ </FilledButton>
428
+ </Dialog.Actions>
429
+ </Dialog>
430
+ </>
431
+ );
432
+ };
433
+
434
+ export default Component;
435
+ ```
436
+
437
+ ### Warning
438
+
439
+ ```tsx
440
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
441
+
442
+ import { Dialog, FilledButton, OutlinedButton } from '@neo4j-ndl/react';
443
+ import { useState } from 'react';
444
+
445
+ const Component = (props: { isOpen: boolean }) => {
446
+ const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
447
+ const handleClick = () => setIsOpen((prev) => !prev);
448
+ const handleClose = () => setIsOpen(false);
449
+
450
+ return (
451
+ <>
452
+ <div className="n-flex n-justify-center">
453
+ <FilledButton
454
+ onClick={handleClick}
455
+ htmlAttributes={{ 'aria-haspopup': 'dialog' }}
456
+ >
457
+ Open Dialog
458
+ </FilledButton>
459
+ </div>
460
+ <Dialog
461
+ onClose={handleClose}
462
+ isOpen={isOpen}
463
+ htmlAttributes={{
464
+ id: 'warning-dialog',
465
+ }}
466
+ variant="warning"
467
+ >
468
+ <Dialog.Header>Header</Dialog.Header>
469
+ <Dialog.Subtitle>This is a subtitle</Dialog.Subtitle>
470
+ <Dialog.Description>This is a description</Dialog.Description>
471
+ <Dialog.Actions>
472
+ <OutlinedButton onClick={handleClose} variant="neutral" size="medium">
473
+ Secondary
474
+ </OutlinedButton>
475
+ <FilledButton onClick={handleClose} size="medium">
476
+ Primary
477
+ </FilledButton>
478
+ </Dialog.Actions>
479
+ </Dialog>
480
+ </>
481
+ );
482
+ };
483
+
484
+ export default Component;
485
+ ```
@@ -0,0 +1,136 @@
1
+ # DismissibleTag
2
+
3
+ Import: `import { DismissibleTag } from '@neo4j-ndl/react'`
4
+
5
+ ## Props
6
+
7
+ ### DismissibleTag
8
+
9
+ | Prop | Type | Required | Default | Description |
10
+ |------|------|----------|---------|-------------|
11
+ | `children` | `ReactNode` | | | The content of the tag |
12
+ | `color` | `'1' \| '2' \| '3' \| '4' \| '5' \| '6' \| '7' \| '8'` | | | Categorical color for the background |
13
+ | `leadingVisual` | `ReactNode` | | | Icon to display before the content |
14
+ | `onRemove` | `MouseEventHandler<HTMLButtonElement>` | ✅ | | Callback function triggered when tag should be removed. |
15
+ | `ref` | `Ref<HTMLDivElement>` | | | A ref to apply to the root element. |
16
+ | `size` | `'large' \| 'medium' \| 'small' \| 'x-small'` | | `medium` | Size of the tag |
17
+
18
+ ## Examples
19
+
20
+ ### Default
21
+
22
+ ```tsx
23
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
24
+
25
+ import { DismissibleTag } from '@neo4j-ndl/react';
26
+
27
+ const Component = () => {
28
+ return (
29
+ <DismissibleTag onRemove={() => console.info('onRemove was called')}>
30
+ Dismissible Tag
31
+ </DismissibleTag>
32
+ );
33
+ };
34
+
35
+ export default Component;
36
+ ```
37
+
38
+ ### Colors
39
+
40
+ ```tsx
41
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
42
+
43
+ import { DismissibleTag } from '@neo4j-ndl/react';
44
+
45
+ const Component = () => {
46
+ const handleRemove = () => {
47
+ console.info('onRemove was called');
48
+ };
49
+
50
+ return (
51
+ <div className="n-flex n-flex-col n-gap-token-16">
52
+ <DismissibleTag color="1" onRemove={handleRemove}>
53
+ Categorical color 1
54
+ </DismissibleTag>
55
+ <DismissibleTag color="2" onRemove={handleRemove}>
56
+ Categorical color 2
57
+ </DismissibleTag>
58
+ <DismissibleTag color="3" onRemove={handleRemove}>
59
+ Categorical color 3
60
+ </DismissibleTag>
61
+ <DismissibleTag color="4" onRemove={handleRemove}>
62
+ Categorical color 4
63
+ </DismissibleTag>
64
+ <DismissibleTag color="5" onRemove={handleRemove}>
65
+ Categorical color 5
66
+ </DismissibleTag>
67
+ <DismissibleTag color="6" onRemove={handleRemove}>
68
+ Categorical color 6
69
+ </DismissibleTag>
70
+ <DismissibleTag color="7" onRemove={handleRemove}>
71
+ Categorical color 7
72
+ </DismissibleTag>
73
+ <DismissibleTag color="8" onRemove={handleRemove}>
74
+ Categorical color 8
75
+ </DismissibleTag>
76
+ </div>
77
+ );
78
+ };
79
+
80
+ export default Component;
81
+ ```
82
+
83
+ ### Sizes
84
+
85
+ ```tsx
86
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
87
+
88
+ import { DismissibleTag } from '@neo4j-ndl/react';
89
+
90
+ const Component = () => {
91
+ const handleRemove = () => {
92
+ console.info('onRemove was called');
93
+ };
94
+
95
+ return (
96
+ <div className="n-flex n-flex-row n-gap-token-8">
97
+ <DismissibleTag size="x-small" onRemove={handleRemove}>
98
+ X-Small
99
+ </DismissibleTag>
100
+ <DismissibleTag size="small" onRemove={handleRemove}>
101
+ Small
102
+ </DismissibleTag>
103
+ <DismissibleTag size="medium" onRemove={handleRemove}>
104
+ Medium
105
+ </DismissibleTag>
106
+ <DismissibleTag size="large" onRemove={handleRemove}>
107
+ Large
108
+ </DismissibleTag>
109
+ </div>
110
+ );
111
+ };
112
+
113
+ export default Component;
114
+ ```
115
+
116
+ ### With Leading Icon
117
+
118
+ ```tsx
119
+ import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
120
+
121
+ import { DismissibleTag } from '@neo4j-ndl/react';
122
+ import { DatabasePlusIcon } from '@neo4j-ndl/react/icons';
123
+
124
+ const Component = () => {
125
+ return (
126
+ <DismissibleTag
127
+ leadingVisual={<DatabasePlusIcon />}
128
+ onRemove={() => console.info('onRemove was called')}
129
+ >
130
+ Dismissible Tag with leading icon
131
+ </DismissibleTag>
132
+ );
133
+ };
134
+
135
+ export default Component;
136
+ ```