10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
- import { Button , Calendar , CalendarCell , CalendarGrid , Cell , Column , ComboBox , DateField , DateInput , DatePicker , DateRangePicker , DateSegment , Dialog , DialogTrigger , Group , Header , Heading , Input , Item , Keyboard , Label , ListBox , Menu , MenuTrigger , Modal , ModalOverlay , NumberField , OverlayArrow , Popover , RangeCalendar , Row , Section , Select , SelectValue , Separator , Slider , SliderOutput , SliderThumb , SliderTrack , Tab , Table , TableBody , TableHeader , TabList , TabPanel , TabPanels , Tabs , Text , TimeField , Tooltip , TooltipTrigger } from 'react-aria-components' ;
13
+ import { Button , Calendar , CalendarCell , CalendarGrid , Cell , Column , ComboBox , DateField , DateInput , DatePicker , DateRangePicker , DateSegment , Dialog , DialogTrigger , Group , Header , Heading , Input , Item , Keyboard , Label , ListBox , Menu , MenuTrigger , Modal , ModalOverlay , NumberField , OverlayArrow , Popover , RangeCalendar , Row , Section , Select , SelectValue , Separator , Slider , SliderOutput , SliderThumb , SliderTrack , Tab , Table , TableBody , TableHeader , TabList , TabPanel , TabPanels , Tabs , TabsProps , Text , TimeField , Tooltip , TooltipTrigger } from 'react-aria-components' ;
14
14
import { classNames } from '@react-spectrum/utils' ;
15
15
import clsx from 'clsx' ;
16
- import React from 'react' ;
16
+ import React , { useState } from 'react' ;
17
17
import styles from '../example/index.css' ;
18
18
import { useListData } from 'react-stately' ;
19
19
@@ -40,6 +40,29 @@ export const ComboBoxExample = () => (
40
40
</ ComboBox >
41
41
) ;
42
42
43
+ export const ComboBoxRenderProps = ( ) => (
44
+ < ComboBox >
45
+ { ( { isOpen} ) => (
46
+ < >
47
+ < Label style = { { display : 'block' } } > Test</ Label >
48
+ < div style = { { display : 'flex' } } >
49
+ < Input />
50
+ < Button >
51
+ < span aria-hidden = "true" style = { { padding : '0 2px' } } > { isOpen ? '▲' : '▼' } </ span >
52
+ </ Button >
53
+ </ div >
54
+ < Popover placement = "bottom end" >
55
+ < ListBox className = { styles . menu } >
56
+ < MyItem > Foo</ MyItem >
57
+ < MyItem > Bar</ MyItem >
58
+ < MyItem > Baz</ MyItem >
59
+ </ ListBox >
60
+ </ Popover >
61
+ </ >
62
+ ) }
63
+ </ ComboBox >
64
+ ) ;
65
+
43
66
export const ListBoxExample = ( ) => (
44
67
< ListBox className = { styles . menu } selectionMode = "multiple" selectionBehavior = "replace" >
45
68
< MyItem > Foo</ MyItem >
@@ -100,6 +123,27 @@ export const SelectExample = () => (
100
123
</ Select >
101
124
) ;
102
125
126
+ export const SelectRenderProps = ( ) => (
127
+ < Select >
128
+ { ( { isOpen} ) => (
129
+ < >
130
+ < Label style = { { display : 'block' } } > Test</ Label >
131
+ < Button >
132
+ < SelectValue />
133
+ < span aria-hidden = "true" style = { { paddingLeft : 5 } } > { isOpen ? '▲' : '▼' } </ span >
134
+ </ Button >
135
+ < Popover >
136
+ < ListBox className = { styles . menu } >
137
+ < MyItem > Foo</ MyItem >
138
+ < MyItem > Bar</ MyItem >
139
+ < MyItem > Baz</ MyItem >
140
+ </ ListBox >
141
+ </ Popover >
142
+ </ >
143
+ ) }
144
+ </ Select >
145
+ ) ;
146
+
103
147
export const MenuExample = ( ) => (
104
148
< MenuTrigger >
105
149
< Button aria-label = "Menu" > ☰</ Button >
@@ -479,6 +523,44 @@ export const TabsExample = () => (
479
523
</ Tabs >
480
524
) ;
481
525
526
+ export const TabsRenderProps = ( ) => {
527
+ const [ tabOrientation , setTabOrientation ] = useState < TabsProps [ 'orientation' ] > ( 'vertical' ) ;
528
+
529
+ return (
530
+ < div style = { { display : 'flex' , flexDirection : 'row' , gap : 8 } } >
531
+ < Button onPress = { ( ) => setTabOrientation ( ( current ) => current === 'vertical' ? 'horizontal' : 'vertical' ) } >
532
+ Change Orientation
533
+ </ Button >
534
+ < Tabs orientation = { tabOrientation } >
535
+ { ( { orientation} ) => (
536
+ < div >
537
+ < div style = { { display : 'flex' , flexDirection : orientation === 'vertical' ? 'row' : 'column' , gap : 8 } } >
538
+ < TabList
539
+ aria-label = "History of Ancient Rome"
540
+ style = { { display : 'flex' , flexDirection : orientation === 'vertical' ? 'column' : 'row' , gap : 8 } } >
541
+ < CustomTab id = "FoR" > Founding of Rome</ CustomTab >
542
+ < CustomTab id = "MaR" > Monarchy and Republic</ CustomTab >
543
+ < CustomTab id = "Emp" > Empire</ CustomTab >
544
+ </ TabList >
545
+ < TabPanels >
546
+ < TabPanel id = "FoR" >
547
+ Arma virumque cano, Troiae qui primus ab oris.
548
+ </ TabPanel >
549
+ < TabPanel id = "MaR" >
550
+ Senatus Populusque Romanus.
551
+ </ TabPanel >
552
+ < TabPanel id = "Emp" >
553
+ Alea jacta est.
554
+ </ TabPanel >
555
+ </ TabPanels >
556
+ </ div >
557
+ </ div >
558
+ ) }
559
+ </ Tabs >
560
+ </ div >
561
+ ) ;
562
+ } ;
563
+
482
564
export const TableExample = ( ) => {
483
565
let list = useListData ( {
484
566
initialItems : [
0 commit comments