Completely updated React, fixed #11, (hopefully)
This commit is contained in:
		
							
								
								
									
										104
									
								
								goTorrentWebUI/node_modules/react-grid-layout/build/components/WidthProvider.js.flow
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										104
									
								
								goTorrentWebUI/node_modules/react-grid-layout/build/components/WidthProvider.js.flow
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,69 +1,77 @@
 | 
			
		||||
// @flow
 | 
			
		||||
import React from "react";
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
import ReactDOM from 'react-dom';
 | 
			
		||||
import type {ComponentType as ReactComponentType} from 'react';
 | 
			
		||||
import PropTypes from "prop-types";
 | 
			
		||||
import ReactDOM from "react-dom";
 | 
			
		||||
import type { ComponentType as ReactComponentType } from "react";
 | 
			
		||||
 | 
			
		||||
type Props = {
 | 
			
		||||
type WPProps = {
 | 
			
		||||
  className?: string,
 | 
			
		||||
  measureBeforeMount: boolean,
 | 
			
		||||
  style?: Object,
 | 
			
		||||
  style?: Object
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
type State = {
 | 
			
		||||
type WPState = {
 | 
			
		||||
  width: number
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * A simple HOC that provides facility for listening to container resizes.
 | 
			
		||||
 */
 | 
			
		||||
type ProviderT = (ComposedComponent: ReactComponentType<any>) => ReactComponentType<any>;
 | 
			
		||||
const WidthProvider: ProviderT = (ComposedComponent) => class extends React.Component<Props, State> {
 | 
			
		||||
export default function WidthProvider<
 | 
			
		||||
  Props,
 | 
			
		||||
  ComposedProps: { ...Props, ...WPProps }
 | 
			
		||||
>(
 | 
			
		||||
  ComposedComponent: ReactComponentType<Props>
 | 
			
		||||
): ReactComponentType<ComposedProps> {
 | 
			
		||||
  return class WidthProvider extends React.Component<ComposedProps, WPState> {
 | 
			
		||||
    static defaultProps = {
 | 
			
		||||
      measureBeforeMount: false
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  static defaultProps = {
 | 
			
		||||
    measureBeforeMount: false
 | 
			
		||||
  };
 | 
			
		||||
    static propTypes = {
 | 
			
		||||
      // If true, will not render children until mounted. Useful for getting the exact width before
 | 
			
		||||
      // rendering, to prevent any unsightly resizing.
 | 
			
		||||
      measureBeforeMount: PropTypes.bool
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  static propTypes = {
 | 
			
		||||
    // If true, will not render children until mounted. Useful for getting the exact width before
 | 
			
		||||
    // rendering, to prevent any unsightly resizing.
 | 
			
		||||
    measureBeforeMount: PropTypes.bool
 | 
			
		||||
  };
 | 
			
		||||
    state = {
 | 
			
		||||
      width: 1280
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
  state: State = {
 | 
			
		||||
    width: 1280
 | 
			
		||||
  };
 | 
			
		||||
    mounted: boolean = false;
 | 
			
		||||
 | 
			
		||||
  mounted: boolean = false;
 | 
			
		||||
    componentDidMount() {
 | 
			
		||||
      this.mounted = true;
 | 
			
		||||
 | 
			
		||||
  componentDidMount() {
 | 
			
		||||
    this.mounted = true;
 | 
			
		||||
 | 
			
		||||
    window.addEventListener('resize', this.onWindowResize);
 | 
			
		||||
    // Call to properly set the breakpoint and resize the elements.
 | 
			
		||||
    // Note that if you're doing a full-width element, this can get a little wonky if a scrollbar
 | 
			
		||||
    // appears because of the grid. In that case, fire your own resize event, or set `overflow: scroll` on your body.
 | 
			
		||||
    this.onWindowResize();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  componentWillUnmount() {
 | 
			
		||||
    this.mounted = false;
 | 
			
		||||
    window.removeEventListener('resize', this.onWindowResize);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  onWindowResize = (_event: ?Event) => {
 | 
			
		||||
    if (!this.mounted) return;
 | 
			
		||||
    const node = ReactDOM.findDOMNode(this); // Flow casts this to Text | Element
 | 
			
		||||
    if (node instanceof HTMLElement) this.setState({width: node.offsetWidth});
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  render() {
 | 
			
		||||
    if (this.props.measureBeforeMount && !this.mounted) {
 | 
			
		||||
      return <div className={this.props.className} style={this.props.style} />;
 | 
			
		||||
      window.addEventListener("resize", this.onWindowResize);
 | 
			
		||||
      // Call to properly set the breakpoint and resize the elements.
 | 
			
		||||
      // Note that if you're doing a full-width element, this can get a little wonky if a scrollbar
 | 
			
		||||
      // appears because of the grid. In that case, fire your own resize event, or set `overflow: scroll` on your body.
 | 
			
		||||
      this.onWindowResize();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return <ComposedComponent {...this.props} {...this.state} />;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
    componentWillUnmount() {
 | 
			
		||||
      this.mounted = false;
 | 
			
		||||
      window.removeEventListener("resize", this.onWindowResize);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
export default WidthProvider;
 | 
			
		||||
    onWindowResize = () => {
 | 
			
		||||
      if (!this.mounted) return;
 | 
			
		||||
      // eslint-disable-next-line
 | 
			
		||||
      const node = ReactDOM.findDOMNode(this); // Flow casts this to Text | Element
 | 
			
		||||
      if (node instanceof HTMLElement)
 | 
			
		||||
        this.setState({ width: node.offsetWidth });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    render() {
 | 
			
		||||
      const { measureBeforeMount, ...rest } = this.props;
 | 
			
		||||
      if (measureBeforeMount && !this.mounted) {
 | 
			
		||||
        return (
 | 
			
		||||
          <div className={this.props.className} style={this.props.style} />
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return <ComposedComponent {...rest} {...this.state} />;
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user