@lglab/compose-ui-mcp 0.0.1
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/README.md +11 -0
- package/dist/assets/llms/accordion.md +184 -0
- package/dist/assets/llms/alert-dialog.md +306 -0
- package/dist/assets/llms/autocomplete.md +756 -0
- package/dist/assets/llms/avatar.md +166 -0
- package/dist/assets/llms/badge.md +478 -0
- package/dist/assets/llms/button.md +238 -0
- package/dist/assets/llms/card.md +264 -0
- package/dist/assets/llms/checkbox-group.md +158 -0
- package/dist/assets/llms/checkbox.md +83 -0
- package/dist/assets/llms/collapsible.md +165 -0
- package/dist/assets/llms/combobox.md +1255 -0
- package/dist/assets/llms/context-menu.md +371 -0
- package/dist/assets/llms/dialog.md +592 -0
- package/dist/assets/llms/drawer.md +437 -0
- package/dist/assets/llms/field.md +74 -0
- package/dist/assets/llms/form.md +1931 -0
- package/dist/assets/llms/input.md +47 -0
- package/dist/assets/llms/menu.md +484 -0
- package/dist/assets/llms/menubar.md +804 -0
- package/dist/assets/llms/meter.md +181 -0
- package/dist/assets/llms/navigation-menu.md +187 -0
- package/dist/assets/llms/number-field.md +243 -0
- package/dist/assets/llms/pagination.md +514 -0
- package/dist/assets/llms/popover.md +206 -0
- package/dist/assets/llms/preview-card.md +146 -0
- package/dist/assets/llms/progress.md +60 -0
- package/dist/assets/llms/radio-group.md +105 -0
- package/dist/assets/llms/scroll-area.md +132 -0
- package/dist/assets/llms/select.md +276 -0
- package/dist/assets/llms/separator.md +49 -0
- package/dist/assets/llms/skeleton.md +96 -0
- package/dist/assets/llms/slider.md +161 -0
- package/dist/assets/llms/switch.md +101 -0
- package/dist/assets/llms/table.md +1325 -0
- package/dist/assets/llms/tabs.md +327 -0
- package/dist/assets/llms/textarea.md +38 -0
- package/dist/assets/llms/toast.md +349 -0
- package/dist/assets/llms/toggle-group.md +261 -0
- package/dist/assets/llms/toggle.md +161 -0
- package/dist/assets/llms/toolbar.md +148 -0
- package/dist/assets/llms/tooltip.md +486 -0
- package/dist/assets/llms-full.txt +14515 -0
- package/dist/assets/llms.txt +65 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +161 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Compose UI MCP Server
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server that exposes [Compose UI](https://compose-ui.dev) library documentation to AI tools like Claude, Cursor etc...
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
To get started, check out the [Compose UI documentation](https://www.compose-ui.dev/overview/mcp).
|
|
8
|
+
|
|
9
|
+
## License
|
|
10
|
+
|
|
11
|
+
Licensed under the [MIT license](https://github.com/LGLabGreg/compose-ui/blob/main/LICENSE.md).
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Accordion
|
|
2
|
+
|
|
3
|
+
A set of collapsible panels with headings.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { AccordionRoot, AccordionItem, AccordionHeader, AccordionTrigger, AccordionPanel } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
AccordionHeader,
|
|
24
|
+
AccordionItem,
|
|
25
|
+
AccordionPanel,
|
|
26
|
+
AccordionRoot,
|
|
27
|
+
AccordionTrigger,
|
|
28
|
+
} from '@lglab/compose-ui/accordion'
|
|
29
|
+
import { ChevronDown } from 'lucide-react'
|
|
30
|
+
|
|
31
|
+
const items = [
|
|
32
|
+
{
|
|
33
|
+
title: 'What is Compose UI?',
|
|
34
|
+
content:
|
|
35
|
+
'Compose UI is a collection of accessible React components built with Base UI and Tailwind CSS, ready to use in your design systems and web apps.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'How do I get started?',
|
|
39
|
+
content:
|
|
40
|
+
'Head to the "Quick start" guide in the docs. Install the package and start using components right away.',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
title: 'Can I use it for my project?',
|
|
44
|
+
content: 'Of course! Compose UI is free and open source.',
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
export default function BasicExample() {
|
|
49
|
+
return (
|
|
50
|
+
<AccordionRoot className='w-full max-w-md'>
|
|
51
|
+
{items.map((item) => (
|
|
52
|
+
<AccordionItem key={item.title} value={item.title}>
|
|
53
|
+
<AccordionHeader>
|
|
54
|
+
<AccordionTrigger className='group'>
|
|
55
|
+
{item.title}
|
|
56
|
+
<ChevronDown className='h-5 w-5 shrink-0 text-muted-foreground transition-transform duration-200 group-data-panel-open:rotate-180' />
|
|
57
|
+
</AccordionTrigger>
|
|
58
|
+
</AccordionHeader>
|
|
59
|
+
<AccordionPanel>
|
|
60
|
+
<div className='pb-4 text-sm'>
|
|
61
|
+
<p>{item.content}</p>
|
|
62
|
+
</div>
|
|
63
|
+
</AccordionPanel>
|
|
64
|
+
</AccordionItem>
|
|
65
|
+
))}
|
|
66
|
+
</AccordionRoot>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Icon
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import {
|
|
75
|
+
AccordionHeader,
|
|
76
|
+
AccordionItem,
|
|
77
|
+
AccordionPanel,
|
|
78
|
+
AccordionRoot,
|
|
79
|
+
AccordionTrigger,
|
|
80
|
+
} from '@lglab/compose-ui/accordion'
|
|
81
|
+
import { Plus } from 'lucide-react'
|
|
82
|
+
|
|
83
|
+
const items = [
|
|
84
|
+
{
|
|
85
|
+
title: 'What is Compose UI?',
|
|
86
|
+
content:
|
|
87
|
+
'Compose UI is a collection of accessible React components built with Base UI and Tailwind CSS, ready to use in your design systems and web apps.',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
title: 'How do I get started?',
|
|
91
|
+
content:
|
|
92
|
+
'Head to the "Quick start" guide in the docs. Install the package and start using components right away.',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: 'Can I use it for my project?',
|
|
96
|
+
content: 'Of course! Compose UI is free and open source.',
|
|
97
|
+
},
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
export default function BasicExample() {
|
|
101
|
+
return (
|
|
102
|
+
<AccordionRoot className='w-full max-w-md'>
|
|
103
|
+
{items.map((item) => (
|
|
104
|
+
<AccordionItem key={item.title} value={item.title}>
|
|
105
|
+
<AccordionHeader>
|
|
106
|
+
<AccordionTrigger className='group'>
|
|
107
|
+
{item.title}
|
|
108
|
+
<Plus className='size-5 shrink-0 text-muted-foreground transition-transform duration-200 group-data-panel-open:rotate-45 group-data-panel-open:scale-105' />
|
|
109
|
+
</AccordionTrigger>
|
|
110
|
+
</AccordionHeader>
|
|
111
|
+
<AccordionPanel>
|
|
112
|
+
<div className='pb-4 text-sm'>
|
|
113
|
+
<p>{item.content}</p>
|
|
114
|
+
</div>
|
|
115
|
+
</AccordionPanel>
|
|
116
|
+
</AccordionItem>
|
|
117
|
+
))}
|
|
118
|
+
</AccordionRoot>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Multiple
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import {
|
|
127
|
+
AccordionHeader,
|
|
128
|
+
AccordionItem,
|
|
129
|
+
AccordionPanel,
|
|
130
|
+
AccordionRoot,
|
|
131
|
+
AccordionTrigger,
|
|
132
|
+
} from '@lglab/compose-ui/accordion'
|
|
133
|
+
import { ChevronDown } from 'lucide-react'
|
|
134
|
+
|
|
135
|
+
const items = [
|
|
136
|
+
{
|
|
137
|
+
title: 'Installation',
|
|
138
|
+
content:
|
|
139
|
+
'Install Compose UI using your preferred package manager: npm, pnpm, yarn, or bun.',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
title: 'Styling',
|
|
143
|
+
content:
|
|
144
|
+
'Import the default styles and register Compose UI as a Tailwind source in your main CSS file.',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
title: 'Usage',
|
|
148
|
+
content:
|
|
149
|
+
'Import components directly from the package and start using them in your React application.',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
title: 'Customization',
|
|
153
|
+
content:
|
|
154
|
+
'Override the default theme by setting CSS variables. All components accept className props for additional styling.',
|
|
155
|
+
},
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
export default function MultipleExample() {
|
|
159
|
+
return (
|
|
160
|
+
<AccordionRoot multiple className='w-full max-w-md'>
|
|
161
|
+
{items.map((item) => (
|
|
162
|
+
<AccordionItem key={item.title} value={item.title}>
|
|
163
|
+
<AccordionHeader>
|
|
164
|
+
<AccordionTrigger className='group'>
|
|
165
|
+
{item.title}
|
|
166
|
+
<ChevronDown className='h-5 w-5 shrink-0 text-muted-foreground transition-transform duration-200 group-data-panel-open:rotate-180' />
|
|
167
|
+
</AccordionTrigger>
|
|
168
|
+
</AccordionHeader>
|
|
169
|
+
<AccordionPanel>
|
|
170
|
+
<div className='pb-4 text-sm'>
|
|
171
|
+
<p>{item.content}</p>
|
|
172
|
+
</div>
|
|
173
|
+
</AccordionPanel>
|
|
174
|
+
</AccordionItem>
|
|
175
|
+
))}
|
|
176
|
+
</AccordionRoot>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Resources
|
|
182
|
+
|
|
183
|
+
- [Base UI Accordion Documentation](https://base-ui.com/react/components/accordion)
|
|
184
|
+
- [API Reference](https://base-ui.com/react/components/accordion#api-reference)
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# Alert Dialog
|
|
2
|
+
|
|
3
|
+
A dialog that requires a user response to proceed.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lglab/compose-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { AlertDialog } from '@lglab/compose-ui'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Basic
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
AlertDialogBackdrop,
|
|
24
|
+
AlertDialogClose,
|
|
25
|
+
AlertDialogDescription,
|
|
26
|
+
AlertDialogPopup,
|
|
27
|
+
AlertDialogPortal,
|
|
28
|
+
AlertDialogRoot,
|
|
29
|
+
AlertDialogTitle,
|
|
30
|
+
AlertDialogTrigger,
|
|
31
|
+
} from '@lglab/compose-ui/alert-dialog'
|
|
32
|
+
|
|
33
|
+
export default function BasicExample() {
|
|
34
|
+
return (
|
|
35
|
+
<AlertDialogRoot>
|
|
36
|
+
<AlertDialogTrigger variant='destructive'>Discard draft</AlertDialogTrigger>
|
|
37
|
+
<AlertDialogPortal>
|
|
38
|
+
<AlertDialogBackdrop />
|
|
39
|
+
<AlertDialogPopup>
|
|
40
|
+
<AlertDialogTitle>Discard draft?</AlertDialogTitle>
|
|
41
|
+
<AlertDialogDescription>
|
|
42
|
+
You can't undo this action.
|
|
43
|
+
</AlertDialogDescription>
|
|
44
|
+
<div className='mt-6 flex justify-end gap-2'>
|
|
45
|
+
<AlertDialogClose>Cancel</AlertDialogClose>
|
|
46
|
+
<AlertDialogClose variant='destructive'>Discard</AlertDialogClose>
|
|
47
|
+
</div>
|
|
48
|
+
</AlertDialogPopup>
|
|
49
|
+
</AlertDialogPortal>
|
|
50
|
+
</AlertDialogRoot>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Close confirmation
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import {
|
|
59
|
+
AlertDialogClose,
|
|
60
|
+
AlertDialogDescription,
|
|
61
|
+
AlertDialogPopup,
|
|
62
|
+
AlertDialogPortal,
|
|
63
|
+
AlertDialogRoot,
|
|
64
|
+
AlertDialogTitle,
|
|
65
|
+
} from '@lglab/compose-ui/alert-dialog'
|
|
66
|
+
import { Button } from '@lglab/compose-ui/button'
|
|
67
|
+
import {
|
|
68
|
+
DialogBackdrop,
|
|
69
|
+
DialogClose,
|
|
70
|
+
DialogPopup,
|
|
71
|
+
DialogPortal,
|
|
72
|
+
DialogRoot,
|
|
73
|
+
DialogTitle,
|
|
74
|
+
DialogTrigger,
|
|
75
|
+
} from '@lglab/compose-ui/dialog'
|
|
76
|
+
import { useState } from 'react'
|
|
77
|
+
|
|
78
|
+
export default function CloseConfirmationExample() {
|
|
79
|
+
const [dialogOpen, setDialogOpen] = useState(false)
|
|
80
|
+
const [confirmationOpen, setConfirmationOpen] = useState(false)
|
|
81
|
+
const [textareaValue, setTextareaValue] = useState('')
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<DialogRoot
|
|
85
|
+
open={dialogOpen}
|
|
86
|
+
onOpenChange={(open) => {
|
|
87
|
+
if (!open && textareaValue) {
|
|
88
|
+
setConfirmationOpen(true)
|
|
89
|
+
} else {
|
|
90
|
+
setTextareaValue('')
|
|
91
|
+
setDialogOpen(open)
|
|
92
|
+
}
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<DialogTrigger>Send Message</DialogTrigger>
|
|
96
|
+
<DialogPortal>
|
|
97
|
+
<DialogBackdrop />
|
|
98
|
+
<DialogPopup>
|
|
99
|
+
<DialogTitle>New Message</DialogTitle>
|
|
100
|
+
<form
|
|
101
|
+
className='mt-4 flex flex-col gap-6'
|
|
102
|
+
onSubmit={(event) => {
|
|
103
|
+
event.preventDefault()
|
|
104
|
+
setDialogOpen(false)
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<textarea
|
|
108
|
+
required
|
|
109
|
+
className='min-h-48 w-full rounded-md border px-3.5 py-2'
|
|
110
|
+
placeholder="What's on your mind?"
|
|
111
|
+
value={textareaValue}
|
|
112
|
+
onChange={(event) => setTextareaValue(event.target.value)}
|
|
113
|
+
/>
|
|
114
|
+
<div className='flex justify-end gap-2'>
|
|
115
|
+
<DialogClose>Cancel</DialogClose>
|
|
116
|
+
<Button type='submit'>Send</Button>
|
|
117
|
+
</div>
|
|
118
|
+
</form>
|
|
119
|
+
</DialogPopup>
|
|
120
|
+
</DialogPortal>
|
|
121
|
+
|
|
122
|
+
<AlertDialogRoot open={confirmationOpen} onOpenChange={setConfirmationOpen}>
|
|
123
|
+
<AlertDialogPortal>
|
|
124
|
+
<AlertDialogPopup>
|
|
125
|
+
<AlertDialogTitle>Discard message?</AlertDialogTitle>
|
|
126
|
+
<AlertDialogDescription>Your tweet will be lost.</AlertDialogDescription>
|
|
127
|
+
<div className='mt-6 flex items-center justify-end gap-2'>
|
|
128
|
+
<AlertDialogClose>Go back</AlertDialogClose>
|
|
129
|
+
<AlertDialogClose
|
|
130
|
+
variant='destructive'
|
|
131
|
+
onClick={() => {
|
|
132
|
+
setConfirmationOpen(false)
|
|
133
|
+
setDialogOpen(false)
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
Discard
|
|
137
|
+
</AlertDialogClose>
|
|
138
|
+
</div>
|
|
139
|
+
</AlertDialogPopup>
|
|
140
|
+
</AlertDialogPortal>
|
|
141
|
+
</AlertDialogRoot>
|
|
142
|
+
</DialogRoot>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Detached triggers
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import {
|
|
151
|
+
AlertDialog,
|
|
152
|
+
AlertDialogBackdrop,
|
|
153
|
+
AlertDialogClose,
|
|
154
|
+
AlertDialogDescription,
|
|
155
|
+
AlertDialogPopup,
|
|
156
|
+
AlertDialogPortal,
|
|
157
|
+
AlertDialogRoot,
|
|
158
|
+
AlertDialogTitle,
|
|
159
|
+
AlertDialogTrigger,
|
|
160
|
+
} from '@lglab/compose-ui/alert-dialog'
|
|
161
|
+
|
|
162
|
+
const demoAlertDialog = AlertDialog.createHandle()
|
|
163
|
+
|
|
164
|
+
export default function DetachedTriggersExample() {
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
<AlertDialogTrigger handle={demoAlertDialog} variant='destructive'>
|
|
168
|
+
Discard draft
|
|
169
|
+
</AlertDialogTrigger>
|
|
170
|
+
|
|
171
|
+
<AlertDialogRoot handle={demoAlertDialog}>
|
|
172
|
+
<AlertDialogPortal>
|
|
173
|
+
<AlertDialogBackdrop />
|
|
174
|
+
<AlertDialogPopup>
|
|
175
|
+
<AlertDialogTitle>Discard draft?</AlertDialogTitle>
|
|
176
|
+
<AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
|
|
177
|
+
<div className='mt-6 flex justify-end gap-2'>
|
|
178
|
+
<AlertDialogClose>Cancel</AlertDialogClose>
|
|
179
|
+
<AlertDialogClose variant='destructive'>Discard</AlertDialogClose>
|
|
180
|
+
</div>
|
|
181
|
+
</AlertDialogPopup>
|
|
182
|
+
</AlertDialogPortal>
|
|
183
|
+
</AlertDialogRoot>
|
|
184
|
+
</>
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Multiple triggers
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import {
|
|
193
|
+
AlertDialogBackdrop,
|
|
194
|
+
AlertDialogClose,
|
|
195
|
+
AlertDialogDescription,
|
|
196
|
+
AlertDialogPopup,
|
|
197
|
+
AlertDialogPortal,
|
|
198
|
+
AlertDialogRoot,
|
|
199
|
+
AlertDialogTitle,
|
|
200
|
+
AlertDialogTrigger,
|
|
201
|
+
} from '@lglab/compose-ui/alert-dialog'
|
|
202
|
+
|
|
203
|
+
export default function MultipleTriggersExample() {
|
|
204
|
+
return (
|
|
205
|
+
<AlertDialogRoot>
|
|
206
|
+
<div className='flex flex-wrap gap-2'>
|
|
207
|
+
<AlertDialogTrigger variant='destructive'>Delete Item 1</AlertDialogTrigger>
|
|
208
|
+
<AlertDialogTrigger variant='destructive'>Delete Item 2</AlertDialogTrigger>
|
|
209
|
+
<AlertDialogTrigger variant='destructive'>Delete Item 3</AlertDialogTrigger>
|
|
210
|
+
</div>
|
|
211
|
+
<AlertDialogPortal>
|
|
212
|
+
<AlertDialogBackdrop />
|
|
213
|
+
<AlertDialogPopup>
|
|
214
|
+
<AlertDialogTitle>Delete item?</AlertDialogTitle>
|
|
215
|
+
<AlertDialogDescription>
|
|
216
|
+
This action cannot be undone. This will permanently delete the item.
|
|
217
|
+
</AlertDialogDescription>
|
|
218
|
+
<div className='mt-6 flex justify-end gap-2'>
|
|
219
|
+
<AlertDialogClose>Cancel</AlertDialogClose>
|
|
220
|
+
<AlertDialogClose variant='destructive'>Delete</AlertDialogClose>
|
|
221
|
+
</div>
|
|
222
|
+
</AlertDialogPopup>
|
|
223
|
+
</AlertDialogPortal>
|
|
224
|
+
</AlertDialogRoot>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Controlled mode with multiple triggers
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import {
|
|
233
|
+
AlertDialog,
|
|
234
|
+
AlertDialogBackdrop,
|
|
235
|
+
AlertDialogClose,
|
|
236
|
+
AlertDialogDescription,
|
|
237
|
+
AlertDialogPopup,
|
|
238
|
+
AlertDialogPortal,
|
|
239
|
+
AlertDialogRoot,
|
|
240
|
+
AlertDialogTitle,
|
|
241
|
+
AlertDialogTrigger,
|
|
242
|
+
} from '@lglab/compose-ui/alert-dialog'
|
|
243
|
+
import * as React from 'react'
|
|
244
|
+
|
|
245
|
+
const demoAlertDialog = AlertDialog.createHandle<{ itemName: string }>()
|
|
246
|
+
|
|
247
|
+
export default function ControlledMultipleExample() {
|
|
248
|
+
const [open, setOpen] = React.useState(false)
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<>
|
|
252
|
+
<div className='flex flex-wrap gap-2'>
|
|
253
|
+
<AlertDialogTrigger
|
|
254
|
+
handle={demoAlertDialog}
|
|
255
|
+
payload={{ itemName: 'Item 1' }}
|
|
256
|
+
variant='destructive'
|
|
257
|
+
>
|
|
258
|
+
Delete Item 1
|
|
259
|
+
</AlertDialogTrigger>
|
|
260
|
+
<AlertDialogTrigger
|
|
261
|
+
handle={demoAlertDialog}
|
|
262
|
+
payload={{ itemName: 'Item 2' }}
|
|
263
|
+
variant='destructive'
|
|
264
|
+
>
|
|
265
|
+
Delete Item 2
|
|
266
|
+
</AlertDialogTrigger>
|
|
267
|
+
<AlertDialogTrigger
|
|
268
|
+
handle={demoAlertDialog}
|
|
269
|
+
payload={{ itemName: 'Item 3' }}
|
|
270
|
+
variant='destructive'
|
|
271
|
+
>
|
|
272
|
+
Delete Item 3
|
|
273
|
+
</AlertDialogTrigger>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<AlertDialogRoot handle={demoAlertDialog} open={open} onOpenChange={setOpen}>
|
|
277
|
+
{({ payload: currentPayload }) => {
|
|
278
|
+
const payload = currentPayload as { itemName: string } | undefined
|
|
279
|
+
return (
|
|
280
|
+
<AlertDialogPortal>
|
|
281
|
+
<AlertDialogBackdrop />
|
|
282
|
+
<AlertDialogPopup>
|
|
283
|
+
<AlertDialogTitle>Delete item?</AlertDialogTitle>
|
|
284
|
+
<AlertDialogDescription>
|
|
285
|
+
{payload && 'itemName' in payload
|
|
286
|
+
? `Are you sure you want to delete ${payload.itemName}? This action cannot be undone.`
|
|
287
|
+
: 'This action cannot be undone. This will permanently delete the item.'}
|
|
288
|
+
</AlertDialogDescription>
|
|
289
|
+
<div className='mt-6 flex justify-end gap-2'>
|
|
290
|
+
<AlertDialogClose>Cancel</AlertDialogClose>
|
|
291
|
+
<AlertDialogClose variant='destructive'>Delete</AlertDialogClose>
|
|
292
|
+
</div>
|
|
293
|
+
</AlertDialogPopup>
|
|
294
|
+
</AlertDialogPortal>
|
|
295
|
+
)
|
|
296
|
+
}}
|
|
297
|
+
</AlertDialogRoot>
|
|
298
|
+
</>
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Resources
|
|
304
|
+
|
|
305
|
+
- [Base UI Alert Dialog Documentation](https://base-ui.com/react/components/alert-dialog)
|
|
306
|
+
- [API Reference](https://base-ui.com/react/components/alert-dialog#api-reference)
|