aesthetic-react
Advanced tools
Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7
@@ -1,12 +0,2 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = _react.default.createContext('ltr'); | ||
exports.default = _default; | ||
import React from 'react'; | ||
export default React.createContext('ltr'); |
@@ -1,15 +0,5 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = DirectionProvider; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _direction = _interopRequireDefault(require("direction")); | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function DirectionProvider(_ref) { | ||
import React from 'react'; | ||
import getDirection from 'direction'; | ||
import DirectionContext from './DirectionContext'; | ||
export default function DirectionProvider(_ref) { | ||
var aesthetic = _ref.aesthetic, | ||
@@ -21,3 +11,3 @@ children = _ref.children, | ||
var Tag = inline ? 'span' : 'div'; | ||
var direction = dir || (0, _direction.default)(value); | ||
var direction = dir || getDirection(value); | ||
@@ -28,7 +18,7 @@ if (!direction || direction === 'neutral') { | ||
return _react.default.createElement(_DirectionContext.default.Provider, { | ||
return React.createElement(DirectionContext.Provider, { | ||
value: direction | ||
}, _react.default.createElement(Tag, { | ||
}, React.createElement(Tag, { | ||
dir: direction | ||
}, children)); | ||
} |
@@ -1,55 +0,14 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
DirectionContext: true, | ||
DirectionProvider: true, | ||
ThemeContext: true, | ||
ThemeProvider: true, | ||
useStylesFactory: true, | ||
useThemeFactory: true, | ||
withStylesFactory: true, | ||
withThemeFactory: true | ||
}; | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
exports.DirectionContext = _DirectionContext.default; | ||
var _DirectionProvider = _interopRequireDefault(require("./DirectionProvider")); | ||
exports.DirectionProvider = _DirectionProvider.default; | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
exports.ThemeContext = _ThemeContext.default; | ||
var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider")); | ||
exports.ThemeProvider = _ThemeProvider.default; | ||
var _useStylesFactory = _interopRequireDefault(require("./useStylesFactory")); | ||
exports.useStylesFactory = _useStylesFactory.default; | ||
var _useThemeFactory = _interopRequireDefault(require("./useThemeFactory")); | ||
exports.useThemeFactory = _useThemeFactory.default; | ||
var _withStylesFactory = _interopRequireDefault(require("./withStylesFactory")); | ||
exports.withStylesFactory = _withStylesFactory.default; | ||
var _withThemeFactory = _interopRequireDefault(require("./withThemeFactory")); | ||
exports.withThemeFactory = _withThemeFactory.default; | ||
var _types = require("./types"); | ||
Object.keys(_types).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _types[key]; | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* @copyright 2017-2019, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
*/ | ||
import DirectionContext from './DirectionContext'; | ||
import DirectionProvider from './DirectionProvider'; | ||
import ThemeContext from './ThemeContext'; | ||
import ThemeProvider from './ThemeProvider'; | ||
import useStylesFactory from './useStylesFactory'; | ||
import useThemeFactory from './useThemeFactory'; | ||
import withStylesFactory from './withStylesFactory'; | ||
import withThemeFactory from './withThemeFactory'; | ||
export * from './types'; | ||
export { DirectionContext, DirectionProvider, ThemeContext, ThemeProvider, useStylesFactory, useThemeFactory, withStylesFactory, withThemeFactory }; |
@@ -1,16 +0,6 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = _react.default.createContext({ | ||
import React from 'react'; | ||
export default React.createContext({ | ||
changeTheme: function changeTheme() {}, | ||
theme: {}, | ||
themeName: 'default' | ||
}); | ||
exports.default = _default; | ||
}); |
@@ -1,12 +0,1 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
@@ -18,2 +7,5 @@ | ||
import React from 'react'; | ||
import ThemeContext from './ThemeContext'; | ||
var ThemeProvider = function (_React$PureComponent) { | ||
@@ -81,3 +73,3 @@ _inheritsLoose(ThemeProvider, _React$PureComponent); | ||
return _react.default.createElement(_ThemeContext.default.Provider, { | ||
return React.createElement(ThemeContext.Provider, { | ||
value: this.ctx | ||
@@ -88,4 +80,4 @@ }, this.props.children); | ||
return ThemeProvider; | ||
}(_react.default.PureComponent); | ||
}(React.PureComponent); | ||
exports.default = ThemeProvider; | ||
export { ThemeProvider as default }; |
@@ -1,19 +0,6 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = useStylesFactory; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _v = _interopRequireDefault(require("uuid/v4")); | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function useStylesFactory(aesthetic) { | ||
import React, { useContext, useState, useLayoutEffect } from 'react'; | ||
import uuid from 'uuid/v4'; | ||
import DirectionContext from './DirectionContext'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function useStylesFactory(aesthetic) { | ||
return function useStyles(styleSheet, customName) { | ||
@@ -24,9 +11,9 @@ if (customName === void 0) { | ||
var dir = (0, _react.useContext)(_DirectionContext.default); | ||
var dir = useContext(DirectionContext); | ||
var _useContext = (0, _react.useContext)(_ThemeContext.default), | ||
var _useContext = useContext(ThemeContext), | ||
themeName = _useContext.themeName; | ||
var _useState = (0, _react.useState)(function () { | ||
var name = customName + "-" + (0, _v.default)(); | ||
var _useState = useState(function () { | ||
var name = customName + "-" + uuid(); | ||
aesthetic.registerStyleSheet(name, styleSheet); | ||
@@ -43,3 +30,3 @@ return name; | ||
var sheet = aesthetic.createStyleSheet(styleName, options); | ||
(0, _react.useLayoutEffect)(function () { | ||
useLayoutEffect(function () { | ||
aesthetic.flushStyles(styleName); | ||
@@ -46,0 +33,0 @@ }, [dir, styleName, themeName]); |
@@ -1,10 +0,10 @@ | ||
"use strict"; | ||
import React, { useContext } from 'react'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function useThemeFactory(aesthetic) { | ||
return function useTheme() { | ||
var _useContext = useContext(ThemeContext), | ||
themeName = _useContext.themeName; | ||
exports.__esModule = true; | ||
exports.default = useThemeFactory; | ||
function useThemeFactory(aesthetic) { | ||
return function useTheme() { | ||
return aesthetic.getTheme(); | ||
return aesthetic.getTheme(themeName); | ||
}; | ||
} |
@@ -1,18 +0,1 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = withStylesFactory; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); | ||
var _v = _interopRequireDefault(require("uuid/v4")); | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
@@ -28,3 +11,8 @@ | ||
function withStylesFactory(aesthetic) { | ||
import React from 'react'; | ||
import hoistNonReactStatics from 'hoist-non-react-statics'; | ||
import uuid from 'uuid/v4'; | ||
import DirectionContext from './DirectionContext'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function withStylesFactory(aesthetic) { | ||
return function withStyles(styleSheet, options) { | ||
@@ -52,4 +40,4 @@ if (options === void 0) { | ||
var baseName = WrappedComponent.displayName || WrappedComponent.name; | ||
var styleName = baseName + "-" + (0, _v.default)(); | ||
var Component = pure ? _react.default.PureComponent : _react.default.Component; | ||
var styleName = baseName + "-" + uuid(); | ||
var Component = pure ? React.PureComponent : React.Component; | ||
aesthetic.registerStyleSheet(styleName, styleSheet, extendFrom); | ||
@@ -134,6 +122,6 @@ | ||
if (passThemeProp) { | ||
extraProps[themePropName] = aesthetic.getTheme(); | ||
extraProps[themePropName] = aesthetic.getTheme(themeName); | ||
} | ||
return _react.default.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
return React.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
}; | ||
@@ -172,5 +160,5 @@ | ||
return _react.default.createElement(_ThemeContext.default.Consumer, null, function (theme) { | ||
return _react.default.createElement(_DirectionContext.default.Consumer, null, function (dir) { | ||
return _react.default.createElement(WithStyles, _extends({}, _this2.props, { | ||
return React.createElement(ThemeContext.Consumer, null, function (theme) { | ||
return React.createElement(DirectionContext.Consumer, null, function (dir) { | ||
return React.createElement(WithStyles, _extends({}, _this2.props, { | ||
dir: dir, | ||
@@ -184,3 +172,3 @@ themeName: theme.themeName | ||
return WithStylesConsumer; | ||
}(_react.default.Component); | ||
}(React.Component); | ||
@@ -193,3 +181,3 @@ _defineProperty(WithStylesConsumer, "displayName", "withStyles(" + baseName + ")"); | ||
(0, _hoistNonReactStatics.default)(WithStylesConsumer, WrappedComponent); | ||
hoistNonReactStatics(WithStylesConsumer, WrappedComponent); | ||
return WithStylesConsumer; | ||
@@ -196,0 +184,0 @@ }; |
@@ -1,12 +0,3 @@ | ||
"use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
exports.__esModule = true; | ||
exports.default = withThemeFactory; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
@@ -18,5 +9,6 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function withThemeFactory(aesthetic) { | ||
import React from 'react'; | ||
import hoistNonReactStatics from 'hoist-non-react-statics'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function withThemeFactory(aesthetic) { | ||
return function withTheme(options) { | ||
@@ -34,3 +26,3 @@ if (options === void 0) { | ||
var baseName = WrappedComponent.displayName || WrappedComponent.name; | ||
var Component = pure ? _react.default.PureComponent : _react.default.Component; | ||
var Component = pure ? React.PureComponent : React.Component; | ||
@@ -50,7 +42,8 @@ var WithTheme = function (_Component) { | ||
var _this$props = this.props, | ||
themeName = _this$props.themeName, | ||
wrappedRef = _this$props.wrappedRef, | ||
props = _objectWithoutPropertiesLoose(_this$props, ["wrappedRef"]); | ||
props = _objectWithoutPropertiesLoose(_this$props, ["themeName", "wrappedRef"]); | ||
var extraProps = (_extraProps = {}, _extraProps[themePropName] = aesthetic.getTheme(), _extraProps.ref = wrappedRef, _extraProps); | ||
return _react.default.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
var extraProps = (_extraProps = {}, _extraProps[themePropName] = aesthetic.getTheme(themeName), _extraProps.ref = wrappedRef, _extraProps); | ||
return React.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
}; | ||
@@ -61,10 +54,32 @@ | ||
_defineProperty(WithTheme, "displayName", "withTheme(" + baseName + ")"); | ||
var WithThemeConsumer = function (_React$Component) { | ||
_inheritsLoose(WithThemeConsumer, _React$Component); | ||
_defineProperty(WithTheme, "WrappedComponent", WrappedComponent); | ||
function WithThemeConsumer() { | ||
return _React$Component.apply(this, arguments) || this; | ||
} | ||
(0, _hoistNonReactStatics.default)(WithTheme, WrappedComponent); | ||
return WithTheme; | ||
var _proto2 = WithThemeConsumer.prototype; | ||
_proto2.render = function render() { | ||
var _this = this; | ||
return React.createElement(ThemeContext.Consumer, null, function (theme) { | ||
return React.createElement(WithTheme, _extends({}, _this.props, { | ||
themeName: theme.themeName | ||
})); | ||
}); | ||
}; | ||
return WithThemeConsumer; | ||
}(React.Component); | ||
_defineProperty(WithThemeConsumer, "displayName", "withTheme(" + baseName + ")"); | ||
_defineProperty(WithThemeConsumer, "WrappedComponent", WrappedComponent); | ||
hoistNonReactStatics(WithThemeConsumer, WrappedComponent); | ||
return WithThemeConsumer; | ||
}; | ||
}; | ||
} |
@@ -1,2 +0,12 @@ | ||
import React from 'react'; | ||
export default React.createContext('ltr'); | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = _react.default.createContext('ltr'); | ||
exports.default = _default; |
@@ -1,5 +0,15 @@ | ||
import React from 'react'; | ||
import getDirection from 'direction'; | ||
import DirectionContext from './DirectionContext'; | ||
export default function DirectionProvider(_ref) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = DirectionProvider; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _direction = _interopRequireDefault(require("direction")); | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function DirectionProvider(_ref) { | ||
var aesthetic = _ref.aesthetic, | ||
@@ -11,3 +21,3 @@ children = _ref.children, | ||
var Tag = inline ? 'span' : 'div'; | ||
var direction = dir || getDirection(value); | ||
var direction = dir || (0, _direction.default)(value); | ||
@@ -18,7 +28,7 @@ if (!direction || direction === 'neutral') { | ||
return React.createElement(DirectionContext.Provider, { | ||
return _react.default.createElement(_DirectionContext.default.Provider, { | ||
value: direction | ||
}, React.createElement(Tag, { | ||
}, _react.default.createElement(Tag, { | ||
dir: direction | ||
}, children)); | ||
} |
@@ -1,14 +0,55 @@ | ||
/** | ||
* @copyright 2017-2019, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
*/ | ||
import DirectionContext from './DirectionContext'; | ||
import DirectionProvider from './DirectionProvider'; | ||
import ThemeContext from './ThemeContext'; | ||
import ThemeProvider from './ThemeProvider'; | ||
import useStylesFactory from './useStylesFactory'; | ||
import useThemeFactory from './useThemeFactory'; | ||
import withStylesFactory from './withStylesFactory'; | ||
import withThemeFactory from './withThemeFactory'; | ||
export * from './types'; | ||
export { DirectionContext, DirectionProvider, ThemeContext, ThemeProvider, useStylesFactory, useThemeFactory, withStylesFactory, withThemeFactory }; | ||
"use strict"; | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
DirectionContext: true, | ||
DirectionProvider: true, | ||
ThemeContext: true, | ||
ThemeProvider: true, | ||
useStylesFactory: true, | ||
useThemeFactory: true, | ||
withStylesFactory: true, | ||
withThemeFactory: true | ||
}; | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
exports.DirectionContext = _DirectionContext.default; | ||
var _DirectionProvider = _interopRequireDefault(require("./DirectionProvider")); | ||
exports.DirectionProvider = _DirectionProvider.default; | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
exports.ThemeContext = _ThemeContext.default; | ||
var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider")); | ||
exports.ThemeProvider = _ThemeProvider.default; | ||
var _useStylesFactory = _interopRequireDefault(require("./useStylesFactory")); | ||
exports.useStylesFactory = _useStylesFactory.default; | ||
var _useThemeFactory = _interopRequireDefault(require("./useThemeFactory")); | ||
exports.useThemeFactory = _useThemeFactory.default; | ||
var _withStylesFactory = _interopRequireDefault(require("./withStylesFactory")); | ||
exports.withStylesFactory = _withStylesFactory.default; | ||
var _withThemeFactory = _interopRequireDefault(require("./withThemeFactory")); | ||
exports.withThemeFactory = _withThemeFactory.default; | ||
var _types = require("./types"); | ||
Object.keys(_types).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _types[key]; | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -1,6 +0,16 @@ | ||
import React from 'react'; | ||
export default React.createContext({ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = _react.default.createContext({ | ||
changeTheme: function changeTheme() {}, | ||
theme: {}, | ||
themeName: 'default' | ||
}); | ||
}); | ||
exports.default = _default; |
@@ -0,1 +1,12 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
@@ -7,5 +18,2 @@ | ||
import React from 'react'; | ||
import ThemeContext from './ThemeContext'; | ||
var ThemeProvider = function (_React$PureComponent) { | ||
@@ -73,3 +81,3 @@ _inheritsLoose(ThemeProvider, _React$PureComponent); | ||
return React.createElement(ThemeContext.Provider, { | ||
return _react.default.createElement(_ThemeContext.default.Provider, { | ||
value: this.ctx | ||
@@ -80,4 +88,4 @@ }, this.props.children); | ||
return ThemeProvider; | ||
}(React.PureComponent); | ||
}(_react.default.PureComponent); | ||
export { ThemeProvider as default }; | ||
exports.default = ThemeProvider; |
@@ -1,6 +0,19 @@ | ||
import React, { useContext, useState, useLayoutEffect } from 'react'; | ||
import uuid from 'uuid/v4'; | ||
import DirectionContext from './DirectionContext'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function useStylesFactory(aesthetic) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = useStylesFactory; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _v = _interopRequireDefault(require("uuid/v4")); | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function useStylesFactory(aesthetic) { | ||
return function useStyles(styleSheet, customName) { | ||
@@ -11,9 +24,9 @@ if (customName === void 0) { | ||
var dir = useContext(DirectionContext); | ||
var dir = (0, _react.useContext)(_DirectionContext.default); | ||
var _useContext = useContext(ThemeContext), | ||
var _useContext = (0, _react.useContext)(_ThemeContext.default), | ||
themeName = _useContext.themeName; | ||
var _useState = useState(function () { | ||
var name = customName + "-" + uuid(); | ||
var _useState = (0, _react.useState)(function () { | ||
var name = customName + "-" + (0, _v.default)(); | ||
aesthetic.registerStyleSheet(name, styleSheet); | ||
@@ -30,3 +43,3 @@ return name; | ||
var sheet = aesthetic.createStyleSheet(styleName, options); | ||
useLayoutEffect(function () { | ||
(0, _react.useLayoutEffect)(function () { | ||
aesthetic.flushStyles(styleName); | ||
@@ -33,0 +46,0 @@ }, [dir, styleName, themeName]); |
@@ -1,6 +0,17 @@ | ||
import React, { useContext } from 'react'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function useThemeFactory(aesthetic) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = useThemeFactory; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function useThemeFactory(aesthetic) { | ||
return function useTheme() { | ||
var _useContext = useContext(ThemeContext), | ||
var _useContext = (0, _react.useContext)(_ThemeContext.default), | ||
themeName = _useContext.themeName; | ||
@@ -7,0 +18,0 @@ |
@@ -0,1 +1,18 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = withStylesFactory; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); | ||
var _v = _interopRequireDefault(require("uuid/v4")); | ||
var _DirectionContext = _interopRequireDefault(require("./DirectionContext")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
@@ -11,8 +28,3 @@ | ||
import React from 'react'; | ||
import hoistNonReactStatics from 'hoist-non-react-statics'; | ||
import uuid from 'uuid/v4'; | ||
import DirectionContext from './DirectionContext'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function withStylesFactory(aesthetic) { | ||
function withStylesFactory(aesthetic) { | ||
return function withStyles(styleSheet, options) { | ||
@@ -40,4 +52,4 @@ if (options === void 0) { | ||
var baseName = WrappedComponent.displayName || WrappedComponent.name; | ||
var styleName = baseName + "-" + uuid(); | ||
var Component = pure ? React.PureComponent : React.Component; | ||
var styleName = baseName + "-" + (0, _v.default)(); | ||
var Component = pure ? _react.default.PureComponent : _react.default.Component; | ||
aesthetic.registerStyleSheet(styleName, styleSheet, extendFrom); | ||
@@ -125,3 +137,3 @@ | ||
return React.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
return _react.default.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
}; | ||
@@ -160,5 +172,5 @@ | ||
return React.createElement(ThemeContext.Consumer, null, function (theme) { | ||
return React.createElement(DirectionContext.Consumer, null, function (dir) { | ||
return React.createElement(WithStyles, _extends({}, _this2.props, { | ||
return _react.default.createElement(_ThemeContext.default.Consumer, null, function (theme) { | ||
return _react.default.createElement(_DirectionContext.default.Consumer, null, function (dir) { | ||
return _react.default.createElement(WithStyles, _extends({}, _this2.props, { | ||
dir: dir, | ||
@@ -172,3 +184,3 @@ themeName: theme.themeName | ||
return WithStylesConsumer; | ||
}(React.Component); | ||
}(_react.default.Component); | ||
@@ -181,3 +193,3 @@ _defineProperty(WithStylesConsumer, "displayName", "withStyles(" + baseName + ")"); | ||
hoistNonReactStatics(WithStylesConsumer, WrappedComponent); | ||
(0, _hoistNonReactStatics.default)(WithStylesConsumer, WrappedComponent); | ||
return WithStylesConsumer; | ||
@@ -184,0 +196,0 @@ }; |
@@ -0,1 +1,14 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = withThemeFactory; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); | ||
var _ThemeContext = _interopRequireDefault(require("./ThemeContext")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -9,6 +22,3 @@ | ||
import React from 'react'; | ||
import hoistNonReactStatics from 'hoist-non-react-statics'; | ||
import ThemeContext from './ThemeContext'; | ||
export default function withThemeFactory(aesthetic) { | ||
function withThemeFactory(aesthetic) { | ||
return function withTheme(options) { | ||
@@ -26,3 +36,3 @@ if (options === void 0) { | ||
var baseName = WrappedComponent.displayName || WrappedComponent.name; | ||
var Component = pure ? React.PureComponent : React.Component; | ||
var Component = pure ? _react.default.PureComponent : _react.default.Component; | ||
@@ -47,3 +57,3 @@ var WithTheme = function (_Component) { | ||
var extraProps = (_extraProps = {}, _extraProps[themePropName] = aesthetic.getTheme(themeName), _extraProps.ref = wrappedRef, _extraProps); | ||
return React.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
return _react.default.createElement(WrappedComponent, _extends({}, props, extraProps)); | ||
}; | ||
@@ -66,4 +76,4 @@ | ||
return React.createElement(ThemeContext.Consumer, null, function (theme) { | ||
return React.createElement(WithTheme, _extends({}, _this.props, { | ||
return _react.default.createElement(_ThemeContext.default.Consumer, null, function (theme) { | ||
return _react.default.createElement(WithTheme, _extends({}, _this.props, { | ||
themeName: theme.themeName | ||
@@ -75,3 +85,3 @@ })); | ||
return WithThemeConsumer; | ||
}(React.Component); | ||
}(_react.default.Component); | ||
@@ -82,3 +92,3 @@ _defineProperty(WithThemeConsumer, "displayName", "withTheme(" + baseName + ")"); | ||
hoistNonReactStatics(WithThemeConsumer, WrappedComponent); | ||
(0, _hoistNonReactStatics.default)(WithThemeConsumer, WrappedComponent); | ||
return WithThemeConsumer; | ||
@@ -85,0 +95,0 @@ }; |
{ | ||
"name": "aesthetic-react", | ||
"version": "1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.7", | ||
"description": "React hooks, composers, and more for styling components with Aesthetic.", | ||
@@ -24,3 +24,3 @@ "keywords": [ | ||
"@types/react": "*", | ||
"aesthetic-utils": "^2.0.0-alpha.5", | ||
"aesthetic-utils": "^2.0.0-alpha.6", | ||
"direction": "^1.0.3", | ||
@@ -43,3 +43,3 @@ "hoist-non-react-statics": "^3.3.0", | ||
}, | ||
"gitHead": "5526792431adeebc7d8ec1420627fbd20d51cc84" | ||
"gitHead": "8a8e92b75a056555209a0690098d0fa855fd1cf3" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56164
895