Completely updated React, fixed #11, (hopefully)
This commit is contained in:
103
goTorrentWebUI/node_modules/material-ui/es/styles/withStyles.js
generated
vendored
103
goTorrentWebUI/node_modules/material-ui/es/styles/withStyles.js
generated
vendored
@@ -1,27 +1,25 @@
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||||
|
||||
// weak
|
||||
|
||||
import _Object$keys from 'babel-runtime/core-js/object/keys';
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import _Map from 'babel-runtime/core-js/map';
|
||||
import _Number$MIN_SAFE_INTEGER from 'babel-runtime/core-js/number/min-safe-integer';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import warning from 'warning';
|
||||
|
||||
import hoistNonReactStatics from 'hoist-non-react-statics';
|
||||
import wrapDisplayName from 'recompose/wrapDisplayName';
|
||||
import getDisplayName from 'recompose/getDisplayName';
|
||||
import wrapDisplayName from 'recompose/wrapDisplayName';
|
||||
import contextTypes from 'react-jss/lib/contextTypes';
|
||||
import { create } from 'jss';
|
||||
import preset from 'jss-preset-default';
|
||||
import * as ns from 'react-jss/lib/ns';
|
||||
import jssPreset from './jssPreset';
|
||||
import createMuiTheme from './createMuiTheme';
|
||||
import themeListener from './themeListener';
|
||||
import createGenerateClassName from './createGenerateClassName';
|
||||
import getStylesCreator from './getStylesCreator';
|
||||
|
||||
// New JSS instance.
|
||||
const jss = create(preset());
|
||||
const jss = create(jssPreset());
|
||||
|
||||
// Use a singleton or the provided one by the context.
|
||||
const generateClassName = createGenerateClassName();
|
||||
@@ -34,9 +32,9 @@ const generateClassName = createGenerateClassName();
|
||||
// specificity, because of the source order.
|
||||
// So our solution is to render sheets them in the reverse order child->sheet, so
|
||||
// that parent has a higher specificity.
|
||||
let indexCounter = Number.MIN_SAFE_INTEGER;
|
||||
let indexCounter = _Number$MIN_SAFE_INTEGER;
|
||||
|
||||
export const sheetsManager = new Map();
|
||||
export const sheetsManager = new _Map();
|
||||
|
||||
// We use the same empty object to ref count the styles that don't need a theme object.
|
||||
const noopTheme = {};
|
||||
@@ -53,43 +51,35 @@ function getDefaultTheme() {
|
||||
return defaultTheme;
|
||||
}
|
||||
|
||||
// Note, theme is conditionally injected, but flow is static analysis so we need to include it.
|
||||
|
||||
|
||||
// Link a style sheet with a component.
|
||||
// It does not modify the component passed to it;
|
||||
// instead, it returns a new component, with a `classes` property.
|
||||
const withStyles = (stylesOrCreator, options = {}) => Component => {
|
||||
const { withTheme = false, flip, name } = options,
|
||||
const { withTheme = false, flip = null, name } = options,
|
||||
styleSheetOptions = _objectWithoutProperties(options, ['withTheme', 'flip', 'name']);
|
||||
const stylesCreator = getStylesCreator(stylesOrCreator);
|
||||
const listenToTheme = stylesCreator.themingEnabled || withTheme || typeof name === 'string';
|
||||
|
||||
if (stylesCreator.options.index === undefined) {
|
||||
indexCounter += 1;
|
||||
stylesCreator.options.index = indexCounter;
|
||||
}
|
||||
indexCounter += 1;
|
||||
stylesCreator.options.index = indexCounter;
|
||||
|
||||
warning(indexCounter < 0, ['Material-UI: you might have a memory leak.', 'The indexCounter is not supposed to grow that much.'].join(' '));
|
||||
|
||||
class Style extends React.Component {
|
||||
process.env.NODE_ENV !== "production" ? warning(indexCounter < 0, ['Material-UI: you might have a memory leak.', 'The indexCounter is not supposed to grow that much.'].join(' ')) : void 0;
|
||||
|
||||
class WithStyles extends React.Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
this.state = {};
|
||||
this.unsubscribeId = null;
|
||||
this.jss = null;
|
||||
this.sheetsManager = sheetsManager;
|
||||
this.disableStylesGeneration = false;
|
||||
this.jss = null;
|
||||
this.sheetOptions = null;
|
||||
this.sheetsManager = sheetsManager;
|
||||
this.stylesCreatorSaved = null;
|
||||
this.theme = null;
|
||||
this.sheetOptions = null;
|
||||
this.theme = null;
|
||||
const { muiThemeProviderOptions } = this.context;
|
||||
|
||||
this.unsubscribeId = null;
|
||||
this.jss = this.context[ns.jss] || jss;
|
||||
|
||||
const { muiThemeProviderOptions } = this.context;
|
||||
if (muiThemeProviderOptions) {
|
||||
if (muiThemeProviderOptions.sheetsManager) {
|
||||
this.sheetsManager = muiThemeProviderOptions.sheetsManager;
|
||||
@@ -105,16 +95,10 @@ const withStyles = (stylesOrCreator, options = {}) => Component => {
|
||||
this.sheetOptions = _extends({
|
||||
generateClassName
|
||||
}, this.context[ns.sheetOptions]);
|
||||
// We use || as it's lazy evaluated.
|
||||
// We use || as the function call is lazy evaluated.
|
||||
this.theme = listenToTheme ? themeListener.initial(context) || getDefaultTheme() : noopTheme;
|
||||
}
|
||||
|
||||
// Exposed for test purposes.
|
||||
|
||||
|
||||
// Exposed for tests purposes
|
||||
|
||||
|
||||
componentWillMount() {
|
||||
this.attach(this.theme);
|
||||
}
|
||||
@@ -165,7 +149,7 @@ const withStyles = (stylesOrCreator, options = {}) => Component => {
|
||||
let sheetManager = this.sheetsManager.get(stylesCreatorSaved);
|
||||
|
||||
if (!sheetManager) {
|
||||
sheetManager = new Map();
|
||||
sheetManager = new _Map();
|
||||
this.sheetsManager.set(stylesCreatorSaved, sheetManager);
|
||||
}
|
||||
|
||||
@@ -181,14 +165,15 @@ const withStyles = (stylesOrCreator, options = {}) => Component => {
|
||||
|
||||
if (sheetManagerTheme.refs === 0) {
|
||||
const styles = stylesCreatorSaved.create(theme, name);
|
||||
let meta;
|
||||
let meta = name;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
meta = name || getDisplayName(Component);
|
||||
if (process.env.NODE_ENV !== 'production' && !meta) {
|
||||
meta = getDisplayName(Component);
|
||||
}
|
||||
|
||||
const sheet = this.jss.createStyleSheet(styles, _extends({
|
||||
meta,
|
||||
classNamePrefix: meta,
|
||||
flip: typeof flip === 'boolean' ? flip : theme.direction === 'rtl',
|
||||
link: false
|
||||
}, this.sheetOptions, stylesCreatorSaved.options, {
|
||||
@@ -243,10 +228,10 @@ const withStyles = (stylesOrCreator, options = {}) => Component => {
|
||||
}
|
||||
|
||||
if (classesProp) {
|
||||
classes = _extends({}, renderedClasses, Object.keys(classesProp).reduce((accumulator, key) => {
|
||||
warning(renderedClasses[key] || this.disableStylesGeneration, [`Material-UI: the key \`${key}\` ` + `provided to the classes property is not implemented in ${getDisplayName(Component)}.`, `You can only override one of the following: ${Object.keys(renderedClasses).join(',')}`].join('\n'));
|
||||
classes = _extends({}, renderedClasses, _Object$keys(classesProp).reduce((accumulator, key) => {
|
||||
process.env.NODE_ENV !== "production" ? warning(renderedClasses[key] || this.disableStylesGeneration, [`Material-UI: the key \`${key}\` ` + `provided to the classes property is not implemented in ${getDisplayName(Component)}.`, `You can only override one of the following: ${_Object$keys(renderedClasses).join(',')}`].join('\n')) : void 0;
|
||||
|
||||
warning(!classesProp[key] || typeof classesProp[key] === 'string', [`Material-UI: the key \`${key}\` ` + `provided to the classes property is not valid for ${getDisplayName(Component)}.`, `You need to provide a non empty string instead of: ${classesProp[key]}.`].join('\n'));
|
||||
process.env.NODE_ENV !== "production" ? warning(!classesProp[key] || typeof classesProp[key] === 'string', [`Material-UI: the key \`${key}\` ` + `provided to the classes property is not valid for ${getDisplayName(Component)}.`, `You need to provide a non empty string instead of: ${classesProp[key]}.`].join('\n')) : void 0;
|
||||
|
||||
if (classesProp[key]) {
|
||||
accumulator[key] = `${renderedClasses[key]} ${classesProp[key]}`;
|
||||
@@ -270,20 +255,34 @@ const withStyles = (stylesOrCreator, options = {}) => Component => {
|
||||
}
|
||||
}
|
||||
|
||||
Style.contextTypes = _extends({
|
||||
WithStyles.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* Useful to extend the style applied to components.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* Use that property to pass a ref callback to the decorated component.
|
||||
*/
|
||||
innerRef: PropTypes.func
|
||||
} : {};
|
||||
|
||||
WithStyles.contextTypes = _extends({
|
||||
muiThemeProviderOptions: PropTypes.object
|
||||
}, contextTypes, listenToTheme ? themeListener.contextTypes : {});
|
||||
Style.Naked = Component;
|
||||
hoistNonReactStatics(Style, Component);
|
||||
|
||||
// Higher specificity
|
||||
Style.options = options;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Style.displayName = wrapDisplayName(Component, 'withStyles');
|
||||
WithStyles.displayName = wrapDisplayName(Component, 'WithStyles');
|
||||
}
|
||||
|
||||
return Style;
|
||||
hoistNonReactStatics(WithStyles, Component);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// Exposed for test purposes.
|
||||
WithStyles.Naked = Component;
|
||||
WithStyles.options = options;
|
||||
}
|
||||
|
||||
return WithStyles;
|
||||
};
|
||||
|
||||
export default withStyles;
|
Reference in New Issue
Block a user