1
1
import { ArrowUpIcon , BellIcon , CheckCircleIcon , CheckIcon , ChevronUpDownIcon } from '@heroicons/react/20/solid' ;
2
2
import { ChatBubbleOvalLeftEllipsisIcon , ExclamationTriangleIcon } from '@heroicons/react/24/outline' ;
3
3
import { useMemo , useState } from 'react' ;
4
- import { Button , Cell , Collection , Column , ComboBox , DateInput , DatePicker , DateSegment , Dialog , DialogTrigger , Group , Header , Heading , Input , Item , Label , ListBox , Menu , MenuTrigger , Modal , ModalOverlay , OverlayArrow , Popover , ProgressBar , Radio , RadioGroup , Row , Section , Select , SelectValue , Separator , Slider , SliderOutput , SliderThumb , SliderTrack , Switch , Tab , Table , TableBody , TableHeader , TabList , TabPanel , TabPanels , Tabs , Text } from 'react-aria-components' ;
4
+ import { Button , Cell , Collection , Column , ComboBox , DateInput , DatePicker , DateSegment , Dialog , DialogTrigger , Group , Header , Heading , Input , Label , ListBox , ListBoxItem , Menu , MenuItem , MenuTrigger , Modal , ModalOverlay , OverlayArrow , Popover , ProgressBar , Radio , RadioGroup , Row , Section , Select , SelectValue , Separator , Slider , SliderOutput , SliderThumb , SliderTrack , Switch , Tab , Table , TableBody , TableHeader , TabList , TabPanel , Tabs , Text } from 'react-aria-components' ;
5
5
import { useAsyncList } from 'react-stately' ;
6
6
import { people } from './people.js' ;
7
7
import stocks from './stocks.json' ;
@@ -41,22 +41,22 @@ function MenuExample() {
41
41
< OverlayButton aria-label = "Menu" > ☰</ OverlayButton >
42
42
< Popover className = "p-1 w-56 overflow-auto rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 data-[entering]:animate-in data-[entering]:fade-in data-[entering]:zoom-in-95 data-[exiting]:animate-out data-[exiting]:fade-out data-[exiting]:zoom-out-95 fill-mode-forwards origin-top-left" >
43
43
< Menu className = "outline-none" >
44
- < MenuItem id = "new" > New…</ MenuItem >
45
- < MenuItem id = "open" > Open…</ MenuItem >
44
+ < MyMenuItem id = "new" > New…</ MyMenuItem >
45
+ < MyMenuItem id = "open" > Open…</ MyMenuItem >
46
46
< Separator className = "border-b border-b-gray-300 mx-3 my-1" />
47
- < MenuItem id = "save" > Save</ MenuItem >
48
- < MenuItem id = "save-as" > Save as…</ MenuItem >
47
+ < MyMenuItem id = "save" > Save</ MyMenuItem >
48
+ < MyMenuItem id = "save-as" > Save as…</ MyMenuItem >
49
49
< Separator className = "border-b border-b-gray-300 mx-3 my-1" />
50
- < MenuItem id = "print" > Print…</ MenuItem >
50
+ < MyMenuItem id = "print" > Print…</ MyMenuItem >
51
51
</ Menu >
52
52
</ Popover >
53
53
</ MenuTrigger >
54
54
</ div >
55
55
) ;
56
56
}
57
57
58
- function MenuItem ( props ) {
59
- return < Item { ...props } className = { ( { isFocused } ) => `
58
+ function MyMenuItem ( props ) {
59
+ return < MenuItem { ...props } className = { ( { isFocused } ) => `
60
60
group flex w-full items-center rounded-md px-3 py-2 sm:text-sm outline-none cursor-default
61
61
${ isFocused ? 'bg-violet-500 text-white' : 'text-gray-900' }
62
62
` } /> ;
@@ -79,21 +79,21 @@ function SelectExample() {
79
79
</ Button >
80
80
< Popover className = "max-h-60 w-[--trigger-width] overflow-auto rounded-md bg-white text-base shadow-lg ring-1 ring-black ring-opacity-5 sm:text-sm data-[entering]:animate-in data-[entering]:fade-in data-[exiting]:animate-out data-[exiting]:fade-out fill-mode-forwards" >
81
81
< ListBox className = "outline-none p-1 [--focus-bg:theme(colors.rose.600)]" >
82
- < ListBoxItem > Aardvark</ ListBoxItem >
83
- < ListBoxItem > Cat</ ListBoxItem >
84
- < ListBoxItem > Dog</ ListBoxItem >
85
- < ListBoxItem > Kangaroo</ ListBoxItem >
86
- < ListBoxItem > Panda</ ListBoxItem >
82
+ < MyListBoxItem > Aardvark</ MyListBoxItem >
83
+ < MyListBoxItem > Cat</ MyListBoxItem >
84
+ < MyListBoxItem > Dog</ MyListBoxItem >
85
+ < MyListBoxItem > Kangaroo</ MyListBoxItem >
86
+ < MyListBoxItem > Panda</ MyListBoxItem >
87
87
</ ListBox >
88
88
</ Popover >
89
89
</ Select >
90
90
</ div >
91
91
) ;
92
92
}
93
93
94
- function ListBoxItem ( props ) {
94
+ function MyListBoxItem ( props ) {
95
95
return (
96
- < Item
96
+ < ListBoxItem
97
97
{ ...props }
98
98
textValue = { props . children }
99
99
className = { ( { isFocused} ) => `
@@ -110,7 +110,7 @@ function ListBoxItem(props) {
110
110
}
111
111
</ >
112
112
) }
113
- </ Item >
113
+ </ ListBoxItem >
114
114
) ;
115
115
}
116
116
@@ -129,11 +129,11 @@ function ComboBoxExample() {
129
129
</ div >
130
130
< Popover className = "max-h-60 w-[--trigger-width] overflow-auto rounded-md bg-white text-base shadow-lg ring-1 ring-black ring-opacity-5 sm:text-sm data-[exiting]:animate-out data-[exiting]:fade-out fill-mode-forwards duration-100 ease-in" >
131
131
< ListBox className = "outline-none p-1 [--focus-bg:theme(colors.sky.600)]" >
132
- < ListBoxItem > Aardvark</ ListBoxItem >
133
- < ListBoxItem > Cat</ ListBoxItem >
134
- < ListBoxItem > Dog</ ListBoxItem >
135
- < ListBoxItem > Kangaroo</ ListBoxItem >
136
- < ListBoxItem > Panda</ ListBoxItem >
132
+ < MyListBoxItem > Aardvark</ MyListBoxItem >
133
+ < MyListBoxItem > Cat</ MyListBoxItem >
134
+ < MyListBoxItem > Dog</ MyListBoxItem >
135
+ < MyListBoxItem > Kangaroo</ MyListBoxItem >
136
+ < MyListBoxItem > Panda</ MyListBoxItem >
137
137
</ ListBox >
138
138
</ Popover >
139
139
</ ComboBox >
@@ -446,12 +446,12 @@ function ContactSection({title, children, items}) {
446
446
447
447
function Contact ( { id, avatar, name, handle} ) {
448
448
return (
449
- < Item id = { id } textValue = { name } className = "group peer relative py-1 px-2 text-sm outline-none cursor-default grid grid-rows-2 grid-flow-col auto-cols-max gap-x-3 rounded aria-selected:bg-blue-500 text-slate-700 aria-selected:text-white aria-selected:[&:has(+[aria-selected=true])]:rounded-b-none aria-selected:peer-aria-selected:rounded-t-none data-[focus-visible]:ring-2 ring-offset-2 ring-blue-500 [&[aria-selected=false]:has(+[aria-selected=false])_.divider]:block [&[aria-selected=true]:has(+[aria-selected=true])_.divider]:block" >
449
+ < ListBoxItem id = { id } textValue = { name } className = "group peer relative py-1 px-2 text-sm outline-none cursor-default grid grid-rows-2 grid-flow-col auto-cols-max gap-x-3 rounded aria-selected:bg-blue-500 text-slate-700 aria-selected:text-white aria-selected:[&:has(+[aria-selected=true])]:rounded-b-none aria-selected:peer-aria-selected:rounded-t-none data-[focus-visible]:ring-2 ring-offset-2 ring-blue-500 [&[aria-selected=false]:has(+[aria-selected=false])_.divider]:block [&[aria-selected=true]:has(+[aria-selected=true])_.divider]:block" >
450
450
< img src = { avatar } alt = "" className = "row-span-2 place-self-center h-8 w-8 rounded-full" />
451
451
< Text slot = "label" className = "font-medium truncate" > { name } </ Text >
452
452
< Text slot = "description" className = "truncate text-xs text-slate-600 group-aria-selected:text-white" > { handle } </ Text >
453
453
< div className = "divider hidden absolute left-12 right-2 bottom-0 h-px bg-gray-200 group-aria-selected:bg-blue-400" />
454
- </ Item >
454
+ </ ListBoxItem >
455
455
) ;
456
456
}
457
457
@@ -473,10 +473,10 @@ function ImageGridExample() {
473
473
< div className = "bg-gradient-to-r from-sky-500 to-teal-500 p-8 rounded-lg flex justify-center" >
474
474
< ListBox aria-label = "Images" items = { list . items } selectionMode = "single" selectionBehavior = "replace" className = "max-h-[280px] overflow-auto outline-none bg-white rounded-lg shadow p-2 grid grid-cols-3 gap-2" >
475
475
{ item => (
476
- < Item textValue = { item . user . name } className = "rounded outline-none group cursor-default" >
476
+ < ListBoxItem textValue = { item . user . name } className = "rounded outline-none group cursor-default" >
477
477
< img src = { item . urls . regular } alt = { item . alt_description } className = "w-full h-[80px] object-cover rounded group-aria-selected:ring group-aria-selected:ring-2 group-aria-selected:ring-offset-2 group-aria-selected:ring-sky-600" />
478
478
< Text slot = "label" className = "text-[11px] text-gray-700 font-semibold overflow-hidden text-ellipsis whitespace-nowrap max-w-full block mt-1" > { item . user . name } </ Text >
479
- </ Item >
479
+ </ ListBoxItem >
480
480
) }
481
481
</ ListBox >
482
482
</ div >
0 commit comments