Completely updated React, fixed #11, (hopefully)
This commit is contained in:
61
goTorrentWebUI/node_modules/material-ui/styles/MuiThemeProvider.js.flow
generated
vendored
61
goTorrentWebUI/node_modules/material-ui/styles/MuiThemeProvider.js.flow
generated
vendored
@@ -1,7 +1,6 @@
|
||||
// @flow
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import warning from 'warning';
|
||||
import createBroadcast from 'brcast';
|
||||
import themeListener, { CHANNEL } from './themeListener';
|
||||
import exactProp from '../utils/exactProp';
|
||||
@@ -11,13 +10,8 @@ import exactProp from '../utils/exactProp';
|
||||
* It makes the `theme` available down the React tree thanks to React context.
|
||||
* This component should preferably be used at **the root of your component tree**.
|
||||
*/
|
||||
class MuiThemeProvider extends React.Component<Object> {
|
||||
static defaultProps = {
|
||||
disableStylesGeneration: false,
|
||||
sheetsManager: null,
|
||||
};
|
||||
|
||||
constructor(props: Object, context: Object) {
|
||||
class MuiThemeProvider extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
// Get the outer theme from the context, can be null
|
||||
@@ -27,12 +21,20 @@ class MuiThemeProvider extends React.Component<Object> {
|
||||
}
|
||||
|
||||
getChildContext() {
|
||||
const { sheetsManager, disableStylesGeneration } = this.props;
|
||||
const muiThemeProviderOptions = this.context.muiThemeProviderOptions || {};
|
||||
|
||||
if (sheetsManager !== undefined) {
|
||||
muiThemeProviderOptions.sheetsManager = sheetsManager;
|
||||
}
|
||||
|
||||
if (disableStylesGeneration !== undefined) {
|
||||
muiThemeProviderOptions.disableStylesGeneration = disableStylesGeneration;
|
||||
}
|
||||
|
||||
return {
|
||||
[CHANNEL]: this.broadcast,
|
||||
muiThemeProviderOptions: {
|
||||
sheetsManager: this.props.sheetsManager,
|
||||
disableStylesGeneration: this.props.disableStylesGeneration,
|
||||
},
|
||||
muiThemeProviderOptions,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,9 +66,21 @@ class MuiThemeProvider extends React.Component<Object> {
|
||||
outerTheme = null;
|
||||
|
||||
// Simple merge between the outer theme and the local theme
|
||||
mergeOuterLocalTheme(localTheme: Object) {
|
||||
mergeOuterLocalTheme(localTheme) {
|
||||
// To support composition of theme.
|
||||
if (typeof localTheme === 'function') {
|
||||
warning(
|
||||
this.outerTheme,
|
||||
[
|
||||
'Material-UI: you are providing a theme function property ' +
|
||||
'to the MuiThemeProvider component:',
|
||||
'<MuiThemeProvider theme={outerTheme => outerTheme} />',
|
||||
'',
|
||||
'However, no outer theme is present.',
|
||||
'Make sure a theme is already injected higher in the React tree ' +
|
||||
'or provide a theme object.',
|
||||
].join('\n'),
|
||||
);
|
||||
return localTheme(this.outerTheme);
|
||||
}
|
||||
|
||||
@@ -108,21 +122,16 @@ MuiThemeProvider.propTypes = {
|
||||
theme: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired,
|
||||
};
|
||||
|
||||
MuiThemeProvider.propTypes = exactProp(MuiThemeProvider.propTypes, 'MuiThemeProvider');
|
||||
|
||||
MuiThemeProvider.childContextTypes = {
|
||||
...themeListener.contextTypes,
|
||||
muiThemeProviderOptions: PropTypes.object,
|
||||
};
|
||||
|
||||
MuiThemeProvider.contextTypes = themeListener.contextTypes;
|
||||
MuiThemeProvider.contextTypes = {
|
||||
...themeListener.contextTypes,
|
||||
muiThemeProviderOptions: PropTypes.object,
|
||||
};
|
||||
|
||||
// Add a wrapper component to generate some helper messages in the development
|
||||
// environment.
|
||||
// eslint-disable-next-line import/no-mutable-exports
|
||||
let MuiThemeProviderWrapper = MuiThemeProvider;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
MuiThemeProviderWrapper = (props: any) => <MuiThemeProvider {...props} />;
|
||||
MuiThemeProviderWrapper.propTypes = exactProp(MuiThemeProvider.propTypes, 'MuiThemeProvider');
|
||||
}
|
||||
|
||||
export default MuiThemeProviderWrapper;
|
||||
export default MuiThemeProvider;
|
||||
|
Reference in New Issue
Block a user