@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.
- 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,200 @@
|
|
|
1
|
+
# SegmentedControl
|
|
2
|
+
|
|
3
|
+
Import: `import { SegmentedControl } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### SegmentedControl
|
|
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 children component of the segmented control |
|
|
13
|
+
| `hasOnlyIcons` | `boolean` | | `false` | If segmented control items will include only icons (makes controls rectangular) |
|
|
14
|
+
| `isFloating` | `boolean` | | `false` | Whether the segmented control has a box shadow applied |
|
|
15
|
+
| `onChange` | `(e: T) => void \| ((e: SetStateAction<T>) => void)` | ✅ | | The callback function triggered when the segmented control value changes |
|
|
16
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
17
|
+
| `selected` | `SegmentedControlID` | ✅ | | The currently selected option |
|
|
18
|
+
| `size` | `'large' \| 'medium' \| 'small'` | | `medium` | Size of the segmented control |
|
|
19
|
+
|
|
20
|
+
Where type `SegmentedControlID` is defined as: `string | number`.
|
|
21
|
+
|
|
22
|
+
### SegmentedControl.Item
|
|
23
|
+
|
|
24
|
+
| Prop | Type | Required | Default | Description |
|
|
25
|
+
|------|------|----------|---------|-------------|
|
|
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` | | | The children component of the segmented control item |
|
|
28
|
+
| `description` | `string` | | | The description of the segmented control item, will be displayed in the tooltip |
|
|
29
|
+
| `isDisabled` | `boolean` | | `false` | Whether the segmented control item is disabled |
|
|
30
|
+
| `ref` | `any` | | | A ref to apply to the root element. |
|
|
31
|
+
| `tooltipProps` | `TooltipObjectProps` | | | The tooltip props that will be applied if tooltip is set |
|
|
32
|
+
| `value` | `string` | ✅ | | The value of the segmented control item |
|
|
33
|
+
|
|
34
|
+
When the `description` prop is set, hovering over the segmented control item will show a tooltip with the text provided in the `description` prop. `tooltipProps` can be used to customize the tooltip appearance. The `TooltipObjectProps` type is defined as: `{ root?: Partial<React.ComponentProps<typeof Tooltip>>; trigger?: Partial<React.ComponentProps<typeof Tooltip.Trigger>>; content?: Partial<React.ComponentProps<typeof Tooltip.Content>>; }`, see the Tooltip component for more details.
|
|
35
|
+
|
|
36
|
+
## Accessibility
|
|
37
|
+
|
|
38
|
+
## Implementation guidelines
|
|
39
|
+
|
|
40
|
+
SegmentedControl is a grouped interactive control rendered with `role='group'` to convey related selection options. Only one item is selectable at a time, and updates are triggered on click events or using the keyboard navigations. Each segmented control item can have a tooltip applied to it to provide additional information to the user.
|
|
41
|
+
|
|
42
|
+
## Examples
|
|
43
|
+
|
|
44
|
+
### Default
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
48
|
+
|
|
49
|
+
import { SegmentedControl } from '@neo4j-ndl/react';
|
|
50
|
+
import { useState } from 'react';
|
|
51
|
+
|
|
52
|
+
const Component = () => {
|
|
53
|
+
const [selected, setSelected] = useState('tag1');
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<SegmentedControl selected={selected} onChange={setSelected}>
|
|
57
|
+
<SegmentedControl.Item value="tag1">Tag 1</SegmentedControl.Item>
|
|
58
|
+
<SegmentedControl.Item value="tag2">Tag 2</SegmentedControl.Item>
|
|
59
|
+
<SegmentedControl.Item value="tag3">Tag 3</SegmentedControl.Item>
|
|
60
|
+
</SegmentedControl>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default Component;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Disabled
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
71
|
+
|
|
72
|
+
import { SegmentedControl } from '@neo4j-ndl/react';
|
|
73
|
+
import { useState } from 'react';
|
|
74
|
+
|
|
75
|
+
const Component = () => {
|
|
76
|
+
const [selected, setSelected] = useState('tag1');
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<SegmentedControl selected={selected} onChange={setSelected}>
|
|
80
|
+
<SegmentedControl.Item value="tag1" isDisabled>
|
|
81
|
+
Tag 1
|
|
82
|
+
</SegmentedControl.Item>
|
|
83
|
+
<SegmentedControl.Item value="tag2" isDisabled>
|
|
84
|
+
Tag 2
|
|
85
|
+
</SegmentedControl.Item>
|
|
86
|
+
</SegmentedControl>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default Component;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Floating
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
97
|
+
|
|
98
|
+
import { SegmentedControl } from '@neo4j-ndl/react';
|
|
99
|
+
import { useState } from 'react';
|
|
100
|
+
|
|
101
|
+
const Component = () => {
|
|
102
|
+
const [selected, setSelected] = useState('tag1');
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<SegmentedControl
|
|
106
|
+
selected={selected}
|
|
107
|
+
onChange={setSelected}
|
|
108
|
+
isFloating={true}
|
|
109
|
+
>
|
|
110
|
+
<SegmentedControl.Item value="tag1">Tag 1</SegmentedControl.Item>
|
|
111
|
+
<SegmentedControl.Item value="tag2">Tag 2</SegmentedControl.Item>
|
|
112
|
+
<SegmentedControl.Item value="tag3">Tag 3</SegmentedControl.Item>
|
|
113
|
+
</SegmentedControl>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default Component;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Only Icons
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
124
|
+
|
|
125
|
+
import { SegmentedControl } from '@neo4j-ndl/react';
|
|
126
|
+
import { BeakerIconOutline, BoltIconOutline } from '@neo4j-ndl/react/icons';
|
|
127
|
+
import { useState } from 'react';
|
|
128
|
+
|
|
129
|
+
const Component = () => {
|
|
130
|
+
const [selected, setSelected] = useState('boltIcon');
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<SegmentedControl
|
|
134
|
+
selected={selected}
|
|
135
|
+
onChange={setSelected}
|
|
136
|
+
hasOnlyIcons={true}
|
|
137
|
+
>
|
|
138
|
+
<SegmentedControl.Item value="boltIcon" description="Bolt View">
|
|
139
|
+
<BoltIconOutline />
|
|
140
|
+
</SegmentedControl.Item>
|
|
141
|
+
<SegmentedControl.Item value="beakerIcon" description="Beaker View">
|
|
142
|
+
<BeakerIconOutline />
|
|
143
|
+
</SegmentedControl.Item>
|
|
144
|
+
</SegmentedControl>
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export default Component;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Sizes
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
155
|
+
|
|
156
|
+
import { SegmentedControl } from '@neo4j-ndl/react';
|
|
157
|
+
import { useState } from 'react';
|
|
158
|
+
|
|
159
|
+
const Component = () => {
|
|
160
|
+
const [selectedSmall, setSelectedSmall] = useState('small1');
|
|
161
|
+
const [selectedMedium, setSelectedMedium] = useState('medium1');
|
|
162
|
+
const [selectedLarge, setSelectedLarge] = useState('large1');
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<div className="n-flex n-gap-token-16">
|
|
166
|
+
<SegmentedControl
|
|
167
|
+
selected={selectedSmall}
|
|
168
|
+
onChange={setSelectedSmall}
|
|
169
|
+
size="small"
|
|
170
|
+
>
|
|
171
|
+
<SegmentedControl.Item value="small1">Small 1</SegmentedControl.Item>
|
|
172
|
+
<SegmentedControl.Item value="small2">Small 2</SegmentedControl.Item>
|
|
173
|
+
<SegmentedControl.Item value="small3">Small 3</SegmentedControl.Item>
|
|
174
|
+
</SegmentedControl>
|
|
175
|
+
|
|
176
|
+
<SegmentedControl
|
|
177
|
+
selected={selectedMedium}
|
|
178
|
+
onChange={setSelectedMedium}
|
|
179
|
+
size="medium"
|
|
180
|
+
>
|
|
181
|
+
<SegmentedControl.Item value="medium1">Medium 1</SegmentedControl.Item>
|
|
182
|
+
<SegmentedControl.Item value="medium2">Medium 2</SegmentedControl.Item>
|
|
183
|
+
<SegmentedControl.Item value="medium3">Medium 3</SegmentedControl.Item>
|
|
184
|
+
</SegmentedControl>
|
|
185
|
+
|
|
186
|
+
<SegmentedControl
|
|
187
|
+
selected={selectedLarge}
|
|
188
|
+
onChange={setSelectedLarge}
|
|
189
|
+
size="large"
|
|
190
|
+
>
|
|
191
|
+
<SegmentedControl.Item value="large1">Large 1</SegmentedControl.Item>
|
|
192
|
+
<SegmentedControl.Item value="large2">Large 2</SegmentedControl.Item>
|
|
193
|
+
<SegmentedControl.Item value="large3">Large 3</SegmentedControl.Item>
|
|
194
|
+
</SegmentedControl>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export default Component;
|
|
200
|
+
```
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# SelectIconButton
|
|
2
|
+
|
|
3
|
+
Import: `import { SelectIconButton } from '@neo4j-ndl/react'`
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### SelectIconButton
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Required | Default | Description |
|
|
10
|
+
|------|------|----------|---------|-------------|
|
|
11
|
+
| `children` | `ReactNode` | | | Content displayed in the button |
|
|
12
|
+
| `description` | `string \| null` | ✅ | | A string that will be shown as a tooltip when hovering over the button. It also acts as an aria-label. {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label} |
|
|
13
|
+
| `isDisabled` | `boolean` | | `false` | Whether the button is in disabled state |
|
|
14
|
+
| `isLoading` | `boolean` | | `false` | If the button is doing something Async, it will display a loading spinner |
|
|
15
|
+
| `isOpen` | `boolean` | | `false` | If the button is opened |
|
|
16
|
+
| `loadingMessage` | `string` | | `Loading` | Accessible message for screen readers when the button is in a loading state |
|
|
17
|
+
| `onClick` | `((e: MouseEvent<HTMLButtonElement, MouseEvent>) => void)` | | | Callback function to be called when the button is clicked |
|
|
18
|
+
| `ref` | `Ref<HTMLButtonElement>` | | | A ref to apply to the root element. |
|
|
19
|
+
| `size` | `'large' \| 'medium' \| 'small'` | | `medium` | Size of button |
|
|
20
|
+
| `tooltipProps` | `TooltipObjectProps` | | | Props for the tooltip component. |
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### Default
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
28
|
+
|
|
29
|
+
import { SelectIconButton } from '@neo4j-ndl/react';
|
|
30
|
+
import { SelectIcon } from '@neo4j-ndl/react/icons';
|
|
31
|
+
|
|
32
|
+
const Component = () => {
|
|
33
|
+
return (
|
|
34
|
+
<SelectIconButton description="Select" isOpen={false}>
|
|
35
|
+
<SelectIcon />
|
|
36
|
+
</SelectIconButton>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default Component;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Sizes
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
47
|
+
|
|
48
|
+
import { SelectIconButton, Typography } from '@neo4j-ndl/react';
|
|
49
|
+
import { SelectIcon } from '@neo4j-ndl/react/icons';
|
|
50
|
+
|
|
51
|
+
const Component = () => {
|
|
52
|
+
return (
|
|
53
|
+
<div className="n-flex n-flex-col n-gap-token-16">
|
|
54
|
+
<div className="n-flex n-flex-row n-gap-token-16 n-items-center">
|
|
55
|
+
<SelectIconButton description="Select" size="small" isOpen={false}>
|
|
56
|
+
<SelectIcon />
|
|
57
|
+
</SelectIconButton>
|
|
58
|
+
<Typography variant="label"> Small</Typography>
|
|
59
|
+
</div>
|
|
60
|
+
<div className="n-flex n-flex-row n-gap-token-16 n-items-center">
|
|
61
|
+
<SelectIconButton description="Select" size="medium" isOpen={false}>
|
|
62
|
+
<SelectIcon />
|
|
63
|
+
</SelectIconButton>
|
|
64
|
+
<Typography variant="label"> Medium</Typography>
|
|
65
|
+
</div>
|
|
66
|
+
<div className="n-flex n-flex-row n-gap-token-16 n-items-center">
|
|
67
|
+
<SelectIconButton description="Select" size="large" isOpen={false}>
|
|
68
|
+
<SelectIcon />
|
|
69
|
+
</SelectIconButton>
|
|
70
|
+
<Typography variant="label"> Large</Typography>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default Component;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### States
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
83
|
+
|
|
84
|
+
import { SelectIconButton, Typography } from '@neo4j-ndl/react';
|
|
85
|
+
import { SelectIcon } from '@neo4j-ndl/react/icons';
|
|
86
|
+
|
|
87
|
+
const Component = () => {
|
|
88
|
+
return (
|
|
89
|
+
<div className="n-flex n-flex-col n-gap-token-16">
|
|
90
|
+
<div className="n-flex n-flex-row n-gap-token-16 n-items-center">
|
|
91
|
+
<SelectIconButton
|
|
92
|
+
description="Select"
|
|
93
|
+
size="small"
|
|
94
|
+
isDisabled
|
|
95
|
+
isOpen={false}
|
|
96
|
+
>
|
|
97
|
+
<SelectIcon />
|
|
98
|
+
</SelectIconButton>
|
|
99
|
+
<Typography variant="label"> Disabled</Typography>
|
|
100
|
+
</div>
|
|
101
|
+
<div className="n-flex n-flex-row n-gap-token-16 n-items-center">
|
|
102
|
+
<SelectIconButton description="Select" size="small" isOpen={true}>
|
|
103
|
+
<SelectIcon />
|
|
104
|
+
</SelectIconButton>
|
|
105
|
+
<Typography variant="label"> Active</Typography>
|
|
106
|
+
</div>
|
|
107
|
+
<div className="n-flex n-flex-row n-gap-token-16 n-items-center">
|
|
108
|
+
<SelectIconButton
|
|
109
|
+
description="Select"
|
|
110
|
+
size="small"
|
|
111
|
+
isLoading
|
|
112
|
+
loadingMessage="Loading"
|
|
113
|
+
isOpen={false}
|
|
114
|
+
>
|
|
115
|
+
<SelectIcon />
|
|
116
|
+
</SelectIconButton>
|
|
117
|
+
<Typography variant="label"> Loading</Typography>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default Component;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### With Menu
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
130
|
+
|
|
131
|
+
import { Menu, SelectIconButton } from '@neo4j-ndl/react';
|
|
132
|
+
import {
|
|
133
|
+
ExploreIcon,
|
|
134
|
+
HierarchyTwoIcon,
|
|
135
|
+
SelectIcon,
|
|
136
|
+
} from '@neo4j-ndl/react/icons';
|
|
137
|
+
import { useRef, useState } from 'react';
|
|
138
|
+
|
|
139
|
+
const menuItems = [
|
|
140
|
+
{ leadingVisual: <ExploreIcon />, title: 'Force-based layout' },
|
|
141
|
+
{ leadingVisual: <HierarchyTwoIcon />, title: 'Hierarchical layout' },
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
const Component = () => {
|
|
145
|
+
const anchorRef = useRef<HTMLButtonElement | null>(null);
|
|
146
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
147
|
+
const [selectedItem, setSelectedItem] = useState<number>();
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<div>
|
|
151
|
+
<SelectIconButton
|
|
152
|
+
description="Options"
|
|
153
|
+
isOpen={isMenuOpen}
|
|
154
|
+
onClick={() => setIsMenuOpen((old) => !old)}
|
|
155
|
+
ref={anchorRef}
|
|
156
|
+
>
|
|
157
|
+
{selectedItem !== undefined ? (
|
|
158
|
+
menuItems[selectedItem].leadingVisual
|
|
159
|
+
) : (
|
|
160
|
+
<SelectIcon />
|
|
161
|
+
)}
|
|
162
|
+
</SelectIconButton>
|
|
163
|
+
<Menu
|
|
164
|
+
isOpen={isMenuOpen}
|
|
165
|
+
anchorRef={anchorRef}
|
|
166
|
+
onClose={() => setIsMenuOpen(false)}
|
|
167
|
+
>
|
|
168
|
+
{menuItems.map((item, index) => (
|
|
169
|
+
<Menu.RadioItem
|
|
170
|
+
key={index}
|
|
171
|
+
isChecked={selectedItem === index}
|
|
172
|
+
title={item.title}
|
|
173
|
+
leadingVisual={item.leadingVisual}
|
|
174
|
+
onClick={() => setSelectedItem(index)}
|
|
175
|
+
/>
|
|
176
|
+
))}
|
|
177
|
+
</Menu>
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export default Component;
|
|
183
|
+
```
|