import * as React from 'react'; import * as CopyToClipboard from 'react-copy-to-clipboard'; import { ColorClassNames } from '@uifabric/styling'; import {getTheme, MessageBar, MessageBarType,IconButton,TextField} from 'office-ui-fabric-react'; export interface ITextFieldProps{ onInputChanged?:(newValue:string)=>void; inputValue?: string; successVisible?: boolean; } export interface ITextFieldControlledExampleState extends React.ComponentState,ITextFieldProps{} const theme = getTheme(); export class TextFieldControlledExample extends React.Component { constructor(props:ITextFieldProps){ super(props); this.state = { inputValue: props.inputValue?props.inputValue:'', successVisible: false }; } render():JSX.Element{ const {successVisible} = this.state; return (
this.setState({copied: true, successVisible: true})}>
{successVisible? ( // Yes // No //
//} >{this.props.inputValue} copied to clipboard ) : null} ); } private onChangeText = (event: React.FormEvent, newValue?: string) => { this.setState({ inputValue: newValue || '' }); if(this.props.onInputChanged){ this.props.onInputChanged(newValue||'') } }; private _onIconClick = ():void=>{ }; private onDismissSuccess = ():void=>{ this.setState({successVisible:false}) } private showSuccessMessage = ():void=>{ this.setState({successVisible:true}); } }