import * as React from 'react' ; import * as ReactDOM from 'react-dom' ; import { IPropertyPaneField , PropertyPaneFieldType , PropertyPaneButtonType } from '@microsoft/sp-webpart-base' ; import PropertyFieldButtonHost from './PropertyFieldButtonWithCalloutHost' ; import { IPropertyFieldButtonWithCalloutPropsInternal , IPropertyFieldButtonWithCalloutProps } from './IPropertyFieldButtonWithCallout' ; import { ButtonType } from 'office-ui-fabric-react/lib/components/Button' ; import omit from 'lodash/omit' ; /**
 * Represents a PropertyFieldButtonWithCallout object
 */ class PropertyFieldButtonWithCalloutBuilder implements IPropertyPaneField < IPropertyFieldButtonWithCalloutPropsInternal > { public targetProperty : string ; public type : PropertyPaneFieldType = PropertyPaneFieldType . Custom ; public properties : IPropertyFieldButtonWithCalloutPropsInternal ; public constructor ( _targetProperty , _properties ) { this . targetProperty = _targetProperty ; this . properties = _properties ; this . properties . onRender = this . _render . bind ( this ) ; this . properties . onDispose = this . _dispose . bind ( this ) ; } private _render ( elem , context ? , changeCallback ? ) { const props = this . properties as IPropertyFieldButtonWithCalloutProps ; const buttonTypeString = ButtonType [ this . properties . buttonType ] ; const buttonType = ButtonType [ buttonTypeString ] ; const element = React . createElement ( PropertyFieldButtonHost , { ... omit ( props , [ 'icon' , 'buttonType' ] ) , buttonType : buttonType } ) ; ReactDOM . render ( element , elem ) ; } private _dispose ( elem ) { ReactDOM . unmountComponentAtNode ( elem ) ; } } param targetProperty param properties export function PropertyFieldButtonWithCallout ( targetProperty , properties ) { return new PropertyFieldButtonWithCalloutBuilder ( targetProperty , { ... properties , onRender : null , onDispose : null } ) ; }