import * as React from 'react' ; import * as ReactDom from 'react-dom' ; import { IPropertyPaneField , PropertyPaneFieldType } from '@microsoft/sp-property-pane' ; import { BaseComponentContext } from '@microsoft/sp-component-base' ; import PropertyFieldListPickerHost from './PropertyFieldListPickerHost' ; import PropertyFieldListMultiPickerHost from './PropertyFieldListMultiPickerHost' ; import { IPropertyFieldListPickerHostProps , ISPList } from './IPropertyFieldListPickerHost' ; import { IPropertyFieldListMultiPickerHostProps } from './IPropertyFieldListMultiPickerHost' ; import { PropertyFieldListPickerOrderBy , IPropertyFieldListPickerProps , IPropertyFieldListPickerPropsInternal , IPropertyFieldList } from './IPropertyFieldListPicker' ; /**
 * Represents a PropertyFieldListPicker object
 */ class PropertyFieldListPickerBuilder implements IPropertyPaneField < IPropertyFieldListPickerPropsInternal > { public type : PropertyPaneFieldType = PropertyPaneFieldType . Custom ; public targetProperty : string ; public properties : IPropertyFieldListPickerPropsInternal ; private label : string ; private context : BaseComponentContext ; private webAbsoluteUrl ? : string ; private selectedList : string | IPropertyFieldList ; private selectedLists : string [ ] | IPropertyFieldList [ ] ; private baseTemplate : number ; private orderBy : PropertyFieldListPickerOrderBy ; private multiSelect : boolean ; private showSelectAll : boolean ; private selectAllInList : boolean ; private selectAllInListLabel : string ; private includeHidden : boolean ; private listsToExclude : string [ ] ; private includeListTitleAndUrl : boolean ; public onPropertyChange ( propertyPath , oldValue , newValue ) { } private customProperties : any ; private key : string ; private disabled : boolean = false ; private onGetErrorMessage : ( value : string ) => string | Promise < string > ; private deferredValidationTime : number = 200 ; private renderWebPart : ( ) => void ; private disableReactivePropertyChanges : boolean = false ; private filter : string ; private onListsRetrieved ? : ( lists : ISPList [ ] ) => PromiseLike < ISPList [ ] > | ISPList [ ] ; /**
     * Constructor method
     */ public constructor ( _targetProperty , _properties ) { this . render = this . render . bind ( this ) ; this . targetProperty = _targetProperty ; this . properties = _properties ; this . properties . onDispose = this . dispose ; this . properties . onRender = this . render ; this . label = _properties . label ; this . context = _properties . context ; this . webAbsoluteUrl = _properties . webAbsoluteUrl ; this . selectedList = _properties . selectedList ; this . selectedLists = _properties . selectedLists ; this . baseTemplate = _properties . baseTemplate ; this . orderBy = _properties . orderBy ; this . multiSelect = _properties . multiSelect ; this . showSelectAll = _properties . showSelectAll ; this . selectAllInList = _properties . selectAllInList ; this . selectAllInListLabel = _properties . selectAllInListLabel ; this . includeHidden = _properties . includeHidden ; this . onPropertyChange = _properties . onPropertyChange ; this . customProperties = _properties . properties ; this . key = _properties . key ; this . onGetErrorMessage = _properties . onGetErrorMessage ; this . listsToExclude = _properties . listsToExclude ; this . filter = _properties . filter ; this . onListsRetrieved = _properties . onListsRetrieved ; this . includeListTitleAndUrl = _properties . includeListTitleAndUrl ; if ( _properties . disabled === true ) { this . disabled = _properties . disabled ; } if ( _properties . deferredValidationTime ) { this . deferredValidationTime = _properties . deferredValidationTime ; } } /**
     * Renders the SPListPicker field content
     */ private render ( elem , ctx ? , changeCallback ? ) { const componentProps = { label : this . label , targetProperty : this . targetProperty , context : this . context , webAbsoluteUrl : this . webAbsoluteUrl , baseTemplate : this . baseTemplate , orderBy : this . orderBy , multiSelect : this . multiSelect , includeHidden : this . includeHidden , onDispose : this . dispose , onRender : this . render , onChange : changeCallback , onPropertyChange : this . onPropertyChange , properties : this . customProperties , key : this . key , disabled : this . disabled , onGetErrorMessage : this . onGetErrorMessage , deferredValidationTime : this . deferredValidationTime , listsToExclude : this . listsToExclude , filter : this . filter , onListsRetrieved : this . onListsRetrieved , includeListTitleAndUrl : this . includeListTitleAndUrl } ; if ( this . multiSelect ) { componentProps [ 'selectedLists' ] = this . selectedLists ; componentProps [ 'showSelectAll' ] = this . showSelectAll ; componentProps [ 'selectAllInList' ] = this . selectAllInList ; componentProps [ 'selectAllInListLabel' ] = this . selectAllInListLabel ; const element = React . createElement ( PropertyFieldListMultiPickerHost , componentProps ) ; ReactDom . render ( element , elem ) ; } else { componentProps [ 'selectedList' ] = this . selectedList ; const element = React . createElement ( PropertyFieldListPickerHost , componentProps ) ; ReactDom . render ( element , elem ) ; } } /**
     * Disposes the current object
     */ private dispose ( elem ) { } } param targetProperty param properties export function PropertyFieldListPicker ( targetProperty , properties ) { const newProperties = { label : properties . label , targetProperty : targetProperty , context : properties . context , webAbsoluteUrl : properties . webAbsoluteUrl , selectedList : ! Array . isArray ( properties . selectedList ) ? properties . selectedList : null , selectedLists : Array . isArray ( properties . selectedList ) ? properties . selectedList : null , baseTemplate : properties . baseTemplate , orderBy : properties . orderBy , multiSelect : properties . multiSelect || false , showSelectAll : properties . showSelectAll || false , selectAllInList : properties . selectAllInList || false , selectAllInListLabel : properties . selectAllInListLabel , includeHidden : properties . includeHidden , onPropertyChange : properties . onPropertyChange , properties : properties . properties , onDispose : null , onRender : null , key : properties . key , disabled : properties . disabled , onGetErrorMessage : properties . onGetErrorMessage , deferredValidationTime : properties . deferredValidationTime , listsToExclude : properties . listsToExclude , filter : properties . filter , onListsRetrieved : properties . onListsRetrieved , includeListTitleAndUrl : properties . includeListTitleAndUrl } ; return new PropertyFieldListPickerBuilder ( targetProperty , newProperties ) ; }