@@ -4,13 +4,43 @@ import { Spinner, SpinnerSize } from 'office-ui-fabric-react/lib/Spinner';
4
4
import { ISite , ISitePickerProps } from './ISitePicker' ;
5
5
import { getAllSites , getHubSites } from '../../services/SPSitesService' ;
6
6
import { IDropdownOption , Dropdown } from 'office-ui-fabric-react/lib/Dropdown' ;
7
- import { SelectableOptionMenuItemType } from 'office-ui-fabric-react/lib/utilities/selectableOption/SelectableOption.types' ;
7
+ import { ISelectableOption , SelectableOptionMenuItemType } from 'office-ui-fabric-react/lib/utilities/selectableOption/SelectableOption.types' ;
8
8
import orderBy from 'lodash/orderBy' ;
9
+ import { SearchBox } from 'office-ui-fabric-react/lib/SearchBox' ;
10
+ import { Checkbox } from 'office-ui-fabric-react/lib/Checkbox' ;
11
+ import { toRelativeUrl } from '../../common/utilities/GeneralHelper' ;
9
12
10
13
const styles = mergeStyleSets ( {
11
14
loadingSpinnerContainer : {
12
15
width : '100%' ,
13
16
textAlign : 'center'
17
+ } ,
18
+ siteOption : {
19
+ display : 'flex' ,
20
+ whiteSpace : 'nowrap' ,
21
+ alignItems : 'center'
22
+ } ,
23
+ siteOptionCheckbox : {
24
+ display : 'inline-block' ,
25
+ marginRight : '4px'
26
+ } ,
27
+ siteOptionContent : {
28
+ display : 'flex' ,
29
+ flexDirection : 'column' ,
30
+ minWidth : '0' ,
31
+ padding : '4px 0'
32
+ } ,
33
+ siteOptionTitle : {
34
+ lineHeight : '18px' ,
35
+ overflow : 'hidden' ,
36
+ textOverflow : 'ellipsis'
37
+ } ,
38
+ siteOptionUrl : {
39
+ fontSize : '12px' ,
40
+ lineHeight : '14px' ,
41
+ fontWeight : '300' ,
42
+ overflow : 'hidden' ,
43
+ textOverflow : 'ellipsis'
14
44
}
15
45
} ) ;
16
46
@@ -36,6 +66,23 @@ export const SitePicker: React.FunctionComponent<ISitePickerProps> = (props: Rea
36
66
const [ filteredSites , setFilteredSites ] = React . useState < ISite [ ] > ( ) ;
37
67
const [ searchQuery , setSearchQuery ] = React . useState < string > ( ) ;
38
68
69
+ const onRenderOption = ( option ?: ISelectableOption , defaultRender ?: ( props ?: ISelectableOption ) => JSX . Element | null ) : JSX . Element | null => {
70
+ if ( ! props ) {
71
+ return null ;
72
+ }
73
+
74
+ if ( option . itemType === SelectableOptionMenuItemType . Header ) {
75
+ return < SearchBox /> ;
76
+ }
77
+ // {multiSelect !== false && <Checkbox className={styles.siteOptionCheckbox} checked={option.selected} disabled={option.disabled} /> }
78
+ return < div className = { styles . siteOption } >
79
+ < div className = { styles . siteOptionContent } >
80
+ < span className = { styles . siteOptionTitle } > { option . text } </ span >
81
+ < span className = { styles . siteOptionUrl } > { toRelativeUrl ( option . data ! . url ) } </ span >
82
+ </ div >
83
+ </ div > ;
84
+ } ;
85
+
39
86
const getOptions = ( ) : IDropdownOption [ ] => {
40
87
const result : IDropdownOption [ ] = [ ] ;
41
88
@@ -132,6 +179,7 @@ export const SitePicker: React.FunctionComponent<ISitePickerProps> = (props: Rea
132
179
options = { getOptions ( ) }
133
180
disabled = { disabled }
134
181
multiSelect = { multiSelect !== false }
182
+ onRenderOption = { onRenderOption }
135
183
/>
136
184
</ >
137
185
) ;
0 commit comments