{"version":3,"file":"DelayedRender.js","sourceRoot":"../src/","sources":["DelayedRender.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA2B/B;;;;;;;GAOG;AACH;IAAmC,iCAAyD;IAO1F,uBAAY,KAA0B;QAAtC,YACE,kBAAM,KAAK,CAAC,SAIb;QAHC,KAAI,CAAC,KAAK,GAAG;YACX,UAAU,EAAE,KAAK;SAClB,CAAC;;IACJ,CAAC;IAEM,yCAAiB,GAAxB;QAAA,iBAOC;QANO,IAAA,wBAAK,CAAgB;QAC3B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;YAClC,KAAI,CAAC,QAAQ,CAAC;gBACZ,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;QACL,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;IAEM,4CAAoB,GAA3B;QACE,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC/B;IACH,CAAC;IAEM,8BAAM,GAAb;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAA4B,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7G,CAAC;IA9Ba,0BAAY,GAAG;QAC3B,KAAK,EAAE,CAAC;KACT,CAAC;IA6BJ,oBAAC;CAAA,AAhCD,CAAmC,KAAK,CAAC,SAAS,GAgCjD;SAhCY,aAAa","sourcesContent":["import * as React from 'react';\n\n/**\n * DelayedRender component props.\n *\n * @public\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface IDelayedRenderProps extends React.Props<{}> {\n  /**\n   * Number of milliseconds to delay rendering children.\n   */\n  delay?: number;\n}\n\n/**\n * DelayedRender component state.\n *\n * @internal\n */\nexport interface IDelayedRenderState {\n  /**\n   * Whether the component is rendered or not.\n   */\n  isRendered: boolean;\n}\n\n/**\n * Utility component for delaying the render of a child component after a given delay. This component\n * requires a single child component; don't pass in many components. Wrap multiple components in a DIV\n * if necessary.\n *\n * @public\n * {@docCategory DelayedRender}\n */\nexport class DelayedRender extends React.Component<IDelayedRenderProps, IDelayedRenderState> {\n  public static defaultProps = {\n    delay: 0,\n  };\n\n  private _timeoutId: number | undefined;\n\n  constructor(props: IDelayedRenderProps) {\n    super(props);\n    this.state = {\n      isRendered: false,\n    };\n  }\n\n  public componentDidMount(): void {\n    let { delay } = this.props;\n    this._timeoutId = window.setTimeout(() => {\n      this.setState({\n        isRendered: true,\n      });\n    }, delay);\n  }\n\n  public componentWillUnmount(): void {\n    if (this._timeoutId) {\n      clearTimeout(this._timeoutId);\n    }\n  }\n\n  public render(): React.ReactElement<{}> | null {\n    return this.state.isRendered ? (React.Children.only(this.props.children) as React.ReactElement<{}>) : null;\n  }\n}\n"]}